blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
aa3229fb98add3d6d5eb8b0555e02630122d6245
chimtrangbu/GraphExam
/NonOverlappingPaths/non_overlapping_paths.py
835
3.671875
4
class Graph(object): def __init__(self, start, end, graph): self.graph = self.__parse_graph__(graph) self.start = start self.end = end self.solutions = [] def __parse_graph__(self, graph): parsed_gr = {} for tup in graph: parsed_gr[tup[0]] = tup[1] ...
809112bce3b9355de7b36f5f47e250dd29f384e8
TheeeBot/contribute
/questao_1165_uri.py
308
3.5
4
# -*- coding: utf-8 -*- n=int(input()) for i in range(n): numero=int(input()) tentativa=0 if numero%1==0: tentativa+=1 for i in range(2,numero): if numero % i == 0: print ("%d nao eh primo" %numero) break else: print ("%d eh primo"%numero)
3dd2a9cfab439bb16726b471ed5f13e3fb6114f8
trebuh/advent-of-code
/2017/day2/day2.py
498
3.59375
4
#!/usr/bin/env python import csv import itertools if __name__ == '__main__': result = 0 second_result = 0 with open("input.csv") as f: file = csv.reader(f) for row in file: int_row = [int(x) for x in row] result += (max(int_row) - min(int_row)) for pair ...
65cc57d38c8511dc106185ff514daa6bab3d41a8
hkneal/DojoAssignments
/Python/funWithFunctions.py
775
4.21875
4
#odd_even function def odd_even(): for count in range(1, 2001): if count % 2 == 0: print "Number is " + str(count) + ". This is an even number." else: print "Number is " + str(count) + ". This is an odd number." #calling odd_even odd_even() #multiply function def multiply(inputList, ...
09031ab8000e270a8aefc4b422534bdfa0374169
Verrado-High-School/dice-rolling-simulator-DolarySatcher44
/dice.py
1,184
3.796875
4
# Name: Shane Mckisson # Period 2 # Dice Rolling Simulator import random tS = 1 c1 = 0 c2 = 0 c3 = 0 c4 = 0 c5 = 0 c6 = 0 rolls = int(input("How many rolls? ")) randNum = 0 while tS <= rolls: rR = random.randint(1,6) print("Roll number: " + str(tS)) print("Result: " + str(rR)) tS += 1 ...
7493769c475935033f2d84572d5b213a092fe256
fank-cd/books_exercise_code
/cookbook/Chapter 4/4.4实现迭代协议.py
1,053
4.375
4
# 实现一个能够以深度优先的模式遍历树的节点 # Python的迭代协议要求__iter__()返回一个特殊的迭代器对象,该对象必须实现__next__() # 方法,并使用StopIteration异常来通知迭代的完成 # (这代码我有点看不懂。) class Node: def __init__(self, value): self._value = value self._children = [] def __repr__(self): return f"Node{self._value}" def add_child(self,node...
2c11b4a9abac325d3f7ed93d1d10b7edb9c7d93e
biomed-bioinformatics-bootcamp/bmes-t580-2019-coursework-Yilin-Y
/Module09/program.py
4,390
3.9375
4
import csv # this modules allow users to read and write in the csv file import os # import the os modules try: # import the statistics modules to provides functions for calculating mathematical statistics of numeric data. import statistics except: # error code instead import statistics_standin_for_py2 as ...
ee629e5f8416a815e109c12e18f2f24844ed7636
guyao/leetcode
/best-time-to-buy-and-sell-stock-iv.py
2,269
3.546875
4
""" Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most k transactions. Note: You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). """ class Soluti...
5166d90b300ce66ace1666cd8e15ec2f5389f648
SMHari/Python-problems
/Module 3/1_robot.py
655
4.28125
4
import math x, y = 0, 0 if __name__ == '__main__': distance = 0 while True: directions = input("Enter the direction UP, DOWN, LEFT, RIGHT with #no.of steps") if directions == '': break else: directions,step = directions.split(" ") if directions == ...
04ec76e2f3ef4e7529534a09886d0d066217673e
Meghnakrishnan/programming-lab
/12.pstv_lst.py
233
4.09375
4
#Generate positive list of numbers from a given list of integers l=[-1,3,6] pstv=[x for x in l if x>0] #check numbers in given list & positive numbers store in variable pstv print(pstv) #print positive list #output [3, 6]
2af995040db050c93ac356a363d754dab26d23d5
ishanoon/Intro_to_python
/yobFunction.py
187
4.03125
4
def yob(): yearOfBirth = int(input("Please enter your year of birth: ")) now = 2019 age = now - yearOfBirth print('Your age is :' + str(age)) print(yob())
21aa08bd909a589351ffc1faaa8450f5dcfe6529
Rohanadityakumar/programming-with-python
/graph1.py
220
3.75
4
#plotting line graph using python import matplotlib.pyplot as rohan x=[2012,2015,2018] y=[66,75,90] rohan.plot(x,y) rohan.xlabel("X Axis") rohan.ylabel("Y Axis") rohan.title("Rise in price of petrol in BLR") rohan.show()
a194fca1db4d8234a88b64e0f5422e82b0e083cc
lollek/scripts-and-stuff
/language-testing/witchsolver/witchsolver.py
3,725
3.515625
4
#! /usr/bin/env python3 P_HEAD, P_TAIL = 1, -1 R_HEAD, R_TAIL = 2, -2 Y_HEAD, Y_TAIL = 3, -3 G_HEAD, G_TAIL = 4, -4 class Card: def __init__(self, num, up, right, down, left): self.num = num self.up = up self.right = right self.down = down self.left = left self.i...
4f464fcaeca6834b52922fc37511c7921a124a4c
tramvn1996/datastructure
/stacks_and_queues/stacks/shortest_path.py
1,484
4.1875
4
#normalize path name #we're splitting the string into an array #the possible elements in the path now can be: names, '..' #we iterate through the array: #if the element is "..", then we have these cases: #1. the beginning of the path name is "..", which points to the parent dir of the current location #2. the last item...
d4980f019fa2826ceddb4d6683f38fefab50fbc5
rlhjansen/Paper_netlists
/code/gridhelper.py
3,229
3.953125
4
import functools import operator ############################################################################### # Circuit Generating # ############################################################################### def gates_from_lol(lol): """ :param lo...
3b7c61b662feb74b428433b591a81d06fa5fd6e1
sheetal804/Python-Repo
/Itertools/Maximize it!.py
462
3.59375
4
import itertools # k=3 # m=1000 # l1=[5,4] # l2=[7,8,9] # l3=[5,7,8,9,10] # l1=[x**2 for x in (l1)] # l2=[x**2 for x in (l2)] # l3=[x**2 for x in (l3)] n=[[5, 4], [7, 8, 9], [5, 7, 8, 9, 10]] print(n) print(list(itertools.product(n))) # from itertools import product # K,M = map(int,input().split()) # N = (list(map(in...
ecb4869c8de03c4cd0a8bfdd763b1185d9e17318
benzitohhh/cs212-style
/week6-scrabble/07_singleRow1.py
839
3.96875
4
class anchor(set): """An anchor is where a new word can be placed; has a set of allowable letters""" # The row (that we're trying to model) # |A....BE.C...D.| # Unrestricted anchor (can take any letter) LETTERS = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') ANY = anchor(LETTERS) # Restricted anchors mnx, moab = anchor('...
386f2f83bd1e8867be8544f86776cc82ca141ede
nklnarayana/projects
/Recursion/wildcard.py
875
3.875
4
#Input: 10? #Output: 101,100 #i.e > behaves like a wild card. when ? is replaced by 1 or 0 there are two possibilities for 10? #Input: 1?0? #Output: 1000, 1001, 1100,1101 #Write a program that takes given input and produces the suggestd output # Once the position in wild character is printed with 0 and 1, it shoul...
1f7925e6f14fbb1573b117ec8df91617685ceee8
ZakirovRail/back_end
/Lesson_6/Lesson_materials/lesson_ex_1.py
1,454
3.625
4
# def trace(func): # def wrapper(*args, **kwargs): # print('start calc') # r = func(*args, **kwargs) # print(f'calc finished: {r}') # return r # return wrapper # # # @trace # def square(x): # return x * x # # # square(2) """ start calc calc finished: 4 """ # ==============...
00208b201105409c858cde9cedd973579abc3d42
jspahn/Python-Code
/Project-Euler/Problems To Do/34-DigitFactorials.py
619
3.59375
4
# Project Euler # Problem 34: Digit Factorials # 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. # # Find the sum of all numbers which are equal to the sum of the # factorial of their digits. # # Note: as 1! = 1 and 2! = 2 are not sums they are not included. # Jeffrey Spahn # Cre...
57f43ffa11a01855cb8c9d41ec21f76b40628152
amirmasoud1420/maktab52_python
/hw6/t2.py
349
3.953125
4
import re def Eval(exp: str): exp_re = "^[0-9]+[ ]*([+]|[-]|[/]|[*])[ ]*[0-9]+[ ]*$" if not re.match(exp_re, exp): raise Exception("struct is wrong!!!") if '/' in exp: s = exp.split('/') if int(s[1]) == 0: raise Exception("division by zero!!!???") return eval(exp) ...
833cd8879bd7f910b83abe105012354683ddec1c
indy728/fractals-in-python
/serpinski-triangle.py
912
4.03125
4
import turtle t = turtle.Turtle() def serpinski(sideLen, level): angle = 60 if level == 0: for i in range(3): t.fd(sideLen) t.left(180 - angle) else: serpinski(sideLen / 2, level - 1) t.fd(sideLen/2) serpinski(sideLen/2, level - 1) t.bk(sid...
97f78514e2bca030bd76e1c34cb70a9477c3892d
Shaurya2007/Data-Sampling
/DataSampling.py
815
3.578125
4
import statistics as st import plotly.figure_factory as ff import csv import random import pandas as pd dataset = [] df = pd.read_csv("medium_data.csv") data = df["publication"].tolist() publication_mean = st.mean(data) def random_set_of_mean(counter): for i in range(0,counter) : rand...
1d1ddfdf511432e6b6e16136aac4e620d3035e5c
ujjavalkag/pythonassignment
/module2/pocket_color.py
435
4.03125
4
x=int(input('number of pocket:')) if x==0: print('pocket is green') elif (x>0 and x<=10) or (x>=19 and x<=28): if x%2==0: print('pocket is black') else: print('pocket is red') elif (x>=11 and x<=18)or(x>=29 and x<=36): if x%2==0: print('pocket is red') else: ...
0ab59a62393cc66c65051cd90d1be29be5febf3a
vladbatalan/ParadigmeDeProgramare
/Laboratorul6/Aplicatia2.py
1,174
3.71875
4
class BaseClass: num_base_calls = 0 def call_me(self, caller): print("Apel metoda din BaseClass, caller=", caller) self.num_base_calls += 1 class LeftSubclass(BaseClass): num_left_calls = 0 def call_me(self, caller): print("Apel metoda din LeftSubclass, caller=", caller) BaseClass.call_me(self, "LeftSu...
8bf2cf56d571f74869ab30632c6875cae5cd07a9
Ambika-Chaudhary/project1
/project.py
3,222
4.25
4
reg_users=[] global score score=0 name=input("enter the name") while name.isalpha() == False: print("invalid") name = input("enter the name") reg_users.append(name) age = input("enter age") while age.isnumeric()==False: print("invalid age") age =input("enter ag...
d7940b133f29dd24a46f42ede91ef5fcb1042dcb
shams169/python
/Leetcode/palindromeNumber.py
491
3.71875
4
#!/usr/bin/env python3 class Solution(object): def isPalindrome(self, x): out = [] input = x temp = 0 while(x > 0): mod = x%10 temp = temp*10 + mod x = x//10 print(temp) if input == temp: return True else: ...
f3a7ad1c2914ee7fe72096fd2d173b48c410802c
yucdong/courses
/ucb_cs61A/lab/lab02/lab02_2015/lab02/lab02.py
2,394
4.40625
4
"""Lab 2: Higher Order Functions & Lambdas""" from utils import letter_to_num, num_to_letter, looper, mirror_letter def make_derivative(f, h=1e-5): """Returns a function that approximates the derivative of f. Recall that f'(a) = (f(a + h) - f(a)) / h as h approaches 0. We will approximate the derivative b...
fb232a9aa1410e385b813ba6f88bea40c1ad37e5
TejeshReddy25/py
/palindrome.py
98
3.875
4
a=input() b=a[::-1] print(b) if a==b: print("palindrome") else: print("not a palindrome")
85a54699c97e4ab0e3480702fa24aa3f391f2970
fadilf/projectEuler
/problem12.py
1,222
3.8125
4
##max = min*10 ##running = True ##result = 0 ##while running: ## test = random.randrange(min,max) ## print test ## count = factors(test) ## if count > 500: ## max = test ## elif count < 500: ## min = test ## else: ## result = test ## break ##print result # The sequence of triangle numbers is generated by adding th...
0f72f01f4bd103615224477e80c4e06db5ea99a7
Emanuelvss13/ifpi-ads-algoritimos2020
/cap_07_iteracao/Lista_Fábio_03_em_for/fabio_iteracao_Q12_listaSomaMédia.py
462
3.828125
4
def main(): variavel_n = int(input('Digite um número: ')) lista_de_n = int(input('Digite um número essa lista deve ter: ')) comeco = 0 soma = 0 media = 0 for i in range(comeco, lista_de_n): soma += variavel_n variavel_n += 1 comeco += 1 media = som...
ce7adb3096b0bc93f2e25e2652549723e98782b8
michael-nakai/briscolol
/AI.py
10,960
3.890625
4
import card_class, random ### A COUPLE OF GUIDELINES # # For all AI, they should have the following methods: # AI_name should return a string of the name of the AI # set_turn sets the turn to either "first" or "second" # set_revealed_card sets revealed_card to the card played by the opponent # startin...
2175d46582c8af9acfefc106924f4d8e67d5c350
joellerena/I_accompany_you_to_code
/codes/codigo42.py
253
3.9375
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 14 19:13:12 2019 """ num1 = 4 if(num1>=0 and num1<=5): print("Buen ingreso") else: print("Mal ingreso") if(num1<0 or num1>5): print("Mal ingreso") else: print("Buen ingreso")
3f6e3462efb69b71f31205f6113c2343ff0a324f
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/shervs/lesson03/slicing_lab.py
1,714
3.90625
4
def exchange_first_last(seq): '''Returns a copy of a sequence with the first and last items exchanged.''' a_new_sequence = seq[-1:] + seq[1:-1] + seq[:1] return a_new_sequence def remove_every_other(seq): '''Returns a copy of a sequence withevery other item removed.''' a_new_sequence = seq[::2]...
2d7167ec369dc03293978c129264f37c3921ef63
AleksandraSandor/codeabbey
/lokata.py
397
3.75
4
print("lokata") poczatkowy = float(input("podaj swój początkowy stan konta ")) stopa = float(input("podaj roczną stopę oprocentowania w % ")) wiek = float(input("podaj liczbę lat na lokacie ")) print("stan Twojego konta, czyli {:.2f} po {:.0f} lat przy oprocentowaniu {:.2f} % będzie wynosił {:.2f}".format(p...
a22fae6866392017267450be3640f68eb3d867a9
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4139/codes/1863_2218.py
211
3.546875
4
from numpy import* from numpy.linalg import* mat = array(eval(input("mat: "))) soma = 0 for i in range(shape(mat)[0]): for j in range(shape(mat)[1]): if j > i: soma = soma + mat[i,j] print(round(soma,2))
9ab6fae1c148e55ab9a3a6f4b4f126c459776956
xixihaha1995/CS61B_SP19_SP20
/temp/toy/python/863. All Nodes Distance K in Binary Tree.py
647
3.796875
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def distanceK(self, root: TreeNode, target: TreeNode, K: int) -> List[int]: conn = collections.defaultdict(list) def connect(paren...
1e2c529fbf2e29bc22173c9432dc609e069b0d9c
coldfix/black-magic
/black_magic/common.py
752
3.5625
4
def param_names(argspec): """ Iterate over all parameter names used in the argspec. """ for argname in argspec.args: yield argname if argspec.varargs: yield argspec.varargs if argspec.kwonlyargs: for argname in argspec.kwonlyargs: yield argname if argspec...
c88491aee61536f42519a6e04df469e52b98512b
H1TechRedneck/SillyPython
/surprise_pie.py
1,334
3.875
4
# This programm demonstrates what luck is # So # Good luck pal import random print("You eaten a pie, but something was inside, Oh gosh, it's surprise...") print("and your suprprise is...") value = random.randint(1,5) if value == 1: print(\ """ __,_____ / __.==--" /#(-' ...
f45460d2b44be5eede87d2cdbee9a5748f519c20
Cbkhare/Algorithms
/Modulo Multiplicative Inverse/GCD.py
416
3.546875
4
def gcd(a,b): c = b b = a % b if b == 0: return c else: return gcd(c,b) if __name__== '__main__': x,y = list(map(int,input().split())) ans = gcd(x,y) print (ans) ''' #In case data is passed as a parameter from sys import argv import re file_name = argv[1] fp =...
a76d259246178314eed60a08114560521c86cc7c
walshj9/Super-Tic-Tac-Toe
/src/controller/ai.py
1,428
3.609375
4
import sys from random import randint from sets import Set class Node(): def __init__(self, player, gameBoard): self.children = [] self.gameBoard = gameBoard # Player is indicating which player's turn it is for the current gameboard self.player = player def createTree(self): # p represents the next player...
897272f0cc9619c05e18c57cb1f0cea04a024a0f
Hardeep18/python-masterclass
/StringFormatting/StringFormatting.py
1,361
4.375
4
age = 33 # Python will not automatically convert integers to strings # We can coerce an integer to a string with str() print("My age is " + str(age) + " years") # Or we can use replacement fields print("My age is {0} years".format(age)) print("There are {0} days in {1}".format(31, "January")) # If we combine multili...
b0cbce10ca13eff6739244a676342d3fad919295
mrevilg/Clock-Conversion
/ClockDictTXTIMP.py
410
4
4
# prompt user for any time in 24hr hh:mm formatting user_time = input("Please input any 24hr time in the following format: hh:mm - ") # TXT import to Dictionary of all possible minutes in 24HRs time_conversion = {} with open('minutes.txt') as fileobj: for line in fileobj: (key, value) = line.split("|") t...
b26932bb8d9562e20bd16a871253d058c78d0be4
bguenthe/pp_python
/texts.py
836
3.546875
4
class Texts: def __init__(self): self.text = [] self.text.append("Python...\nwurde 1991 entwickelt von\n Guido van Rossum (NL)") self.text.append("Python...\nist universelle, interpretierte\n höhere Programmiersprache") self.text.append("Python...\nwill einen gut lesbaren,\n knappen...
b96dfc39c89ccbec08693bd62c545e5b454da6fa
RebeccaRaccuglia/esercizi-28-31
/es28.py
421
3.796875
4
nome=[] lanci=[] contatore= 1 while True: nome_cand=input("inserisci nome studente " + str(contatore)) lanci_cand= input("inserisci il numero di lanci di "+ nome_cand) nome.append (nome_cand) lanci.append(lanci_cand) contatore += 1 domanda= int(input("vuoi inserire un nuovo candidato? se si digi...
0dd854f7ed7fe64cdde9f70242d8a4ff5033fdce
GoncalvesCarol/algoritimos1_2021
/entradaesaida/concatenarValores.py
392
3.546875
4
cidade="Campo Grande" dia=12 mes="junho" ano=2021 horas=14 local="salão de festa do clube" print(cidade+ ", " + str(dia) + " de " + mes + " de " + str(ano) + ", às " + str (horas) +" horas, no " + local) print(cidade, "," , dia , "de" , mes, "de" , ano , "às" , horas , "horas no" , local) print(cidade + "," , dia ...
af397d519f0f9f2efb82ef62d986e5cfdf46a75d
mocusez/XUTPracticals
/prac_03/broken_score.py
555
3.984375
4
""" CP1404/CP5632 - Practical Broken program to determine score status """ import random def main(): score = float(input("Enter score: ")) print("Your score is:{:.0f}, is {}".format(score, check(score))) randomscore = random.randint(0, 100) print("Your score is:{:.0f}, is {}".format(randomscore, check...
16e799bc431d240aef2041792651ba3069c1af34
lmcuende/tools
/strings.py
2,640
4.5
4
#! python # working with strings # We can concatenate atrings with the + operator, and repeat with *: phrase = 'Internet' + 'of' + 'Things ' print phrase print '<' + phrase*5 + '>' # Two string literals next to each other are automatically concatenated; # the first line above could also have been written "phrase ...
b73e8c901b697d299dcca8ccc0849a1fc3233303
raunakvijan/Algorithms
/graphs/dijkstra.py
1,322
3.640625
4
import heapq as priority import math visited = {} parent_node = {} def dijkstra(start,edges): def relax(a, b, wt): if b in visited: return if myDict[b] > myDict[a]+wt: myDict[b] = myDict[a]+wt parent_node[b] = a for i in range(len(h)): ...
6b3c3ba320f976069b0a88c50e77d5b166f58392
mistrydarshan99/Leetcode-3
/interviews/amazon/199_binary_tree_righ_side_view.py
957
3.90625
4
from collections import deque # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def rightSideView(self, root): """ :type root: TreeNode :rtype: List[int] ...
80e9849ea7425e3626d0703290b35a166d5ce227
Darshan-code-tech/CMPE282
/test.py
474
3.578125
4
class Solution(object): def twoSum(self,nums,target): self.nums = nums self.target = target required = {} for i in range(len(nums)): if target - nums[i] in required: return [required[target - nums[i]],i] else: required[nums[i]] ...
3d8b4a30b459945ccd4e3524f598a75900b66a14
piyushagarwal08/Adhoc-Python
/problem6.py
834
4.21875
4
#!/usr/bin/python3 print(''' 1. to show contents of single file 2. to show contents of multiple file 3. insert using cat 4. display line numbers in file -n ''') option = input('Select an option: ') if option == '1': file_name = input('Enter file name: ') fhand = open(file_name) print(fhand.read()) fhand.close() el...
322f2b93a949a8b37b96b0815bf1a402a07a60ed
Green-Blood/TOPL
/HW/cases/recursion.py
86
3.59375
4
def f(x): if x > 10: return else: f(x + 1) print x f(1)
676238caf42a4939fef910ad9c5c08dfe83ce35b
solpic/SmartDSS
/DeltaObjects.py
725
3.859375
4
''' Houses INSERT and DELETE classes''' class Insert(): def __init__(self,loc,s, u_id=-1): self.location = loc self.string = s self.u_id = u_id def show(self): print("ID: "+str(self.u_id)+"Insert: "+self.string+", at "+str(self.location)) return "ID: "+str(self...
9e0ef710b3ecc99bb9683d729e4e57fbf82c2a76
renjieliu/leetcode
/0001_0599/270.py
957
3.703125
4
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def closestValue(self, root: TreeNode, target: float) -> int: def flat(output, node, target): #output: [diff, ...
1768bf8d86d10d8f0b7d78f37d1bf9d00caf536e
Umang070/Python_Programs
/lambda.py
464
3.65625
4
from functools import reduce # mul = lambda a,b : a * b # print(mul(2,3)) # print(mul) # rev_string_with_capital_char= lambda s : s[::-1].title() # print(rev_string_with_capital_char("umang")) numbers=[1,2,3,4] # is_even = list(map(lambda no : 'Even' if no % 2 == 0 else 'Odd',numbers)) is_ev = list(filter(lambda a : a...
e9de723950d9afd23c1a703f5d6a45973ffdba08
akantuni/Kattis
/apaxianparent.py
233
3.609375
4
y, x = input().split() vowels_no_e = ["a", "i", "o", "u"] if (y[-2] + y[-1]) == "ex": print(y + x) elif y[-1] == "e": print(y + "x" + x) elif y[-1] in vowels_no_e: print(y[:-1] + "ex" + x) else: print(y + "ex" + x)
433d03e27d655c90873d6a6c99eafa1dbbecb80b
Aasthaengg/IBMdataset
/Python_codes/p03946/s434587193.py
851
3.640625
4
#!/usr/bin/env python3 import sys INF = float("inf") def solve(N: int, T: int, A: "List[int]"): amin, amin_i = (INF, -1) gmax = 0 cand = [] for i, a in enumerate(A): if a < amin: amin = a amin_i = i else: if a-amin > gmax: gmax = a-...
3b23837576d95931346ccc5bb3284bc89ea20b2d
zhaihongle/zhaihongleck1
/14-day/3函数字典.py
322
3.890625
4
list= [{'beijing':{'renkou' :' 10000','roujou' : '200000'}},{'shanghai':{'renkou' :'11111 ', 'mianji' : '22222' }}] for temp in list: #temp = 大字典 for address,s_num in temp.items(): #address= 大组点的建 for name in s_num: print('%s:%s:%s'%(address,name,s_num[name]))
3871d6710f4c8cf8861aa98e1225ad4d5dfa8eec
faisal-git/Data_Structure
/Tree/build_from _postorder.py
1,325
3.53125
4
# one can't build a tree without inorder , # inorder and any one of pre or post is sufficient # https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/discuss/810963/beginner-Friendly-or-recursive-or-O(N2)-to-O(N)-or-handles-duplicates-values # preorder is passed in reversed order to m...
c5405eb01ba406026381f8b039336402c6063046
autoself/python_start
/days01.py
715
3.5625
4
# -*- coding: utf-8 -*- """ 比如我们用户拥有一个这样的数据结构,每一个对象是拥有三个元素的tuple。 使用namedtuple方法就可以方便的通过tuple来生成可读性更高也更好用的数据结构。 """ from collections import namedtuple websites = [ ('Sohu', 'http://www.google.com/', u'张朝阳'), ('Sina', 'http://www.sina.com.cn/', u'王志东'), ('163', 'http://www.163.com/', u'丁磊') ] Website = nam...
7598038ca5d56c0da97b99ab25eaf1e7c3ed598d
dchen3121/algo
/Leetcode/28_implement_strstr.py
495
3.640625
4
# QUESTION: # implement strstr class Solution: def strStr(self, haystack: str, needle: str) -> int: if not needle: return 0 if not haystack: return -1 hlen, nlen = len(haystack), len(needle) if nlen > hlen: return -1 for i in range(hlen - ...
b47e2a4188342254992b2a1eb10303c5a27420a2
dalek7/Algorithms
/Optimization/tensorflow-linear_regression/05-minimizing_cost_tf_optimizer.py
973
3.53125
4
# Lab 3 Minimizing Cost import tensorflow as tf import matplotlib.pyplot as plt tf.set_random_seed(777) # for reproducibility # tf Graph Input X = [1, 2, 3] Y = [1, 2, 3] # Set wrong model weights W = tf.Variable(-1.0) # Linear model hypothesis = X * W # cost/loss function cost = tf.reduce_mean(tf.square(hypothesi...
07758aa2cd316ed32ebb252e3f6d6d0585bbe3c2
Hemie143/python_features_hp
/day_by_day/day_023.py
922
3.765625
4
# https://docs.python.org/3/library/stdtypes.html#typecontextmanager # Context managers must implement __enter__ and __exit__ class Letter: def __init__(self, letter_name): self.letter_name = letter_name def __enter__(self): self.letter = open(self.letter_name, 'w') return self.letter ...
0fafb66cfb898716a0c71491ae1379b9fee9d278
TaeHongGil/study
/_124country.py
1,060
3.546875
4
import math def solution(n): answer = '' while(n!=0): if(n%3==0): answer += "4" n=math.floor(n/3)-1 else: answer += str(n % 3) n=math.floor(n/3) return ''.join(reversed(answer)) n=10 print(solution(n)) ''' 문제 설명 124 나라가 있습니다. 124 나라에서는 10진...
3a53d59f06ec307346693371d7919ae5edc74864
joelpeckham/8puzzle
/puzzle.py
3,517
4
4
""" puzzle.py Joel Peckham September 15, 2021 8-Puzzle Search Algorithm Home Work For Richard Halterman's CPTR-418-Artificial Intelligence """ import queue as Q def getPuzzleChildren(puzzle): blankIndex = puzzle.index("-") blankCoordinates = (blankIndex // 3, blankIndex % 3) potentialChildren = [] fo...
ee7bce450e2d429aa0a2ac890f7ae6cd5839871b
econmang/Student-Files
/cs356/hw/labs/lab_2/GroupFiveECMHcontacts.py
4,011
4.125
4
''' Assignment 2: Phone Contacts Evan Conley and Mark Huff April 16, 2018 ''' def main(): ''' Contacts dictionary is designed such that the keys are tuples of names and each value is a list where first position is the phone number, second is the email, and third is age. ''' #Creation o...
45b63538d0ea211b27cdf9b797332565fa1ff2f0
amacgowa23/intro-machine-learning
/svm/svm_author_id.py
1,545
3.515625
4
#!/usr/bin/python """ This is the code to accompany the Lesson 2 (SVM) mini-project. Use a SVM to identify emails from the Enron corpus by their authors: Sara has label 0 Chris has label 1 """ import sys from time import time sys.path.append("../tools/") from email_preprocess import preproce...
67f6a99ef9889c68774debd24a8c2c65d8b1911b
rocker2019/python_homework
/Sixth/rest/restaurant.py
1,106
3.703125
4
import datetime class Restaurant: def __init__(self, name, category, customers): self.name = name self.category = category self.business_hour = 8 self.customers = customers def get_restaurant_info(self): print('餐馆名字:{},餐馆类型:{}'.format(self.name, self.categor...
dd511a79c49f7b0e1dc953e36b6bd7b1d2c96be4
librar127/PythonDS
/B2BSWE/Arrays/all_primes_to_n.py
2,243
3.734375
4
class Solution: def enumeratePrimes(self, n): ''' :type n: int :rtype: list of int ''' if n in [0, 1]: return [] if n in [2, 3]: return [n] result = [2, 3] for each in range(4, n, 1): # T(n) = O(n) pri...
7aecf2a06cc7f51d6e9713b49d96c86f2ad25910
kde0820/ProgrammersAlgorithm
/Level_2/자연수를 뒤집어 리스트로 만들기/main.py
318
3.75
4
def digit_reverse(n): # 함수를 완성해 주세요 result = [] numlist = list(str(n)) for i in range(-1,-len(numlist)-1, -1): result.append(int(numlist[i])) return result # 아래는 테스트로 출력해 보기 위한 코드입니다. print("결과 : {}".format(digit_reverse(12345)))
926051e08d3955822d656e48c58d32f3d37cc6de
Knickmeyer18/lpthw
/ex5.py
1,180
4.46875
4
#learning python the hard way #ex5.py ''' Ex5: More Variables and Printing - using a "format string" - learning how to make strings that have variables embedded in them. -- this is done by using spec format sequences and then putting the variable at the end with special syntax, telling python this is a format string...
50bbf02ab74550cd7be6aa20519106ef8d1d8229
thioaana/DataStructuresAndAlgorithms
/AlgorithmsOnGraphs/Week3PathsInGraphs/bfs.py
3,823
3.734375
4
#Uses python3 import sys class Graph : def __init__(self, n) : self.numOfVertices = n self.graph = [[] for _ in range(self.numOfVertices)] # Return the number of Vertices def getNumOfVertices(self) : return self.numOfVertices # Return the number of Edges def getNumOfEdges...
3bba492bafd30dd5e3be71a0f2314259e51483e3
margaridav27/feup-fpro
/PEs/PE04 model/gcd.py
359
3.890625
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 18 15:04:09 2019 @author: Margarida Viera """ # Euclid's algorithm says that gcd(a,b) == gcd(b, a(mod b)) # solution using while def gcd(a,b): while b != 0: a, b = b, a % b return a # solution using recursion def gcd(a,b): if b == 0: return ...
d3b905bd585584e84415164f014cb8c31b9f8a92
duanxuepeng11/Alive
/pythonDemo/高级特性/切片.py
520
3.890625
4
L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack'] print(L[0:3]) #['Michael', 'Sarah', 'Tracy'] print(L[:3]) #['Michael', 'Sarah', 'Tracy'] print(L[1:3]) #['Sarah', 'Tracy'] print(L[1:]) #[ 'Sarah', 'Tracy', 'Bob', 'Jack'] print(L[-1]) #['Jack'] print(L[-2:]) #'Bob', 'Jack' print(L[-2:-1]) #Bob', 'Ja...
7e1e4dcefb73ec9af8f40ec129589f0221e552c4
Issaquah/TicketBooking
/Main.py
2,778
3.765625
4
bus_types = ['Volvo A/C Semi Sleeper (2+2)', 'Non A/C Sleeper (2+1)', 'Scania AC Multi Axle Semi Sleeper(2+2)', 'Volvo A/C Multi Axle Sleeper(2+1)', 'Non A/C Seater/Sleeper (2+1)', 'Volvo Multi Axle SemiSleeper I-Shift B11R (2+2)', 'Mercedes Benz ...
8f20331d6e6c9d8ed1f15973cc04311a10c6d6c8
salman-naheed/python-tkinter
/hello.py
151
3.8125
4
from tkinter import * root = Tk() # Creating label widget myLabel = Label(root, text="Hello") # Shoving into screen myLabel.pack() root.mainloop()
918cc75d6187527881066450c1c3199890dedb8f
Ahn-jae-hee/Python
/AJH.py
248
3.765625
4
class Calcul: def __init__(self,num1,num2): self.num1=num1 self.num2=num2 class Calcul1(Calcul): def sum(self): result=self.num2+self.num1 return result a=Calcul1(10,20) a.sum() print(a.sum())
3fcfca4e8e24d488ea979474eea20d133bbaa51c
jyeoniii/algorithm
/20201207/time_based_key_value_store.py
1,552
3.5
4
# https://leetcode.com/problems/time-based-key-value-store/ from collections import defaultdict import bisect class TimeMap: def __init__(self): """ Initialize your data structure here. """ self.d = defaultdict(list) self.MAX_STRING = "z" * 100 def set(self, key: str, ...
dcba347a83bab2a403bb702c6f6d41f55141f027
MarcosHolloways/Alien-Game
/Alien_Ship.py
1,417
3.640625
4
import pygame from pygame.sprite import Sprite class Alien(Sprite): """Uma classe que representa um único alienígena da frota.""" def __init__(self, ai_settings, tela): """Inicializa o alienígena e define sua posição inicial.""" super(Alien, self).__init__() self.tela = tela ...
4d5df6bae58028f3079ad8c320c299c162b61b0d
app-stack/l3codingpractice
/While exercice .py
628
4.09375
4
while True : # Ask user if they are happy to follow the rules number = input("How many rounds would you like to play? [3 or 5]") if number == "3" or number == "5" : break """return number - The above code was inside a function i created, if your using it w...
5127e20babf24056f89216ccef4706819f5a9b43
DaviSilva70/Python
/Desafio_34_Resultado.py
533
3.90625
4
"""Escreva um programa que pergunte o salario de un funcionario e calcule o valor do seu aumento. Para Salario superiores a R$1.250.00, calcule um aumento de 10%. Para Salarios Inferiores ou iguais ,o aumento e de 15%.""" salario = float(input('Digite o Salario do Colaborador R$: ')) if salario <=1250: nov...
e6ffc2aec447c45dd10bd8b715fb198ce1055314
DKostyuk/introduction
/doneTask_01/Task11_hoursMinutes.py
222
3.703125
4
print('С начала суток прошло N минут. Введите натуральное число N:') n = int(input()) minTotal = n % 1440 hours = minTotal // 60 minutes = minTotal % 60 print(hours, minutes)
96c514946706b2d8a1b88fd119fa24bf48834438
antadlp/pythonHardWay
/ex5_studyDrill_02.py
444
3.765625
4
#2. Try to write some variables that convert the inches and pounds to #centimeters and kilograms. Do not just type in the measurements. Work out the #math in Python #input pulgadas And pounds inCm = 1.0 inPounds = 1.0 print "Las pulgadas que quieres convertir son %f" % inCm print "que son %f centimetros" % (inCm*2.54...
ad541d5d10cc1e33549a2ad7e75f52864b00b1f9
dimpusagar91/python_tutorials
/9_Errors_exceptions/exception.py
1,976
4.09375
4
''' #But what about division by zero? a = int(input('First number, please: ')) b = int(input('Second number: ')) print('Your result is ', a/b) ''' ''' #Let's do a simple try-except block. try: a = int(input('First number, please: ')) b = int(input('Second number: ')) print('Your result is ', a/...
4ae7e69dae9d38d40e6be025f4d609c332184985
zanixus/py-hw-mcc
/chapter16/DistanceFunctions_KM.py
4,296
4.09375
4
#!/usr/bin/python3 """ Kevin M. Mallgrave Professor Janet Brown-Sederberg CTIM-285 W01 06 May 2019 Python trip itinerary calculator. Needs zip codes csv. This program uses lists and dictionaries to calculate distance between destinations. It prints outputs in km and attempts to handle u...
30ce9b29f7e86c9be261bff06a463f361328faca
Jeewandeep008/Python-learning-all-here
/RangeExamples.py
1,781
4.125
4
# >>>>>>>>>>>>>>>>>>>>>>>> RANGE with list >>>>>>>>>>>>>>>>>>>>>>>> short demo # Remove all the odd and even numbers from list / RANGE >>>>>>>>>>>>>>>>>> # rem_odd = [1,3,5,7,9,2,4,6,8,10] # rem_even = [1,3,5,7,9,2,4,6,8,10] # L = range(10) # for a in L: # print(a) # nuum = range(10) # nuum = range(1, 11) # for a in n...
785f123a05c2bd7b1c3e3aad42843d96a0ab1541
malarc01/codejournal
/python.py
817
3.78125
4
def mark_starting_point_and_move(): put("token") while not front_is_clear(): turn_left() move() def follow_right_wall(): if right_is_clear(): turn_right() move() elif front_is_clear(): move() else: turn_left() # Program execution below while not at...
7c3219883a004a12c85fcba93005b8f1f40fc23a
futrica/python_4_zombies
/exercicios/exercicio02_joaomarcelo_07.py
225
3.625
4
area = float(input ("informe m²: ")) tinta = area / 3 galao = tinta / 18 if (galao % 18 != 0 ): galao = int(galao)+1 total = galao * 80 print("vão precisar de %.0f galões e valor a pagar R$ %.2f " %(galao, total))
4c3d8924519987844d8bf057d368f0f9c6dc9b91
astondevops/test1511
/test.py
2,220
3.921875
4
#!/usr/bin/python3 # import de la lib sys import sys print(sys.version_info) print(sys.version) print(sys.platform) print("Hello") print('Hello') print("c'est") print(""" texte a la suite""") print("c'est le texte dans C:\\user") strAdresse = "Spam" print (strAdresse) a = [ 'a', 'b','c','d','e','f','g',...
7b3e58cda801fe3cc15d924b5baadfbc9834aa4d
csvenja/LeetCode
/Linked List Cycle.py
622
3.828125
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @param head, a ListNode # @return a boolean def hasCycle(self, head): fast = head slow = head while fast is not None and fast.next is not ...
4233bb3ecab865e5ab03b4f5dac8a75c42ddd7ee
noisykeyboard/adventofcode
/Day 3/houses1.py
1,220
3.828125
4
directions = open("input", 'r').read() robocoordinates = [0, 0] realcoordinates = [0, 0] visitedhouses = [] uniquehouses = 0 currentsanta = "real" coordinates = realcoordinates def coordswap(): global currentsanta, coordinates if currentsanta == "real": coordinates = robocoordinates currentsan...
c5e6294cdaa677714880ec03738b79cbd00df00c
nacholagorta/PythonBasics
/Raiz.py
593
3.859375
4
# Cálculo del sumatorio de la raíz de i desde un número a hasta un número b # proporcionado por el usuario. Comprobar antes de calcular que 0<=a<=b # i=b # ∑√i # i=a para a y b introducidos desde teclado., siendo 0<= a<=b import math a = int(input("ingresa primer número:\n")) while a < 0: a = int(input("El número ...
5aa8b0e14dbde0bd169417c3fd2ef012451e3186
luccaki/FuncoesHash
/FunçõesDeEspalhamento.py
1,599
3.90625
4
# Módulo/Biblioteca de Funções de Espalhamento pelos métodos de Divisão e Multiplicação from collections import defaultdict # Função de espalhamento pelo método da divisão # h(K) = K mod M # Recebe dois valores K e M # K - Um número natural (chave/key) # M - Um número natural (Recomendado um numero primo não...
46a021e780aa64f824c4c707f1d20e8d41bd9a62
ChristopheCluizel/codingame
/src/challenge/python/starcraft/app.py
4,780
3.640625
4
import sys import copy class Position: def __init__(self, x, y): self.x = x self.y = y def __str__(self): return "({},{})".format(self.x, self.y) class Robot: def __init__(self, id, position, direction): """ :param id: :type id: integer :param pos...
76888188318d00736f58a3bcde7dc3331da8fcbe
sagarnikam123/learnNPractice
/hackerEarth/practice/dataStructures/hashTables/basicsOfHashTables/difficultCharacters.py
1,599
3.953125
4
# Difficult Characters ####################################################################################################################### # # Yesterday while Omar was trying to learn English, he saw that there are letters repeated many times in words # while some other letters repeated only few times or not r...
dc56d3be68d2bec31d801e6794fbf5fffdc768eb
Amit32624/Python
/Python_codes/DemoMax.py
296
3.96875
4
''' Created on 12-Jun-2017 @author: mohan.chinnaiah ''' print("Enter three numbers"); n1=int(input()); n2=int(input()); n3=int(input()); if (n1 > n2 and n1 > n3): print("N1 is Bigger"); else: if(n2 > n3): print("N2 is Bigger"); else: print("N3 is Bigger")
745aa3f91a40120e61742662b8423ff062777644
Graziellah/BootCampPython
/d00/ex04/operation.py
839
3.609375
4
import sys def operations(nb1, nb2): print("Sum:", nb1 + nb2) print("Difference:", nb1 - nb2) print("Product:", nb1 * nb2) try: print("Quotient:", nb1/nb2) except ZeroDivisionError: print("Quotient :ERROR (div by zero)") try: print("Reminder:", nb1 % nb2) except Zer...
cebe396bb1193cd38a6679195c03edf33b5c4379
DamianvdD/PythonAchievements
/DailyChoices.py
2,518
3.9375
4
import time def dailychoices(): print("Hey hoi hallo goeie morgen! Ga je nu je bed uit of niet en blijf je nog 10 minuten liggen? Antwoord met: Ja/Nee") choice = input() if choice.lower() == "ja": print("Mooi zo je bent iemand die vroeg zn bed uit gaat.") elif choice.lower() == "nee": ...
76827abd8736237eed99c4f46b07fe1c2a7b093d
jbc-cp/csc202-assignments
/labs/lab-01/lab1.py
651
4.1875
4
def max_list_iter(int_list): # must use iteration not recursion """finds the max of a list of numbers and returns the value (not the index) If int_list is empty, returns None. If list is None, raises ValueError""" pass def reverse_rec(int_list): # must use recursion """recursively reverses a lis...