blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
85edd6b7d6c8490c09b40db79c6bb337c60a79d4
iWonder118/atcoder
/python/ABC134/C.py
192
3.578125
4
n = int(input()) a = [int(input()) for _ in range(n)] a_sort = sorted(a, reverse=True) for i in range(n): if a[i] == a_sort[0]: print(a_sort[1]) else: print(a_sort[0])
ec54b5db79357118b8829c13559817573b13930f
un4ckn0wl3z/ntp-scanner
/ntp-scanner.py
1,905
3.546875
4
#!/usr/bin/env python #coding=utf8 """NTP Scanner and 'monlist' checker INSTALLATION: (debian)-- sudo apt-get install python-pip python-argparse ntp; sudo pip install ntplib iptools; Usage: python ntp-scanner.py [ARGS] -f, --file : specify input file -t, --target : specify specifi...
e71f13030e7308a6871ae98ba0a4a5751acde156
AnaelBourgneuf/imie
/maths/transpositionmatrice.py
240
3.5
4
def transposition(mat): nmat=[]; lignes=len(mat) colonnes=len(mat[0]) for i in range(0,colonnes): nmat+=[[],] for j in range(0,lignes): nmat[i]+=[mat[j][i],] return nmat print(transposition([[1,0,4],[-3,2,5],[7,-3,6],[1,0,7]]))
2386f31d0c47643f77be7030b3ec09d486b482e6
sam1017/pythonstudy
/find_prime_number.py
574
3.8125
4
import time from math import sqrt prime_number_list = [2] n = 10000 start = time.clock() for i in range(3,n): is_prime = False sqrt_i = int(sqrt(i) + 1) for j in prime_number_list: if(j <= sqrt_i): if i%j == 0: is_prime = False break else: ...
b0498c139793f93a1b2facf9bd7a665b87dfb78c
MrHamdulay/csc3-capstone
/examples/data/Assignment_1/bdlren001/question2.py
475
4.21875
4
# A program to check the validity of a time entered by the user as a set of three integers. # BDLREN001 # Budeli Rendani # 01 March 2014 def time(): hours = eval(input("Enter the hours:\n")) minutes = eval(input("Enter the minutes:\n")) seconds = eval(input("Enter the seconds:\n")) if 0<=hours...
150f73ab74236b7e9de7b19949f1020e1cae1d9c
thinkerston/curso-em-video-python3
/mundo-01/exercicio-024.py
226
3.875
4
'''Crie um programa que leia o nome de uma cidade e diga se ala começa ou não com o nome SANTO''' nomeCidade = str(input('Insira o nome de sua cidade: ')).lower() santoExiste = bool('santo' in nomeCidade) print(santoExiste)
90575b86313a86d861d02833cc3ae5de1131ca6a
jwutt3/Python-Masterclass-Code
/Variables/varables.py
999
4.1875
4
# 5.4 Storing items invariables # Variables can start with a letter (upper or lower) or an underscore # Greeting = "'ello govner" # greeting = "Hello" # _myName = "Jamie" # # age = 24 # print(age) # # print(greeting + age) # a = 12 # b = 3 # print(a + b) # print(a-b) # print(a*b) # print(a/b) # print(a // b) # print(...
4a255f928c8f9b38e14f4f69edb6726f07f72011
qinyaoting/python3-study
/lxf/function_def_func.py
1,005
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ' a test module ' from multiprocessing import Process, Pool, Queue import os, time, random import math __author__ = 'chin' def my_abs(x): if not isinstance(x, (int, float)): raise TypeError('bad operand type') if x >= 0: return x else: ...
e31ca9bc31bc643656b4133028f22840011a8ae0
futurice/PythonInBrowser
/examples/sessiona/010_print.py
1,705
3.75
4
## Printtailu ja laskutoimitusharjoituksia print u"Terve jälleen!" print u"Nyt lasketaan: 77 + 89 = ", 77+89 ## Python on ohjelmointikieli, jota voi tietenkin käyttää myös laskimena #print 5+6 ######################################################## ## TEHTÄVÄ 1: ## Poista alla rivien aluista kommenttimerkit, el...
574bf1cf0a182ef2730ccda313ae0f7da4aa4f6b
namichael/Grad_School_Coding
/Misc/recursive_step.py
234
4.0625
4
# Recursive Step Problem def recurse_step(n): if n and n - 1: return recurse_step(n-1) + recurse_step(n-2) else: return 1 def main(n): print recurse_step(n) if __name__ == "__main__": import sys main(int(sys.argv[1]))
104714cc569c16259c8454ca10c587902e92a24b
hegde421201/python_programming
/arrays/TwoSum1.py
1,620
4.125
4
from typing import List def twoSum(nums: List[int], target: int) -> List[int]: # step 1 : define a hashmap with key as the element of the List and the corresponding value as the index in the List hashmap = dict() # step 2: We require both index and the actual number for the hashmap created in step 1 abov...
06a15f23b1b553a94ddde85529412ee350602d61
royqh1979/programming_with_python
/Chap04Functions/5-1-3.求某班平均分-高阶函数实现.py
1,458
3.546875
4
import csv from easygraphics import dialog as dlg from dataclasses import dataclass @dataclass() class Score: id: str name: str clazz: str math: int literacy: int english: int def read_csv(filename): """ 从csv文件中读取学生成绩信息 :param filename: 文件名 :return: 学生信息列表 """ scores=[]...
a322a47eb4e0cdb5fd8313416ba4e2e327ef3de3
Divij-berry14/Python-with-Data-Structures
/StringMatchingAlgos/NaivePatternSearching.py
976
4.0625
4
def NaivePatternSearching(txt,pat): n=len(txt) m=len(pat) for i in range(n-m+1): j=0 while(j<m): if(txt[i+j]==pat[j]): j=j+1 else: break if j==m: print("Pattern found at index at position",i) txt = "AABAACAADAABAAAB...
961d3d9f80c130f3f1fe0b5443b2f516bedd51f0
eamaccready/STP_Exercises
/python_scripts/stack_reverse_list.py
602
4
4
class Stack(): def __init__(self): self.items = [] def is_empty(self): return self.items == [] def push(self, new_item): self.items.append(new_item) def pop(self): return self.items.pop() def peek(self): return self.items[len(self.items)-1] def size(s...
84195deb2246e90b6aae3413c6a10d48976f2e0f
chenyaoling/python-study2
/day04/06-TCP服务端增强.py
1,803
3.546875
4
# 1、导入模块 import socket # 2、创建套接字 tcp_server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 3、绑定端口和ip tcp_server_socket.bind(("", 8081)) # 4、开启监听(设置套接字为被动模式) # listen() 作用设置 tcp_server_socket 套接字为被动监听模式,不能在主动发送数据 # 128 允许接受的最大的连接数,在windows 128 有效,但是在linux 此数字无效 tcp_server_socket.listen(128) # 5、等待客户端连接...
c573ec5425620fc5c6da572635c24f3cdd828e1e
sluisdejesus/Week_2_single_class_lab
/team_class/src/team.py
769
3.890625
4
class Team: def __init__(self, input_name, input_players,input_coach): self.name = input_name self.players = input_players self.coach = input_coach self.points = 0 def team_has_name(self): return self.name def team_has_players(self): return self.players ...
92e65cce9c70fcc506313b326855389ea90a309f
Mukilavan/python
/Even.py
101
3.515625
4
a,n=input().split() a=int(a) n=int(n) for i in range(a,n): if(i%2==0 and i!=a): print(i,end=" ")
7e8feeb318bf16f3b0274e5bf3146fd369130314
eklavaya2208/practice-ml-cp
/Machine Learning/Part 2 - Regression/Section 8 - Decision Tree Regression/selfcoded.py
803
3.703125
4
#importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd #importing the dataset dataset = pd.read_csv('Position_Salaries.csv') X = dataset.iloc[:,1:2].values y = dataset.iloc[:,2:3].values #Fitting the decision tree regression to the dataset from sklearn.tree import DecisionTree...
6b93c93a3afee03573c143e0d8110b887ac0e63c
HeyYou-dev/ninjaRepo
/Easy/TwoSumProblem/twoSUM_GreedyApproach.py
1,066
3.625
4
class Solution: def twoSum (self,nums,target): temp =[] #Sort the arrary first nums.sort() #Getting forward and backward index forward = 0 backward = len(nums)-1 #Last index of nums while (forward<backward): sum = nums[forward]+nums[backward] ...
9d1502c8c43336cdbea7b3f27bf7493edc05cb16
apusty/pcl2_ex4
/fun_with_strings.py
1,453
3.90625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Programmiertechniken in der Computerlinguistik II # Augabe 4 # Autor: Angelina Pustynskaia from typing import Iterable def longest_substrings(x: str, y: str) -> Iterable[str]: # make both lower case x = x.lower() y = y.lower() n = len(x) m = len(...
dd592911102160de535df11665866d9d78b7e9f3
radrajith/Artificial_Intelligence
/Search Algorithms - Proj 1/SearchAlgorithms/Node.py
589
3.8125
4
#implementation of the tree. Each node has 4 children. class Node: up = 0; down = 1; left = 2; right = 3; parent = -1; def __init__(self, parent): self.node = [] self.parent = parent def addUp(self, child): self.node[self.up] = [child, 'up'] def addDown(self, chi...
2d6ceb13782c1aa23f2f1c9dce160b7cb51cb5f3
nguya580/python_fall20_anh
/week_02/week02_submission/week02_exercise_scrapbook.py
2,398
4.15625
4
# %% codecell # Exercise 2 # Print the first 10 natural numbers using a loop # Expected output: # 0 # 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 x = 0 while x <= 10: print(x) x += 1 # %% codecell # Exercise 3: # Execute the loop in exercise 1 and print the message Done! after # Expected output: # 0 # 1 # 2 # 3...
c700c0f2155ae38d41684a83362f4d861b91003b
5coho/Stock-Predictor
/src/stockPredictor.py
4,189
3.5625
4
""" --stock predictor file-- This file hold one class, stockPredictor which hold the function relating to predicting a stock such as Linear Regression """ # Metadata __author__ = "Scott Howes, Braeden Van Der Velde, Tyler Leary" __credits__ = "Scott Howes, Braeden Van Der Velde, Tyler Leary" __email__ = "showes@unb...
f8aaa4edfb0fba58558f1a5d52f7cfc4076d57ca
zaincbs/PYTECH
/overlappingUsingForLoop.py
606
4.21875
4
#!/usr/bin/env python """ Define a function overlapping() that takes two lists and returns True if they have at least one member in common, False otherwise. You may use your is_member() function, or the in operator, but for the sake of the exercise, you should (also) write it using two nested for-loops. """ def overla...
da5fb9420b7f39929b0ab83d667ce02e4876ad4e
bjweiqm/Practice
/模块/re_demo.py
417
3.765625
4
#!/usr/bin/env python # encoding:utf-8 """ @software: PyCharm @file: re_demo.py @time: 2017/5/2 18:07 """ import re data = '1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )' # 生成要匹配的正则对象 p = re.compile('\d+') # 从头开始匹配 s = re.match('\d', data) # s = re.search('\d{3}', data)...
81d834dc83aa1502e586634c4fa0e84af582b247
greenblues1190/Python-Algorithm
/LeetCode/12. 정렬/973-k-closest-points-to-origin.py
656
3.5625
4
# https://leetcode.com/problems/k-closest-points-to-origin/ # Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, # return the k closest points to the origin (0, 0). # The distance between two points on the X-Y plane is the Euclidean distance (i.e., √(x1 - x2)2 + ...
6312d5bfbd34a8f4b26d1f9a5b2ec034a6f68479
saltywalnut/CIT_SKP
/200627/branch.py
150
3.71875
4
Lamborghini = 200 money = 500 if (Lamborghini < money): print ("I got a Lamborghini") else : print ("I can't afford it") print ("FIN.")
94c3c36d4cc8564b78f975eec3852198c237de31
ErickViz/Quiz09.py
/Problema3.py
190
3.890625
4
#Quiz09 #Problema3 def superpower(x,y): c=0 a=1 while(c!=y): a=x*a c=c+1 return a x=int(input("Dame un numero: ")) y=int(input("Dame su exponencial: ")) p=superpower(x,y) print(p)
813014e3133428360132ec10acb9d7fa9a180367
baconrider46/python-0
/hi
156
3.890625
4
#!/usr/bin/env python3 import colors as c print('Hi ' + c.blue + " what's your name" + c.reset) name = input('>') print("Hello " + c.blue + name)
9a73dfd2c11b671030edfc8167ae5bba218c9eb4
AtteKarppinen/IrelandStudies
/Systems_Security/Lab 1/VigenereDecipher.py
2,069
4.125
4
# Vigenere Cipher # Key: KISWAHILI # Formula used in deciphering: # Ti = Ci - Ki {mod m} # Ti = plaintext character # Ci = ciphertext character # Ki = key character # m = length of alphabet import string # Fetch alphabet from string library alphabet = string.ascii_uppercase def generate_key(ciphertext, key_word...
5e60ad7f07f63a0a3ab736e3df02aaf445d087a0
ksrajiba/Testpygit
/trickdict5.py
1,534
4.5625
5
# new dict for iterating and dict comprehensions # from typing import Tuple a_dict = {'apple':'fruit','dog':'pets','car':'vehicle','twitter':'social network'} # to know the methods whtever dictionary holds print(dir(a_dict),end='--->') # using for loop to access the keys for key in a_dict: print(key) # simple tri...
5ca8ea5d09ad20f0588886bd937f4c8ee6be8788
PacktPublishing/Modern-Python-Cookbook-Second-Edition
/Chapter_15/collector.py
3,291
4.03125
4
"""Python Cookbook 2nd ed. The Coupon Collector test for random arrival times. """ import random from fractions import Fraction from statistics import mean from typing import Iterator, Iterable, Callable, cast def arrival1(n: int = 8) -> Iterator[int]: while True: yield random.randrange(n) test_arrival...
bf09de6103d6341dd5244b6a6cc7b360bbd95553
jiunwei/homework
/backend-01-tictactoe/tictactoe/game.py
5,628
3.75
4
# Zopim Take Home Exercise # Jiun Wei Chia # 2017-03-22 import sys DEFAULT_MARKERS = ('X', 'O') class TicTacToe: """ Represents state, logic and rendering for a Tic-Tac-Toe game. :param n: immutable length for one side of Tic-Tac-Toe board :param markers: 2-tuple of one-character strs ...
e8fe7f4290d4439a57c02e06254f78f3bd9dba85
ssaulrj/codes-python
/codeacademy-python3/strings/splitting_string_lastname.py
476
4.09375
4
authors = "Audre Lorde, William Carlos Williams, Gabriela Mistral, Jean Toomer, An Qi, Walt Whitman, Shel Silverstein, Carmen Boullosa, Kamala Suraiyya, Langston Hughes, Adrienne Rich, Nikki Giovanni" author_names = authors.split(',') def last_names(author_names): listx = [] for i in author_names: x = i.split...
c316168ea5c67539b1f06efeeba80ac48d1d7fb4
olaramoni/Zeller-s-Congruence
/Zeller_MonthInput.py
565
4.40625
4
def inputMonth() monthValid = False print( "March=3, April=4, May=5, June=6, July=7, August=8, September=9, October=10, November=11, December=12, January=13, February=14") while monthValid == False: try: month = input("Please enter the number corresponding to the month you want: ...
5f3a26cb949f722a82a8ca44fea0df82ea129a54
imrahul22/placementProgram
/GCD&LCM.py
837
3.8125
4
#GCD & LCM of two number num1 = int(input("Enter 1st number: ")) num2 = int(input("Enter 2nd number: ")) i = 1 while(i <= num1 and i <= num2): if(num1 % i == 0 and num2 % i == 0): gcd = i i = i + 1 print("GCD is", gcd) lcm=(num1*num2)//gcd print("LCM is",lcm) #GCD of more than two no in a array...
a5490acef5ca106d6f41e57dc143196e9f2178d1
ethanchu15/Deepcoder-SyGuS-Solver
/network.py
3,136
4.09375
4
''' Code adapted from http://pytorch.org/tutorials/beginner/pytorch_with_examples.html ''' import torch from initializer import * from torch.autograd import Variable def normalize(y_pred): # copied from https://discuss.pytorch.org/t/normalize-a-vector-to-0-1/14594 min_v = torch.min(y_pred) range_v = torch....
e95310601c68abf51195af94018f3a9673bce217
likunhong01/PythonDesignPatterns
/复合模式/MVC模式/no01实现.py
1,412
3.5
4
# coding=utf-8 # Version:python3.7.0 # Tools:Pycharm 2019 # Author:LIKUNHONG __date__ = '' __author__ = 'lkh' # 模型-视图-控制器模式 class Model: services = { 'email': { 'number': 1000, 'price': 2, }, 'sms': { 'number': 100...
826de7aa45546b8fede372722f2d556072b486aa
haruming/python-exercises
/tensorflow_mnist_nn.py
3,096
3.890625
4
import tensorflow as tf import numpy as np # use the MNIST data set in tensorflow from tensorflow.examples.tutorials.mnist import input_data data_path = os.path.join('.', 'mnist_data') # one-hot representation, here we use number 0-9 which means 10 entrances mnist = input_data.read_data_sets(data_path, one_hot=True) ...
e667268a98557ab678d3f5db6085d767e1800725
anshulmttl/FaceDetctionUsingPythonAI
/FaceDetector.py
2,042
3.703125
4
import cv2 print ("FaceDetector.py") trained_face_data = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') #Choose an image to detect the faces in. # input image using openCV and not normal image read #img = cv2.imread('RDJ.jpg') webcam = cv2.VideoCapture(0) #0 => Goes to webcam #iterate forever...
8faf9e0c0c995955cdf331e4b39b63fa516ab93a
daniel-reich/turbo-robot
/BHBXNfeMsA43d8Tys_2.py
1,508
4.09375
4
""" As far as we currently know, approximations for the mathematical constant **pi** (π) in the history of mathematics started surfacing with Ancient Babylonians, who found its correct truncation up to 1 decimal place. During the 5th century, the Chinese mathematician Zu Chongzhi raised it to 7 decimal places and fr...
6963ad1538d038d446d85c9fa59ece1a2b73193d
adirz/sample-projects
/samle projects/school projects/intro to CS/ex8/sllist_utils.py
10,724
4.25
4
from sllist import List, Node def merge_lists(first_list, second_list): """ Merges two sorted (in ascending order) lists into one new sorted list in an ascending order. The resulting new list is created using new nodes (copies of the nodes of the given lists). Assumes both lists are sorted in ascen...
59393fd8565d54335034d4c35ff3fee3da49ffbb
Adjeju/Laboratorni-Python
/Laboratorna7/lab7_3.py
290
3.625
4
import random row = int(input('row= ')) cols = int(input('cols= ')) num = int(input('number= ')) a = [] for i in range(row): row = [] for j in range(cols): elem = random.randint(1,9) row.append(elem * num) a.append(row) for i in range(len(a)): print(a[i])
49447dc605d8297a9fc137c76beba9f1434cb675
nshahm/learning
/python/listopr.py
1,122
3.6875
4
listt = [1,2,3,4,5,6,7,8,9,0] l = listt * 2; print (l) # concantenate two times print (l[-2]) # Index from reverse tuplee = (1, 's') listFromTuple = list(tuplee); print (listFromTuple) print (len(listt)) print (max(listt)) print (min(listt)) del listt[2]; print (listt) # Compare lists def cmp(a, b): # Not in py...
c37866834aaf8ad7dac284c2939bd310b7c13193
Keftcha/codingame
/training/hard/the-greatest-number/python3.py
524
3.515625
4
n = int(input()) nb = input().split() digits = [d for d in nb if d.isdigit()] # make the number if all([d == "0" for d in digits]): # only 0 digits = ["0"] elif "-" in nb: # negative number digits.sort() if "." in nb: digits.insert(1, ".") digits.insert(0, "-") else: # psitive number ...
ba703ddd37af2d62d7e94fc2d33502a24a02e80d
jyssh/codility
/rotate.py
901
3.671875
4
## List Number -> List ## Given a list and an integer n, produce a list by rotating the given list n times def rotate(l, k): if not l or k == 0: return l r = k % len(l) return l[-r:] + l[0:-r] if __name__ == '__main__': # n=k ## n=k=0 assert rotate([], 0) == [] ## n=k>0 asser...
5d749deda4852cb4483d559df6d53b05c8f6f835
hoque-nazmul/python-cheat-sheet
/Program/loop-exception.py
737
4.40625
4
# When the loop iteration is completed, then the 'StopIteration Exception' & 'else' execute. for item in range(1,4): print(item) else: print('Item Finished!') # Output: 1 2 3 # Item Finished! # If the loop iteration isn't completed, 'StopIteration Exception' & 'else' won't execute. for i in range(1, 5): if...
096499b900a9a3c86fae63cc6fda5c91b3840f92
stden/geometry
/coord.py
3,667
3.78125
4
# -*- coding: utf-8 -*- # Операции в однородных координатах from fractions import * print(gcd(10, 5)) class Point: # Класс "Точка" (вектор) с однородными координатами x, y, w = 0, 0, 1 # Конструктор def __init__(self, x=0, y=0): self.x, self.y, self.w = x, y, 1 # Строка для вывода def...
1d5b226a199ead8df4ff78f1a4db313916480521
nmmarzano/daily-coding-problem
/2020-01-22/in_place_list_reversal.py
1,216
3.75
4
class Node: def __init__(self, val='', child=None): self.val = val self.child = child def get_child(self): return self.child def set_child(self, node): self.child = node def __repr__(self): return f'{{val: {self.val}, child:{type(self.child)}}}' def reverse_l...
4c4a2eab409f3a3c677a6aec239ae0bf3cee1f0f
reneenie/python_for_evy
/m2w6.py
2,011
4.25
4
# Tuple data structure # 1. immutable: cannot be modified # things not to do with tuple ######### will return traceback!!! # tuple.sort() # tuple.append() # tuple.reverse() # assign values to tuple (x,y) = ('Amy', 4) print((x,y)) # compare tuple # compare the first one first. # if the first ones are equal, goes to ...
00f8be711cd8a2a4a5d1014999cc080625e21992
jameszhan/notes-ml
/06-programing-languages/01-pythons/03-just-for-fun/02-algorithms/20_dijkstra.py
1,697
3.65625
4
# -*- coding: utf8 -*- """ def dijkstra(): OPEN = [] CLOSE = [] CLOSE.append((0, 0)) for i in range(len(m[0])): if m[0][i] < N: OPEN.append((m[0][i], i)) while True: curr, index = min(OPEN) CLOSE.append((curr, index)) for i in range(index, len(m[index])):...
9de76437629d0b7b35c037681f16d71904919a4b
MOHAMMAD-FATHA/Python_Programs
/Data Structures/Dictionary/UniqueValueDic.py
459
3.765625
4
""" * @Author: Mohammad Fatha * @Date: 2021-09-24 15:50 * @Last Modified by: Mohammad Fatha * @Last Modified time: 2021-09-15 01:52 * @Title: :Python program to print all unique values in a dictionary """ L = [{"V":"S001"}, {"V": "S002"}, {"VI": "S001"}, {"VI": "S005"}, {"VII":"S005"}, {"V":"S009"},{"VIII":"S007"}] ...
afde6e73d28bffffad3ed33cf51f73da3aa57284
Shakirsadiq6/Basic-Python-Programs
/Basics_upto_loops/More examples/palindrome.py
388
3.796875
4
'''Print palindrome numbers upto 1 million''' __author__ = "Shakir Sadiq" MAXIMUM = 1000000 print("Palindrome Numbers upto 1 million") for num in range(1, MAXIMUM + 1): temp = num reverse = 0 while(temp > 0): reminder = temp % 10 reverse = (reverse * 10) + reminder temp = temp /...
523586d535d2908bcf5038f9c802f3e926bd9cce
MTGTsunami/LeetPython
/src/leetcode/tree/199. Binary Tree Right Side View.py
1,055
4.1875
4
""" Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example: Input: [1,2,3,null,5,null,4] Output: [1, 3, 4] Explanation: 1 <--- / \ 2 3 <--- \ \ 5 4 <--- """ # Definition for ...
7f1fccaa8ef9ed927a3382be87a4f105224b07d4
yubit/python_ders1
/8-hesap_makinesi.py
685
4.0625
4
sayi1 = int(input("Lütfen 1.sayıyı girin : ")) sayi2 = int(input("Lütfen 2 sayıyı girin : ")) print('Toplam: {} \nÇıkarma: {}\nBölüm: {}\nÇarpım: {}'.format('+', '-', '/', '*')) operator = input("İşlem girin: ") if operator == "+": sonuc = sayi1 + sayi2 print('{} + {} = {}'.format(sayi1, sayi2, sonuc)) elif o...
464058d30f8f40c6076675e770f12985ffced719
YugoNishio/python_study
/day_2/class_1.py
1,344
3.9375
4
#classについて """用語 クラス:オブジェクトを定義する(どんなオブジェクトなのかの説明) メソッド:クラス内にある関数 オブジェクト:全ての物、事柄を指す オブジェクトの生成:クラスからオブジェクトを作ること、インスタンス生成とも呼ぶ(class_2.py) """ class Planet: #オブジェクトの定義 普通クラス名の先頭は大文字 def earth(self): #メソッド 最低1つ引数が必要な為、第一引数はself(慣例) print("地球は過ごしやすい") #earthメソッドの実行内容 self.mars('寒すぎる') #marsメソッドの呼び出し 同じオブ...
e409c8b61d0757e66b5da0c9b207cfd04d3990f4
tyagihimansh/search_list
/withoutforloop.py
164
3.953125
4
Simple code to search list for 2**5 """ L=list(map(lambda x:2**x,range(7))) X=5 if 2**X in L: print('at index',L.index(2**X)) else: print(X,"not found")
06b455ec7fde722159cccbe18f6eebcdf48f0b53
baolibin/leetcode
/腾讯/链表/两数相加.py
2,497
4.03125
4
''' 两数相加 给你两个 非空 的链表,表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的,并且每个节点只能存储 一位 数字。 请你将两个数相加,并以相同形式返回一个表示和的链表。 你可以假设除了数字 0 之外,这两个数都不会以 0 开头。 示例 1: 输入:l1 = [2,4,3], l2 = [5,6,4] 输出:[7,0,8] 解释:342 + 465 = 807. 示例 2: 输入:l1 = [0], l2 = [0] 输出:[0] 示例 3: 输入:l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9] 输出:[8,9,9,9,0,0,0,1] 提示: 每个链表中的节点数在范围 [1, 1...
2b7b1621239406a0ec82d84f3ef03c2d13342044
AgFeather/StudyNote
/models/ML_Algorithm/PLA algorithm/PLA_pairing.py
755
3.609375
4
#使用python3实现对偶形式的感知机算法 def PLA(): dataset = np.array([[3,3],[4,3],[1,1]]) label = [1,1,-1] n = np.zeros([len(dataset)]) learning_rate = 1 b = 0 temp = [] for i in range(0,len(dataset)): for j in range(0,len(dataset)): temp.append(np.dot(dataset[i],dataset[j].T)) gram_matrix = np.array(temp).reshape([le...
c741b82ff1f6375445b80fe097a27eee3499816d
alexnro/Codewars-Katas
/Python/8kyu/invertListValues.py
215
3.828125
4
def invert(lst): return [-x for x in lst] if __name__ == "__main__": assert invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5] assert invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5] assert invert([]) == []
4729195d0ca6ad5afd6934e0e28500cee891ac45
ZoranPandovski/al-go-rithms
/data_structures/check_bipartite/python/bipartite.py
2,323
4.03125
4
from __future__ import print_function # Python program to find out whether a # given graph is Bipartite or not class Graph(): def __init__(self, V): self.V = V self.graph = [[0 for column in range(V)] for row in range(V)] # This function returns tr...
15537d8b7d99516f46226683c188bd268bc4c28f
xomay/NSI
/Thonny/rando.py
2,359
3.609375
4
import csv import matplotlib.pyplot as plt def lecture_fichier(donne: str) -> list: """ fonction qui récupère un fichier et qui renvoie une liste avec les entetes et une liste avec les données :param donne: fichier de données :return: liste d'entetes et liste de données """ with open(donne, "r"...
6778bff91f32c5882b413f2e066c044cc48e2836
playandlearntocode/main
/mlp/basic/src/mlp.py
2,239
4.15625
4
''' Simple Multilayer Perceptron example in Python Author: Goran Trlin Find more tutorials and code samples on: https://playandlearntocode.com ''' import numpy from PIL import Image from classes.mlp.mlp import MLP from classes.csv.csv_data_loader import CsvDataLoader from classes.extraction.image_feature_extractor imp...
71b87520ab10e18dca97f30f729df7b9b2efc8d7
JMCalizario/chatbot
/JuntandoStrings.py
417
4.0625
4
# Capitulo 1 # chat bot em ingles print('Learning Inglish Names ') print('-' * 40) print('hi !!! i am a robot, nice to meet you :) ') char1 = (input('what is your first name ?')) char2 = (input('ok, so what is your middle name ?')) print('Nice :) !!!') char3 = input('what is your last name ?') print('Than...
b74a6752bee666996abaed1c55f192b62213ad1b
fredcomby/IUTPyhton
/pendu.py
2,837
3.578125
4
# -*- coding: UTF-8 -*- """ pendu.py """ # Import import tools_chaines import random # Constantes COUPS_MAX = 10 # fonctions def choix_mot(): dico = tools_chaines.liste_mots_francais() mot = random.choice(dico) return mot def affiche_mot_un_caractere(mot, caractere): chaine_masq...
097982aa7bb970002dcdc6194392283cba83ecb7
lcxidian/soga
/5th/5th code 17.py
2,964
4.1875
4
1、tuple————类似于pair类型 tuple操作: tuple<T1,T2,...Tn> t; #未初始化的tuple对象 tuple<T1,T2,...Tn> t(v1,v2,...vn); #初始化的tuple对象 make_tuple(v1,v2,...vn); #生成一个匿名tuple对象 t1 == t2; t1 != t2; t1 relop t2; get<i>(t) #tuple对象的第i个引用 tuple_size<TupleType>::value #特定的类模板tuple_size...
f26eb32d5d508362213c61631c7e83195146fc49
tienduy-nguyen/coderust
/2.linked-list/single-linked-list/swap-node/test.py
952
3.90625
4
class ListNode: def __init__(self, val, next= None): self.val = val self.next = next class Linkedlist: def __init__(self, head = None): self.head =head def swap_with_head(self, head, n): headVal = head.val current=head count = 0 while(current and current.next): count += 1 ...
409ecf1cd7736dfe2d5c5e1bafa83a57f6ee47b1
lulubeanana17/Project_Euler
/6.py
199
3.5
4
b = 0 # the sum of from 1 to 100 a = [a**2 for a in range(1,101)] # list of a**2 from 1 to 100 for i in range(1, 101): b += i # add from 1 to 100 to b print(f'the answer is {b**2 - sum(a)}')
5f2d1a029e92d37fa7d09e4e78483d21ac100656
ayushupneja/2020-sensor-miniproject
/src/sp_iotsim/client.py
2,310
3.53125
4
""" WebSockets client This program receives simulated data for multiple rooms, with multiple sensors per room. The default behavior is to only access the computer itself by parameter "localhost" so that no firewall edits are needed. The port number is arbitrary, as long as the server and client are on the same port ...
3ee7438f6c04ab1bbf28988e6f0f3a8c750ba200
Prabukumaradoss/Python
/Day 2 - Conditional/Pin Number.py
120
4
4
n=int(input("Enter the PIN NUMBER")) if n==12345: print("Heloooo") else: print("Enter correct PIN NUMBER")
eca863c83b7f0d4d2419842e034a125e79006345
dnmanveet/Joy-Of-Computing-In-Python-Nptel-Course-Python-Programs
/binary_search_recursion.py
821
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 16 11:44:40 2018 @author: manveet """ l=[1,2,3,4,5] def binary_search(l,x,start,end): #Base case is one element in the list if start==end: if l[start]==x: return start else: return -1 else: ...
5a2c04658cfdd60d4a479b07879092a034ed5f69
rashmiranganath/list-programs-python-
/matrices.py
322
3.859375
4
def matrices(a,b): i=0 while i<len(list1): j=0 while j<len(list1): if list1[i]==list2[i]: result="matrices are identical" else: result="matrices are not identical" j=j+1 i=i+1 print result list1=[[1,2,3],[1,2,3],[1,2,3],[1,2,3]] list2=[[1,2,3],[1,2,3],[1,2,3],[1,2,3]] matrices(list1,list2) ...
ce533c024651a9d863c7acf6f4dff80c0f6f1314
eujonas/Python
/Aula 02/questao2.py
341
4.15625
4
"""2-Escreva uma função que receba dois números como argumento e retorne o produto do dobro do primeiro pelo triplo do segundo """ num1 = int(input("Primeiro valor:")) num2 = int(input("Segundo valor:")) def result(num1, num2): return (2 * num1) *(3 * num2) a = result(num1, num2) # retornar print(a) # função i...
09925281ad41f4ded886c9ab6e4b4cb5dba9c86c
blhwong/algos_py
/leet/valid_parenthesis/main.py
456
3.78125
4
class Solution: def isValid(self, s: str) -> bool: stack = [] opposite = { '(': ')', '[': ']', '{': '}' } i = 0 while i < len(s): l = s[i] if l in opposite: stack.append(opposite[l]) else...
332dc044a55f2ebca7b48339d505f81b22a22ae1
Effiongoto/Devcamp-Technical-Task
/Task_4.py
937
4
4
# Python function to check the strength of a password def passwordValidation(input_string): # declaring variables n = len(input_string) hasString = False hasDigit = False specialChar = False normalChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 " # vali...
713cef434fdb56f5658fe14f51d5be9b17591738
zeguil/python-exercicios
/exercicio_else.py
312
3.828125
4
print('E necessario ter informaçoes para entrar no exercito\n') peso=input('Digite seu peso: ') idade=input('\nDigite sua idade: ') altura=input('\nDigite sua altura: ') if peso >= '70' and idade >= '18' and altura >= '1.70': print('\nvoce esta APROVADO') else: print('\nvoce esta REPROVADO')
da4c43a23cbffe76666dfc9dfbaa45bc9c0f1ac7
larileonso23/exercicio-groger_bank
/exercicio/groger.bank.py
152
3.640625
4
nome = input('Digite o seu nome: ') idade = input('Digite sua idade: ') saldo = input('(Simulação de saldo) - Digite a simulação de saldo: ') if
b9a6a764a38da3205ece0b4f1ebf4e42653f375f
unclebob2008/stepik_py
/stars.py
78
3.578125
4
s = 0 n = int(input()) while n != 0: s += n n = int(input()) print(s)
488009397276beea5f96c60d00104302abf39e39
fanxiao168/pythonStudy
/AIDStudy/01-PythonBase/day17/demo02.py
2,154
4.21875
4
''' 迭代器 ---> yield 练习:exercise04.py 目标:让自定义类所创建的对象,可以参与for. iter价值:可以被for next价值:返回数据/抛出异常 class 自定义类的迭代器: def __next__(self): pass class 自定义类: def __iter__(self): pass for item in 自定义类(): pass ''' class SkillIterator: def __ini...
7f2549f72200761c1ad22d6c2d1f4f74f583f219
IsaacNewLee/SimpleFactory
/simple_factory.py
1,309
3.5
4
# _*_ coding=utf-8 _*_ from abc import ABCMeta, abstractmethod """ 不直接向客户端暴露对象创建的实现细节,而是通过一个工厂类来负责创建产品的实例 优点:1隐藏对象创建的实现细节 2客户端不需要修改代码 缺点:1违反了单一职责原则,将创建逻辑集中到一个工厂类 2违反开闭原则,当添加新产品时,需要修改工厂类代码 """ class Payment(metaclass=ABCMeta): """抽象产品角色""" @abstractmethod def pay(self, money): pass...
59bee163613d39b5a7cd923440fda5be5a4f32e5
huybv1999/PythonSolution
/ch4/bai4.10.py
338
3.59375
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 8 22:03:57 2020 @author: huybv1998 """ def convert(): gio = int(input("nhập số giờ: ")) * 3600 phut = int(input("nhập số phút: ")) * 60 giay = int(input("nhập số giây: ")) time = (gio + phut + giay)/86400 return time print(convert()) ...
89efb5ea99cc15960cbe6fae337e8c22b948dcaa
YarnYang/jianzhi-offer
/code/058-对称的二叉树.py
1,504
3.984375
4
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None ''' @题目描述 请实现一个函数,用来判断一颗二叉树是不是对称的。注意,如果一个二叉树同此二叉树的镜像是同样的,定义其为对称的。 @解题思路 一颗对称的二叉树: 5 / \ 4 4 / \ / \ 3 2 2 3 显然,root结点的左右子树应该相等,且左右子树应该成镜像关系,即左子树的左节点应该...
48b3d657455b4adc53b29feb087257685e9330a1
khiner/Barcodes
/CodeMaker.py
7,474
3.921875
4
"""This script generates a simulated code-11 barcode reading The process is as follows: 1. get a string representation of the code 2. remove invalid characters from the code string 3. append the C check value to the code string 4. append the K check value to the code string 5. convert the code to a ...
1959628b24c122a9e2c8e4072960ad389cfbdb57
neequole/my-python-programming-exercises
/unsorted_solutions/question91.py
337
3.796875
4
""" Question 91: With two given lists [1,3,6,78,35,55] and [12,24,35,24,88,120,155], write a program to make a list whose elements are intersection of the above given lists. Hints: Use set() and "&=" to do set intersection operation. """ a = set([1, 3, 6, 78, 35, 55]) b = set([12, 24, 35, 24, 88, 120, 155]) print(a....
62a58f56dcef75eb07ef6b821758b0bc499d0009
Nahidjc/python_problem_solving
/PRACTICE-2 SOLUTION.py
106
3.71875
4
n=int(input("Enter a Number: ")) sp= " " st="*" for i in range(1,n+1,1): print(sp*(n-i)+(st*(i*2-1)))
f5dcaeaf7358d88450e5e9f5e857deed29b786bd
sharkEater18/Space-Invader-using-Python-
/prev versions/spaceinvd.py
5,536
3.5
4
# Those who came before me # Lived through their vocations # From the past until completion # They'll turn away no .... # Importing Libraries import turtle from os import * import random import time delay = 0.1 # Window/ Screen wn = turtle.Screen() wn.bgcolor("black") wn.title("Space Invader V_12.08") wn.setup(655, ...
84f815564f143b76183fd3f7c5a5875d19fa03c5
acharyas121/tourism
/hangmangame.py
802
4.125
4
import random # creating a list of words for the game list = ["dictionary","books","popular","mouse","conversation"] # choice() chooses one of the elements from the list a = random.choice(list) name = input("Enter your name") print("Hello {} \n Welcome to Hangman game!".format(name)) print("A random word will be...
880a246caac68b54f74b78a985a1e4d0ea59d98f
pjm8707/Python_Beginning
/py_basic_functions.py
1,127
3.875
4
from __future__ import division import sys # from __future__ import division temp_value_1 = 5/2; temp_value_2 = 5//2; print("temp_value_1(", type(temp_value_1), "):", temp_value_1) print("temp_value_2(", type(temp_value_2), "):", temp_value_2) # function def Double(x): """ ex this function is to...
29ed56ffae6863259f383e437d61b79a63968e57
hampgoodwin/automated-software-testing-with-python
/section2/classes_objects.py
890
3.53125
4
# lottery_player_dict = { # 'name': 'Rolf', # 'numbers': (5, 9, 12, 3, 1, 21) # } # class LotterPlayer: # def __init__(self, name): # self.name = name # self.numbers = (5, 9, 12, 3, 1, 21) # def total(self): # return sum(self.numbers) # player_one = LotterPlayer("Rolf") # play...
1b685ead833c90b45ed65c0ee242abe7a1738c53
ghffadel/Atividade-008
/department.py
366
3.671875
4
class Department: def __init__(self, name, teacher_list): self.name = name self.teacher_list = teacher_list def insert_teachers(self, teacher): self.teacher_list.add(teacher) def __str__(self): return "%s [%s]" % ( self.name, ", ".join([teacher.name ...
6a332d2e824c2090e886847b898b486b9cf6bc49
Romny468/FHICT
/palindrome_checker/palindrome_checker_v1.py
435
4.1875
4
#This is a palindrome checker def palindromeCheck(): string = input("enter a word: ") for i in range(0, int(len(string)/2)): if string[i] != string[len(string)-i-1]: return False return True #program beginning print("i am a programmed to check if a word is a palindrome") ans =...
d9598290d39dcbd35dd6b9bc527f82508b9fa7cd
Keviwevii/Python-Crash-Course
/If Statements/stages_of_life.py
335
4.125
4
#Determining age age = 65 if age < 2: message = 'You are a baby!' elif age < 4: message = 'You are a toddler!' elif age < 13: message = 'You are a kid!' elif age < 20: message= 'You are a teenager!' elif age < 65: message = 'You are an adult!' elif age >= 65: message = 'You are an elder!' ...
728dc30452dd8f94c46cfe8e30175eb79d88c855
PickertJoe/python_problems
/binary_converter.py
3,165
4.28125
4
# A program to convert any user-provided decimal value into binary form and vice versa class Stack: """A class to simulate the stack data structure""" def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item)...
1a66581bc108933db0657eeb04c97c65d3e8222e
sgbm0592/python_class
/ej_operador.py
439
3.796875
4
#operador incremental += #suma a variable de izq lo de la derecha #operador decremental -= numero = 15 numero -= 10 print(numero) #operador incrimental *= numero = 5 numero *= 3 print(numero) #operador incrimental /= #operador incrimental //= valor entero numero = 25 numero //= 4 print(numero) #operador incrimen...
e3611ce016fec6872fc67ae0272a7f5518e4e791
Carayav/HackerRank-Contests
/2014-04-21-Weekly/MaxXor/mx.accepted.py
228
3.5625
4
#!/bin/python # Complete the function below. def maxXor(l, r): return max([a ^ b for a in range(l, r + 1) for b in range(a, r + 1)]) _l = int(raw_input()); _r = int(raw_input()); res = maxXor(_l, _r); print(res)
fda676be2e72001b38707317df6bf8484f22fefe
SR-Razavi/python_level_2
/OOP_project.py
4,053
4.25
4
""" * OOP is a fundemental to becoming a good python programmer, so let's get some extra practice by bulding a game! * we will use OOP to create a cart game war! """ from random import shuffle # to useful variables for creating cards SUITE = 'H D S C'.split() RANKS = '2 3 4 5 6 7 8 9 10 J Q K A'.spli...
28fb082aae22056f2068b6eebd05c23a4d6453e9
fd-developer/papybot-fd
/pappyapp/clean_query.py
1,301
4.03125
4
#! /usr/bin/env python # coding: utf-8 import json import unicodedata class CleanQuery: """ CleanQuery is used to remove from a string accents, uppercase, and a list of words belonging to a list of bad words called STOP WORDS """ wordlist = [] def __init__(self, query): self.strquery = query...
ba3d81204c8df85090c441e0c2c37def39d0c402
wh122714892/-2018
/tanxin_version3.py
21,444
3.96875
4
import math #写的比骄乱,也没整理,整体思路就是按找对应服务器的比例进行放置。 def knapsack_version3(Vm_list,input_lines,cpu_memory_choose): # cpu = int(input_lines[0].split( )[0]) # mem = int(input_lines[0].split( )[1]) # input_list = [] # input_list.append(cpu) # input_list.append(mem) # cpu_memory_choose = ...
bb3020a779d42ef4c6481c5f6d505268a89bb3ad
EmlynLXR/Python
/str2float.py
652
3.578125
4
# -*- coding: utf-8 -*- from functools import reduce DIGITS={'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} def char2num(sss): return DIGITS[sss] def fun(x,y): return x*10+y def count(s): i=0 while s[i]!='.': i=i+1 return len(s)-i-1 def str2float(s): s1 =...
7dfa539769a7dbae44f573a0906c9d544a1d4b68
ja123oconnor/ProjectsByJanine
/chatbot.py
1,119
4.1875
4
print("Hi, my name is Robin the Robot. I love to talk to new people.") name = input("What is your name? ") print("Hello",name,"it is very nice to meet you!") year = input("I'm terrible with remembering the date, what year are we in please? ") print("Yes, I think you are right, thanks!") myage = input("Can you guess my ...