blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
803c36f7e03bdaddf8de080c8d38e74598bfd169
adrianomota/projeto_open_street_map
/udacity/helper/clean_data.py
1,453
3.8125
4
''' Descrição: Esta função verifica se há mais de um telefone Utilização: update_phones('+551199991111;+551199991111') Parâmetros: phones Valor do tipo texto a ser pesquisado. No caso 'station' Retorno string ''' def update_phones(phones): if phones.find(";") > -1:...
e28cd191b76ad5bf392a931041ce43f215bc99f3
imayush15/python-practice-projects
/Learn/Almost_There.py
220
4.0625
4
def myfunc(num): if (num > 90 and num <110) or ((num > 190 and num <210)): return True else: return False x = int(input("Enter any Integer between 0 - 300 : ")) result = myfunc(x) print(result)
e0981cbc40424ea6cc0ae130c5953d7ef611d3f8
kishan3/leetcode_solutions
/24.py
603
3.65625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ dummy = ListNode(0) dummy.next = he...
952e73286042134eff61ecc1143cafe46e850285
rid47/python_basic_book
/review_ex_page101.py
343
4.21875
4
print("AAA".find('a')) given_string = "Somebody said something to Samantha." modified_string = given_string.replace("s", "x") print(modified_string) user_input = input("Enter a string") search_result = user_input.find("a") if search_result != -1: print("You have 'a' in your string") else: print("You don't hav...
1ff7326297109251332985cdd11325f88f43f871
badmathematics/projecteuler
/problem57.py
312
3.765625
4
from fractions import Fraction from decimal import Decimal count = 0 for a in range(1,1000): frac = Fraction(1,2)+2 for i in range(0,a): frac = 2 + Fraction(1,frac) frac = 1+Fraction(1,frac) if len(str(frac.numerator)) > len(str(frac.denominator)): count += 1 print(count)
a24e12e65405894c0446b7b1946a706fb8d6de92
HeitorAnglada/Simulador_de_Memoria_Cache_Grupo_Sigma
/main.py
19,832
3.609375
4
import math import random import funcoes as f f.mensagem_de_entrada() entrada = input('->') print(entrada) posicao_virgulai = entrada.find(',') numero_linhas = int(entrada[:posicao_virgulai]) print(numero_linhas) posicao_virgulaf = entrada.find(',', posicao_virgulai + 1) tamanho_palavra = int(entrada[...
4fbf88716d4aa8f25505e59cae0817f979934fa0
tr1503/LeetCode
/Sort/HIndex.py
415
3.8125
4
# Sort the array firstly and iter the array to find the first element that # is smaller the count class Solution: def hIndex(self, citations): """ :type citations: List[int] :rtype: int """ n = len(citations) citations.sort() for i in range(n-1,-1,-1): ...
9c06f3df397ab453343f99f4ea1a57f0eaf0c74c
krab1k/aoc2020
/16/ticket.py
1,297
3.515625
4
from collections import defaultdict def main(): rules = defaultdict(list) tickets = [] with open('input.txt') as f: for line in f: line = line.strip() if not line: break name, rules_str = line.split(':') for rule in rules_str.split(' o...
6af97fc185baf3876080e36c16634f398be77098
DwyaneTalk/AlgorithmsAndDataSturctures
/algorithmSolution/leetCodePython/002_Add Two Numbers.py
1,489
3.78125
4
''' DwyaneTalk@gmail.com https://leetcode.com/problems/add-two-numbers/ ''' def initList(nums): size = len(nums) listNode = None if size < 1: return listNode else: listNode = ListNode(nums[0]) curNode = listNode for x in range(1, size): curNode.next = ListNode(nums[x]) curNode = curNode.next return list...
c7ce5e6d9b3a3b2504d8806f821141e27b7bfa7e
karlacordovafez/Learning_Python_UPIITA
/while.py
246
3.921875
4
"""Clase de while""" count = 0 loop = True while loop: print(count) count+=1 if count == 100: loop = False numbers = [] i=0 while i<21: i=i+2 numbers.append(i) print("\nNumeros de 2 en 2 hasta 21:") print(numbers)
450059d4fc2cf3f823f91e148652b21ce73bacf7
romilBMS/ADA1BM17CS081
/lab4/lab4_a.py
548
3.796875
4
# n=5 # visited= [0]*n # adjacent=[[0,1,1,0,0],[1,0,0,0,0],[1,0,0,0,0],[0,0,0,0,1],[0,0,0,1,0]] def DFS(v): print(v," ",end="") visited[v]=1 for i in range(0,len(visited)): if adjacent[v][i]==1 and visited[i]==0: DFS(i) n=int(input("Enter number of nodes:")) visited=[0]*n adjacent=[] f...
4f5c788dcbb401180845989acbbcf008dbafc3c2
winterSkys/test
/zhaodong/area.py
2,307
3.90625
4
# 获取规定的图形面积 # ZD def yuan(number): r = float(input("请输入圆的半径:")) s = 3.14*r*r return round(s, number) # 长方形 def chang(number): w = input('请输入长方形的宽:') h = input('请输入长方形的高:') s = float(w)*float(h) return round(s, number) # 三角形 def san(number): d = input('请输入三角形的底:') h = input('请输...
26966089ec7d7f050fb256bcb141faad2d07d679
wangfangjie1/TestExample
/test_3.py
699
3.9375
4
#-*- coding:utf-8 -*- """目的:为了测试类中全局变量的值是否会在新创建的实例中存在""" def test_insert(num, l): i, j = 0, len(l) print "first: ", i, j while i < j: m = (i+j)//2 m_data = l[m] print "middle data: ",m, m_data, i,j if num > m_data: i = m + 1 elif num < m_data: ...
45890fb3c9b91f6c0dd80a7da5d7c4c273658b81
magedu-pythons/python-19
/P19032-xiaowen/week8/one.py
138
3.765625
4
#!/usr/local/python3/bin/python3 def change(): a = "1,2,3" b = str(a.split(",")).replace("'", '"') return b print(change())
a529dcae938a3dd101e3fe97efa9909948347cf0
Solenyalyl/sort-code
/02_merge_sort_non_recurrence.py
1,402
3.890625
4
#!/usr/bin/env python # -*- coding:UTF-8 -*- import numpy as np def merge_sort(lst, low, mid, high):# merge part former = lst[low:mid] latter = lst[mid:high] result = [] while(len(former) > 0) or (len(latter) > 0): if(len(former) > 0 and len(latter) > 0): if(former[0] < la...
a5a627c17c1a7d7df71aafbfe436ce0701016ef3
chisoftltd/PythonListTuplesandDictionaries
/PythonListTuplesandDictionaries.py
2,034
4.125
4
# Python Dya 7 by ChisoftMedia # Creating a list names = ['Benjamin', 'Joy', 'Shepherd', 'Emmanuel', 'Mikael'] grades = ['A','B', 'C', 'D', 'E', 'F'] scores = [78, 37, 48, 99, 89] print(names[0]) print(len(grades)) print(scores + names) print(names[2:5]) print(scores * 3) # Modifying a List # Updating existing elem...
293080d2d09c53b84c52f087d4fe2788ea1ed34c
PKW97/2021-python
/4주/8.py
774
3.65625
4
n = 56 print("첫 값은 %d이다." % (n)) while True: c = input("산술 연산의 종류를 입력하세요. >> ") if c == "*": n2 = int(input("두 번째 피연산자를 입력하세요. >> ")) print("%d * %d = %d" % (n, n2, n*n2)) elif c == "/": n2 = int(input("두 번째 피연산자를 입력하세요. >> ")) print("%d / %d = %d" % (n...
60f220e85d428b8dca140e5c4b0ad01670d2d29c
qq2681121906/win10-2-1804
/08-day/3-测试.py
284
3.515625
4
class Animal(object): def move(self): print("走") class Dog(Animal): def move(self): print("狗四条腿走路") class Person(Animal): def move(self): print("人用两条腿走路") def walk(obj): obj.move() dog = Dog() walk(dog) person = Person() walk(person)
92c77c478de167ec9c7ec73d016553da009bdf7e
bruceSz/learnToexcellent
/algorithm/sort/insert.py
335
4.125
4
#!/usr/bin/python def insert_sort(l): """ l is the input list""" length = len(l) for i in range(1,length): cur = l[i] j = i-1 while j>=0 and l[j]>cur: l[j+1] = l[j] j=j-1 l[j+1]=cur return l if __name__ == '__main__': l=[5,2,4,6,1,3] print 'before:',l l=insert_sort(l) ...
8ed82df4a462b4c02e271f8c403474673e44e610
jirigav/Primality-tests
/miller_rabin.py
728
3.875
4
from random import randint def is_probably_prime(n, k=1): """ Miller–Rabin primality test :param n: Number to be tested :param k: number of iterations, more iterations equals higher accuracy and time complexity :return: True if number is probably prime, otherwise False """ if n < 4: ...
3519815319bafbbb3903bfa174678302dbffd0dc
dhruvik1999/DSA
/Dubbl_Link-list.py
1,073
3.953125
4
class Node: def __init__(self,data): self.prev=None self.next=None self.data=data class DLinkedList: def __init__(self): self.head=None self.tail=None self.size=0 def insertFirst(self,data): node=Node(data) if self.head is None: s...
828f949a670605a686e3aafa3ffd5526342d7221
yunakim2/Algorithm_Python
/프로그래머스/level3/가장 긴 팰린드롬.py
429
3.875
4
def solution(s): def is_palindrome(word): return word == word[::-1] for idx in range(len(s), 0, -1): for start in range(0, len(s)): word = s[start:start + idx] if is_palindrome(word): return len(word) if start + idx >= len(s): ...
432c3a875a35c218feae5240155ab5c4dff96178
MingfeiPan/leetcode
/string/859.py
951
3.515625
4
class Solution: def buddyStrings(self, A: str, B: str) -> bool: if not A or not B or len(A) != len(B): return False index = 0 flag = 0 buddy = [] if A == B: if len(A) < 2: return False temp = set() ...
81be539e733e512dd74504baa459b4859065c679
ssanderson/pybay2016
/pybay2016/encoding.py
1,025
4.125
4
""" A rot13 python encoding. """ from codecs import CodecInfo from encodings import utf_8 def rot13(s): """ rot13-encode a unicode string. """ chars = [] for c in s: if 'a' <= c <= 'z': newchar = chr((((ord(c) - ord('a')) + 13) % 26) + ord('a')) elif 'A' <= c <= 'Z': ...
85b57ae2215e0413acb9a7e0ca166d64817db78b
JeromeLefebvre/ProjectEuler
/Python/Problem266.py
565
3.78125
4
#!/usr/local/bin/python3.3 ''' http://projecteuler.net/problem=266 Pseudo Square Root Problem 266 ''' ''' Notes on problem 266(): ''' from PE_basic import powerset,product from PE_primes import primesUpTo def productMod(c,mod=10**6): prod = 1 for a in c: prod *= a prod %= mod return mod def PSR(primes): re...
8597d9086a0e3bf470f0efcd672305c03a9eba06
usiege/Interview
/Offer/2020-0323.py
1,348
3.765625
4
#!/usr/bin/env python # 二分查找 def binary_search(l, num): left = 0 right = len(l) - 1 while left <= right: mid = (left + right) // 2 if num < l[mid]: right = mid - 1 elif num > l[mid]: left = mid + 1 else: return mid return -1 def binary_search(l, left, right, num): if left < right: return -1 ...
1cb023cc3694f2a08fb4ebda3ef82ad915a0152a
sirvolt/Avaliacao1
/questao19.py
134
3.71875
4
def numeroPNZ(): numero=float(input('Numero: ')) if numero<0: return 'N' elif numero>0: return 'P' else: return 'Z'
aafbc5d36aa403634a70bfa59c7776d31639b54c
sidduGIT/list_examples
/range1.py
205
4
4
#! python # range function print range(10) print range(5, 10) print range(0, 10, 3) a = ['Mary', 'had', 'a', 'little', 'lamb'] print len(a) for i in range(len(a)): print i, a[i]
57685683a850f6d82be325f428ab7e4b43947bb2
cbartoe/election_analysis
/PyPoll.py
3,899
4.40625
4
#Goals Of The Project #1. Total number of votes cast #2. A complete list of candidates who received votes #3. Total number of votes each candidate received #4. Percentage of votes each candidate won #5. The winner of the election based on popular vote #PseudoCode #1. open the data file #2. write down names of candidat...
8cf1edbfc60a16d8e671ead930cbd31eaabbcb27
l-johnston/toolbag
/toolbag/mpl_utilities.py
696
4.21875
4
"""Matplotlib utilities""" import matplotlib.pyplot as plt def reset_plot(fig): """Reset matplotlib figure. After plt.show(), matplotlib automatically creates a new figure instance which invalidates the existing figure. In an interactive session, this function resets figure 'fig' to the next figure i...
5cabd6b790d6628a0d273110fffa0a6dd011372f
zlohner/Reversi
/AI/AI.py
2,312
3.578125
4
#!/usr/bin/env python class AI(object): def __init__(self, me): self.me = me self.opp = 1 if me == 2 else 2 # check if player can play on a square based on given direction (combination of dx and dy) def checkDirection(self, state, row, col, dx, dy, player): oppFound = False r = row+dx c = col+dy while...
e64c23907b0ba8596450027505656feef57ed93f
cMinzel-Z/Python3-review
/Data_structure_&_algorithm/sort/insert_sort.py
425
3.921875
4
def insert_sort(data_set): # i表示摸到的牌的下标 for i in range(1, len(data_set)): tmp = data_set[i] # j指的是手里的牌 j = i - 1 while data_set[j] > tmp and j >= 0: data_set[j + 1] = data_set[j] j -= 1 data_set[j + 1] = tmp return data_set if __name__ == '__...
1607a80d7bfa98d40010fdfb8e7490083a2197ce
uzmakhan9/Basic-Python-Programs
/Basic Python Programs/currency convertor.py
877
4.34375
4
with open('currencyConvertor.txt') as f: lines=f.readlines() # learn file handling for better understanding currencyDict={} # made an empty dictionary for line in lines: parsed=line.split("\t") # split is a function who splits the string by given separator into a list currencyDict[parsed[0]]=parsed[1] ...
65bbca25db332fe1a3318c4dcf8722981e9c46b0
pradyumnkumarpandey/PythonAlgorithms
/LeetCode/0087_Scramble_String.py
701
3.703125
4
class Solution: def isScramble(self, s1: str, s2: str) -> bool: def scramble(s1, s2): key = (s1, s2) if key in mem: return mem[key] if sorted(s1) != sorted(s2): return False if s1 == s2: mem[key] = True ...
4ae2aa90adbe441996ead871979274e5a8d2ee80
nunoyuzoreis/aula2
/main.py
184
4.125
4
def fatorial(): print("insira um numero") num = int(input()) cont = 2 fatorial = 1 while cont <= num: fatorial = fatorial * cont cont = cont +1 print(fatorial) fatorial()
f08f3ac7d01c79e7903c995c02478f7b0a0778f6
shineYG/Python-A-B-C
/time/calcTime.py
519
3.84375
4
#! /usr/bin/env python # -*- coding:utf-8 -*- import time import datetime # str 转datetime str = '2012-11-19' date_time = datetime.datetime.strptime(str, '%Y-%m-%d') print(date_time) # 获取当前时间 t_date = datetime.date.today() print('------------------------') print(datetime.date.ctime(t_date)) print(t_date) # 获取第几周 week ...
e7e8b71d02df4798156d0c28ed4b9aab76ecd54e
borchr27/recipes_test
/Direction.py
422
3.65625
4
class Direction: """A sample direction for a recipe class """ def __init__(self, recipe, source, direc): self.recipe = recipe self.source = source self.direc = direc @property def item(self): return '{}.{}.{}'.format(self.recipe, self.source, self.direc) def __...
8ae040b03b42acf18478de9e7662ef97548c8e36
mikomoares/robot19-r
/particle/math_utils.py
403
3.90625
4
import math EPS = 1e-8 def dist_sq(p1, p2): """Square distance between points p1 and p2""" return (p1[0] - p2[0])**2 + (p1[1] - p2[1])**2 def dist(p1, p2): """Distance between points p1 and p2""" return math.sqrt(dist_sq(p1, p2)) def my_atan2(y, x): """atan2 in range [0, 2*pi].""" theta ...
e65f7837edb3ff39b0205e1d4f1d6c1a286a0f19
pwnmeow/Basic-Python-Exercise-Files
/CSV/read.py
280
3.734375
4
from csv import reader with open("data.csv") as file: csv_reader = reader(file) data = list(csv_reader) for row in csv_reader: print(row) from csv import DictReader with open("data.csv") as file: csv_reader = DictReader(file) for row in csv_reader: print(row)
4bf5fe3c14928c2a8a978dc37519eeba50745e9a
Parth731/Python-Tutorial
/Telusko/33_Mutable_immutable.py
316
3.578125
4
def update(x): print(id(x)) x = 8 print(id(x)) print("x => ",x) a = 10 print(id(a)) update(10) print("a => " ,a) # mutable def update_lst(x): print(id(x)) print(x) x[1] = 25 print(id(x)) print("x => ",x) lst = [10,20,30] print(id(lst)) update_lst(lst) print("lst => " ,lst)
0374bc20577ff758801cbce8390ef2f6ec46dfbc
cravo123/LeetCode
/Algorithms/1154 Day of the Year.py
910
3.640625
4
import datetime # Solution 1, simulation class Solution: def dayOfYear(self, date: str) -> int: big = set([1, 3, 5, 7, 8, 10, 12]) # monthes with 31 days y, m, d = date.split('-') y, m, d = map(int, [y, m, d]) res = d i = 1 while i < m: if i in b...
ecf1aaa53db1c95312de9b88b6039049cf49ebc7
divir94/Python-Projects
/Algorithms Practice/Trapping Water.py
789
3.53125
4
def trapping_water(region): max_left = [0]*len(region) max_right = [0]*len(region) water_level = [0]*len(region) # get left boundaries max_seen = region[0] for i in range(1, len(region)-1): max_left[i] = max_seen max_seen = max(max_seen, region[i]) # get right boundaries ...
83925e317b30250dba394cf6b744b7fd96f9fbde
tloula/tea-implementation
/tea_algorithm.py
1,219
3.515625
4
# ********************************************* # # Tiny Encryption Algorithm Implementation # # Ian Bolin & Trevor Loula # # CS-3350 Foundations of Computer Security # # ********************************************* # import sys from ctypes import * class TEA: @staticmethod de...
a8761033d808d171512284baf462be122a69b544
denghuanqing/pythonStudey
/demo/classTest.py
330
3.84375
4
# 定义汽车类 class Car: def __init__(self, newWheelNum, newColor): self.wheelNum = newWheelNum self.color = newColor def move(self): print('车在跑,目标:夏威夷') # 创建对象 BMW = Car(4, 'green') print('车的颜色为:%s'%BMW.color) print('车轮子数量为:%d'%BMW.wheelNum)
4cb7c298dc6ce0e5ccbadcbe8e48ceed96bacdb4
Rohit-Gupta-Web3/Articles
/ML Libariries/python_pandas/dataframe_column.py
184
3.921875
4
import pandas as pd data = {'Name':['C','Sharp','Corner'], 'Age':[20,21,22], 'Address':['Delhi','Kanpur','Tamil Nadu']} df = pd.DataFrame(data) print(df[['Name','Address']])
654726df5d9f0f0543feca520ed17aee7bbe0cba
AfonsohsS/DataScienceCurso2_Pandas
/extras/OrganizandoDataFrames.py
611
3.859375
4
# Oraganizando DataFrames (Sort) import pandas as pd data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] df = pd.DataFrame(data, list('321'), list('zyx')) df # Organizando as linhas ## O sort_index organiza o índice levando toda a linha junto df.sort_index(inplace=True) df # Com a inclusão (axis = 1) as colunas são reorgani...
56741cad843867b0bb8227df748e91ad5ccfc4f6
innakaitert/programWithUs
/Day5/exercise03.py
1,226
3.84375
4
class CreditCard: card_number = "" card_type = "" valid = True def __init__(self, card_number): self.card_number = card_number def getCardNumber(self): return self.card_number def getCardType(self): return self.card_type def getValid(self): return self.valid def setCardNumber(self, card_numbe...
3302b57f4782ee6748236425d2786291071edabc
gauravk268/Competitive_Coding
/Python Competitive Program/gretest_no.py
168
3.859375
4
a = 10 b = 14 c = 12 if (a >= b) and (a >= b): largest = a elif (b >= a) and (b >= c): largest = b else: largest = c print("The largest number is", largest)
0e68d7ff694e7c962c63ca236baa079e7ffaf4ce
ninanguyen24/CPSC5610-AI
/NguyenAssignment2/Solver.py
3,087
4.21875
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 26 12:46:15 2019 @author: hanks """ """ Nina Nguyen CPSC 5610 - AI February 23, 2019 Assignment 2 (Problem 1) """ ## This method is called from Boards.py -- the two inputs are ## -- initial cell assignments, a list of length N where N is ## th...
24e1f924e9dd726e34aba2082824d71048527dd7
karimadel88/linked-in-programming-foundations-course
/4- Programming Foundations Algorithms/Ch1-Overview/GCd.py
290
3.796875
4
# function to get gcd # steps # if a havnt remind b is greatest # else a is b and b is reminder def gcd(a, b): while(b != 0): t = a a = b b = t % b return a # 20 8 ==> # t = 20 a=8 # b=4 # t =8 a=4 b=0 # a as return print(gcd(60, 96)) print(gcd(20, 8))
81455e52144e9bea4561ce9a033ebfe4651db060
jacksonbill2/pythonbasicfile-learning-github-
/python executable files/program5(loops while).py
750
4.03125
4
a=0 while a<=5: #after the end of each statement give a colon it is important a=a+1 #a=a+1 print(a) # important statement and its implementation usin while loop a=1 s=0 while a<6: print ("current sum: ",s) #indentation under while a=int(input("enter the number:"))...
17ae9e1f8003532ffbfe82a707e24e4eb8da0204
GrishaAdamyan/All_Exercises
/Shopping list.py
104
3.71875
4
n = int(input()) list = [] for i in range(n): list.append(input()) for elem in list: print(elem)
0efd6c49d5d815fedc0205a13444765dbb7391ef
KHATRIVINAY1/Data-Structures
/Array/anagramCheck.py
799
3.890625
4
def anagram(s1,s2): l1= [i.lower() for i in s1 if i !=" "] l2 =[i.lower() for i in s2 if i != " "] return sorted(l2)==sorted(l1) def anagram_2(s1,s2): s1 = s1.replace(" ",'').lower() s2 =s2.replace(" ", '').lower() return sorted(s1)==sorted(s2) def anagram_3(s1,s2): s1 = s1.replace(" ",'').lower() s2 =s2.repl...
32d64b8da9e94cc98ed6ca436b09de477380d42f
ChanWhanPark/EmbeddedVisionSystem
/03주차_파이썬 기초/7_리스트.py
290
3.671875
4
x = [3, 2, 1] y = ["리스트", "문자열"] z = [1, 2, 2.2, "리스트"] print(x) print(y) print(z) print(x+y) numLen = len(x) sorList = sorted(x) sumList = sum(x) print(numLen) print(sorList) print(sumList) for i in z: print(i) print(y.index("문자열")) print("리스트" in y)
c3be2df8d72107bcc740728eceda197aa3be0540
sankumsek/assorted-python
/November 11, 2013 Notes.py
495
3.515625
4
#November 11, 2013 Notes lst = [] lst.append(5) print.(lst.append(7)) lst2 = lst + [9] #putting those two ideas together lst = lst + [11] #more efficient way (append1 is the faster way) def append1(x): lst = [] for i in range(n): lst.append(i) return lst def append2(n): lst = [] for ...
556c7e5d2ba3a478ff399e80266d9ae628998e42
Moulick/HackerRank
/30-Days-of-Code/Day 6 Let's Review.py
107
3.859375
4
for i in range(int(input())): word = input() print(''.join(word[::2]) + " " + ''.join(word[1::2]))
792197d0aa9d46cb1541a625a4862e10cbd76ee1
scott-gordon72/python_crash_course
/chapter_4/summing_a_million.py
259
3.90625
4
numbers = [] for value in range(1, 1_000_001): numbers.append(value) print(f"The minimum value in the list is: {min(numbers)}") print(f"The maximum value in the list is: {max(numbers)}") print(f"The sum of all the values in the llst is: {sum(numbers)}")
73bffa0cada85c03f89c0cb64133f28961caa174
varunchandan2/python
/house.py
1,053
4.15625
4
#The graphics library used and new graphics window from graphics import * newWin = GraphWin() #Draw a triangle as the hut of the house aPolygon = Polygon(Point(85,50),Point(10,50),Point(50,10)) aPolygon.setFill('blue') aPolygon.draw(newWin) #Draw a circle as a window in the hut center = Point(50,35) blackCircle = Cir...
7d0a36ecf3b75e010506652bbc9c6f0a4344737b
Simbadeveloper/Yummy_recipes
/tests/test_recipe.py
2,159
3.75
4
"""Module contains unittests for the recipelist class""" import unittest from app.classes.recipe import recipe from app.classes.activity import Activity class Testrecipelist(unittest.TestCase): """Class contains tests methods in recipelist class""" def setUp(self): self.myrecipelist = recipe('Coffee', ...
af401a7bde84318965b81ef5f3e2fc2283e22fdb
smartinsert/CodingProblem
/amazon/symmetric_k_ary_tree.py
1,006
4.21875
4
""" A tree is symmetric if its data and shape remain unchanged when it is reflected about the root node. """ class TreeNode: def __init__(self, data): self.data = data self.children = [] def __repr__(self): return '{} -> {}'.format(self.data, self.children) def update_levels_dict(no...
61e277792c48067ded72e242bc0f74aa5cd9a020
algorithm005-class01/algorithm005-class01
/Week_07/G20190343020242/LeetCode_56_0242.py
1,110
3.5625
4
# # @lc app=leetcode.cn id=56 lang=python3 # # [56] 合并区间 # # https://leetcode-cn.com/problems/merge-intervals/description/ # # algorithms # Medium (39.36%) # Likes: 263 # Dislikes: 0 # Total Accepted: 47.6K # Total Submissions: 119.4K # Testcase Example: '[[1,3],[2,6],[8,10],[15,18]]' # # 给出一个区间的集合,请合并所有重叠的区间。 #...
71f13d89d1696e0228445b598bd9eacece5d23d4
AshurMotlagh/CECS-174
/Lab 10.11.py
486
3.578125
4
empty_dic = {} file_name = input("Enter the input file name: ") file = open(file_name) line = file.readline() num = 0 while line != '': for wd in line: if wd.upper().isalpha(): num += 1 if wd.upper() in empty_dic: empty_dic[wd.upper()] += 1 else: ...
caf9000931f566f0c3df6ee1458cfd10e5a6677d
ishankaul1/algos-python
/subsets/subsets_recursion.py
744
4.15625
4
#Returns all subsets of a list using recursion def get_subsets(arr): subsets = [[]] if not arr: return subsets subsets_excluding_last = get_subsets(arr[:-1]) subsets_including_last = [] for subset in subsets_excluding_last: subsets_including_last.append(subset + [arr[-1]]) retu...
1f58e6ad3c81d632d87c4fdc466e907141291e91
AlceniContreras/Project-Euler
/Prob22.py
557
3.53125
4
# -*- coding: utf-8 -*- # Names scores # ------------ def value(n): alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' m = list(n) for i in range(len(m)): m[i] = alphabet.index(m[i]) + 1 return sum(m) # Opening and cleaning the list of names file = open('names.txt', 'r') temp = file.read() temp = temp.re...
a48b547f546e72f258995709132e44fa2b314848
AntoRojo16/Ejercicio8Unidad2
/Ejercicio8.py
851
3.875
4
from claseConjunto import Conjunto def test (): unConjunto=Conjunto() otroConjunto=Conjunto() unConjunto.AgregarEle() otroConjunto.AgregarEle() print("SE MOSTRARA EL PRIMER CONJUNTO") unConjunto.mostrar() print("SE MOSTRARA EL SEGUNDO CONJUNTO") otroConjunto.mostrar() nuevoConjunto= ...
ce9a9bbff522ae73df58ddf8cd8174a3cf15861b
dudaji/dsy
/DSA/participant/zuhern/week2/sort/sort_merge.py
1,826
3.921875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # O(nlogn) def sort_merge_start(arr): sort_arr = arr[:] sort_merge(sort_arr, 0, len(arr)-1) return sort_arr def sort_merge(sort_arr, start_index, end_index): # 최소 크기 사이즈가 되면 재귀 멈춤 if (end_index - start_index) < 1: return mid_index = (start_index + end_inde...
b7b30ddaf796e89591ccf2166fa0c3e9df83c020
srinivasgln/ProjectEuler_Solutions
/Euler3.py
341
4.1875
4
def LargePF(a): pf=2 while(a>pf): if a%pf==0: a=a/pf pf=2 else : pf+=1 return pf x=int(input('Enter the number for which you want to find the largest prime factor:\t')) if x<2 and x>0: y=1 else: y=LargePF(x) print('The largest Prime f...
b636078c562d33ee94dbf8daf7517b3ee9a24ae0
Aasthaengg/IBMdataset
/Python_codes/p02384/s508123933.py
1,303
3.765625
4
class Dice2(): def front(self,up,front,dice): #index == 5 if(up==dice[2] and front==dice[1])or(up==dice[1] and front==dice[3])or(up==dice[3] and front==dice[4])or(up==dice[4] and front==dice[2]): return dice[5] #index == 4 elif(up==dice[0] and front==dice[2])or(up==dice[2...
1b65ecdd59f110efdedd35791d17526b371624a7
jpallavi23/Smart-Interviews
/06_SI_Basic-Hackerrank/23_Transpose Matrix.py
564
3.921875
4
''' Given a matrix of size N x M. Print transpose of the matrix. Input Format First line of input contains N, M - the size of the matrix. Its followed by N lines each containing M integers - elements of the matrix. Constraints 1 <= N, M <= 100 -109 <= ar[i] <= 109 Output Format Print the transposed matrix. Sample I...
12b495e4c8be4f966e035d0392e1188e90532873
LoveDarkblue/PythonTest
/test1/test1_5_map.py
735
4.3125
4
# 定义一个dict students = {'z1': 18, 'z2': 19, "z3": 20, 'z3': 21, } # 另一种定义的方式 # students = dict([('z1', 18), ('z2', 19)]) # 取值 print(students['z1'], students.get('z2')) # 获取一个不存在的键对应的值 print(students.get('zz')) # 获取一个键对应的值,如果不存在赋默认值 print(students.get('zz', 123)) # 判断z1是否在students中...
e34ecbbd3d59946f981089c61b269a79e7e569b7
nyucusp/gx5003-fall2013
/cbj238/assignment3/problem3.py
2,616
3.671875
4
''' Christopher B. Jacoby Urban Informatics Homework 3, Problem 3 ''' import sys import numpy as np from Queue import Queue from readInputFile import Problem3Input class PaperAuthor: def __init__(self): self.erdosNum = None self.connectedAuthors = [] def __str__(self): return "(Erdos#:{0}, Connections:{1})".f...
8087c602d9211585bf6c127a1191aa3de87166ec
cspickert/advent-of-code-2019
/day06.py
821
3.828125
4
def path(orbits, start): if start not in orbits: return [] return [start] + path(orbits, orbits[start]) def count(orbits, start): return len(path(orbits, start)) def main(entries): orbits = {} for body, satellite in entries: orbits[satellite] = body # Part 1 total_count = ...
c4f9dfcb1d4c9299361e58e2b73aac753b97987a
lily01awasthi/python_assignment
/19_smallestfrom_list.py
352
4.03125
4
"""19. Write a Python program to get the smallest number from a list. """ no_of_items=int(input("enter the no of items you want in a list: ")) inp_list=[] for i in range(no_of_items): inp=int(input("enter the list items of integers : ")) inp_list.append(inp) print(inp_list) inp_list.sort() print(f"smallest item...
2095b37334760c7299fbc408ac3e2c62f86894db
lucaryholt/python_elective
/42/Mandatory/exercises.py
2,341
3.734375
4
# Ex 1 print("\t\tEXERCISE 1\n\n") board_of_directors = {"Benny", "Hans", "Tine", "Mille", "Torben", "Troels", "Søren"} management = {"Tine", "Trunte", "Rane"} employees = {"Niels", "Anna", "Tine", "Ole", "Trunte", "Bent", "Rane", "Allan", "Stine", "Claus", "James", "Lars"} print("who in the board of directors is n...
4c76504f9f881d51089199db2b254da79dffa861
ashaindlin/brainfucker
/brackets.py
1,126
4.25
4
def match(string, pos): """ Return the position of the matching bracket to the bracket at string[pos], or -1 if pos is an invalid index or string[pos] is not a bracket. Works for parentheses, square brackets, and curly braces. """ if pos not in range(len(string)) or string[pos] not in "([{}])":...
71d1799e9d6955dbd6862d574e61ecc90dd124f6
AP-MI-2021/seminar-2-ioana02
/prim.py
636
3.9375
4
def prime(n): ''' Aratati daca un numar este prim sau nu param: un numar intreg return:True daca e prim si False daca nu este prim ''' if n>1: for i in range(2,n): if(n%i)==0: print(n,"nu este prim") else: print(n,"n este prim...
9cb72968372f17489a98e43b632e82d13acb310e
ZX1209/gl-algorithm-practise
/leetcode-gl-python/leetcode-31-下一个排列.py
2,782
3.765625
4
# leetcode-31-下一个排列.py # 实现获取下一个排列的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。 # 如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。 # 必须原地修改,只允许使用额外常数空间。 # 以下是一些例子,输入位于左侧列,其相应输出位于右侧列。 # 1,2,3 → 1,3,2 # 3,2,1 → 1,2,3 # 1,1,5 → 1,5,1 """ 思路: 将,最大的,,找到?? 左边大于右边? 1 2 3 4 1 2 4 3 1 3 2 4 1 3 4 2 1 4 2 3 1 4 3 2 2 1 3 4 2 1 4 3 2 3 1 4 2 3...
33a457a4bce7058bc5aa57560bc3a891cfc19346
Kmeiklejohn/backend-web-scraper
/scraper.py
1,747
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ This is a program that scrapes web pages for emails, urls, and phone numbers. """ __author__ = "Kyle Meiklejohn" import argparse import requests import re import pprint from htmlparser import MyHTMLParser parser = MyHTMLParser() def request_func(url): """ ...
e654dfceb723ecb093e7093e9b994ce227557df7
Myhuskygod/20F_CST8279_Lab10
/task2.py
218
3.8125
4
import csv f = input("Please enter which file you want to read: ") with open(f, newline='') as csvfile: spamreader = csv.reader(csvfile, delimiter=' ') for row in spamreader: print(' '.join(row))
0528f7c021d74ecb7ee8cb342c1259a964238220
gunjan1991/CSC-455---Assignments
/Assignment 6 - Gunjan - Part 3(f) Solution.py
1,340
3.53125
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 17 09:53:17 2016 @author: gunja """ # Assignment: 6 # Name: Gunjan Pravinchandra Pandya # Part: 3(f) import json #you read the file through to the fd variable fd = open('C:\Gunjan DePaul\CSC 455\Segment 6\Assignment6.txt', 'r', encoding='utf8') #similar t...
0ea18f6709b5c80e0c5b44712a043d44951b49c2
venky1603/python
/py4e/ex_03_02.py
386
3.828125
4
#Ex 3.2 Python 4 everybody strhr = input("Enter Hours:") strrate = input("Enter Rate:") fhr = 0 fr = 0 try: fhr = float(strhr) frate = float(strrate) except Exception as e: print("Please enter numerical values") quit() overtime = fhr - 40 pay = 0 if(overtime>0): pay = (40*frate) + (o...
72a055d0d318e9a960c2d9e82d0f667cbba6716a
schakalakka/sorter
/src/sorter.py
1,588
3.96875
4
import random import sys import time def create_rand_list(size): return random.sample(range(size * 1000), size) def quicksort(a): if len(a) <= 1: return a pivot = a[0] return quicksort([x for x in a if x < pivot]) \ + [x for x in a if x == pivot] \ + quicksort([x for x ...
1bb90763b793bf9ef822178776c99434154267ee
Kohdz/Algorithms
/LeetCode/easy/59_heaters.py
1,580
3.921875
4
# https://leetcode.com/problems/heaters/ # Winter is coming! Your first job during the contest is to design a standard heater with # fixed warm radius to warm all the houses. # Now, you are given positions of houses and heaters on a horizontal line, find out minimum radius # of heaters so that all houses could be cov...
89fdff5e7a6f25698f37bd8d2a080602379cd136
alu-rwa-dsa/week-2--create-multiple-unit-tests-linda_david_calebcohort1
/question7.py
392
4.0625
4
#Authors: Group2 #function to count word redudancy in a text def frequency_counter(text): """ in the frequency_counter function, you enter a word and it returns the occurrence of the word entered in a dictionary format """ counter = {} for i in text: if i in counter: count...
edd76369bbf01afaeb6f744c65d4dbc8f5a573a5
snpanchal/game-ai
/tic-tac-toe.py
7,360
4.125
4
# Import import os import time # Define the board board = [" ", " ", " ", " ", " ", " ", " ", " ", " "] # Define players human = "X" computer = "O" # Other Global Variables best_move = 0 # Print the header def print_header(): print("Welcome to tic-tac-toe! To win, you must get three of your symbols in a row, w...
1e23150ec06b6c8dfb2a9ad0bed6802196ea497a
jparris3213/Frame_Costing
/frame_costing.py
3,779
3.828125
4
import time print("Welcome to Furniture Frame Pricing Module v 0.1") time.sleep(1) print("First Enter Nesting Information") time.sleep(1) one_whole = int(input("1 qty Whole ")) one_fraction = int(input("1 qty Fraction ")) one_of = int(input("of? ")) five_whole = int(input("5 qty Whole ")) five_fraction = int(input("5 ...
fc774f1425715386868386fe243ff6c8206bee59
abhi-verma/LeetCode-Algo
/Python/Implement_Stack_using_Queues.py
1,249
4.3125
4
class MyStack(object): def __init__(self): """ Initialize your data structure here. """ self.queue = [] self.stack = [] def push(self, x): """ Push element x onto stack. :type x: int :rtype: void """ self.queue.insert(0, x...
ab59052e4da869941465714ed850ae7ca0d36645
rafaelperazzo/programacao-web
/moodledata/vpl_data/73/usersdata/227/39174/submittedfiles/triangulo.py
132
3.5
4
# -*- coding: utf-8 -*- import math a=int(input('digite uma valor') b=int(input('digite uma valor') c=int(input('digite uma valor')
37ff5b163ae32a056b013ea80d52ffb23353423e
viswasvarmaK/cspp1
/cspp1_practise/m7/eval_quadratic.py
628
3.828125
4
''' Author: VISWAS Date: 6-8-2018 ''' def eval_quadratic(a_a, b_b, c_c, x_x): '''function to quadratic equation''' s_s = (a_a* (x_x ** 2)) + (b_b*x_x) + c_c return s_s def main(): ''' main function''' data = input() data = data.split(' ') data = list(map(float, data)) # print(data) ...
62129d6f93f78f72ebbfd6e9ff24961b24fd97b5
akhmadagil/basic_python4
/Soal 1.py
258
3.734375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: Nama=input("nama saya:") Umur=input("umur saya:") Tinggi=input("tinggi saya:") # In[9]: print( "nama saya " + Nama, "umur saya " + Umur, "tahun ""dan tinggi saya " + Tinggi,) # In[ ]: # In[ ]:
3c83da9d396bc568eb5d42e6bc85d63474004a7d
shivamrai/pycode
/sellStock.py
174
3.640625
4
def maxProfit(prices): if(min(prices)) == min[:-1]: return 0 if __name__ == "__main__": a= [7,1,5,3,6,4] print(min(a)) print(a[-1])
b2ad9ca9bb69b8542f4ebc2678a56d65580befe4
LuisPatino92/holbertonschool-higher_level_programming
/0x0A-python-inheritance/1-my_list.py
380
3.96875
4
#!/usr/bin/python3 """This module has a Class MyList derived from list""" class MyList(list): """Class derived from list class with a new method to print sorted""" def print_sorted(self): """Method that prints the list in ascending order""" print(sorted(self)) if __name__ == "__main__": ...
3f058a03f2dd95eb3a1516a944fff1fd91d675f3
Klnmitch/git_practice
/while_loops.py
682
4.125
4
# while loops practice total = 0 for i in range(1, 5): total += i print(total) total2 = 0 j = 1 while j < 5: total2 += j j += 1 print(total2) # another example: find the sum of even numbers only given_list = [5, 4, 4, 3, 1] total3 = 0 i = 0 while i < len(given_list) and given_list[i] > 0: #len(given_li...
aa210e40d3793dcd8a9ee353f6d5078040118940
Koilada-Rao-au16/Practice_Repo
/week02/operators.py
431
4.125
4
#Arthematic operators a = 5 b = 6 print(a + b) print(a - b) print (a // b) #Basic Calculator # print ("hey !! use my calculator") # print ("enter your 1st no") # no1 = float(input()) # print ("enter your 2nd no") # no2 = float(input()) # print(no1 * no2) #Assignment operator a = 1 b = 2 print(a == b) pri...
5884a7f5ca3b6c499ffb9c1e78a12c5e1afab0c1
gonzalob24/Learning_Central
/Python_Programming/LinkedLists/SingleLinkedList.py
370
3.609375
4
class SingleLinkedList: def __init__(self): self.head_node = None def get_head(self): return self.head_node def is_empty(self): return self.head_node is None def print_list(self): p = self.head_node while p is not None: print(p.data, end="-->") ...
b06854bd102a4de6d953304cfcda6c8dce88ced0
aaaaasize/algorithm
/collections/2.py
2,958
3.984375
4
# 2. Написать программу сложения и умножения двух шестнадцатеричных чисел. # При этом каждое число представляется как массив, элементы которого это цифры числа. # Например, пользователь ввёл A2 и C4F. Сохранить их как [‘A’, ‘2’] и [‘C’, ‘4’, ‘F’] соответственно. # Сумма чисел из примера: [‘C’, ‘F’, ‘1’], произведение —...
152bc48b4d9bdb5f583106298fa2ebf390dce0e3
muthuku/polyname
/polyname/combine_files.py
2,659
3.984375
4
#!/usr/bin/env python '''Code written to combine the CEMS from individual text files into a single text file and remove duplicates for further steps if needed''' #imports import os import glob import pandas as pd def combine_files_cde(filepath): '''function that takes in a directory of textfiles and combines it in...
b373c730b0524db84f200558b44e673a8860bcfc
vltlswk/Baekjoon-Algorithm
/b11720.py
116
3.671875
4
num = int(input()) arr = [] nums = input() for i in range(len(nums)): arr.append(int(nums[i])) print(sum(arr))
ffc77d423381f65e3e8c05fccc1b09a44d3916ce
frankye1000/GUI_practice
/Python GUI5-Radiobutton.py
715
3.671875
4
import tkinter as tk window = tk.Tk() window.title('my window') window.geometry('500x300') var= tk.StringVar() l = tk.Label(window, bg='yellow', width=16,text='empty') l.pack() def print_selection(): l.config(text='you have selected'+var.get()) r1 = tk.Radiobutton(window,text='Option A', ...
6a9fb2623ca6ac76b50d6ed7b5f49d98f3f1581f
dezhili/My_learnings
/tensorflow_note/tensorflow_book/ch04_classification/linear_regression_classification_01.py
1,545
3.53125
4
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt # Numbers close to 5 will be given the label [0], # and numbers close to 2 will be given the label [1] x_label0 = np.random.normal(5, 1, 10) x_label1 = np.random.normal(2, 1, 10) xs = np.append(x_label0, x_label1) labels = [0.] * len(x_la...