blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
68d677e2cc3c502f5e110b53d9944cd4b034cf12
djorll/ProjectEuler
/projecteuler04 Largest palindrome product.py
429
4
4
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is # 9009 = 91 × 99. # # Find the largest palindrome made from the product of two 3-digit numbers. solution = 0 for i in range(100, 1000): for j in range(i, 1000): if str(i * j) == ...
885dc1e6d28593e354e9fd2032e7a4ab96384230
djorll/ProjectEuler
/projecteuler21 Amicable numbers.py
813
3.59375
4
# Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). # If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called # amicable numbers. # # For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and ...
2ca64a5a4740b0dcc3059586e66fc6e5ec82fcf4
vladiant/SoftUniMachineLearning2019
/2_Linear_And_Logistic_Regression/PythonSklearn/linear_logistic_regression_polynomial.py
2,496
3.671875
4
import numpy as np import pandas as pd from sklearn.linear_model import LinearRegression, RANSACRegressor from sklearn.preprocessing import PolynomialFeatures import matplotlib.pyplot as plt # housing_data = pd.read_fwf("https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data", header=None) hous...
b372d9e64cd5d83f33fa41da8c234d1a5c925395
takeuchisatoshi/08_if_and_go
/for.py
232
3.96875
4
# for i in range(10): # print(i) # # for i in range(11): # print(i) # # for i in range(3, 11): # print(i) for i in range(21): if i % 2 != 0: print(i) for i in range(21): if i % 2 == 1: print(i)
36e4433cbcea1001412b1934d2cb2fc51ea46f71
rinayumiho/course_projects
/burnt_pancake_flipping/hw1.py
11,539
3.734375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: """ Author: Long Chen CISC 681 AI, HW1 pancake flipping with BFS and A* algorithms """ # In[2]: # Global Variable goalId = '1w2w3w4w' # build a node class to be easy show result and search class PancakeNode: def __init__(self, nodeId, g, h): self.nodeId ...
d1bebe1083b7895483da79ba4bef2d56a204108d
gb08/30-Day-LeetCoding-Challenge
/max_sum_subarray.py
470
3.8125
4
""" Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. """ class Solution(object): def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ maxsum = nums[0] final_sum...
197a9a568e4b1d6885237d1e301c107e64e73f80
fnava621/tradesy-bi-tap
/send_sms.py
4,009
3.953125
4
# At the top of the file we declare what "packages" we want to use. # You can think of a package as some code someone else has already written that we can use so we don't have to re-write that code. # In this case we are using twilio package that was created by company twilio. # Twilio company has done a bunch of work ...
03d14d0a015c462afaec3f994f3af59cadfc51e4
peiss/ant-learn-spider
/web_crawler/utils/url_manager.py
1,214
3.8125
4
class UrlManager(): """ url管理器 """ def __init__(self): self.new_urls = set() self.old_urls = set() def add_new_url(self, url): if url is None or len(url) == 0: return if url in self.new_urls or url in self.old_urls: return self.new_u...
6292708f3338a9b02821beedbcd06f4ac3290949
TimothyFothergill/Over-Like-Rover
/Mars Rover/main.py
7,455
3.84375
4
valid_directions = ["N", "E", "S", "W"] class MyRover: """Create your very own Mars Rover 1. We salute you, Mars Rover 1. There's only one Mars Rover 1, until you make more of them, I guess. Define your Mars Rover 1 with: MyRover( starting_point = [list], starting_direction = string...
a9c3c2b7626701edc89ec9f4767e588bbfc64049
wassimbel/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/tests/test_rectangle.py
3,807
3.703125
4
""" module - Rectangle testing """ from models.rectangle import Rectangle from models.base import Base import unittest class TestRectangle(unittest.TestCase): """ testing all the methods inside Rectangle class """ def test_create_subclass(self): """ testing the creation of class Rectangle that inher...
389962ce81f783cffdda02934cb2069ca7ee7b67
Sivaji-Marripudi/Vinnovatelabz-Bangalore
/problem2.py
93
3.625
4
a = input() r = [] for i in list(a): if i not in r: r.append(i) print(''.join(r))
ed6cc5f0875d466eade14018f46412eb99b9d560
Soares/natesoares.com
/overviewer/utilities/miscellaneous.py
854
4.0625
4
def roman_numeral(number): """ Convert a number between 0 and 4999 inclusive to roman numerals >>> roman_numeral(0) '' >>> roman_numeral(1) 'I' >>> roman_numeral(3) 'III' >>> roman_numeral(8) 'VIII' >>> roman_numeral(97) 'XCVII' >>> roman_numeral(1900) 'MCM' >...
6cd204d47bb1937a024c1afa0c25527316453468
Soares/natesoares.com
/overviewer/utilities/string.py
633
4.5
4
def truncate(string, length, suffix='...'): """ Truncates a string down to at most @length characters. >>> truncate('hello', 12) 'hello' If the string is longer than @length, it will cut the string and append @suffix to the end, such that the length of the resulting string is @length. ...
5675d6d852585aa8f5831228db5c381dbafe2256
Avinash2205/Python-lab-assignments
/Lab Assignment 2/Source/first.py
695
4.09375
4
# The details of the book which are available in the library det = { "Python":40, "Data Analytics":50, "Jython":30, "Big data":20 } # for loop for assigning of the key value pairs for k,v in det.items(): # printing the key value pairs print(k,v) # asking the user to enter the minimum and maximum r...
1b5a1de7efab7aae8b07c110b1136a366756e337
1Crazymoney/exercism
/cpp/MatDiscreta/projetofinal/Questão4/gerarCadeias.py
980
3.546875
4
# Esse script Gera os arquivos das cadeias e compila e executa o programa questao4 no modo execução 1 # Fiz ele para realizar teste mais automatizados, e com cadeia maiores import random import os # Gera string que define a cadeia def cadeia(tamanho): cadeia = "" for _ in range(tamanho): escolha = rand...
198b174dade7b64c6dd307064ac4246748ef8ba3
7MAX1998/sayHello
/insert.py
794
3.828125
4
#-*- coding:utf-8 –*- # chinese.py import sqlite3, sys def insert(a, b, c, d, e ): conn = sqlite3.connect('sayHello.db') c = conn.cursor() c.execute("INSERT INTO COMPANY (姓名,学号,性别,年龄,学院) \ VALUES ('%s', '%s', '%s', '%s', '%s' )" % (a, b, c, d, e)); conn.commit() c = conn.cursor() cursor = c.ex...
066bcfb00c4f01528d79d8a810a65d2b64e8a8a2
bchaplin1/homework
/week02/03_python_homework_chipotle.py
2,812
4.125
4
''' Python Homework with Chipotle data https://github.com/TheUpshot/chipotle ''' ''' BASIC LEVEL PART 1: Read in the data with csv.reader() and store it in a list of lists called 'data'. Hint: This is a TSV file, and csv.reader() needs to be told how to handle it. https://docs.python.org/2/library/csv.html ''' ...
8ad385c4a6c807458ca3413cf7d8c012e27f68b5
zh-cse18/Selenium_Webdriver_Operation
/generate valid url.py
248
4.09375
4
given_string = 'ALASKA NATIVE MEDICAL CENTER' print(len(given_string)) words = given_string.split() # Forget () wordCount = len(words) print(words[0]) print(words[1]) print(words[2]) print(words[3]) print("The total word count is: %s" % wordCount)
8e217eead217b9f42ded65269ffa7a93edaa2471
Arnon00/Projetos.Python
/CursoEmVideo/Exercicios/ex0010.py
149
3.734375
4
valor = float(input("Quantos reais você possui?")) conv = float((valor/3.27)) print("você pode comprar {:.2f} em dolares".format(conv))
e3b6776b3517b77b4ffa62f91e1bcf8c0f814c29
Arnon00/Projetos.Python
/CursoEmVideo/Exercicios/ex0017.py
417
4.03125
4
from math import pow co = float(input('Digite o Cateto oposto: ')) ca = float(input('Digite o Cateto Adjacente: ')) # Forma matematica pura: hi = (co ** 2 + ca ** 2) ** (1/2) # print('A hipotenusa é {:.2f}'.format(hi)) co2 = pow(co,2) ca2 = pow(ca,2) hipo = co2+ca2 print('O Cateto Adjacente é: {:.0f...
74d2be6bb4583b12f4d2dfaa562d4246daafd357
Arnon00/Projetos.Python
/CursoEmVideo/Exercicios/ex0008.py
232
3.609375
4
num = float(input('Digite a distancia em metros: ')) cen = float(0.00100) mil = float(0.00010) rescen = int(num/cen) resmil = int(num/mil) print('metros: {}, centimetros: {}, Milimetros: {}'.format(num, rescen, resmil))
69bd7b8813a0e768e35d68e524a39564e8bd9f44
joestone51/ctci
/is_unique.py
646
3.609375
4
import unittest def is_unique(s: str) -> bool: ht = {} for c in s: if c in ht: return False ht[c] = True return True class TestIsUnique(unittest.TestCase): def test_passing(self): cases = ['abcdefg', 'a', 'ab', 'abc', '.,/;', 'aAbB '] for case in cases: with self.subTest(c...
76a53f154f6ba53310d810ac49120a193f103c5d
kevinjqiu/hackerrank
/ctci-contacts/trie.py
1,973
3.515625
4
class Node: def __init__(self, ch=None, parent=None): self.parent = parent self.ch = ch self.size = 0 self.children = [] def __str__(self): return '<ch=%s, parent=%s, children=%s>' % (self.ch, id(self.parent), self.children) __repr__ = __str__ class Trie: def ...
c8f061d0a557f3b03147282a76e80e117ed6acaf
aconsilvio/SwarmAlgorithms
/Ants/ants.py
1,885
3.578125
4
from models import * import random Graph = [[0, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [0, 1, 0, 0, 1], [1, 0, 1, 1, 0]] def initialize_nodes(value_list): nodes = [] for i, val in enumerate(value_list): node = Node(val, i) nodes.append(node) return nodes def initialize_ants(start_node, num_ants):...
2d154709a3e075a95bd12f94c4692261dc6201c3
FayeLee303/DataStructureWithPython
/m_10_二叉排序树.py
6,234
3.515625
4
""" 左子树不为空时,左子树上所有结点都小于根结点 右子树不为空时,右子树上所有结点都小于根结点 左右子树也分别是二叉排序树 查找:小了往左子树去找,大了往右子树去找 插入:小了去左,大了去右 删除: 如果删除的结点是叶子,直接删除 如果要删除结点只有左子树或者只有右子树,则删除结点后将子结点连到父结点上 如果要删除结点同时有左右子树,则可以将二叉排序树中序遍历 取将要删除结点的前驱或者后继代替这个被删除的结点的位置 如果要删除结点同时有左右子树,取其右子树的最小结点代替该结点,调整完之后 该树应该呈现是度为1的结点的子结点在左 二叉排序树的中序遍历是把这些数从小到大排列!! """ class...
d8dd320a054b5eaea903b6eab60b4baa09e8ab95
DavidAfework/Python-projects
/Microsoft python exercises/exercise1.py
185
4.25
4
value = '9' if value == '6': print('The value is 6') elif value < '8': print('The value is less than 8') else: print('The value is greater than 8') print('Finished!')
f23343dc635f53dd54db3df7ca6e121bb05679be
Rustam544/Python
/Kasumov_Rusatm_dz_3/task_3_3.py
437
3.78125
4
def thesaurus(*args): dict_args = {} key_str = '' for i in range(len(args)): if args[i][0] not in key_str: key_str += args[i][0] for i2 in key_str: list_name = [] for i3 in range(len(args)): if i2 == args[i3][0]: list_name.append(args[i3]) ...
0982d07b0af6e12ee34a1bad96af8d9e7730bc8c
andrericardoweb/curso_python_cursoemvideo
/exercicios/ex008.py
287
4.1875
4
# Exercício Python 008: Escreva um programa que leia um valor em metros e o exiba convertido em centímetros e milímetros. m = eval(input('Uma distância em metros: ')) print('CONVERTENDO MEDIDAS') print(f'{m/1000}km | {m/100}hm | {m/10}dam | {m}m | {m*10}dm | {m*100}cm |{m*1000}mm')
8e9ba2f7d1953d7707489702b309d4d03010aa45
Wilkenfeld/CityTraveling-2.0
/samples/classes/road.py
735
3.578125
4
import math class Road(): def __init__(self, start, end, maxPollution = None): self.start = start self.end = end self.maxPollution = maxPollution self.actualPollution = 0 self.actualSpaceLeft = math.sqrt(int(start)**2 + int(end)**2) def addCar(self, car): isAc...
263a7e9e667c1a18607988b10fa49186194c63ff
Akaexus/semantic-tableau
/logic/operator/__init__.py
917
3.59375
4
class Operator: symbols = [] args = [] numberOfArguments = 2 # for most cases def __init__(self, args): if isinstance(args, list): self.args = args else: self.args = [args] def __repr__(self): if self.numberOfArguments == 2: return "{} {...
9b3d1b9e0e0d185b79f05886634c7657e80f6f0b
MagomedNalgiev/Ozon-New-Skills
/DZ_3-2.py
474
4.0625
4
print('Таблица умножения:\n') #Задаем цикл для первого множителя for first_multiplier in range(1, 10): print(f'------{first_multiplier}------') #Задаем цикл для второго множителя и выводим операции на экран for second_multiplier in range(1, 11): print(f'{first_multiplier} * {second_multiplier} = {first_mul...
81ad7ff791adaf6dfad0b90fbb9f60c56139be6c
MagomedNalgiev/Ozon-New-Skills
/DZ_3-1.py
609
4.375
4
string1 = 'Съешь ещё этих мягких французских булок ДА выпей же чаю' #Преобразуем текст в список string1_list = string1.split() #Выводим четвертое слово в верхнем регистре print(string1_list[3].upper()) #Выводим седьмое слово в нижнем регистре print(string1_list[6].lower()) #Выводим третью букву восьмого слова print...
157acd8013f57c045aa5bc4977219b0fff492c1f
abnormalmakers/generator-iterator
/generator_test3.py
135
3.65625
4
l=[1,2,3,4] lst=[x for x in l] gen=(x for x in l) print(lst) print(gen) l[1]=222 print(lst) print(gen) for i in gen: print(i)
90af163267b8d485c28169c9aeb149df021e3509
hemenez/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
423
4.3125
4
#!/usr/bin/python3 def add_integer(a, b): """Module will add two integers """ total = 0 if type(a) is not int and type(a) is not float: raise TypeError('a must be an integer') if type(b) is not int and type(b) is not float: raise TypeError('b must be an integer') if type(a) is fl...
1dc73af907ff9a71ca3cfd048dd630b1938fc43f
hemenez/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/tests/6-max_integer_test.py
900
3.875
4
#!/usr/bin/python3 """Unittest for max_integer([..]) """ import unittest max_integer = __import__('6-max_integer').max_integer class TestMaxInteger(unittest.TestCase): """Utilizes unittest to evaluate max_integer module """ def outcome_pos_ints(self): self.assertEqual(max_integer([1, 2, 3, 4]), 4)...
59dfa0d9f3adbc50e7aa19f36c1b242304a3c1c7
hemenez/holbertonschool-higher_level_programming
/0x0A-python-inheritance/2-is_same_class.py
242
3.84375
4
#!/usr/bin/python3 def is_same_class(obj, a_class): """Function returns True if object is an instance of specified class, otherwise returns False """ if type(obj) is a_class: return True else: return False
be92a7a0e04813b166cc30c7d00cb9a0b357409f
hemenez/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/tests/test_square.py
6,337
3.78125
4
#!/usr/bin/python3 """Unittest for Base() class """ import unittest import io import sys from models.rectangle import Rectangle from models.base import Base from models.square import Square class TestSquareClass(unittest.TestCase): """Utilizes unittest to evaluate possible outcomes of creating instances of a ...
dbb83d0461e2f93fb463380da950cf83a61eeee4
28kayak/CheckIO_TestFile
/BooleanAlgebra/boolean_algebra.py
1,299
4.15625
4
OPERATION_NAMES = ("conjunction", "disjunction", "implication", "exclusive", "equivalence") def boolean(x, y, operation): return operation(x,y) def conv(x): if x == 1: x = True else: x = False def conjunction(x,y): if x == y and x == 0: #print "T" return 1 elif x == y and x == 1: #print "F x and y are ...
17cad3fa4c94d394cfed3c649083e9f0b31e611a
Andrej300/week3_day3_homework
/modules/calculator.py
395
3.703125
4
def add_numbers(number1, number2): return f"The answer is {int(number1) + int(number2)}" def subtract_numbers(number1, number2): return f"The answer is {int(number1) - int(number2)}" def multiply_numbers(number1, number2): return f"The answer is {int(number1) * int(number2)}" def divide_numbers(number1, ...
79e5addff477b76dd4c6d317584ed0d1a8856718
canid/g-codes
/rqtoend
385
3.796875
4
#!/usr/bin/python import math import sys def main(argv): def endpoint(x, y, angle, length): endx = x + (length * math.cos(math.radians(angle))) endy = y + (length * math.sin(math.radians(angle))) print("X: "+str(endx)+", Y: "+str(endy)) endpoint(float(argv[1]), float(argv[2]), float(argv[3]...
bbacd79658e6d21b21c0d6c415376819f57398c9
FraserP117/MATH3024-Project
/sandpile.py
2,221
3.546875
4
def create_sandpile(num_grains): sandpile = {} # create the sandpile: # for node in range(0, 401): for node in range(0, num_grains): sandpile[node] = random.randint(0, 3) return sandpile def add_sand(num_grains_to_add, sandpile): for node, num_grains in sandpile.items(): if num...
ba2c8e1e768b24f7ad7a4c00ee6ed4116d31a21a
kjigoe/Earlier-works
/Early Python/Fibonacci trick.py
866
4.15625
4
dic = {0:0, 1:1} def main(): n = int(input("Input a number")) ## PSSST! If you use 45 for 'n' you get a real phone number! counter = Counter() x = fib(n,counter) print("Fibonacci'd with memoization I'd get",x) print("I had to count",counter,"times!") y = recursivefib(n, counter) print("And with recusion I stil...
ee52b9ea66e6ef6c0356f85e574f8539a0d3afa2
teloyang/NITF-master
/1234.py
561
3.609375
4
class Data_test2(object): day=0 month=0 year=0 def __init__(self,year=0,month=0,day=0): self.day=day self.month=month self.year=year @classmethod def get_date(cls,data_as_string): #这里第一个参数是cls, 表示调用当前的类名 year,month,day=map(int,cls.string_date.split('-')) date1=cls(year,month,day) ...
66a664e4fc2ba05451b2448175ce524bdd91f210
kunwarakash/django-sql-explorer
/explorer/counter.py
2,054
3.71875
4
# Taken from http://code.activestate.com/recipes/576611-counter-class/ class Counter(dict): '''Dict subclass for counting hashable objects. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values. >>> Counter('zyzygy') Counter({...
fb3508031d725d1729357e163db1861669c79125
Kaylotura/-codeguild
/practice/blackjack/hand.py
4,837
4.125
4
"""Module containing the Hand class""" from card import Card class Hand: """A class for representing a Hand of cards""" def __init__(self, cards): self.cards = cards def __eq__(self, other): return ( self.cards == other.cards ) def __repr__(self): ret...
e996c9bff605c46d30331d13e44a49c04a2e29be
Kaylotura/-codeguild
/practice/greeting.py
432
4.15625
4
"""Asks for user's name and age, and greets them and tells them how old they'll be next year""" # 1. Setup # N/A # 2. Input name = input ("Hello, my name is Greetbot, what's your name? ") age = input(name + ' is a lovely name! How old are you, ' + name + '? ') # 3. Transform olderage = str(int(age) + 1) # 4. Output...
b5821f9ae0d837747da91bc4ebb1361cd496a922
vinxavier/metodosdeotimizacao
/Problem36c.py
887
3.59375
4
from ortools.linear_solver import pywraplp MAX_AD = 250 BUDGET = 1000000 labels = ["Television","Radio", "Newspaper"] #custo de cada ad custos = [4000,500,1000] #custo de produção de ad para determinada mídia pCustos = [500000,50000,100000] alcance = [500000, 50000, 200000] p = pywraplp.Solver("", pywraplp.Solver.C...
3136b8e832aca2260c5e5ea950d4730560e72e0f
kkittif/Timetable-scheduling
/scheduler.py
21,904
3.796875
4
import module import tutor import ReaderWriter import timetable import random import math class Scheduler: def __init__(self,tutorList, moduleList): self.tutorList = tutorList self.moduleList = moduleList #Using the tutorlist and modulelist, create a timetable of 5 slots for each of the 5 work days of the week...
f1d529366856a2a5d8f322d8c8a5f8ec7d119d41
Gulshan06/List-Assessment-
/day8/numlist.py
409
3.59375
4
# li = [1,2,3,4,5,6,7,8,9,10] # new = [i for i in li if i%2==0 ] # print(new) li=['english','tamil','civic','river','rotor','madam','malayalam','example','running','noon'] # new = [i for i in li if i==i[::-1]] # print(new) # li =[i for i in range(2,500)] # new=[j for j in li if j%2==1] # print(new) # new = [i.upper()...
e4f99a1dddc7fb08aec810f9f15a78912e456b4c
Gulshan06/List-Assessment-
/day9/val.py
1,264
3.9375
4
import re name=input("enter the name: ") mobile=input("enter the number: ") pincode=input("enter the pincode: ") address=input("enter the address: ") emailId=input("enter the email id: ") nam=re.search("^[a-zA-Z\s\.]*$",name) if nam: print("Name is acccepted",name) else: print("Name is incorrect",name) val1=re....
cb6f2ead652916fe72637ce01465979611724136
Gulshan06/List-Assessment-
/day4/listevn_odd.py
234
3.984375
4
num = int(input()) even =[] odd = [] def evenodd(num): if num%2==0: even.append(num) else: odd.append(num) evenodd(num) if (len(even)>0 and len(odd)<=0): print(even,"even no") else: print(odd,"odd no ")
d49f208ba464b18f018df60c0724ea9e57ec3d07
Gulshan06/List-Assessment-
/day8/add.py
237
3.875
4
num = 10 a = num.__add__(10) print(a) class Employee: def __init__(self): self.name='Ram' self.salary=10000 def __str__(self): return 'name='+self.name+' salary='+str(self.salary) e = Employee() print(e)
6453e6301f6470bf40f0dbf183f07ef9454bc9c3
Gulshan06/List-Assessment-
/ASS/sorting.py
921
3.828125
4
import timeit # By sort() funcetion def compareSort(): getlist=[4,2,5,34,6,3,76,43] getlist.sort() print(timeit.timeit(compareSort,number=100000)) # By Insertion sort def insertion(): def insertionSort(arr): for i in range(1, len(arr)): m = arr[i] j = i-1 whi...
b8602cfcb48369836e4d5b35081ca70785963913
cravingdata/Testing-operations
/testing_operations.py
185
3.53125
4
print int(3.14) print float(63/45) print str(88888888888) print 2 ** 3 ** 2 print (2 ** 3) ** 2 fruit = "banana" baked_good = " nut bread" print (fruit + baked_good) print ('fun' * 3)
922c0d74cf538e3a28a04581b9f57f7cfb7377e4
BstRdi/wof
/wof.py
1,573
4.25
4
from random import choice """A class that can be used to represent a wheel of fortune.""" fields = ('FAIL!', 'FAIL!', 100, 'FAIL!', 'FAIL!', 500, 'FAIL!', 250, 'FAIL!', 'FAIL!', 'FAIL!', 'FAIL!', 1000, 'FAIL!', 'FAIL!', 'FAIL!', 'FAIL!', 'FAIL!', 'FAIL!') score = [] class WheelOfFortune: """A simple at...
22349e2b8bc3f99956fb293d14463d71420ad45c
gustavocrod/vrp
/util.py
1,619
4.21875
4
from graph import * def cost(route, graph): """ Funcao que computa a soma das demandas dos clientes de uma rota :param route: rota a ser computada :param graph: grafo :return: """ cost = 0 for i in route: edge = graph.findEdge(i) cost += edge.demand return cost def...
85f15022f8f1fd325c04634155433b672e6e0e9d
riscen/codeFights
/InterviewPractice/lists/reverseNodesInGroups.py
569
3.796875
4
# Definition for singly-linked list: # class ListNode(object): # def __init__(self, x): # self.value = x # self.next = None # def reverseNodesInKGroups(l, k): reversedL = [] while l: kList = [] while l and len(kList) < k: kList.insert(0, l.value) l = l.next ...
77760c1ede00fe7386072150306ec7ed894312cf
riscen/codeFights
/InterviewPractice/trees/hasPathWithGivenSum.py
606
3.734375
4
# # Definition for binary tree: # class Tree(object): # def __init__(self, x): # self.value = x # self.left = None # self.right = None def hasPathWithGivenSum(t, s): if not t and s == 0: return True elif preorder(t, s, 0): return True return False def preorder(t, s, actualSum)...
83270e57364f28f2f7673cc4bd616262004282b6
tchal100/Election_Analysis
/While_loop.py
93
3.890625
4
x=0 while x <= 5: print(x) x=x+1 count = 7 while count < 1: print("Hello World")
48564ad5a773e46b3b80684deab8adb2c76fa3c3
sammilward/Car-Dash
/Python Files and Images/ViewHighScores.py
2,359
3.625
4
from tkinter import * import sys, os root = Tk() #root.title("View High Scores") #Poss app = Frame(root) app.grid() def MainMenuClick(): root.withdraw() os.system('StartUp.py') def GetHighScores(): #Open the file in read mode HighScoreFile = open("HighScores.txt", "r") #Initalise the big list...
91019edbbe911f4e03befbcdfa1895c26398ec20
babiswas2020/New-graph
/test1.py
443
3.828125
4
class A: def __init__(self,a): self.a=a def __iter__(self): self.b=0 return self def __next__(self): item=0 if self.b>self.a: raise StopIteration else: item=self.b self.b=self.b+1 return item if __name__=="__main__": a=A(10) iter(a) print(ne...
2ea07d28bf31947a89ef54a71cd497a9c4e53734
babiswas2020/New-graph
/test5.py
1,083
3.59375
4
class Cell: def __init__(self,x,y,dist): self.x=x self.y=y self.dist=dist def is_valid(x,y,M,N): if x<0 or x>=N: return False if y<0 or y>=N: return False if M[x][y]==0: return False return True def mark_island(M,i,j,visited,N): dx=[0,0,1,-1,1,1,-1,...
148958f2eaf730db4bc1f25e813688d29640684e
kaden60/dev-bio2
/calc.py
400
4
4
print( " ____ ___ ====== ") print( " | \ @ \__ \ || ") print( " | [] | || \ || ") print( " L____/ || \___/ || calc ") a = input("enter the distance: ") d = input("enter the time it takes to travel : ") x = int(a)/i...
cd03409b6c75c1037635569b30124235acfdd454
rammymansour/To-Do
/todo.py
2,048
4.09375
4
def to_hello(): print("Welcome to a simple To-Do app ") def day(): while True: day = input("Which day of the week do you want to choose? "+ "\n") if day in [ "monday", "tuesday", "wednesday", "thursday", "friday", "...
b3f5ecf38585d8e75a4cdff714789f7228d69a3a
bibeksh101/MVPPollingApplication
/database.py
2,902
3.90625
4
import sqlite3 connection = sqlite3.connect("data.db") ########################################################################### # CREATE TABLES CREATE_PLAYERS_TABLE = """CREATE TABLE IF NOT EXISTS players ( username TEXT PRIMARY KEY, voted BOOLEAN );""" CREATE_VOTES_TABLE = """CREATE TABLE IF NOT EXISTS v...
85526c345d79b7cc0c236f74767c94f5c24524b7
AnchalMallick/Dodging_the_blocks
/dodging_blocks_game.py
6,748
3.59375
4
#dodgging_the_blocks import pygame import random pygame.init() display_width = 1200 display_height = 700 yellow = (255, 250, 0) blue = (0, 0, 100) green = (0, 100, 0) bright_blue = (0, 0, 255) bright_green = (0, 255, 0) black = (0, 0, 0) red = (255, 0, 0) orange = (255, 165, 0) purple = (255, 0, 255) white = (255, 2...
5beca5caf7e6893cd8dbff75a67bcffae8f2d680
balajiforaix/EDUREKHA
/sum_db.py
153
3.890625
4
def sum_double(a, b): if a == b: c = a+b * 2 print("double data",c) #return c else: return False sum_double(3, 3)
9ac46c093387df80779612c5324a63d6f5ef985e
Balajisivakumar92/100_DAYS_OF_ML_CHALLENGE
/ML code-s/Day 1 LINEAR REGRESSION WITH GRADIEANT DESCENT/lin-reg with sklearn.py
770
3.578125
4
# importing the packages import numpy as np import pandas as pd from sklearn.linear_model import LinearRegression from sklearn.cross_validation import train_test_split import matplotlib.pyplot as plt from sklearn import metrics # data preprocessing df = pd.read_csv("data.csv") X = df.iloc[ : , :1 ].values Y = df.i...
af94a33d45025332fa706413c23e2b93b7c93246
gdodeva/itmo-2019
/students/gdodeva/3/cli.py
3,061
3.5625
4
# -*- coding: utf-8 -*- """Homework 3.""" import argparse from datetime import datetime import os def create_parser(): """Create parser for command line arguments.""" parser = argparse.ArgumentParser() parser.add_argument( 'command', type=str, nargs='*', h...
4d986370d01a9908ecf59c3244541dc54d33b7f2
nlattessi/utn-frba
/2015-Matematica Discreta/automata.py
2,270
3.578125
4
# coding: utf-8 """ Automata reconocedor de contraseas. Matematica Discreta - TP Anual Nahuel Lattessi 2014 """ import sys #--- FUNCIONES ---# def nuevo_estado(estado, entrada): """Devuelve el estado nuevo segun el actual y la entrada recibida. Toma como base el automata definido en el documento. """ if estado =...
817edc0934c6e661f258326c4ab621f85129ae9b
h-sendai/kenshu
/ex2/read-file-filename-2.py3
143
3.515625
4
#!/usr/bin/python3 filename = 'sample0.txt' with open(filename, 'r') as f: for line in f: line = line.strip() print(line)
77a1a59bb2130429a04fda1c4cd06fb426443d1b
karenseunsom/python101
/tip_calc2.py
1,138
4.03125
4
initial_total = float(input("Total bill amount? ")) quality_of_service = input("Was service good, fair or bad? ") split = int(input("Split how many ways? ")) if quality_of_service == "good": good_tip = initial_total * .20 total_amount = initial_total + good_tip total_after_split = total_amount / split p...
b63879f6a16ae903c1109d3566089e47d0212200
idahopotato1/learn-python
/01-Basics/005-Dictionaries/dictionaries.py
1,260
4.375
4
# Dictionaries # A dictionary is an associative array (also known as hashes). # Any key of the dictionary is associated (or mapped) to a value. # The values of a dictionary can be any Python data type. # So dictionaries are unordered key-value-pairs. # Constructing a Dictionary my_dist = {'key1': 'value1', 'key2': 10...
042e82b93dbc71b0c20a1075c35c19ef9cb9b87c
idahopotato1/learn-python
/08-Built-in Functions/002-reduce.py
493
3.828125
4
# reduce from functools import reduce print('=============================================') l = [1, 2, 3] print(max(l)) # 3 print('=============================================') def find_max(a, b): if a > b: return a else: return b print(find_max(100, 1200)) # 1200 print('=========...
be8bdf542d3b437fddf05ef202859d173d587bb7
idahopotato1/learn-python
/11-Advanced Python Modules/005-datetime.py
1,470
3.828125
4
# Date time print('=============================================') import datetime print('=================Time============================') t = datetime.time() print(t) # 00:00:00 t = datetime.time(2, 25, 2) print(t) # 02:25:02 print(datetime.time) # <class 'datetime.time'> print(datetime.time.min) # 00:0...
41b7282b4199def5b90db24e153c67c877e856eb
idahopotato1/learn-python
/11-Advanced Python Modules/001-collections-module-counter.py
799
3.765625
4
# collections module counter from collections import Counter print('=============================================') num_l = [1, 1, 1, 2, 4, 5, 5, 4, 6, 4, 8, 65, 5, 132, 321, 4, 4, 5, 4, ] print(Counter(num_l)) # {4: 6, 5: 4, 1: 3, 2: 1, 6: 1, 8: 1, 65: 1, 132: 1, 321: 1} print('==================================...
b5dbb2bc21aca13d23b3d3f87569877ce9951eec
idahopotato1/learn-python
/04-Methods-Functions/001-methods.py
736
4.34375
4
# Methods # The other kind of instance attribute reference is a method. # A method is a function that “belongs to” an object. # (In Python, the term method is not unique to class instances: # other object types can have methods as well. # For example, list objects have methods called append, insert, remove, sort, an...
dea957cc7bed1973b12cfa34be33a77c203b47b6
Rodagui/Cryptography
/Gammal.py
2,146
3.84375
4
from exponenciacion import* from generadorPrimos import* from inversoModular import* from primalidad import* from random import * # Python Program to find the factors of a number def obtenerFactoresPrimos(n): factores = set({}) if n % 2 == 0: factores.add(2) while n % 2 == 0: n = n // 2 ...
abb45102966579d6e8efcc54af764ae78c20bccb
QuickJohn/Python
/test/recursion.py
1,287
4.34375
4
# Author: John Quick # Recursion demonstration def main(): print() print('RECURSION WITH PYTHON') print('Choose option:') print('[1] Find factorial') print('[2] Convert to binary') print('[3] Fibonacci') print() # get choice from user option = int(input('Pick option: \n')) ...
6bb4d1ee4559dab93ec5ef0ddec74b2fa65e816f
bigjiminboy/random-python-shit
/AdaptiveRPS.py
1,939
4.09375
4
#Introduction to the game print ("Welcome to spicy Rock Paper Scissors!") long = input("How many rounds would you like the game to be?(must be an integer)\n") long = int(long) rounds = 0 x_pt = 0 y_pt = 0 z = [1, 2, 3] #Bigboi gameplay loop while rounds != long: #Lookin for player input print("\nRound", ...
4afb88e53ccddb16c631b2af181bb0e607a2b37b
Evakung-github/Others
/381. Insert Delete GetRandom O(1).py
2,170
4.15625
4
''' A hashmap and an array are created. Hashmap tracks the position of value in the array, and we can also use array to track the appearance in the hashmap. The main trick is to swap the last element and the element need to be removed, and then we can delete the last element at O(1) cost. Afterwards, we need to update ...
59fe1cef58a8ee0e856bba5388de605b74844ad8
Evakung-github/Others
/1171. Remove Zero Sum Consecutive Nodes from Linked List.py
3,548
3.65625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None ''' At first, I tried to solve the problem by create the list, remove the zero sum subset and turn it back to link list. I couldn't think up a good way to find the zero sum subset, so b...
0e4ebca1ef7701c2c6830ba972ec085e1d1ee665
Evakung-github/Others
/287. Find the Duplicate Number.py
426
3.515625
4
''' O(1) space Use two pointers, fast and slow pointers, to detect the cycles. ''' class Solution: def findDuplicate(self, nums: List[int]) -> int: s = nums[0] f = nums[s] while nums[s] != nums[f]: s = nums[s] f = nums[nums[f]] s= 0 ...
ea1b780e79a9360ce902497f1f3854998fc8e36e
reviakin/SICP
/1.12.py
241
3.625
4
m = {} def pascal(row, element): if row == 1 or element == 1 or row == element: return 1 if (row, element) not in m: m[(row, element)] = pascal(row - 1, element - 1) + pascal(row - 1, element) return m[(row, element)]
c57eab0302c15814a5f51c2cbc0fa104910eef08
hihihien/nrw-intro-to-python
/lecture-06/solutions/exponent.py
261
4.28125
4
base = float(input('What is your base?')) exp = float(input('What is your exponent?')) num = exp result = 1 while num > 0: result = result * base num = num - 1 print(f'{base} raised to the power of {exp} is: {result}. ({base} ** {exp} = {base**exp})')
2de4da90b40a4d1f9dfb8f3e984757b675e10208
hihihien/nrw-intro-to-python
/lecture-06/solutions/even_or_odd.py
136
4.28125
4
number = float(input('What is your number?')) if number % 2 == 0: print(f'{number} is even.') else: print(f'{number} is odd.')
01c5cfa5d587e6651d40b33ed32dfb28c55ae1c2
hihihien/nrw-intro-to-python
/2020/autumn/lecture-8/zoo.py
1,284
3.78125
4
class Zoo: def __init__(self, animals = []): self.animals = animals def visit(self): for animal in self.animals: print( f'You see a {animal.__class__.__name__} with name {animal.name}') def listen(self): for animal in self.animals: animal.s...
ef2e1747c49dca4e17fe558704d05d50b2a11506
kengbailey/interview-prep
/selectionsort.py
1,507
4.28125
4
# Selection Sort Implementation in Python ''' How does it work? for i = 1:n, k = i for j = i+1:n, if a[j] < a[k], k = j → invariant: a[k] smallest of a[i..n] swap a[i,k] → invariant: a[1..i] in final position end What is selection sort? The selection sort algorithm is a combination of searching ...
1a6bc2804d0a9f8428815ac2004baa3fc9239654
aajjbb/advent-of-code-2020
/day07/sol1.py
1,266
3.53125
4
import sys import re def add_edge(graph, from_node, to_node): if from_node not in graph: graph[from_node] = [to_node] else: graph[from_node].append(to_node) def count_child(graph, node): queue = [node] visited = [node] while queue != []: curr_node = queue.pop...
2c8dd83dcf61ea4c0c44878fd6ddbe991f9f44b6
phpor/pythonexample
/basic/list.py
170
4.3125
4
# -*-coding:UTF-8-*- List = [1, 2, 3] for i in List: # 冒号前面最好不要有空格 print(i) List = [1, 2, 3, "a", "b", "c"] for i in List: print(i)
10430dee13058866a20995696013edb3c64a7b49
tking21/Comp_Phylo
/Assignment3_King.py
4,215
3.71875
4
from scipy.stats import binom, uniform, norm import numpy import random import matplotlib.pyplot as plt flips = ["H", "H", "H", "H", "H", "H", "H", "T", "T", "H"] #defining data, determining the number of heads (successes) successes = sum([1 for _ in flips if _ == "H" ]) #and the total number of flips (n) --> ...
99521eae5b622e52d132697db0bcb6794b63478b
MateusLopesNunes/AprendendoPython
/testeDeSintaxe/hello.py
1,031
4
4
#for i in range(1, 101): # if (i % 2 == 0): # print(i, end=', ') #------------------------------------------------------------ def divi(n1, n2): print(n1 // n2) #divisão inteira #divi(20, 3) #------------------------------------------------------------ def expo(n1,n2): print(n1**n2) #exponenciaçã...
53b17b9e7e9572f56f7e864bf03f552cd6082799
jesbarlow/CP1404_practicals
/Prac_3/print_second_letter_name.py
318
3.84375
4
def main(): name = get_name() print_name(name) def print_name(name): print(name[::2]) def get_name(): while True: name = input("What is your name?: ") if name.isalpha(): break else: print("Sorry, i didn't understand that.") return name main()
6e868a20699bce55248c3df3ed77125c0735c4cd
MaximMak/DL_Academy_Lessons
/kurs_1/Lesson_2/lesson2_dz.py
4,344
4.09375
4
__author__ = 'Makarkin Maxim Boricovich' import math # Задача-1: Запросите у пользователя его возраст. # Если ему есть 18 лет, выведите: "Доступ разрешен", # иначе "Извините, пользоваться данным ресурсом можно только с 18 лет" age = int(input('Please input your age: ')) if age <= 0: print("You are entering the wro...
3c2d8c1d057ef6827028d77769365684717e2a44
bmiraski/pandas_cookbook
/ch8.py
7,600
4.4375
4
"""Conduct sample exercises from Chapter 8.""" import numpy as np import pandas as pd def change_col_name(col_name): """Change column names to have numbers at the end.""" col_name = col_name.replace('_name', '') if 'facebook' in col_name: fb_idx = col_name.find('facebook') col_name = col_...
0ff6efa124129922594e4e996dd1b2955e6002b8
BethMwangi/python
/rock_paper_scissors.py~
1,165
4.21875
4
#!/usr/bin/python # Rock, paper ,scissors game # The rules apply, i.e , # * Rock beats scissors # * Paper beats rock # * Scissors beats paper import sys print "Let's get started!" player1 =raw_input("Enter your name please:") #prompts the user to input their name player2 = raw_input("Enter your name please:") play...
fbbcdcba0ace29718db8360f3010d30e8dad6aab
ddaaggeett/ddaaggeett
/src/pc/scripts/wavmaker.py
4,208
3.5
4
# Overall, this script enables users to record clapping sounds, save them as a WAV file, visualize the waveform, and label the peaks with syllables generated based on the rhythm of the claps. import sounddevice as sd import numpy as np from scipy.io import wavfile import matplotlib.pyplot as plt from scipy.signal impo...
6c612b3a3904a9710b3f47c0174edf1e0f15545b
spots1000/Python_Scripts
/Zip File Searcher.py
2,412
4.15625
4
from zipfile import ZipFile import sys import os #Variables textPath = "in.txt" outPath = "out.txt" ## Announcements print("Welcome to the Zip Finder Program!") print("This program will take a supplied zip file and locate within said file any single item matching the strings placed in an accompanying text...
6b4dbea0e59cc3945834918dafcc406e14047311
ntferr/Python
/python_postgre_course/lottery/app.py
672
3.734375
4
import random def lottery_app(): user_numbers = get_user_numbers() lottery_numbers = get_lottery_numbers() sorted_numbers = lottery_numbers.intersection(user_numbers) print(f'You hit the numbers {sorted_numbers} you won {100 * len(sorted_numbers)}') def get_lottery_numbers(): values = set() w...
876d20266c813fcc29a939e11eeda692af57b996
ntferr/Python
/split_string.py
347
4.09375
4
def take_numbers(): string_numbers = input("Enter your numbers, separated by commas: ") numbers = string_numbers.split(",") return numbers def sum_numbers(): sum_numbers = 0 numbers = take_numbers() for number in numbers: sum_numbers = sum_numbers + int(number) return sum_num...