blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
31f46be2be3594e0deb8d3f798615f0da83f5ee1
sukurcf/DSA_old
/binary_search.py
503
3.78125
4
numbers_list = [12, 15, 17, 19, 21, 24, 45, 67] def binary_search(numbers, left_index, right_index, key): if right_index > left_index: mid = (left_index + right_index) // 2 if numbers[mid] == key: return mid elif numbers[mid] < key: return binary_search(numbers, mid...
208da5282d2ac39f6a51343025bd78f422d2441b
alecbw/Learning-Projects
/Bank Account.py
1,147
4.34375
4
""" This code does the following things Top level: creates and manipulates a personal bank account * accepts deposits * allows withdrawals * displays the balance * displays the details of the account """ class BankAccount(object): balance = 0 def __init__(self, name): self.name = name def __repr__(self...
d7882c21bc666164b05d1138685c9fc3340f0567
TaiPham25/PhamPhuTai---Fundamentals---C4E16
/Session3/baitap3.py
365
3.546875
4
#tach cau thanh tung chu # print('champion'.split('')) #tach chu # character = list("champion") # print(character) #random lay ra 1 ki tu from random import choice character = list("champion") print(character) random_char = choice(character) print(random_char) answer = input('Your answer: ') if answer == champion: ...
e02247e2be0e3a638d8a222bfde68f9dd1609f18
TaiPham25/PhamPhuTai---Fundamentals---C4E16
/Session3/Homework/Guess.py
788
3.84375
4
# #3a from random import choice from random import shuffle playing = True while playing: fun = list('champion') shuffle(fun) print(*fun, sep=', ') write = input('Your answer: ') if write == 'champion': print('Hura') break else: print('Your aswer: ', write) print(...
13408db5de2e32cd359d691ac80ad724b2495253
TaiPham25/PhamPhuTai---Fundamentals---C4E16
/Session04/clera.py
742
4.15625
4
print ('Guess your number game') print ('Now think of a number from 0 to 100, then press " Enter"') input() print(""" All you have to do is to asnwer to my guess 'c' if my guess is 'C'orrect 'l' if my guess is 'L'arge than your number 's' if my guess is 'S'mall than your number """) #string formatting from random imp...
7ec7708a0a5006a5432241f25261f70389373a54
TaiPham25/PhamPhuTai---Fundamentals---C4E16
/Session3/baitap2.py
390
3.90625
4
#delete favs = ['death note', 'netflix', 'teaching'] print('hi,list: ') for index, fav in enumerate(favs): print(index + 1, '. ', fav, sep='') position =int(input('Vi tri ban muon xoa: ')) del favs[position - 1] # favs.pop(position - 1) for index, fav in enumerate(favs): print(index + 1, '. ', fav, sep='') ...
5c0f8e47d69922dac71676bd1fc09346e7ce8f9c
TaiPham25/PhamPhuTai---Fundamentals---C4E16
/Session01/Homework/rua4.py
138
3.796875
4
from turtle import * shape('turtle') speed(-1) color('green') for i in range(300): left(90) circle(120) left(7) mainloop()
b8d1eb36eae36181f6676f5458bf69f5e5655339
TaiPham25/PhamPhuTai---Fundamentals---C4E16
/Session02/sum-n.py
159
3.8125
4
n = int(input('Enter a number: ')) # total = n # # for i in range(n): # total += i # print(*range(5)) seq = range(n + 1) total = sum(seq) print(total)
7cca5cbc6d4594267807d5123bcd3730c4fc64d9
christianesl/python-workspace
/Advanced Funtions/LongestCharSequence.py
450
3.65625
4
def method(input): charS = '' previous = '' maxS = 0 dict1 = {} for itr in input: if(previous == itr): dict1[itr] = dict1[itr] + 1 if(dict1[char] > maxS): maxS = dict1[char] charS = char else: dict1.clear() ...
e74a8d776c60d9f438b62d0654fa8e84468aab70
Honnegowda/MyProject1
/propertey_decorator.py
603
3.84375
4
class Employee(object): def __init__(self, fn, ln): self._fn = fn self._ln = ln @property def _email(self): return self._fn+"."+self._ln+"@zeomega.com" @_email.setter def _email(self, value): fn_ln_li = value.split("@")[0].split('.') self._fn = fn_ln...
ea931632cbcfdb9ce1704da44a26b9e10c495490
hse-ml-da/date-preparation-chatbot
/util.py
762
3.65625
4
from nltk.tokenize import word_tokenize from pymystem3 import Mystem from string import punctuation from typing import List def lemmatize(msg: str) -> List[str]: msg = msg.lower() tokens = word_tokenize(msg) # words without punctuation filtered_tokens = [w for w in tokens if not w.lower() in punctuat...
1043f2e7ec3ec01822a2c581b7402d8d87ac0726
omeregri/RekatFinder
/rekatfinder.py
1,115
3.5
4
__author__ = "omeregri" import os import time while True: print("Namaz Rekatları") print("Sabah Namazı(1)") print("Öğle Namazı(2)") print("İkindi Namazı(3)") print("Akşam Namazı(4)") print("Yatsı Namazı(5)") print("Ek namazlar için (6) \n") vakit_secimi = int(input("Hangi namazın rekat ...
65240998e3eee7f8897536256a1be9da535a6944
aaroncsolomon/244proj
/linear_regression2.py
2,331
4.0625
4
import tensorflow as tf import numpy as np # Generate samples of a function we are trying to predict: samples = 100 xs = np.linspace(-5, 5, samples) # We will attempt to fit this function ys = np.sin(xs) + np.random.uniform(-0.5, 0.5, samples) # First, create TensorFlow placeholders for input data (xs) and # output (...
557290c14e673328305c174b87be8d8ca53786a6
arielchm/cryptography-exercises
/railfence_cypher.py
1,423
3.59375
4
#plaintext = input("Type a message to encode:") # Convert plaintext to UPPERCASE plaintext = "HELLO EVERYONE" n = 3 def cypher(plaintext, n): plaintext = plaintext.upper() pl = len(plaintext) up = False ctlist = [""]*n k = 0 for i in range(pl): if i % (n-1) == 0 and i != 0: ...
cda24eb518418585eaacc80dafbc7d6e1e3cd75a
nikashan02/calculator-swift
/calculator final.py
8,226
3.625
4
def parseList(strExpression): exprList = list(strExpression) count = -1 for index in exprList: count += 1 if index != "+" and index != "-" and index != "*" and index != "/" and index != "(" and index != ")": while count < len(exprList)-1: while count < len(exprLis...
4f6af3980b64c748b8afddfd11af6054e01e5b64
Toruitas/Python
/Practice/Daily Programmer/DP44 - Divide into sentences.py
1,943
3.671875
4
__author__ = 'Stuart' """ http://www.reddit.com/r/dailyprogrammer/comments/srowj/4252012_challenge_44_easy/ Write a program that divides up some input text into sentences and then determines which sentence in the input has the most words. Print out the sentence with the most words and the number of words that are in ...
e4bcb4e0cb4ab147dcea02a80bc3c4302879fdb7
Toruitas/Python
/Practice/Daily Programmer/DP34 - 3 nums, sum largest squares.py
586
3.890625
4
__author__ = 'Stuart' """ http://www.reddit.com/r/dailyprogrammer/comments/rmmn8/3312012_challenge_34_easy/ A very basic challenge: In this challenge, the input is are : 3 numbers as arguments output: the sum of the squares of the two larger numbers. Your task is to write the indicated challenge. """ def do_work(num1,...
ef28f1eb265cb90c47a2c1fec8c714d3542f7d8c
Toruitas/Python
/Practice/Daily Programmer/DP13 - Find number of day in year.py
2,659
4.40625
4
__author__ = 'Stuart' """ http://www.reddit.com/r/dailyprogrammer/comments/pzo4w/2212012_challenge_13_easy/ Find the number of the year for the given date. For example, january 1st would be 1, and december 31st is 365. for extra credit, allow it to calculate leap years, as well. https://docs.python.org/3.4/library/date...
162ee234c3a1163543bec30571c12eaaf0ffd260
Toruitas/Python
/Practice/Daily Programmer/DP20 - Find Primes under 2000.py
524
3.515625
4
__author__ = 'Stuart' """ create a program that will find all prime numbers below 2000 http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes http://en.wikipedia.org/wiki/Fermat%27s_little_theorem http://www.reddit.com/r/dailyprogrammer/comments/qnkro/382012_challenge_20_easy/ """ import math maxnum = 2000 L2 = list(range...
185f03b68bac3ca937ecee2d5b4b033314fb3d06
Toruitas/Python
/Practice/Daily Programmer/Random Password Generator.py
811
4.15625
4
__author__ = 'Stuart' """ Random password generator default 8 characters, but user can define what length of password they want """ def password_assembler(length=8): """ Takes user-defined length (default 8) and generates a random password :param length: default 8, otherwise user-defined :return: pass...
0bf7196c62a44a5a28cc4d8f86d226859924402e
Toruitas/Python
/Practice/Daily Programmer/DP24 - election winner.py
2,589
4.03125
4
__author__ = 'Stuart' """ http://www.reddit.com/r/dailyprogrammer/comments/qxuug/3152012_challenge_25_easy/ In an election, the person with the majority of the votes is the winner. Sometimes due to similar number of votes, there are no winners. Your challenge is to write a program that determines the winner of a vote, ...
81c846a6b622b5d55a87e3427271078f53d28fd4
Toruitas/Python
/Practice/Daily Programmer/DP7 - Morse Code.py
2,462
3.671875
4
__author__ = 'Stuart' """ http://www.reddit.com/r/dailyprogrammer/comments/pr2xr/2152012_challenge_7_easy/ Write a program that can translate Morse code in the format of ...---... A space and a slash will be placed between words. ..- / --.- For bonus, add the capability of going from a string to Morse code. Super-bonus...
d2ebd37a1a4c6b32991098ff6590b54a1aa964fd
Toruitas/Python
/Practice/Daily Programmer/DP43 - binary tree.py
325
3.5625
4
__author__ = 'Stuart' """ http://www.reddit.com/r/dailyprogrammer/comments/sq3p9/4242012_challenge_43_easy/ Today is a common interview question. Given a binary tree t and two elements of the tree, m and n, with m < n, find the lowest element of the tree (farthest from the root) that is an ancestor of both m and n. ...
47567240773ccbedbccd4a4f098e3911419cd163
Toruitas/Python
/Practice/Daily Exercises/day 11 practice.py
1,409
4.25
4
_author_ = 'stu' #exercise 11 #time to complete: 15 minutes """Ask the user for a number and determine whether the number is prime or not. (For those who have forgotten, a prime number is a number that has no divisors.) You can (and should!) use your answer to Exercise 4 to help you. Take this opportunity to practi...
6731adb1c12886d6921b434883e6f432056e6420
Toruitas/Python
/Practice/Learn Python the Hard Way/ex36.py
3,161
3.671875
4
__author__ = 'Stuart' def the_woods(): print("You find yourself in the dark dark woods.\n" "What could be lurking around the corner?\n" "You hear something crashing through the bushes behind you, and see a clearing ahead.\n" "Do you 'look back' or do you 'run away' to the clearing?\n"...
6b69b857f5a2e8aeb5c6eed342b0dbaf12c027c3
Toruitas/Python
/Practice/Python Projects/try it out 1.py
1,608
4
4
__author__ = 'Stuart' def straight_line(gradient, x, constant): """ returns y coordinate of a straight line: gradient * x + constant y = mx+c :param gradient: slope :param x: duh :param constant: y intercept :return: """ return gradient * x + constant # print(straight_line(2,4,...
e825be3736c83d1579e2e155ac0a1c2d3bc8255c
fabiancaraballo/CS122-IntroToProg-ProbSolv
/project1/P1_hello.py
213
4.25
4
print("Hello World!") print("") name = "Fabian" print("name") print(name) #print allows us to print in the console whenever we run the code. print("") ambition = "I want to be successful in life." print(ambition)
b5af30c878bded4aaf613ee861b5afeba5c2a233
fabiancaraballo/CS122-IntroToProg-ProbSolv
/project8/P8_1_unending.py
338
3.8125
4
# P8_1_unending.py # Help - when I run this program it keeps going and going... my_list = ['Jim', 'Ashley', 'Amanda', 'Zelda'] # Add more names hint = "Type Q to quit or first name to add (such as Anne): " name = input(hint).title() while name != 'Q': my_list.append(name) print("Added", name) name = in...
c9aa90191fb020dbcfac45795a7cc66090397b8c
fabiancaraballo/CS122-IntroToProg-ProbSolv
/project4/P4_for.py
394
3.71875
4
top_movies = ["Pulp Fiction", "Scarface", "Step Brothers", "The Godfather"] movies_list = len(top_movies) print("Good Movies") print("") for i in range(movies_list): print(top_movies[i]) numbers = [5, 9, 26, 4, 21, -6] num = len(numbers) for i in range(num): if(i % 2 == 0): numbers[i] = numbers[i] elif(i % 2 ==...
47f1633922c2014d2550b3de4be750c97ff31acc
ravish0007/patterns
/p0162.py
208
3.796875
4
d = [ {'a': 1, 'b': 2, 'f': 3, 'd': 4}, {'a': 1, 'b': 2, 'c': 3, 'd': 4}, {'d': 1, 'b': 2, 'c': 3, 'e': 4}, ] a = list(set.intersection(*[set(k.keys()) for k in d])) print(a) """< ['b', 'd'] >"""
aeaeb67cbb76874f33add8f469f473bc359311ef
ravish0007/patterns
/p0040.py
225
3.6875
4
a = [1, 2, 3, 4] b = [[3, 5, 6, 7], [1, 8, 9, 10]] # a - b[0] - b[1]: c = [x for x in a if not any([x in l for l in b])] print(c) """< [2, 4] >""" d = list(set(a).difference(*[set(l) for l in b])) print(d) """< [2, 4] >"""
c6e3e77672ac71db10c138460a2b25d30b7e55de
ravish0007/patterns
/p0001.py
683
3.84375
4
# split based on whitespace: a = 'a b c d '.split() # ['a', 'b', 'c', 'd'] # specify a delimiter: a = 'a |b||c|d'.split('|') # ['a ', 'b', '', 'c', 'd'] # omit whitespace and empty strings: a = [s.strip() for s in 'a ,b,,c,d'.split(',') if s.strip()] # ['a', 'b', 'c', 'd'] # no more than 3 splits: a = ...
06b366b49e1eb6954eb946658284c974bb8fa1a9
ravish0007/patterns
/p0047.py
349
3.671875
4
x = 3 y = 4 a = [1, 2, 4, 5, 4, 6, 2] try: a.insert(a.index(y), x) except ValueError: a.append(x) print(a) """< [1, 2, 3, 4, 5, 4, 6, 2] >""" a = [1, 2, 4, 5, 4, 6, 2] try: i = a.index(y) b = a[:i] + [x] + a[i:] except ValueError: b = a + [x] print(b) """< [1, 2, 3, 4, 5, 4, 6, 2] >""" print(a) """...
4a51fe109f3a647d0c258d51f70a152490b71dfb
ravish0007/patterns
/p0190.py
615
3.5
4
from datetime import datetime from dateutil.relativedelta import relativedelta def timespan(dt1, dt2=None): delta = relativedelta(dt1, dt2 or datetime.now()) for i, s in enumerate([ 'years', 'months', 'days', 'hours', 'minutes', 'seconds', ]): v = ab...
4a4b538b6d6aab009f842f376e42854c686e2b0a
NoalTessman/learningPython
/practice/Skipping ahead/secet.py
366
3.9375
4
secret_number = 9 guess_count = 0 guess_limit = 3 while guess_count <guess_limit: guess = int(input('Guess:')) guess_count +=1 if guess == secret_number: print('You are winner') break # elif guess_count == 3: # print('you are lose') # break else: print('you are lose') #e...
61c54516c6f4387b9d67ca1455c6f9e4cf175da2
NoalTessman/learningPython
/projects/securityPracticeWords/securityPlus.py
215
3.515625
4
import csv words = csv.writer(open("keyWords.txt","a"), delimiter = ",", lineterminator = "\n") counter = 0 x = 1 while x == 1: newWord = input("Next word pls: ") counter += 1 words.writerow([newWord])
d944ea79029ec1f3168ad20173a2ca15b414690a
jlopez1328/Python
/Ejercicios_basicos/fibonacci.py
451
3.765625
4
aux = 1 fib = 0 init = 1 _INFO = """Este programa imprime la sucesion de fibonacci desde 1 hasta N, siendo este ultimo un numero ingresado por el usuario """ print(_INFO) lim = int(input("Ingrese un numero para la sucesion de fibonacci: ")) if lim > 0: while init <= lim: print("[{0}]".format(fib), end="...
e6276a0fe28867a7eb0de90a9695326e11ce134b
jlopez1328/Python
/Ejercicios_conceptos_basicos/meses_transcurridos.py
386
3.75
4
import datetime fechaactual = datetime.datetime.now() print('Fecha actual', fechaactual.date()) fechanaci = input('Digite su fecha de nacimiento (aaaa-mm-dd)\n') fechanacimiento = datetime.datetime.strptime(fechanaci, '%Y-%m-%d') print('Fecha nacimiento:', fechanacimiento.date()) diferencia = fechaactual - fechanaci...
4d76540b2f4f377539892c5a5387ad4387fdea54
thebongy/scrapeit
/scrape.py
3,127
3.546875
4
Symbol = str # A Scheme Symbol is implemented as a Python str List = list # A Scheme List is implemented as a Python list Number = (int, float) # A Scheme Number is implemented as a Python int or float\ Env = dict class DOMParser: def __init__(self,parse,parent): self.parser = parse self.parsed...
4121c187d612ecd6552a1ba066bc96c18e3a95ab
sungwooman91/Huconn_Project_1
/Class_test/Class_test_1.py
375
3.515625
4
class Car: def __init__(self, model, year): ## 클래스에서 정의된 함수를 '메서드'라 한다.(생성자) self.model = model ## 입력받은 값을 바인딩 하기 위한 과정1 self.year = year ## 과정2 sonata = Car("SONATA", 2017) g80 = Car("G80", 2018) print(sonata.model,sonata.year) print(g80.model, g80.year)
7af8d3d72f45c4909bba34e9876d384cc2b770cf
KalenchitsKarina/test
/example_8.py
122
3.671875
4
mail=input('Enter your email: ') if 'gmail.com' in mail: print (mail) else: print ('DOMAIN NAME is not supported')
4ef6cab1801df00fb707bec46b777dacac40ca99
Leila571/tic_tac_toe
/main.py
402
3.734375
4
''' 10/1/2020 Leila Lopez Marks Tic Tac Toe Board ''' print("Welcome to Tic Tac Toe") board = [None, None, "None", "None", "None", None, "None", None, "None"] # python ttt.py [['_', '_', '_'], ['_', '_', '_'], ['_', '_', '_']] # ttt.py board = [ ["_","_", "_"], ["_", "_", "_"], ["_", "_", "_"] ] for r...
80de1e0515cdb5c8fce2043728efb12a1aedb0f4
onejeton/gorsel-programlama
/soru1.py
231
3.609375
4
mail = "ali.erbey@usak.edu.tr" def emailControl(mail): control = False for e in mail: if e == "@": control = True if control and e == ".": return True return False print(emailControl(mail))
bc4d24fb1507c54e3b0764173bfd5ca5647e3997
Artemis3A/firstpythonrepox
/classex1.py
1,061
3.90625
4
lower_limit = int(input('Enter lower limit: ')) upper_limit = int(input('Enter upper limit: ')) def evnum(): for evval in range(lower_limit, upper_limit): if evval % 2 == 0: print (evval) def odnum(): for oddval in range(lower_limit, upper_limit): if oddval % 2 == 1: pr...
cab97dc4a94aca03f33ed9fa135ec4c9e4426a78
prithuchugh/Google_Coding_Challenge
/python/src/video_player.py
11,997
3.921875
4
"""A video player class.""" import random from .video_library import VideoLibrary playing_video = [] paused_video = [] playlist = {"":[]} class VideoPlayer: """A class used to represent a Video Player.""" def __init__(self): self._video_library = VideoLibrary() def number_of_videos(self): ...
b816c1109dd0c37161a3aea3e54eaf77c3604486
kinziematt/Matthew-Dunne-Data-Science-Portfolio
/Code_(Sample Work)/Coursera, Charting and Plotting (Python)/Weather Plot Code.py
7,605
3.625
4
# coding: utf-8 # # Assignment 2 # # Before working on this assignment please read these instructions fully. In the submission area, you will notice that you can click the link to **Preview the Grading** for each step of the assignment. This is the criteria that will be used for peer grading. Please familiarize your...
50cb4fc4c8b8cae802f0cf90fa4449a8223cdd31
VenkatRamReddyK/MazeIn4D
/MazeGen.py
5,279
3.515625
4
import math import random from random import randrange from MazeCell import MazeCell # pushes the index to end of the neighbourlist and returns it def pushIntoTuple(neighbourlist,index): neighbourlist=neighbourlist[:len(neighbourlist)]+(index,) return neighbourlist # returns the index of QUATRAPLE 'dim' def...
d22c8f2e9ec302387aac1759151ad4b0b15c16d9
kakalimahapatra/PythonExplore
/W9/leap_year.py
298
4.0625
4
# Name - Kakali Mahapatra # Program to calculate leap year def main(): inputString = input("Enter a year: ") inputYear = int(inputString) if inputYear%4 == 0: print ("This is a leap year") else: print ("This is not a leap year") #if __name__ == "__main__": main()
abe7ef7ceb47fb58cfaf74a4dc93e24ddf577214
JoeyZhen/Life_data_analysis
/jxz5374/growth.py
3,922
3.96875
4
""" file:growth.py author: Joey Zhen created: 12/09/2017 """ from utils import * import math from jxz5374.utils import CountryValue, read_data, filter_income, filter_region def expectancy(country): """ This function return the key for sorting the life expectancy growth of countries from largest ...
634ad3c17d105f95cd627425354fd78826177710
meridian-school-computer-science/pizza
/src/classes_pizza.py
930
4.53125
5
# classes for pizza with decorator design class Pizza: """ Base class for the building of a pizza. Use decorators to complete the design of each pizza object. """ def __init__(self, name, cost): self.name = name self.cost = float(cost) def __repr__(self): return...
72b0b87d086034831c04990fefa152c0caf0535d
knarg/hw_gc
/Code Samples/code_sample.py
463
3.9375
4
def setupInitMoney(): money = input("Insert the initial balance above 0: ") #TODO: Add a loop to make sure the data is corrct #TODO: Add user input validation #TODO: convert to float before return #TODO: ... return money ... def main(): print("Describe your app") initMoney = setupIni...
4f98063e7bf464f06ef31d06f2a9aa6ba8907cf7
ffrankies/tf_rnn
/tf_rnn/layers/utils/metrics.py
1,120
3.609375
4
"""Holds the performance metrics for a model. @since 0.6.1 """ from . import Accumulator class Metrics(object): """Holds the performance metrics for a given model. Instance Variables: - train (Accumulator): The accumulator that holds training performance metrics - valid (Accumulator): ...
c2b204a839175dfd072e116137035963f7658625
mayweed/6.00x
/6.00.1x/pset1/polysum.py
506
4.0625
4
#!/usr/bin/python import math def polysum(n,s): """ This function takes as input the number of sides n and the length of each side s of a polygon. It returns as output the sum of the area and the square of the polygon perimeter . """ def perimeter(numberofside,length): retu...
103484273c0348f4e9aa3cec9398658a2a0730d1
mayweed/6.00x
/6.00.1x/quizz/flattenList.py
612
4
4
#!/usr/bin/python def flatten(aList): ''' aList: a list Returns a copy of aList, which is a flattened version of aList ''' liste=[] #base case if len(aList) ==0: return aList for element in aList: if type(element)==list: for item in (element): ...
0f7c0022b62267b735af471f24ccef16594d6ad7
siyanapavlova/AMR_annotations
/preprocessor.py
3,015
3.765625
4
import re def get_amr_sents(amrs_list): '''a function to extract the sentence and the list of lines for the AMRs contained in a readlines pull from a .txt file of AMR data input | a list containing a .readlines() pull from a .txt file of AMR data output | sentence: str - an unparsed sentence extracted from the AM...
684ada57ad12df9053cad5f14c71452e1625c0f2
bear148/Bear-Shell
/utils/calculatorBase.py
637
4.28125
4
def sub(num1, num2): return int(num1)-int(num2) def add(num3, num4): return int(num3)+int(num4) def multiply(num5, num6): return int(num5)*int(num6) def divide(num7, num8): return int(num7)/int(num8) # Adding Strings vs Adding Ints # When adding two strings together, they don't combine into a different number, ...
2fc9da16ee5061cd7515867707ab2697a5cc88df
IuryChagas25/algebralinearcompython
/Calcula-Determinante-Pelo-Metodo-dos-Co-Fatores.py
1,010
4
4
#Código criado por: Iury Chagas da Silva Caetano import numpy as np #importando bibliotena numpy ao objeto "np" print("Insira uma matriz quadrada para calcular seu determinante! \n") Linha = int(input("Insira a dimensão da Matriz: ")) Coluna = Linha #gerando uma matriz com lixo de memoria, mas com as dimensões inserid...
b8b591909cf25d30d9f984b12b898ec1f54330f7
mare-astrorum/leetcode-practice
/191009 Watering Plants.py
3,743
3.75
4
""" https://leetcode.com/discuss/interview-question/394347/google-oa-2019-watering-flowers-20 """ plants = [2, 4, 1, 5, 6, 100] capacity1 = 5 capacity2 = 7 watering_plants(plants, capacity1, capacity2) sum(plants) def watering_plants(plants, capacity1, capacity2): import copy ...
f165ade8ca3245db7ff17c65c4a9dcaed8eebb03
mare-astrorum/leetcode-practice
/191011 K Closest Points.py
692
3.59375
4
""" https://leetcode.com/problems/k-closest-points-to-origin/ """ points = [[3,3],[5,-1],[-2,4],[3,14]] K = 2 import math def kClosest(points, K): total_list = [] ans = [] # Find the distance for pair in points: response = math.sqrt(pair[0]**...
70ce676c4ec901b96137f91afbd37c894aa6947c
FilosGabriel/school-stuff
/python/caz1/5/utils.py
327
3.984375
4
def process_item(x): test = lambda a: a == 1 or a == 2 or a == 3 or a % 2 != 0 and len( [i for i in range(3, int(a / 2)) if a % i == 0]) == 0 i = x + 1 if x % 2 == 0 else x + 2 while not test(i): i += 2 return i if __name__ == "__main__": x=input("Number: ") print(process_item(i...
db25562fc690ad005def70b93d8df8a51cfb29a7
techgymjp/techgym_python
/h2EU.py
916
3.53125
4
import random class Player: def __init__(self, name, coin): self.name = name self.coin = coin def info(self): print(self.name + ':' + str(self.coin)) def set_bet_coin(self, bet_coin): self.coin -= bet_coin class Human(Player): def __init__(self, name, coin): super().__init__(name, coin) ...
3cf3d7fdd92d79dc5b4c9896c36e8be03f12047c
zyj20200/pyspark_learn
/pyspark-04-DataFrame/p02创建dataframe.py
467
3.9375
4
# -*- coding:utf-8 -*- # author:zyj from pyspark.sql import SparkSession spark=SparkSession.builder.appName('my_first_app').getOrCreate() # 使用自动类型推断的方式创建dataframe data = [(123, "Katie", 19, "brown"), (234, "Michael", 22, "green"), (345, "Simone", 23, "blue")] df = spark.createDataFrame(data,...
66329cdb2a85bac08f3c3b32f1c1b1bd58ebe9f3
zyj20200/pyspark_learn
/pyspark-04-DataFrame/p04-read-csv.py
529
3.609375
4
# -*- coding:utf-8 -*- # author:zyj from pyspark.sql import SparkSession spark=SparkSession.builder.appName('my_first_app').getOrCreate() # 先创建csv文件 import pandas as pd import numpy as np # 创建数据,并保存至csv文件中 df=pd.DataFrame(np.random.rand(5,5),columns=['a','b','c','d','e']).applymap(lambda x: int(x*10)) ...
bf915e2cab0a7f03ee58d253cd758bc83db84a33
LiYingbogit/pythonfile
/ustc_02_格式化输出.py
300
3.703125
4
name = "小敏" print("你好,我叫%s,请多多关照!" % name) student_no = 1 print("我的学号是%03d" % student_no) price = 2.0 weight = 3 money = price * weight print("单价是%.2f,重量是%.2f,总价格是%.2f" % (price, weight, money)) scale = 0.24 print("比例是%.2f%%" % scale)
3c3eceb966e8bae35dbf963933c8e6f73c42dc95
hezy10/myproject
/PyCharm 2017.3.2/测试面试题.py
2,131
3.828125
4
# 1、大文件的读取 # f = open('./爬虫/爬取的ip.csv','r') # op = f.readlines() # print(op) # f.close() # 2、迭代器与生成器的区别 # 迭代是一个访问集合元素的方式 # 迭代器是一个可以记住遍历位置的对象 # 迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束 # 迭代器只能向前不会后退 # 生成器:一边循环,一边计算,生成器是一个返回迭代器的函数,只能用于迭代操作 # 3、装饰器以及装饰器的使用场景 # 接收一个函数作为参数 # 嵌套一个包装函数, 包装函数会接收原函数的相同参数,并执行原函数,且还会执行附加功能 # 返回嵌套函数 # ...
97465d4d43c7a30c7ddb29a9b3b5a4eeee0871a2
hezy10/myproject
/PyCharm 2017.3.2/自动化测试/类的继承相关.py
2,928
3.859375
4
#1、创建Person类,属性有姓名、年龄、性别,创建方法personInfo,打印这个人的信息 class Person(): def __init__(self,name,age,gender): self.name = name self.age = age self.gender = gender def personInfo(self): print('{},{},{}'.format(self.name,self.age,self.gender)) # 2、创建Student类,继承Person类,属性有学院college,班级class,...
457b6d14e9c80c33e276e7e96410173c3e00920d
hezy10/myproject
/PyCharm 2017.3.2/元组.py
321
3.765625
4
# ########################元组的元素不可以被修改######################## # tuple(元组) tup = (1,2,3,4,5,6,'admin',1,1,1) print(tup.count(1)) print(tup.index(1)) ###################当元组的元素只有一个时后面要加上','类型才会是元组###################### tup1 = (2,) print(type(tup1))
91fb374eecc47e55cca792b6d9dc5982345628b1
hexuanzhang/python_demo
/src/libary/collections/counter.py
1,593
3.8125
4
from collections import Counter # Counter() print(Counter()) print(Counter('abcbabcba')) print(Counter(['a', 'b', 'a', 'c', 'b', 'b'])) print(Counter({'a': 4, 'b': 2})) print(Counter(a=3, b=6)) print('---修改计数---') # 修改计数 c = Counter(['a', 'b', 'a', 'c', 'b', 'b']) print(c['a']) print(c['d']) c['a'] = 5 print(c['a']) ...
d31c521a0004349c0c7d939cb72536db3f7a5c75
cdrn/Algorithms
/merge_sort_test.py
222
3.640625
4
import merge_sort pre_sorted_list = [5, 2, 1, 5, 9, 2] print(merge_sort.MergeSort(pre_sorted_list)) def test_merge_sort(): sorted_list = merge_sort.MergeSort(pre_sorted_list) assert sorted_list == [1, 2, 2, 5, 5, 9]
bf3a5caa3e68bdf5562bf7270ba11befeb5ab21c
jijo125-github/Solving-Competitive-Programs
/LeetCode/0001-0100/43-Multiply_strings.py
832
4.28125
4
""" Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You must not use any built-in BigInteger library or convert the inputs to integer directly. Example 1: Input: num1 = "2", num2 = "3" Output: "6" Example 2:...
0616186cf49f22bd53dd2c3bff6f3a3f7e4fc771
jijo125-github/Solving-Competitive-Programs
/LeetCode/0001-0100/70-Climbing_stairs.py
569
4.09375
4
""" You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 3 Output: 3 Explanation: There are three ways to climb to the top. 1. 1 step + 1 step + 1 step 2. 1 step +...
3dbd67c6823cc8691fb25983ef1ef1128957028b
jijo125-github/Solving-Competitive-Programs
/LeetCode/0101-0200/155-Min_stack.py
1,492
3.9375
4
""" Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. getMin() -- Retrieve the minimum element in the stack. Example 1: Input ["MinStack"...
c4d943bb69e808bbf5a4098037c71f61c353cfac
caofengnian/A-MapReduce-practice
/URL_path.py
738
3.515625
4
from mrjob.job import MRJob import csv def csv_readline(line): #Given a sting CSV line, return a list of strings. for row in csv.reader([line]): return row class Part4(MRJob): def mapper(self, line_no, line): #map the URL which contains each link cell = csv_readline(line) for each in cell: yi...
e4ab97dda998e4829a002f824511b6b47dba4f7b
ShiryaevNikolay/Mathematical_modeling_labs
/lab_5/simple_iteration_method.py
1,275
3.75
4
from lab_5.equations import * import matplotlib.pyplot as plt def iteration_method_with_param(x, eps, number, a, b, c, d): if abs(derivative_phi_with_param(a, b, c, x)) >= 1: return print("Итерационный процесс расходится") root = phi_with_param(a, b, c, d, x) n = 0 while abs(root - x) >= eps: ...
f96730d27d70a5a7f4ff551aa7d17e27f7903ac1
sbeaumont/AoC
/2016/AoC-2016-16.py
875
3.53125
4
#!/usr/bin/env python """Solution for the Advent of Code challenge 2016, day 16.""" __author__ = "Serge Beaumont" __date__ = "December 2016" INPUT = "11110010111001001" FILL_LENGTH = 272 FILL_LENGTH_PART_2 = 35651584 def dragonize(s): reverse = ''.join(['1' if x == '0' else '0' for x in s[::-1]]) return "{0...
88dbe14ab7e482a960710069aac80a036158ce05
sbeaumont/AoC
/2019/scratchpad.py
560
3.578125
4
print("Hello 2019!") num_list = [int(n) for n in str(122345)] num_list2 = [int(n) for n in str(123245)] print(num_list == sorted(num_list)) print(num_list2 == sorted(num_list2)) print(num_list) print(set(num_list)) print(list(str(122345))) print(set(str(122345))) print(set(list(str(122345)))) # def gen(): # for ...
7f20251ab9720d21d84cd42aa01f98a196b2fec5
sbeaumont/AoC
/2021/AoC-2021-X.py
834
3.625
4
#!/usr/bin/env python3 """Solution for Advent of Code challenge 2021 - Day X""" __author__ = "Serge Beaumont" __date__ = "December 2021" def part_1(entries): return 0 def part_2(entries): return 0 def read_puzzle_data(file_number): with open(f"AoC-2021-{file_number}-input.txt") as infile: li...
74a691a4b0718e0d7de6977d9675d50c158a5467
sbeaumont/AoC
/2019/AoC-2019-11.py
2,455
3.625
4
#!/usr/bin/env python3 """Solution for Advent of Code challenge 2019 - Day 11""" __author__ = "Serge Beaumont" __date__ = "December 2019" from intcode_computer import Computer from collections import namedtuple, defaultdict from visualize import Visualizer, Color def load_input(day): with open(f"AoC-2019-input...
64450cd6c899b0d0825cb2373df04eb64b2768b0
sbeaumont/AoC
/2016/AoC-2016-10.py
2,071
3.546875
4
#!/usr/bin/env python """Solution for the Advent of Code challenge 2016, day 10 part 1 and 2.""" __author__ = "Serge Beaumont" __date__ = "December 2016" import re import operator import functools # Load with open("AoC-2016-10-data.txt", 'r') as content_file: lines = [line.strip() for line in content_file] bot...
144c82de5de6afbf341f98632a74a014c66e4eb0
sbeaumont/AoC
/2019/AoC-2019-2.py
1,832
3.671875
4
#!/usr/bin/env python3 """Solution for Advent of Code challenge 2019 - Day 1""" __author__ = "Serge Beaumont" __date__ = "December 2019" from norvigutils import load_input def run_program(data): instruction_pointer = 0 halt_and_catch_fire = False while not halt_and_catch_fire: opcode = data[ins...
d8d08cbba6fd8dd19bef88eab6b842e9f0bc328b
sbeaumont/AoC
/2020/AoC-2020-21.py
2,038
3.640625
4
#!/usr/bin/env python3 """Solution for Advent of Code challenge 2020 - Day 21""" __author__ = "Serge Beaumont" __date__ = "December 2020" from pprint import pprint from itertools import chain def load(filename): result = list() with open(filename) as infile: for line in [l.strip() for l in infile.r...
d1b8b812b81a56a19028ebbe823dd1035d17d157
sbeaumont/AoC
/2019/AoC-2019-1.2.py
468
3.578125
4
#!/usr/bin/env python3 """Solution for Advent of Code challenge 2019 - Day 1""" __author__ = "Serge Beaumont" __date__ = "December 2019" from norvigutils import load_input def calc_fuel(x): return x // 3 - 2 data = [int(x) for x in load_input(1)] total2 = 0 for mass in data: fuel_needed = calc_fuel(mass...
4fbead301176f2a31c58fa1818c0ffdcb3aa6dbb
sbeaumont/AoC
/2018/AoC-2018-14.2.py
1,241
3.5
4
#!/usr/bin/env python3 """Solution for Advent of Code challenge 2018 - Day X part 1""" __author__ = "Serge Beaumont" __date__ = "December 2018" import time from collections import deque FIRST_RECIPES = 37 PUZZLE_INPUT = 505961 def do(search_pattern): start = time.time() search_deque = deque([int(i) for i ...
81778802d619ff31c9d5ac2320615e8f77fd1f9a
sbeaumont/AoC
/2021/AoC-2021-2.py
1,317
3.875
4
#!/usr/bin/env python3 """Solution for Advent of Code challenge 2021 - Day 2""" __author__ = "Serge Beaumont" __date__ = "December 2021" def part_1(entries): position = 0 depth = 0 for e in entries: if e[0] == 'forward': position += e[1] elif e[0] == 'down': depth...
ac3a26558056f3fc9a3935f967d3e2c606441a03
sbeaumont/AoC
/2020/AoC-2020-8.py
1,425
3.6875
4
#!/usr/bin/env python3 """Solution for Advent of Code challenge 2020 - Day 8""" __author__ = "Serge Beaumont" __date__ = "December 2020" from copy import deepcopy with open(f"AoC-2020-8-input.txt") as infile: program_file = [line.strip().split() for line in infile.readlines()] for line in program_file: ...
e096d7914171686f31613d49a1e03e94d9f9b25b
sbeaumont/AoC
/2021/AoC-2021-6.py
1,735
3.578125
4
#!/usr/bin/env python3 """Solution for Advent of Code challenge 2021 - Day 6""" __author__ = "Serge Beaumont" __date__ = "December 2021" from collections import Counter, defaultdict def calculate_generations(entries, nr_of_generations): generation = Counter(entries) for i in range(nr_of_generations): ...
c385391399c2d9f85f4389ae8feb2c4eb24670a2
laerty/hello-world
/helloworld.py
66
3.640625
4
nome = (input("Nome:") print("Hello, "+ nome) print("Até mais!")
7399d7fac8dec77469382455940f2fc8ea47fdb5
GauravKodmalwar/PythonIBM
/Day_1/Session3.py
2,430
4.09375
4
# Arithmetic Operators a = 22 b = 7 print("********** arithmatic **********") print("addition of two vars is ", a + b) print("subtraction of two vars is ", a - b) print("division of two vars is ", a/b) print("multiplication of two vars is ", a*b) print("remainder after division of two vars is ", a%b) print("quotient a...
e4a43efac9ace092cd6deadfa313c37393132b3c
StRobertCHSCS/fabroa-justin-d-sudo
/Working/ClassExamples/1_2_3_Operators.py
84
3.5625
4
name = "Arthur" age = 62 print ("Hi! My name is " + name + "and I am 62 years old")
010deeb0e6d821c9c259d7935139623e29e30910
AndreuxMath/Hackinscience
/exercises/020/solution.py
112
3.6875
4
""" Created on Tue Sep 29 17:45:34 2015 @author: MA """ for i in range(1,101): if(i%2==0): print(i)
d99badd5ed59ff94d72279fc5aecae4099049d21
anta-kader/crypto
/main.py
2,172
3.75
4
import file_handler import threefish choice = 0 slct_made = False while not slct_made : if 1 <= choice <= 6 : slct_made = True else: try: choice = int(input(""" Selectionner votre fonction de chiffrement : ->1<- Chiffrement symétrique ThreeFish (3 ><(((> ) ->2<- Chiffrement de Cra...
a32f44cc255d3400bb77844290926f52a0e8a93a
sainathgunavat1999/CP
/cp2.py
218
3.59375
4
a = input("Enter your String") b = a.split(" ") c = [] count = 0 for i in b: c.append(len(i)) maxlength = max(c) for i in c: if(i == maxlength): count = count + 1 print(maxlength) print(count) # shubham jadhao
eb2ce69a4c329843753a620a8d7933b30598c633
zachmarcus7/Random_Address_Microservice
/person-generator.py
11,170
3.59375
4
# Zach Marcus # CS 361 # Person Generator Project # # ========================================================================================= # This program takes a selected state along with an amount and generates a list of # random addresses from that state, outputting the list into a CSV file and displaying ...
9b03e9f8b1fde07bb1c18074fe9010413294e0e8
sivaprasanna575/tasks
/task2/tasks3.py
166
3.671875
4
u = [1, 2, 3, 3, 5, 5, 9, 2, 2] a = [] for num in u: if len(a) != 0: if a[-1] != num: a.append(num) else: a.append(num) print (a)
4ae9655c164133f1f753ab25239b2c31084a90a4
sivaprasanna575/tasks
/task1/task8.2.py
141
3.78125
4
a=["y","n"] while True: str = raw_input("please enter[y/n]") str1=str.lower() if str1 in a: print "hello" break
716c23042d44912c9bff66d6d5aa5be6217503e5
zibo-yang/graph_mining
/src/advanced_basic_functions.py
4,488
3.78125
4
from dataclasses import dataclass, field from typing import List import time import matplotlib.pyplot as plt #construct dataclass "graph" with vertice and edges matrix class graph: vertice: List[int] matrix : List[str] degreetable: List[List[int]] neighbortable: List[List[int]] def __init__(s...
2a216c4100923f4b0f5a4a4b3dbd98bd1c379f40
wuyanzu45/Python
/Codes/day01.py
149
3.96875
4
# 你是要干什么 print("Hello World!") num = int(input("请输入一个数字:")) if num > 0: print("大于0") else: print("小于0")
296735856569cad32e427b282906d414170f68de
Robloxer321/Programming-11
/area.py
179
3.8125
4
variable1 = int (input("Please give me a number: ")) # x value variable2 = int (input("Please give another number: ")) # y value area = variable1* variable2 print (area)
ca87fd04f72d0bea9d77b6edfdae44b2b01b19a1
DevinHale1/LeetCodePython
/Twosum.py
854
3.578125
4
class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ target = 9 test = 0 nums = [2,7,11,15] count = 0 count1 = 1 solution = [] while test != target: ...
d17fa3b2714814e0f8724e0a9e2f2200263ecd82
Moiz-A-H-07/atm
/atm.py
861
3.703125
4
class atm: def __init__ (self,cardnumber,pin): self.cardnumber=cardnumber self.pin=pin def checkbalance(self): print("your balance is 15,000") def withdrawel(self,amount): newamount=15000-amount print("you have withdrawn amount:- "+str(amount)+"your new balanc...