blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
18d67c0ab336dde18bdaa0f1bb308818e78be601
Allan-Perez/CStudies-
/Algorithms/naive_function.py
563
3.890625
4
# Naive algorithm for multiplying two numbers # use it with args import sys import time def naive(a,b): x = a y = b z = 0 while y > 0: z = z + x y = y - 1 return z def main(func): if(len(sys.argv) < 3): raise Exception("Pass me args to multiply!") a = int(sys.argv[1]) b = int(sys.argv[2]) init = time.t...
600d61cbd3e88dbc7213dba444a67812f358876e
akudaibergen/labsOfwebka
/week8/3h.py
82
3.796875
4
a=int(input("Number is ")) for i in range (1,a+1): if a%i==0: print(i)
56fba54fc8790969f85210c98e7166905be3893e
JusticeTorkornoo/PasswordManager
/Update_Website.py
2,735
4.21875
4
import sqlite3 import time import Start_Manager # # # This abstraction allows the user to be able to update any website thats on any of their # # accounts in the database ...
817d056fe9543ba5a501261f1448d2c581f6dcb9
Isabel-Mtz/examen
/examen.py
3,054
3.59375
4
# -*- coding: utf-8 -*- """ Editor de Spyder autores: Luna Gonzales Rosio. Martinez Garcia Isabel Este es un archivo temporal. """ # ============================================================================= # """ #Primos <generadores> 30 pts #Realice una generador que devuelva de todos lo numeros primo...
d872cac1bb712ccdeaf58ab4f1ab132ba36722a1
BD20171998/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/9-multiply_by_2.py
178
3.890625
4
#!/usr/bin/python3 def multiply_by_2(a_dictionary): newdict = a_dictionary.copy() for i in a_dictionary: newdict[i] = a_dictionary[i] * 2 return newdict
aef724da9ccf4787fa4ae8ad7ab9eaf8988c87af
XinYou-w/analytics-vidhya-demo
/pywebioDemoCodes/basic (without pywebio).py
540
3.75
4
def demo(): age = int(input("Enter your age: ")) year_exp = int(input("Enter your years of experience: ")) if (age >= 16 and age <=20) and (year_exp <=1): print("Your Expected Salary: {}".format(10000)) elif (age >= 21 and age <=26) and (year_exp >= 2 and year_exp <5): print("Your...
5266b2f4cf4569269fd2d3a178312b7902b51120
Baumelbi/SchoolWork
/CloudSeattle911/seattle911.py
1,210
3.8125
4
"""This program will call to the seattle 911 api and recieve information realting to the given latitude and longitude as well as the radius of the circle. The returned information will be ranked by most common instance to least common""" #!/usr/bin/env python # make sure to install these packages before running: # p...
f3f9498e12cf369fd07da6d3a90e588351b83f78
zacjohnston/skynet_tools
/traj_code/mathRecipes.py
387
3.578125
4
"""Module containing some usefull mathematical recepies.""" import numpy as np import math def find_nearest(array,value): """Return the nearest array entry to the given value""" idx = np.searchsorted(array, value) if math.fabs(value - array[idx-1]) < math.fabs(value - array[idx]): result = array[id...
5659a8e391913561686383ccac38230fa0df009e
virginiah894/python_codewars
/8KYU/greet.py
100
3.5
4
def greet(name: str, owner: str) -> str: return "Hello boss" if name is owner else "Hello guest"
8d9c8f25221710cb4cecec4e4fd5075dff23726d
PiJoules/lazy-typist
/lazy-typist.py
4,076
3.671875
4
#!/usr/bin/python import sys class Coord: def __init__(self, x, y): self.x = x self.y = y def distance(self, coord): dx = abs(self.x - coord.x) dy = abs(self.y - coord.y) return dx + dy class Keyboard: keyrows = ["qwertyuiop", "asdfghjkl ", "^zxcvbnm ^", " ##### "] def __init__(...
fd7daa7646cdc382f32d2fdc4a00f2cfc8539fd1
Becojo/adventofcode
/2016/day09.py
635
3.65625
4
data = input().strip() def decompress(data): count = 0 while '(' in data: s = data.index('(') e = data.index(')') + 1 a, b = map(int, data[s+1:e-1].split('x')) count += s + a * b data = data[(e+a):] return count def decompress2(data): if '(' not in data: ...
0721ee896173ff807377da545f601510789acb6f
dmierm/PythonPY200
/PythonPY200/Инкапсуляция, наследование, полиморфизм/Практические задания/task4_Figure_polymorphism_inheritance/main.py
1,109
4.25
4
import math class Figure: """ Базовый класс. """ def area(self): print(f"Вызван метод класса {self.__class__.__name__}") return None class Rectangle(Figure): """ Производный класс. Прямоугольник. """ def __init__(self, a, b): self.a = a self.b = b ... # TODO оп...
87d12e0bf41b5356d89c5ed66e1a4a2c8cad3982
Mehadisa18/PythonProject
/02_StringsInPython.py
606
3.96875
4
message1 = "Hello this is a string with double quotes" message2 = 'Hello this is string with single quotes' message3="Hello this is a string where there are 'single quotes' with in double quotes" message4='Hello this is a string where there are "double quotes" with in single quotes' message5='Here I\'m escaping the apo...
85e9b72971dece21331d34ced84e13e7c7166471
rudyn2/cc5114
/src/neural_network/preprocessing/Normalizer.py
1,764
3.828125
4
import numpy as np class Normalizer: """ This class provides the functionality to performs normalization over a dataset. """ def __init__(self): """ Constructor for the Normalizer class. """ self.data = None def fit(self, data): """ Fits the data t...
05c4ffe3d5f208172b90c6b4af2cc5c231185ecd
davidecarzaniga/nba-py
/locations.py
161
3.515625
4
import csv reader = csv.reader(open(r"db-locations.csv"), delimiter=',') filtered = filter(lambda p: 'Andre Iguodala' == p[3], reader) for row in filtered: print(row)
22fc65ec8afc471fa56337c2b74e81ca175d856a
benwarner/euler
/primes.py
3,505
3.953125
4
import math import copy #def phi(n): def prime_powers(n, primes=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]): """ Like the factorize method but returns a list of tuples where the first entry is a prime and the second is the number of occurances of that prime. """ prime_list = factorize(...
d6d9d362b9ea8031cb48480100ef987554cfbfcf
shindeswapnil/46-Exercise
/8.py
306
4.28125
4
#Define a function is_palindrome() that recognizes palindromes (i.e. words that look the same written backwards). For example, is_palindrome("radar") should return True. def is_palindrome(s): s1=s[::-1] if s==s1 : return True else : return False s=input('Enter String : ') print(is_palindrome(s))
e8091cc6b1b0baf4a706b249f1d565bd4b4343b1
rosteeslove/bsuir-4th-term-python-stuff
/numerical_analysis_methods/nonlineqs/rootapprox/newtons_method.py
683
3.9375
4
""" This module contains the calculate_root method to approximate polynomial's root in an interval using Newton's method. """ from numpy.polynomial.polynomial import Polynomial from rootapprox import simple_iteration_method as sim def calculate_root(f: Polynomial, a, b, eps): """ Return root approximation c...
415d899572427dd56d1345cb15d7ec73ec4a2c59
yost1219/python
/python/labs/lab2d-f.py
1,701
4.4375
4
>>> #lab2d >>> def reverse(): ... userInput = raw_input("Tell me something good.\n") ... reverseInput = userInput[::-1] ... reverseCaps = reverseInput.upper() ... print reverseCaps ... return ... >>> def reverse(): ... print raw_input("Tell me something good.\n")[::-1].upper() ......
9108a5bc1f4c9011ca673c09f328cc6dae8ea961
mhyang123/tensorflow_test1
/calc/__init__.py
357
3.578125
4
from calc import Calc def main (): calc=Calc(3,7) print("{}+{}={}".format(calc.first,calc.second,calc.sum())) print("{}*{}={}".format(calc.first,calc.second,calc.mul())) print("{}-{}={}".format(calc.first,calc.second,calc.minus())) print("{}/{}={}".format(calc.first,calc.second,calc.div())) if _...
bed21fdbca48ef2a65f56e88535af24680062d20
cruzortiz99/python-course
/cap_3/exercise/solution.py
8,297
3.96875
4
# 1. Crear una función encargada de sumar dos números from functools import reduce def add(first, second): return first + second # 2. Crear una función encargada de sumar n números enteros def add(*nums): result = 0 for num in nums: result = result + num return result # 3. Crear una función...
283ae88e3b896f402ca1729ede8c5b5fd4872fee
anshulagl/Art-Gallery-Simulation
/triangle.py
1,066
3.9375
4
from point import Point from side import Side class Triangle(object): """ Class representing a Triangle that is composed by three Point objects """ def __init__(self, u, v, w): if not all(isinstance(point, Point) for point in (u, v, w)): raise TypeError("u, v, w must be Point obj...
703554f2964859d5e580ae03480e1dec83d026ec
ryan-moll/SNKRSbot
/nike.py
1,338
3.546875
4
import urllib.request from bs4 import BeautifulSoup # specify the url quote_page = 'https://www.nike.com/launch/?s=upcoming' # query the website and return the html to the variable 'html' with urllib.request.urlopen(quote_page) as response: html = response.read() # parse the html using beautiful soup and store i...
352d7ff4033dbb05cfdec83dae6371b6fa3e09a0
MayThandaSoe/test1
/Documents/python exercise/GUI (Day 2)/GUI_day2/kilo_converter(label).py
2,566
3.6875
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 16 17:48:00 2020 @author: Yu Hlaing Win """ import tkinter class KiloConvertor(): def __init__(self): self.main_window = tkinter.Tk() #Create two frames self.top_frame= tkinter.Frame(self.main_window) sel...
36c907ac4273cd927e1a5764ed1a715375d55874
jerkuebler/pyeuler
/11-20/highdivtrinum.py
425
3.703125
4
def find_triangular_number(factors): divis = [] position = 0 num = 0 while len(divis) < factors: divis = [] position += 1 num += position for i in range(1, int(num**0.5) + 1): if num % i == 0: divis.append(i) divis.append(num ...
3269a836052aa3399acdf0490398dc11989ddb8b
Soe-Htet-Naung/CP1404PPrac
/Prac03/password_check.py
233
3.75
4
def main(): password = input("Please enter Password: ") get_password(password) def get_password(password): output = "" for i in password: output += "*" print(output) if __name__ == '__main__': main()
81aa41c2c910a64bbd446093ad8172930108a9b1
CodeMan31/Lab12AdvEmb_JustinLandry
/Part2.py
1,088
3.734375
4
import numpy as np import cv2 as cv cap = cv.VideoCapture(0) if not cap.isOpened(): print("Cannot open camera") exit() while True: # Capture frame-by-frame ret, frame = cap.read() # if frame is read correctly ret is True if not ret: print("Can't receive frame (stream end?). ...
e550206dfcc98509ef54953873864b6329e6f9f3
fingerman/python_fundamentals
/python-fundamentals/1.2_PersonInfo.py
180
3.859375
4
name = input() age = int(input()) town = input() salary = float(input()) print(name + " is " + str(age) + " years old, is from " + town + " and makes $" + str(round(salary, 2)))
9762afa11252796229d6afcb5c30f84c436e8a46
muhammadosmanali/HackerRank
/Python/4. Sets/Introduction to Sets.py
301
4.03125
4
def average(array): array = list(set(array)) total = 0 for x in array: total += x result = total / len(array) return round(result, 3) if __name__ == '__main__': n = int(input()) arr = list(map(int, input().split())) result = average(arr) print(result)
10762752d4441afab2196bbb707336f2c6c41c16
S-O-S/Python-Programming-A-Concise-Introduction
/Problem Set Solution/ProblemSet1/problem1_3.py
106
3.671875
4
def problem1_3(n): my_sum = 0 for x in range(1,n+1): my_sum = my_sum + x print(my_sum)
bf6409efa7a7a16e5b0134004a97821e5bf7fd53
namanofficial10/pymycaptainnaman
/circle_area.py
121
4.125
4
a = float(input("Input the radius of the circle : ")) print(f"The area of the circle with radius {a} is: {(22/7)*a*a}")
2c8daa3c6497329990feb5703a92e8054e8e0e32
JaiRaga/FreeCodeCamp-Data-Structures-and-Algorithms-in-Python
/Basic_Algorithm_Scripting/WhereDoIBelong.py
401
3.515625
4
def getIndexToIns(lis, num): if len(lis) == 0: return 0 for i in range(len(lis)): if lis[i] >= num: return i elif i == len(lis)-1: return len(lis) print(getIndexToIns([10, 20, 30, 40, 50], 35)) print(getIndexToIns([10, 20, 30, 40, 50], 30)) print(getIndexToIns...
5b3ef3c3ae8c6affd709ecbeda1bed47492c28c4
Manuelpv17/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
1,585
4.15625
4
#!/usr/bin/python3 """function that prints My name is <first name> <last name> """ def matrix_divided(matrix, div): """[summary] Arguments: matrix {int, float} -- matrix to be divided div {int, float} -- division number Raises: ...
974cf20c28cb338f1fa2088aa644b5ebeffa8a1a
CarlosZS9/PythonCurso
/prueba_excepsiones2.py
1,064
4.09375
4
def divide(): try: op1=float((input("Introduce el primer numero"))) op2=float((input("Introduce el segundo numero"))) print("La division es: "+ str(op1/op2)) except ValueError: print("El valor es erroneo") except ZeroDivisionError: print("No se puede dividir entre 0") #finally siempre s...
223282303cdd226c1f03e90dd45486022990fbe3
shabbirkhan0015/python_programs
/list2add.py
224
3.828125
4
s=[] def add(l1,l2): s=[[0]*2 for i in range(3)] for i in range(0,len(l1)): for j in range(0,len(l1[i])): s=s+s[i][j] return(s) print(add([[1,2,3],[4,5,6]],[[1,2,3],[4,5,6]]))
d4b490f7d33b98c717f1bcb98598096053218105
AlphaAlpacaa/Project-Euler-s-Solutions
/Project Euler's Solutions/Pandigital_prime.py
940
4.0625
4
"""pandigital olan en büyük asal sayı kaçtır?(padigital 1 den n e kadar bütün rakamları 1 kez içeren) 9 veya 8 basamaklı olsaydı 3 e bölünür sayımız en fazla 7 basamaklı olacak.""" liste = [] def pandigital_Controller(number): if "1" in str(number): if "2" in str(number): if "3" in str(number):...
0ad29d8514c21fffc9d356255adbc9aaa2ebc771
Userbash/my_python
/generate_permutation.py
462
3.8125
4
#!/usr/bin/python def find(number, A): for x in A: if number == x: return True return False def generate_permutation(N:int, M:int=-1, prefix=None): M = N if M == -1 else M prefix = prefix or [] if M == 0: print(*prefix) return for number in range (1, N+1): if find(nu...
2c69884794d96e40eca44f499aeb49a99b723e33
jalisdotco/Hangman
/hangman.py
536
3.59375
4
import random, string, sys bank = ['print','bank','prints','printing','printed','printer','letter',\ 'kalashkinov','honduras','yeti','roaming','backup','ohkay'] bank = ['hello there'] letters = string.ascii_lowercase words = random.choice(bank) ##star = '*' * len(words) guesses = 0 end = 'game over' # Ad...
5be924224931100b1962c00d7bbe0a76bc10dde1
dymodi/tensorflow_basics
/dnn_on_mnist_with_tf.py
1,933
3.859375
4
# A tutorail code for learning TensorFlow # Based on the tutorial provided by TensorFLow # Use deep NN on MNIST datt # Yi DING @ 01/05/18 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # ==================== First section, simple softmax model # Load MNIST Data mnist = input_data.r...
f56af69fdb69f2e6abd2b1d01f14e4fc766ce05b
KenSH77/LearnPython
/ex29.py
900
4.25
4
people = 40 cats = 30 dogs = 41 if people < cats: print "Too many cats! the world is doomed!" if people > cats: print "Not many cats! the world is saved!" if people < dogs: print "The world is drooled on!" if people > dogs: print "The world is dry" dogs +=5 if people >=dogs: ...
59c6bc5f134f7fbb901f70849b6219426f78bb98
jingong171/jingong-homework
/闫凡/第一次作业/第一次作业-金融工程17-1-2017310390-闫凡/循环用法:水仙花数.py
220
3.78125
4
print("三位数中的水仙花数有:") for number in range(100,1000): a=number%10 b=(number%100-a)/10 c=(number-a-b*10)/100 num=a**3+b**3+c**3 if num==number: print(str(number)+" ")
4030ec6d144efd3792e3ef0f48d36bddf77bc0cf
carlosfabioa/TDS_exercicios_logica_programacao
/3-Lacos de repeticao/Enquanto/exercicio1.py
601
4.09375
4
''' Apresentar todos os valores numéricos inteiros ímpares situados na faixa de 0 a 20. Para verificar se o número é ímpar, efetuar dentro da malha a verificação lógica desta condição com a instrução se, perguntando se o número é ímpar; sendo, mostre-o; não sendo, passe para o próximo passo. ''' #iniciamos um contado...
bc727408cac31114be43b131bc0a4c86c6f88fe4
andro-demir/ModernSignalProcessingAlgorithms
/reverseLevinson/main.py
1,106
3.78125
4
#A is a vector of doubles, #first number corresponds to z^0, second z^-1, third z^-2 etc... #You must enter 0 if a term does not exist. import numpy as np from fractions import Fraction # For problem 1: H = np.array([1, 2, Fraction(1,3)]) # For H1 in problem 2: H1 = np.array([1, 0.4, -1.2, 2]) # For H2 in problem 3: ...
08c29ba19053f72eea5ffe94481f9973e3aed87b
yatashashank/python
/ass-1/first.py
750
4.15625
4
import re p=raw_input("enter a password : ") if len(p)>16 or len(p)<6 : print "not a valid password. Make sure length of password should be in range 6-16 characters" elif p.isalnum()==True : print"not a valid password. should contain atleat one digit" elif not re.search("[[$@!*]",p): print " not a valid pas...
f3bb3d9848a321f760d6dd8bb64a9f8a99c4201e
BigSamu-Coding-Dojo-Python-Assignments/Functions_Basic_I
/Functions_Basic_I.py
5,496
4.125
4
#Excercise_1 def Excercise_1(): def a(): return 5 print(a()) # Function a() return value 5. Value 5 is printed on the terminal #Excercise_2 def Excercise_2(): def a(): return 5 print(a()+a()) # Function a() return value 10. Value 10 is printed on the terminal #Excercise_3 def Excerci...
b6c600d1c0e1640b1f5918bb37f3bf0b34d5e2a6
pymd/DataStructures
/DataStructuresPython/tree/02_MaxInBinaryTree.py
1,650
3.921875
4
from TreeNode import TreeNode as Node class Tree: def __init__(self): self.root = None def createNode(self, val): node = Node() node.setVal(val) return node def maxInBinaryTree (self, root): """ Visit each element of the tree recursively, and maintain a maximum. Recursive visit: Get max from...
5d46e5cd5da5caa8cad966d40f214d32cc537e0f
tjhobbs1/python
/Module6/payroll_calc.py
1,769
4.40625
4
""" Program: payroll_calc.py Author: Ty Hobbs Last date modified: 09/30/2019 The purpose of this program is to take an employees name, the number of hours they work and their rate of pay. It will then return the total amount of pay that employee will receive. """ def hourly_employee_input(): # This function wil...
2d1ec4c579c590e64ee7d37e761fe7669557d9b0
synxelm/360video-edge-rendering
/client/client.py
1,834
3.515625
4
#!/usr/bin/env python # Program: # To set up its socket differently from the way a server does. Instead of binding to a port and listening, it uses connect() to attach the socket directly to the remote address. # Author: # Wen-Chih, MosQuito, Lo # Date: # 2017.3.11 import socket import sys im...
b7cd7be832f852d66250c9e3de2b7b65465ba8f5
1505069266/python-study
/day9/init.py
1,131
4.34375
4
# 类要用大驼峰写法 class Cat: """定义了一个类""" # 属性 # 初始化对象 def __init__(self,new_name,new_age):# 这个方法自动执行 除了self的参数是需要创建对象的时候输入的参数 self.name = new_name self.age = new_age def __str__(self): #打印对象的返回信息就这个函数返回的信息 return "名字:%s,年龄:%d"%(self.name,self.age) # 方法 def eat(self): ...
324faecc3d04210bf75c5ac1510bda70d7d0ac0f
AbhishekKhaneja/PythonTutorial
/PythonBasics/Functions.py
651
3.6875
4
class abc: num = 100 def __init__(self, a, b): self.first = a self.second = b print("i am a default constructor and called automatically when a object is created") def indian(self): print("i am a indian nothing to do with hindu muslim") def summation(self): retu...
befe70f966dfde02516772ff7724d9883132b961
Axel164ful/LearnPython
/26-Excepciones.py
902
4.3125
4
#Las excepciones son errores detectados por Python durante la ejecución del programa Print ("hola") try: #<--- la estructura basica de las excepciones es mediante los try except print (x) except: #<--- se le puede agregregar excepciones en especifico ejem TypeError= que solo funciona con #errore...
ec4d6a4baa8299d73de537e7569ba03aef3ba382
jasujon/Start-Python
/lession21/index.py
2,994
4.6875
5
#------------------------------------Intro to *args / *operator----------------------------- # *operator # *args #data gather tuple #normal function # def total(a,b): # return a+b # print(total(2,3)) #output : 5 #but if we try to pass many argument #### print(total(3,4,6)) ####output : TypeError: total() ...
b9c8699875f65188b373233cd95b33e21c9bfb56
juliannepeeling/class-work
/Chapter 5/5-8.py
232
3.953125
4
usernames = ['admin', 'jpeeling', 'deden', 'lisah', 'paulp'] username = input("What is your username? ") if username == 'admin': print("Hello, admin. Would you like to see a status report?") else: print("Hello, " + username + "!")
9c2b0b113d57ce3f09cac0457d29a3419e54056f
Andersirk/INF200-2019-Exersices
/src/anders_karlsen_ex/pa01/snakes_and_ladders.py
3,192
3.890625
4
# -*- coding: utf-8 -*- __author__ = "Kåre Johnsen", "Anders Karlsen" __email__ = "kajohnse@nmbu.no", "anderska@nmbu.no" import random import statistics as st class Players: def __init__(self): self.current_position = 0 self.number_of_throws = 0 def position(self): return self.curre...
feb0870ef1fc66f49fc77d1bdf737d7644a3794b
wheejoo/PythonCodeStudy
/7주차 이분탐색,그래프/백준/랜선자르기/김휘주.py
817
3.5
4
# https://www.acmicpc.net/problem/1654 k,n = map(int,input().split()) line = [] for _ in range(k): line.append(int(input())) def solution(n, line): left = 1 right = max(line) while left <= right: mid = (left + right) // 2 # print(mid) log = 0 for l in line: ...
01ee142df5a314a6415c8a8aa3c18a0b1f33a9dc
GuriSandal/Django_works
/Python/lcm_hcf.py
350
3.78125
4
num1 = int(input("Enter First Number= ")) num2 = int(input("Enter Second Number= ")) small = min([num1,num2]) large = max([num1,num2]) x = large y = small while(y): x,y = y,x%y print("H.C.F. or G.C.D.=",x) x=large y=small while(True): if((large % x == 0) and (large % y == 0)): print("L.C.M.= ",large)...
9947d41ac9f7916fe45bfcf34832f1c3f2e44959
hanasmarcin/leading-color-finder-service
/ClusteringAlgorithm.py
5,567
3.75
4
import numpy as np POW = 3 def calculate_distance(point_a, point_b): """ Function calculates distance between two points :param point_a: fist point's coordinates :param point_b: second point's coordinates :return: distance between two points """ return np.linalg.norm(point_a-point_b) de...
2695819330b303df541b3d74cce1ebcbc8cf7dff
prajjwalkumar17/DSA_Problems-
/dp/Dice_Throw.py
3,343
4.03125
4
""" Author: Akash Kumar Bhagat (akay_99) Dice Throw Problem : Given n dice each with m faces, numbered from 1 to m, find the number of ways to get sum X. X is the summation of values on each face when all the dice are thrown. Purpose: Return the number of ways you can get a sum equal to K ...
40bfd6f68f59233ae0791321afc79b251e487db3
chirag1992m/geeky
/HackerRank/ProjectEuler/euler004.py
842
3.890625
4
#!/bin/python3 ''' Largest Palindrome Product https://www.hackerrank.com/contests/projecteuler/challenges/euler004 ''' import sys ''' Pre-calculate all the palindromes time complexity: O(899 + 898 + 897... + 1) The list only contains around 600 unique members, which is not to hard to search for with a ...
c49939de6a0b7808ff4298c84e263ec95c6dfa96
tharani247/PFSD-Python-Programs
/Module 1/Program-60.py
394
4.40625
4
# 60.python program to demonstrate polymorphism(Method Overloading) class shape: def area(s,a=None,b=None): if a!=None and b!=None: print("Area:",a*b) elif a!=None:##special literal None print("Area:",a*a) else: print("Area:",0) s=shape() s.area(...
757c8a6da36b360d3c1d08032d024ab2cfd0d276
longfight123/16-CoffeeMachineProject
/main.py
3,559
3.875
4
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, "cappuccino": { ...
9415ad86d1d84d28d09f9475a576cfac9380f481
amanpate531/undergraduate_portfolio
/Year 4/CSCI-A 310/Labs/LinkedList.py
1,932
4.125
4
# Aman Patel # CSCI-A 310 # January 31, 2021 class Empty: def __init__(self): pass def cons(self, item): return LinkedList(item) def length(self): return 0 def isEmpty(self): return True def append(self, lst): return lst def __str__(self)...
a65b0020802d2d0d23c56922705e7e75a7209312
cristianjs19/codefights-solutions-Python
/The Core/54 - isCase-InsensitivePalindrome?/isCase-InsensitivePalindrome.py
176
3.5
4
def isCaseInsensitivePalindrome(inputString): reverse = inputString[::-1] if inputString.lower() == reverse.lower(): return True else: return False
77fca5d1a9c12910075eb292a65c799222399372
zxl123129/Business-card-management
/cards_tools.py
3,819
3.8125
4
#记录所有的名片字典 card_list =[] def show_menu(): """显示菜单""" print("*"*50) print("欢迎使用【名片管理系统】v1.0") print("") print("1.新增名片") print("2.显示全部") print("3.搜索名片") print("") print("0.退出系统") print("*"*50) def new_card(): """新增名片""" print("-"*50) print("新增名片") #1.提示用户输入名片信息 ...
96973203f93a28bdfbdd4951e7751613ab691d6f
skymoonfp/python_learning
/python_project/test/test.py
5,464
3.5
4
#!/usr/bin/env python3 # -*- coding:UTF-8 -*- print("3") # # 查看当前文件路径 # import os # os.system("cd") # # # 显示当前文件夹信息 # import os # os.system("dir") # # # 保存当前文件路径 # import os # path = os.popen("cd").read() # print(path) # # # 查看模块详细信息 # help("os") # # # 查看模块内方法 # print(dir(os)) # # 文件读写方式 # encode_test = open("E:\\D...
88c67c79a374572d89ca01d06819fa3babda562f
SamyT-code/Python-Assignments
/a4_Q3_300184721.py
848
4.125
4
# Family name: Samy Touabi # Student number: 300184721 # Course: ITI 1120 C # Assignment Number 4 Question 3 # year 2020 raw_input = input("Please enter a list of integers separated by spaces: ").strip().split() n = [] for i in raw_input: n.append(float(i)) def longest_run(n): '''(list of n...
76b9873a232c5c9eb13d24bba3612ba73b729a9d
RoyalBosS-Ayush/IndianFlag-Turtle
/IndianFlag.py
730
3.59375
4
from turtle import * def draw_rect(x,y,l,b,color): goto(x,y) fillcolor(color) begin_fill() pendown() for _ in range(2): forward(b) left(90) forward(l) left(90) end_fill() penup() def draw_chakra(x,y,r,color): goto(x,y-r) pencolor(color) pendown()...
a48d59e04015faae08ec0f7aa38305af525cdae6
RwJr89/PythonClass
/bounce.py
355
4.15625
4
height = float(input("Enter the height:")) bouncy_index = float(input("Enter the bounciness index:")) bounces = int(input("Enter the number of bounces:")) distance = 0 while bounces > 0: distance = distance + height height = height * bouncy_index distance = distance + height bounces -= 1 print("The di...
9a9e7d12157da0be07fbaea24147f84309aeddca
Zirmaxer/Python_learning
/Prometeus/tmp.py
327
4.21875
4
def MyInputInteger (): while True: try: number_of_words = int(input('Please, enter number of words in the sentence:')) return number_of_words except: print('Not an integer number. Try again!') continue return number_of_words a = MyInputInteger() p...
5a3df3aef1cfede1dfeb6c52f449e1ae54027218
fallaciousreasoning/KDD2014
/smalleriser.py
685
3.53125
4
"""Just uses the first 300 rows for testing""" def smallerise(filename, lines_count = 6000): """Creates a small version of different files""" lines = [] with open(filename, 'r', errors='ignore') as f: for i in range(lines_count): try: lines.append(f.readline()) except: print('uh oh, coudln\'t read l...
d36c3b6010b3121293b0eb30c806bf9244b49e32
alikemalcelik42/Fibonacci
/main.py
263
4.125
4
# Fibonacci Serisi def Fibonacci(first, second, max): if first + second > max: pass else: print("{} - {}".format(second, first + second)) Fibonacci(second, first + second, max) max = int(input("Enter Max: ")) Fibonacci(1, 2, max)
ab601b35098b41ee81f116bc1866a538883f17a2
SaiSanthoshikiran/python-programs
/lucky number.py
432
3.640625
4
#"printing the num if no.of occurences and the num is same --lucky num ,in case 2 or more possible outcomes printing the largest val" def lucky(arr): c={} for i in arr: c[i]=c.get(i,0)+1 print(c) for i in sorted(set(arr),reverse=True): if i==c[i]: return i return...
eb09f9c962ac361ea78af8714aa18d8414c0d631
shobhit-nigam/qti_panda
/day5/adv_funcs/6.py
174
3.71875
4
listx = ["joey", "does'nt", "share", "food"] print(list(enumerate(listx))) print(list(enumerate(listx, start=6))) enum = (enumerate(listx)) print(type(enum)) print(enum)
aeae73a356a8c3e44d1d1f3ed76160236ca5c8e7
LucasVanni/Curso_Python
/Exercícios/ex015.py
251
3.546875
4
dias = int(input('Informe a quantia de dias que o carro foi alugado: ')) kmR = float(input('Informe quantos Kilometros foram percorridos pelo carro: ')) pago = (dias * 60) + (kmR * 0.15) print('O total a pagar é de R$ {:.2f}'.format(pago))
6393aa3091b64375bdc51e691807eab7dda4681b
abhishekbansal815/TicTacToe
/main.py
10,082
3.640625
4
# This is a game called tic tac toe # you can play with friend or AI # add score,reset and undo button import math import random import pygame import time pygame.init() pygame.display.set_caption("Tic Tac Toe") pygame.display.set_icon(pygame.image.load("icon.png")) win = pygame.display.set_mode((400, 500)) backgrou...
85f3ee7ef1d9713dafcca2fe45c409f2811921e6
RaniaMahmoud/SW_D_Python
/Sheet4/S4/P10.py
128
3.53125
4
list1 = ["Mike", "", "Emma", "Kelly", "", "Brad"] l=[x for x in list1 if x != ""] print (l) r= list(filter(None,list1)) print(r)
95ddcb895f50995da23a5c6c74a816352dda5efc
zdyxry/LeetCode
/dynamic_programming/1546_maximum_number_of_non_overlapping_subarrays_with_sum_equals_target/1546_maximum_number_of_non_overlapping_subarrays_with_sum_equals_target.py
491
3.640625
4
from typing import List class Solution: def maxNonOverlapping(self, nums: List[int], target: int) -> int: s = {0} cur_sum = 0 ans = 0 for num in nums: cur_sum += num if cur_sum - target in s: s = {0} cur_sum = 0 ...
66876f6b661e802a6b98f0352bbf0cdfb21105ab
schulzsebastian/python_firststeps
/playlista.py
733
3.5
4
#! /usr/bin/python # -*- coding: utf-8 -*- """ Tworzenie playlisty z tagu na Wykopie """ import urllib import re def stworz_playliste(tag): url = 'http://www.wykop.pl/tag/' + tag html = urllib.urlopen(url).read() links = re.findall('href="https://www.youtube.com/watch\?v=([a-zA-Z0-9]+)"', html) powto...
1341c126165519be7d49175962e14de9a96219d0
kartikeychoudhary/competitive_programming
/hackerrank/problem_solving/strings/funny_string.py
650
3.6875
4
#!/bin/python3 import math import os import random import re import sys # Complete the funnyString function below. def funnyString(s): rs = s[::-1] flag = True print(s, rs) r1 = [] r2 = [] for x in range(len(s)-1): r1.append(abs(ord(s[x])-ord(s[x+1]))) r2.append(abs(ord(rs[x])-...
077edb29b23c2e3fa68d2fc7cd9c5c147dc6ce3d
Mudassir-Hasan/Mysql
/books_store_sql_database_project.py
32,946
3.65625
4
import mysql.connector # class about Author: class Author: myDb = mysql.connector.connect( host='localhost', user='root', password='Allah786??' ) # creating the cursor object: my_cursor = myDb.cursor() # function to create the author table : def creat...
d77e1d4bb8a9d20f80eb43981f3e06ab2bbbaf9d
kersky98/stud
/coursera/pythonHse/third/10.py
521
3.890625
4
# Даны действительные коэффициенты a, b, c, при этом a != 0. Решите # квадратное уравнение ax²+bx+c=0 и выведите все его корни. import math a = float(input()) b = float(input()) c = float(input()) d = b**2 - 4*a*c if d > 0: x1 = (-b - math.sqrt(d)) / (2*a) x2 = (-b + math.sqrt(d)) / (2*a) ...
5ee23fefe3969639ebb99a7f5bf4c0df71985e74
jessicamunga/witchallenges2_DayFour
/DayFour1.py
131
3.921875
4
def sum(numbers): total=0 for x in numbers: total += x return total print(sum([8,2,3,0,7]))
f16f53062e43506e87b19a70d2a0aa77e2c68a99
Psp29/basic-python
/chapter 6/08_pract_05.py
203
4.21875
4
names = ["prasad", "amar", "akhbar", "anthony"] name = input("Enter the name to check: ") if name in names: print("Entered name is in the list!") else: print("Entered name is not in the list!")
b112929c1836af29d6fe388e1fc749a47695c84e
arpine58/python_homework
/homework3/Palindrome numbers.py
320
3.84375
4
a = int(input()) b = int(input()) def palindrome(x): temp = x rev = 0 while x > 0: dig = x % 10 rev = rev*10+dig x = x//10 if temp == rev: return True else: return False for i in range(a, b): if palindrome(i) is True: print(i)
f4393ae506528879897ee1fd0bce6cb13facec8e
gthomson31/Learning
/python/Basics/lists_and_dict/tuples.py
148
3.65625
4
# tuples are immutable and values cannot be changed t = (1,2,3) mylist = [1,2,3] print (type(t)) print (t[2]) t = ('a','a','b') print (t.count)
eca4cd19c4980c376e2a358d298b037965dcb782
BZAghalarov/Hackerrank-tasks
/Cracking coding interview/10 Sorting Bubble Sort.py
623
3.953125
4
''' https://www.hackerrank.com/challenges/ctci-bubble-sort/problem ''' #!/bin/python3 # Complete the countSwaps function below. def countSwaps(arr): k = len(arr) cnt_op = 0 for i in range(k): for j in range(k-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], ...
8e1b30f95c4345a2a8034f7b27d79dc629d5813d
ubi-python/study
/euler/problem5/chjsik.py
251
3.796875
4
result = 2 def gcd(a, b): while b != 0: remainder = a % b a = b b = remainder return abs(a) def lcm(a, b): return abs((a * b) / gcd(a, b)) for i in range(2, 20): result = lcm(result, i + 1) print(result)
8f2b73ac5bc4ff224b23c8a12ecf68db2cfefc0e
gbrs/EGE_current
/#8 27539.py
1,019
3.625
4
''' Задание 8 № 27539 Борис составляет 6-буквенные коды из букв Б, О, Р, И, С. Буквы Б и Р нужно обязательно использовать ровно по одному разу, букву С можно использовать один раз или не использовать совсем, буквы О и И можно использовать произвольное количество раз или не использовать совсем. Сколько различных кодов м...
21171ae4785925406936e953ab93431a550a452c
yekingyan/Flask_for_my_web
/test.py
76
3.53125
4
d1 = {'x': 1, 'y': 2, 'z': 3} d2 = {k: v for (k, v) in d1.items()} print(d2)
de1995513527ef736a83611d8db0a5cc9e8d953e
educa2ucv/Material-Apoyo-Python-Basico
/Codigos/8-Extras/Extras4.py
624
3.75
4
class Persona: def __init__(self,nombre): self.nombre = nombre def saludo1(self): print("Hola, soy una persona") class Empleado: def __init__(self,sueldo): self.sueldo = sueldo def saludo2(self): print("Hola, soy un empleado") class Cajero(Persona,Emplea...
205b5eaca3b4bcf7759903945cabdb14fef7810f
xie233/ComputerGraphics
/line_bresenham.py
794
3.921875
4
from graphics import * import time def MidpointLine(x1,y1,x2,y2): dx=x2-x1 dy=y2-y1 d=2*dy-dx incrE=2*dy incrNE=2*(dy-dx) x=x1 y=y1 win = GraphWin('Brasenham Line', 600, 480) PutPixle(win, x, y) while x < x2: if (d<= 0): d=d+incrE x=x+1 els...
df31e1cb1cf26b88d50bc0cd3758aed7eb8e4828
mdhatmaker/Misc-python
/interview-prep/geeks_for_geeks/dynamic_programming/ugly_numbers.py
491
3.890625
4
import sys # return nth ugly number (number whose only prime factors are 2, 3, 5 -- 1 is ugly by default) # first 11 ugly numbers: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, … def ugly_number(n): ugly = [0] * n ugly[0] = 1 # 1 is ugly number by default for i in range(1, n-3, 3): ugly[i] = 2 * ugly[i-1] ...
d4186e83271170d9cc66698b4dcf64e84fd18677
heuzin/interview-codes
/adjacentElementsProduct.py
361
3.96875
4
# Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. def adjacentElementsProduct(inputArray): x = 0 y = 0 p = float('-inf') for i in range(len(inputArray) - 1): x = inputArray[i] y = inputArray[i + 1] if x * y > p...
6aabb04631d57cbd43d9f0e49f78095efac86edd
RanchDress/EatWhere
/eatwhere.py
2,387
3.6875
4
import json import datetime import random from enum import Enum class Weekday(Enum): SUNDAY = 0 MONDAY = 1 TUESDAY = 2 WEDNESDAY = 3 THURSDAY = 4 FRIDAY = 5 SATURDAY = 6 restaurants = {} preferences = {} people_going = input("Who's going? (separated by spaces)\n").split(" ") restaurants_...
fc7644383c2c201df0826096f54960beb603a0a6
r0ttan/AoC2020
/day2.py
1,321
3.578125
4
import re test = ['1-3 a: abcde','1-3 b: cdbefg','2-9 c: acaaaaaaca'] def solve(data): count = 0 for p in data: p = p.split() # split on whitespace to separate parts of input a = p[0].split('-') # extract numbers separated by - pol =...
3e9f503c1b2e9e28fa06688a2e0ea910efc9603d
hessio/pythonExamples
/HissingMicrophone.py
189
3.890625
4
string = str(input()) flag = 0 for i in range(1, len(string)): if string[i] == 's' and string[i - 1] == 's': flag = 1 if flag == 1: print("hiss") else: print("no hiss")
a84ed49de2e47983eab6fe2786f4900f4a706dca
clemwek/ande_bc_18
/day1/prime_numbers/prime.py
1,238
4.21875
4
def gen_prime(upper_limit): """ A function that generates prime numbers First check if its greater than 2 since 2 is the smallest prime number create list to hold the variables Then iterate through integers btn 2 and n since 2 is the first prime number we add it to the prime list the for lo...
8367dbd9be20eb4bd5dc88ba06b582fede74b809
pralhad88/ProjectEluer
/project2.py
1,043
3.71875
4
# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... #By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued term...
17b5161a3f78d6f4c8299383a494413ccbe9215a
kr-MATAGI/coursera
/2-NLP_with_Probabilistic_Models/Week_3/Assignment/Autocomplete/suggest_a_word.py
3,667
3.890625
4
# UNQ_C11 (UNIQUE CELL IDENTIFIER, DO NOT EDIT) # GRADED FUNCTION: suggest_a_word def suggest_a_word(previous_tokens, n_gram_counts, n_plus1_gram_counts, vocabulary, k=1.0, start_with=None): """ Get suggestion for the next word Args: previous_tokens: The sentence you input where each token is a...
d13d3f4257c2c33ae7f400d51ee257147c7a39bf
CJ8664/leetcode
/746-min-cost-climbing-stairs/746-min-cost-climbing-stairs.py
673
3.609375
4
class Solution: def minCostClimbingStairs(self, cost: List[int]) -> int: for i in range(2, len(cost)): # To cost[i] represents the cost you need to pay to get to next # step starting from i. # But to get to step i, you need to pay some cost. # That is pay the...