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
912a424503a40ee722d387c7e36c42d89154e97f
jacobfdunlop/TUDublin-Masters-Qualifier
/3.py
170
3.890625
4
speed = int(60) birthday = bool(False) if birthday == True: speed -= 5 if speed <= 60: print(0) elif speed <= 80: print(1) else: print(2)
efd37abad30060a9c670221bdf1beabb24d2fc08
jacobfdunlop/TUDublin-Masters-Qualifier
/2.py
299
3.90625
4
temp = int(95) summer = bool(True) if (temp >= 60) and (temp <= 90) and (summer == (False)): party = bool(True) print(party) elif (temp >= 60) and (temp <= 100) and (summer == (True)): party = bool(True) print(party) else: party = bool(False) print(party)
fe94c67660a68772c4905710f2cf33d746899a4c
jacobfdunlop/TUDublin-Masters-Qualifier
/7.py
117
4.0625
4
usernum = int(input("Please enter a number: ")) if usernum % 2 == 0: print("Even") else: print("Odd")
c593ca80cbc671e86d12f8d2ffaf0829fdb024ea
jacobfdunlop/TUDublin-Masters-Qualifier
/10.py
470
4.1875
4
usernum1 = int(input("Please enter a number: ")) usernum2 = int(input("Please enter another number: ")) usernum3 = int(input("Please enter another number: ")) if usernum1 > usernum2 and usernum1 > usernum3: print(usernum1, " is the largest number") elif usernum2 > usernum1 and usernum2 > usernum3: pri...
0de459da4ba683c92fb56128f1eef870ab822c15
jacobfdunlop/TUDublin-Masters-Qualifier
/calculator.py
794
4.09375
4
check = bool(False) while check == (False): usernum1 = int(input("Please enter a number: ")) userop = str(input("Please enter an operator + - * or /: ")) usernum2 = int(input("Please enter a number: ")) if userop == "+": answer = int(usernum1 + usernum2) print(usernum1, ...
5c98a2fc08bb815d3278866a9f32469c82a214cf
jacobfdunlop/TUDublin-Masters-Qualifier
/rev_secondword.py
383
3.515625
4
def reverse_second_word(user_str): b = [] a = user_str.split(" ") count = 0 for c in a: if count % 2 != 0: b.append(c[::-1]) count += 1 else: b.append(c) count += 1 print(' '.join(b)) string = "One thousand and e...
952e2170cc98d6d104decc89a0b26267b340624f
udrea/interplanetary-rover
/rover/rover.py
4,697
3.765625
4
from typing import List, Tuple class PlanetGrid: """Class responsible for setting up the planet grid """ def __init__(self, grid_size: Tuple[int, int]) -> None: self.m, self.n = grid_size # number of rows/columns of grid self.grid = self.generate_grid() def generate_grid(self) -> List...
ff7a1bc5e6f0020f7dcaf65aa68eb1fd2ccb676f
kirankumarnallamalli/firstPyProject
/Sampletest.py
561
3.890625
4
#list l1=["apple","Banana",1250,5000.23,"Kumar"] print(l1) l1.append("kiran") print(l1) l1.remove("kiran") print(l1) print(len(l1)) l1.reverse() print(l1) l1.pop(4) print(l1) #Tuples t1=("Kiran",122,178.78,"Kiran",True,1234.56) print(t1) for t2 in t1: print(t2) print(len(t1)) x=list(t1) print(x) x.append("John") ...
1d4b232ce7be7260fd8dc317a2fdb9cf13a35aef
bllxue090/210CT-Coursework
/basic_7.py
238
3.875
4
def check_prime(n, x): if(n<=1): return False if(x>=n): return True if(n%x==0): return False return check_prime(n,x+1) if __name__ == '__main__': n = 47 print check_prime(n, 2)
10f606d6afdf608dd51aa2641237550b75070466
cryptogeekk/cryptography
/ceaser_encryption.py
675
4.03125
4
text=' ABCDEFGHIJKLMNOPQRSTUVWXYZ' key=3 def caesar_encrypt(plain_text): cipher_text='' plain_text=plain_text.upper() for l in plain_text: index=text.find(l) index=(index+key)%len(text) cipher_text=cipher_text+text[index] return cipher_text def caes...
bf3011a8789935e977bf8f8965a53617627ffbe1
abiodun0/amity-room-allocation
/tests/test_main.py
5,083
3.84375
4
import unittest from models.people import * from main import * from models.room import * class TestOfMainSpacesAllocation(unittest.TestCase): """ This are for testing the main.py class function and method """ def setUp(self): """ This is to setup for the rest of the testing the input """ self.andela = Buil...
ebbb82d3b60fafbbd90fd254c7c813a99325b413
KudoS1410/Fouriers
/p3.py
2,021
3.671875
4
"""To make a moving point on a circle image""" import cv2 as cv import numpy as np import math import colorsys as cs import random page = np.zeros([512, 512, 3], np.uint8) blank = page.copy() time = 0 yplot = [] while True: # reset the template each time we write a new screen page = blank.copy...
76425414b1d88727dc471850636025bccdfee408
JackRDmacc/Final_Project
/ecommerce_project/Customer.py
765
3.84375
4
"""Jack Reser This program is an ecommerce store with a customer database and GUI 11/25/20""" from ecommerce_project import Cart class Customer: """class Customer""" next_id = 1000 # Constructor def __init__(self, fname, lname): self.fname = fname self.lname = lname self.cust_...
993a0e034aba9cacecf504b877490a63e876604f
eloybarbosa/Desenvolvimento-Python-para-Redes-e-Sistemas-Operacionais
/AT/06/Servidor.py
1,482
3.84375
4
""" Escreva um programa cliente e servidor sobre TCP em Python em que: O cliente envia para o servidor o nome de um diretório e recebe a lista de arquivos (apenas arquivos) existente nele. O servidor recebe a requisição do cliente, captura o nome dos arquivos no diretório em questão e envia a resposta ao cliente de vo...
7bef7916f76ce70d2ca19e5899b6b4e9f479a878
farheenzaman01/computational-principles-in-python
/Entrance trackerFarheenZaman1.py
2,027
4.09375
4
# I created a progra for a user to sign in using their name a #program records the number of people each user is signing in #Program detects if the building is exceeding capacity #proogram signs out user out of the system #prpgram reports the signed in people (min/max) by one user #declaring the function to ask the us...
06ed38941edbfc0f8d04c22ca71587b59b51df94
farheenzaman01/computational-principles-in-python
/exam2.py
2,699
4.03125
4
#list created to store menue details names = ['Coffee', 'Pizza', 'Burger', 'Fries', 'Donut'] costs = {"a":5.00, "b":6.00, "c":7.00, "d":8.00, "e":0} status = {"default":"Confirmed", "a":"Prepared", "b":"On Delivery", "c":"Delivered", "d":"Cancelled"} #following class and object is supposed to store the costs and name...
d9951e117fe7cd6107403eb6f7631f778561e8aa
farheenzaman01/computational-principles-in-python
/GIFT CARD TACKER.FARHEEN.py
2,141
3.75
4
def addgiftcard(code, giftcard_dic):#storing gift card ammount to the assigned codes to create a new card if code < 10000: print("Invalid code") return elif code >= 50000: c = "$5" elif code in range(40000, 50000): c = "$4" elif code in range(30000, 40000): c = "$...
20cad7654cd9b3f27d9263d17bf10871e75442fc
YuriiSynyavskiy/PythonForBeginnersRofl
/class.py
3,634
3.5625
4
''' #1 def sered(*args): sum = 0 for i in args: sum+=i return sum/len(args) print(sered(10,20,30)) #2 def myAbs(number): return number if number>0 else number*(-1) print(myAbs(-2)) print(myAbs(-4)) print(myAbs(2)) #3 def max(var_1, var_2):''' #docstring ''' return v...
9e8651c2be2e81b9260ff07ec4f1c69d3de4ecfe
Uther88/metabol
/metabol.py
3,003
4
4
#---------------------------------------------------------------------------------# # Программа для расчета скорости метаболизма и количества необходимых калорий # # для поддержания актуальной массы тела в течении суток, в зависимости от уровня # # дневной активности ...
267335a2b28e9bc77b99f0b288f5bbb6f5b4d763
KelseySlavin/CIS104
/Assignments/Lab1/H1P1.py
524
4.15625
4
first_name = input("What is your first name?: ") last_name = input("What is your last name?: ") age = int(input("What is your age?: ")) confidence=int(input("How confident are you in programming between 1-100%? ")) dog_age= age * 7 print("hello, " + first_name+ " " + last_name + " , nice to meet you! You might be " + s...
e77fa8624d18fc83c991cc75ed4fd7a91d55167c
zbnmoura/python-demo
/py_json.py
401
3.890625
4
# JSON is commonly used with data APIS. Here how we can parse JSON into a Python dictionary import json #sample json user_json = '{"name":"bruno", "age":27}' #parse to dict user = json.loads(user_json) print(user, type(user)) print(user['name']) #dict to json(str) car = {'color':'gray', 'make':'toyota', 'model':'y...
ebd053e13774a318fc462af8bebc3f7234a254a7
FloatingFowl/ValueIterationMDP
/value_iteration.py
5,461
3.859375
4
def move_up(A,i,j,walls): '''Utility function if you move up''' final = 0.0 try: if (i+1,j) not in walls: val = A[i+1][j] final += 0.8*val else: raise IndexError except IndexError: final += 0.8*A[i][j] try: if (i,j+1) not in walls: val = A[i][j+1] final += 0.1*A[i][j+1] else: ...
7d60bd6fda2d94da3cebbf66d07b9564591dd089
rajputarun/machine_learning_intern
/keras_bottleneck_multiclass.py
6,828
3.578125
4
''' Using Bottleneck Features for Multi-Class Classification in Keras We use this technique to build powerful (high accuracy without overfitting) Image Classification systems with small amount of training data. The full tutorial to get this code working can be found at the "Codes of Interest" Blog at the following li...
b772d28d9f6ec808e4fc417b1487ced30b19b1ec
NguyenVuNhan/cpp
/solution/Week5/matrix.py
2,927
3.59375
4
class Matrix(): def __init__(self): self.setPoint = [] self.setPointLen = 0 pass def refresh(self): self.setPoint = [] self.setPointLen= 0 def addSetPoint(self, x, y): self.setPoint.append([x,y]) self.setPointLen += 1 def createMatrix(self): ...
6f8020d3159ccb6190cf4f57d7c85cadd34e4dcd
gauravssnl/python3-network-programming
/dns_mx.py
1,975
3.84375
4
#!/usr/bin/env python3 # Looking up a mail domain - the part of an email address after the `@` import dns.resolver def resolve_hostname(hostname, indent=''): """ print an A or AAAA record for hostname; follow CNAME if necessary """ indent = indent + ' ' answer = dns.resolver.query(hostname, 'A') if a...
dcbb89d1234dbba6acc1d3439df4dea019e50235
josepdecid/MAI-IML
/labs/w2/algorithms/pca.py
9,763
3.765625
4
import logging from typing import Union, Tuple import matplotlib.pyplot as plt import numpy as np from utils.plotting import mat_print class PCA: """Principal component analysis (PCA) Algorithm to transform multi-dimensional observations into a set of values of linearly uncorrelated variables called pr...
3b1132a97a381abd155d82d061d7cff1ef065133
madfrogsec/id0-rsa
/caesar.py
632
3.53125
4
#!/usr/bin/env python2.7 # coding: utf-8 import string cipher = "ZNKIGKYGXIOVNKXOYGXKGRREURJIOVNKXCNOINOYXKGRRECKGQOSTUZYAXKNUCURJHKIG\ AYKOSZUURGFEZURUUQGZZNKCOQOVGMKGZZNKSUSKTZHAZOLOMAXKOZYMUZZUHKGZRKGYZROQKLOLZEE\ KGXYURJUXCNGZKBKXBGPJADLIVBAYKZNUYKRGYZZKTINGXGIZKXYGYZNKYURAZOUT" charsetlen = len(string....
87e0c4f5b7335390da9274aedad193cbdb99d5ce
Ghelpagunsan/classes
/lists.py
2,473
4.15625
4
class manipulate: def __init__(self, cars): self.cars = cars def add(self): self.cars.append("Ford") self.cars.sort() return self.cars def remove(self): print("Before removing" + str(self.cars)) self.cars.remove("Honda") return str("After removing" + str(self.cars)) def update(self, car): car.u...
2f12b3b8b93d24222a5856b78c6b3c335139c8ab
iKanae/ML_algorithm
/24.py
1,444
3.765625
4
#-*- coding: utf-8 -*- import random #输入目标数字 def FirstInput(): num=[] while len(num)<4: temp=raw_input("Enter the number:") if temp.isdigit(): if int(temp)>=14 or int(temp)<=0: print("This number is out of range!") else: num.append(int(te...
849f89ad2affd58959e659ecc9e04ade09a538bd
Vitalius1/Python_OOP_Assignments
/math_dojo.py
2,046
3.5625
4
# PART 1 Support only for integerspy class MathDojo(object): def __init__(self): self.result = 0 def add(self, *num_a): self.add_result = 0 for value in num_a: self.add_result += value self.result += self.add_result return self def subtract(self, *num_s):...
8411166d3b4014fc9e41599512aa1b964e53cc0b
Vitalius1/Python_OOP_Assignments
/Hospital/register.py
1,148
3.734375
4
from hospital import Hospital from patient import Patient # creating 6 instances of Patient class p1 = Patient("Vitalie", "No allergies") p2 = Patient("Diana", "No allergies") p3 = Patient("Galina", "Yes") p4 = Patient("Nicolae", "Yes") p5 = Patient("Ion", "No allergies") p6 = Patient("Olivia", "Yes") # Create the hos...
18bad60ca2d5f57a9864b9885cdea01fca19e3a3
DangerousCode/DAM-2-Definitivo
/Python/Funciones/Ejercicio1.py
459
3.9375
4
#-*-coding:utf-8-*- __author__ = 'AlumnoT' from math import sqrt '''Crea una funcin que nos haga la raz cuadrada de un nmero que habremos elevado antes al cuadrado. Lo que si debemos tener claro y ese es el objetivo del ejercicio es que debemos importar directamente la funcin que nos haga la raz cuadrada''' def rai...
265049dd5c7273612076608f805ee6f00e3f2430
DangerousCode/DAM-2-Definitivo
/Python/Funciones de Alto orden/Ejemplo4.py
1,256
4.3125
4
__author__ = 'AlumnoT' '''Funcion dada una lista de numeros y un numero cota superior, queremos devolver aquellos elementos menores a dicha cota''' lista=list(range(-5,5)) '''1)Modificar la sintaxis anterior para que solo nos muestre los numeros negativos''' print filter(lambda x:x<0,lista) '''2)Crear funcion a la que ...
9120d38a16996a33341e5dc748b331694a03ebee
DangerousCode/DAM-2-Definitivo
/Python/Recursividad/Invertir.py
189
3.609375
4
__author__ = 'AlumnoT' def invertir(l,m): if l==[]: return m else: m.append(l[len(l)-1]) return invertir(l[:len(l)-1],m) #main m=[] print invertir([1,2,3],m)
dfdd7c21112d4354fbbcce108399dcaf2374d537
ytreeshan/BeginnerPython
/IMAGE.py
804
3.9375
4
#Name: Treeshan Yeadram #Date: Sept -24 -2018 #This program loads an image, displays it, and then creates, displays, # and saves a new image that has only the red channel displayed. #Import the packages for images and arrays: import matplotlib.pyplot as plt import numpy as np i =input("Enter the name of an input...
6de79716bba3f70746d3b0383cec3cf5d318670e
ytreeshan/BeginnerPython
/Flower.py
260
3.921875
4
#Name: Treeshan Yeadram #Date: August 27, 2018 #This program draws a flower import turtle tia = turtle.Turtle() for i in range(36): tia.forward(100) tia.left(145) tia.forward(10) tia.right(90) tia.forward(10) tia.left(135) tia.forward(100)
6ba11745ac18a6684b494920a5c04cea1bdb6ec7
ProTrickstar/Python-Classes
/main.py
903
3.8125
4
from typing import Collection class Car(object): def __init__(self, name, color, speed, weight, model): self.name = name self.color = color self.speed = speed self.weight = weight self.model = model def start(self): print("Started") def stop(...
171561d4d9db4d191b834ba2a1ab1ddba5bd102a
Souvikns/NPTL
/Assignment/week2.py
2,786
4.0625
4
# to check whether a number can be expressed as the sum of three squares import math def isSquare(n: int): root = math.sqrt(n) if int(root + 0.5) ** 2 == n: return True else: return False def threesquares(n: int): for a in range(n): for b in range(n): if n == pow(...
f49c4a5e794cb8b565e74cc65cb7abcd1319cb81
LenouarMiloud/data-preprocessing-miloudLenouar
/data_preprocessing_assignement.py
1,545
3.921875
4
""" Do not delete this section, Please Commit your changes after implementing the necessary code. - The data file called Social_Network_Ads.csv. - Your Job is to preprocess this data because we gonna use it later one in the course. The Features of this dataset are: - UserID: Which represent id of user in the databas...
b61bd2fb18af6e022e1fcf22645d6d871e22c93b
Erimus-Koo/utility
/coudan_order_for_min_cost.py
2,499
3.671875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'Erimus' # 商品凑单算法 # 计算有限个商品,达到指定价格的所有排列组合。 import logging as log # ═══════════════════════════════════════════════ class Order(): def __init__(self, itemList, targetPrice): self.r = {} self.itemList = itemList # 商品字典{price:nume} ...
9314d79806a7272dfddf71b958b2b1088cf57410
mahdibny/Python_ML
/ch06_Write_Read.py
2,250
3.6875
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 29 02:25:30 2016 Chapter 6: Data Loading, Storage, and File Formats inputs and outputs with panda objects @author: Mahdi """ """ Reading and Writing Data in Text Format pg 155 Parsing Function in pandas read_csv Load delimited data from a file, URL, or file-like ...
1b5ce70200e871bc8c00df5b011d72410c73981a
abhishek98as/30-Day-Python-DSA-Challenge
/oops-Code/oops2.py
317
3.84375
4
class Laptop: def __init__(self,brand,model_name,price): #instance veriable self.brand=brand self.model_name=model_name self.price=price self.laptop_name= brand + ' '+model_name laptop1=Laptop('hp','ld758',60000) print(laptop1.brand) print(laptop1.laptop_name)
17d9da227eaebcddf62a7c7fdc105b4a630c2d37
abhishek98as/30-Day-Python-DSA-Challenge
/Tkinter/files1.py
112
4.0625
4
lst=[] for i in range(3): name=input("enter name:") lst.append(name) for i in lst: print(i)
4f8ec851f83e7149a418a6b51d1f6a5db39bc7dd
abhishek98as/30-Day-Python-DSA-Challenge
/list inbuilt 2.py
194
4.0625
4
a=[] for i in range(10): x=input("enter item to add in the list:") a.append(x) x=input("enter the value whose frequency you want") f=a.count(x) print("frequency of ",x,"is=",f)
d33d729641934f15a3890017dd8b1ce577a49f83
abhishek98as/30-Day-Python-DSA-Challenge
/n start print.py
230
3.8125
4
n=int(input("enter the rows")) i=1 while(n>0): b=1 while(b<i): print(" ",end="") b=b+1 j=1 while(j<=(n*2)-1): print("*",end="") j=j+1 print() n=n-1 i=i+1
56df3b34dc4446dcbdd480e74851d75cfae53cae
abhishek98as/30-Day-Python-DSA-Challenge
/reverse string.py
179
4.375
4
#program to find reverse of a string # a=input("enter the string") # print(a[-1::-1]) a=input("enter the string") for i in rnage((len(a)-1),-1,-1): print(a[i],end='')
3d86264c9fe1870958e35659a0fcc8ebd9d50fb7
abhishek98as/30-Day-Python-DSA-Challenge
/square.py
108
3.765625
4
n=int(input("enter the no.")) i=1 sum=0 while(i<=n): sum=sum+(i*i) i=i+1 print("sum=",sum)
7b58be538dd3c1812c10b375b5ed392e7c46c8fc
abhishek98as/30-Day-Python-DSA-Challenge
/marks of subject.py
456
3.9375
4
a=int(input("enter the 1st marks")) b=int(input("enter the 2nd marks")) c=int(input("enter the 3rd marks")) d=int(input("enter the 4rth marks")) e=int(input("enter the 5th marks")) total= a+b+c+d+e percentage=(total/500)*100 print("total marks",total,"total percentage",percentage) if percentage>=80: pr...
3dfce3bc28489d24728b25c6f1eeb76d76157952
rscsam/Evolve
/spawner.py
9,546
4
4
"""This module defines a series of spawners capable of spawning occupants into their world""" from creature import * from plant import * class Spawner: """A superclass that defines a spawner capable of keeping track of its own occupants and deciding when to spawn a new one in the world it is created in"""...
f14b52073894e095f4540d58eee77ff0aa4930fa
acanizares/advent_of_code
/day01.py
504
3.625
4
from functools import reduce from itertools import cycle file = "input01.txt" with open(file, 'rt') as f: lines = f.readlines() # Part 1 def sum_str(a: str, b: str): return int(a) + int(b) res1 = reduce(sum_str, lines) print(f"The result is: {res1}") # Part 2 lines_int = map(lambda x: int(x), lines) freqs...
f258b3e7709eefaf83d7cb62d1965af0bbfa7803
MaxRozendaal/AoC2020
/day11/puzzle.py
1,870
3.625
4
import copy, string def box(coordinate: tuple, height: int, width: int) -> list: x, y = coordinate return [(x + i, y + j) for i in range(-1,2) for j in range(-1,2) if all([ x + i >= 0, y + j >= 0, x + i < height, y + j < width, (x + i, y + j) != coordinate ])] def i...
3cac0579ed84aaeeb6cd68e8dba63fbfa5caefee
brentirwin/automate-the-boring-stuff
/ch7/regexStrip.py
1,091
4.6875
5
#! python3 # regexStrip.py ''' Write a function that takes a string and does the same thing as the strip() string method. If no other arguments are passed other than the string to strip, then whitespace characters will be removed from the beginning and end of the string. Otherwise, the characters specified in the seco...
c86a09cf6d893b85a67cf094b8fcf3e1b1e22e9b
realdavidalad/python_algorithm_test_cases
/longest_word.py
325
4.375
4
# this code returns longest word in a phrase or sentence def get_longest_word(sentence): longest_word="" for word in str(sentence).split(" "): longest_word=word if len(word) > len(longest_word) else longest_word return longest_word print get_longest_word("This is the begenning of algorithm") ...
359bb72cb48016ffc26ac72b81a607df7bf62bc3
emilydowgialo/hackbright_coding_challenges
/graph-practice.py
1,427
4.09375
4
class PersonNode(object): """ Node in a graph representing a person """ def __init__(self, name, adjacent=None): """ Create a person node with friends adjacent """ adjacent = adjacent or set() self.name = name self.adjacent = set(adjacent) def __repr__(self): """ D...
7aa5652177d2beb2f1e29d63a2d5c44e4cd1980f
paulofranciscon/courses-class-python
/LeituraPython.py
265
3.703125
4
with open("first_file.txt", "r") as arquivo: """ ## Nesta forma lê o aquivo inteiro conteudo = arquivo.read() """ ### Nesta forma lê a primeira linha conteudo = arquivo.readline() for linha in arquivo.readlines(): print(linha)
bed4536a9e45ea5bbe4e437abf0eb8df23c389c9
PaoloLRinaldi/read_write_binary_python_dummies
/readwritebin.py
8,579
3.90625
4
from struct import pack, unpack def dtype_str_to_char(type_name): ''' Convert the name of the type to a character code to be interpreted by the "struct" library. ''' if not (type(type_name) is str): raise TypeError("You must insert a string.") if type_name == 'unsigned char': r...
eac9e099603de5785fc9c0d0e533fb5cfb39aa90
ant0ndk/autocost
/src/main.py
404
3.59375
4
from functions import Dialog Dialog.clear() while True: answer = input('>>> ') if answer == '/help': Dialog.help() elif answer == '/clear': Dialog.clear() elif answer == '/donate': Dialog.donate() elif answer == '/exit': exit() elif answer == '/autocost': ...
f25a009feace4cd5c587bbcda8af72afa281fafc
peterFran/CryptoHashAttacks
/BruteForce.py
2,420
3.515625
4
#!/usr/bin/env python # encoding: utf-8 """ BruteForce.py Created by Peter Meckiffe on 2013-02-15. Copyright (c) 2013 UWE. All rights reserved. """ import sys import os import unittest from hashlib import sha1 class BruteForce: def __init__(self, hashtuple, salt): self.alphabet = "abcdefghijklmnopqrstuvwxyz012345...
69015c173899ac3b237d2e7ce00c3503182717bc
EnGinear87/Python
/Romeos_Dictionary_Email.py
5,477
4.4375
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 4 16:31:09 2021 @author: Melvin Wayne Abraham | Module 4_Python Assignment """ #Question 1: Using the Romeo data file download, write a program to open the file and read it line by line. #For each line, split the line into a list of words using the split function. #When ...
06f270d632cfd5007e9dffa79348605cd4e94bc2
sebbycake/HackerRank
/Data_Structures/2D Array - DS.py
1,008
3.65625
4
# link to problem description # https://www.hackerrank.com/challenges/2d-array/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=arrays def get_max_sum_hourglass(arr): num_rows = len(arr) num_cols = len(arr[0]) hourglass_sum_list = [] # to iterate through eac...
fa0c8bc224b3c091276166cd426bd5153edb0b73
Lynkdev/Python-Projects
/shippingcharges.py
508
4.34375
4
#Jeff Masterson #Chapter 3 #13 shipweight = int(input('Enter the weight of the product ')) if shipweight <= 2: print('Your product is 2 pounds or less. Your cost is $1.50') elif shipweight >= 2.1 and shipweight <= 6: print('Your product is between 2 and 6 pounds. Your cost is $3.00') elif shipweig...
6d678659bf552174f4fbda373d079ae25b9c3a79
Shivani-Y/Assignment_6
/fibonacci.py
1,562
4.09375
4
""" This is a Fibonacci Iterator """ class Fibonacci: """The class accepts a sinlge agrument which should be a integer""" def __init__(self, limit): self.limit = limit self.number_1 = 0 #setting defaults self.number_2 = 1 #setting defaults self.iteration_count = 0 #setting defa...
3647c4684453494b07d2000b1f7d2a9cfd7eaef0
ching-yi-hsu/practice_python
/6_String_Lists/string_lists.py
206
4.3125
4
str_word = str(input("enter a string : ")) str_word_rev = str_word[::-1] if str_word == str_word_rev : print(str_word , " is a palindrome word") else : print(str_word, " isn't a palindrome word")
46131795cbfb5c47dfab2f3f6adeed58106b8f45
GaryChen10128/bblcg
/thread.py
489
3.609375
4
# -*- coding: utf-8 -*- """ Created on Sat May 15 15:11:24 2021 @author: DIAMO """ import threading import time # 子執行緒的工作函數 def job(): for i in range(5): print("Child thread:", i) time.sleep(1) # 建立一個子執行緒 t = threading.Thread(target = job) # 執行該子執行緒 t.start() # 主執行緒繼續執行自己的工作 for i in range(3): print("...
964dbd05aba2232c55aea32b45ae7f254d8575ee
selece/aoc2020-python
/day01.py
641
3.53125
4
from util.filereader import FileReader data = FileReader('inputs/01.txt').parseInt() found = False for index_1, data_1 in enumerate(data): for index_2, data_2 in enumerate(data): if not found and index_1 != index_2 and data_1 + data_2 == 2020: print("part1: ", data_1, data_2, data_1 * data_2) ...
ec31e6c3c5eb2b9d3233e31330e60b3e5c715d60
mandarwarghade/Python3_Practice
/ch10ex11.py
833
3.953125
4
""" Exercise 11 Two words are a “reverse pair” if each is the reverse of the other. Write a program that finds all the reverse pairs in the word list. Solution: http://thinkpython2.com/code/reverse_pair.py. """ import bisect from ch10ex10 import listWords2 if __name__ == '__main__': word_list = listWords2() ...
bf07fa0385b64213f01583fe22a86deb00ea65d2
mandarwarghade/Python3_Practice
/ThinkPython_Ex3.py
1,035
4.1875
4
#Exercise 3 #Note: This exercise should be done using only the statements and other features we have learned so far. #Write a function that draws a grid like the following: #+ - - - - + - - - - + #| | | #| | | #| | | #| | | #+ - - - - + - - - - + #| ...
0c64a84dd309c60d67983f471a8e9e7b222deafe
mandarwarghade/Python3_Practice
/ch10.py
4,755
4.125
4
""" Chapter 10 short exercises, # 1 - #7 Exercises""" from __future__ import print_function, division import time # (for Ex. 9 exercises ) # Exercise 1 # Write a function called nested_sum that takes a list of lists of integers and # adds up the elements from all of the nested lists. For example: # >>> t = [[1, 2], ...
8a71ab1b2ab89fcc2296be219571a80408c0b726
Valoderah/Python-Play
/final-project-keal-master/final-project-keal-master/gui_setup.py
2,141
3.796875
4
from tkinter import * # test of function called by button and passed values def test_func(entry, value): print("Testing grabbing from text box:", entry, value) # test of pop up window def popup(): #Window root = Tk() #Closes popup button = Button(root, text="Close", command=root.destroy) butt...
bec5623135d5387e7bb16e3f63d93522a2a6f69a
sbuffkin/python-toys
/stretched_search.py
1,172
4.15625
4
import sys import re #[^b]*[b][^o]*[o][^a]*[a][^t]*[t](.?) #([^char]*[char])*(.?) <- general regex #structure of regex, each character is [^(char)]*[(char)] #this captures everything that isn't the character until you hit the character then moves to the next state #you can create a "string" of these in regex to see i...
de2c4ac7bfbd1eb42659b496dbb5cef33937bba4
berkbenzer/Python
/user_delete_in_mysqldb.py
2,426
3.5625
4
import mysql.connector import getpass # Get database credentials from user raw_input #password = getpass.getpass("Enter database password: ") # Connect to database def establish_connection(): conn = mysql.connector.connect( database='mysql', user='root', password='password' ) retur...
eb67725e6d7dd3d94fdb42cf8e1bfee5459c38aa
alexandrumeterez/MLlibrary
/steepest_descent.py
604
3.78125
4
import numpy as np def steepest_descent(A, b, x, max_iterations = 49, eps = 0.001): """ Gives the solution to Ax = b via the steepest descent method. """ i = 0 r = b - np.dot(A, x) delta = np.dot(r, r) delta_zero = delta while i < max_iterations and delta > (eps**2) * delta_zer...
b8b78d051aac3047317b0374ce7eb596b0bccd96
singmyr/project-euler
/Python/problem17/main.py
1,867
3.984375
4
""" If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? NOTE: Do not count spaces or hyphens. For example, 342 (thre...
4f557ded70a629951844921d64fbea421a4d729d
Jaaga/project_sphere
/searchv2.py
851
3.625
4
#!/bin/python import pickle def main(): data = pickle.load( open('alldata.pickle', 'rb') ) def search(data, phrase): results = {} for stakeholder in data: for question in data[stakeholder]: for response in data[stakeholder][question]: count = 0 ...
615bd2cd21a24f313ec38f841fe467411cf2d0f0
mthompson-CU/Thompson_CSCI3202_Assignment1
/Node.py
370
3.6875
4
# Author: Matthew Thompson # IdentiKey: math1906 # Date: August 25, 2015 # Programming Assignment 1 # Implements a Node to be used in a Binary Tree # Inspired by https://www.ics.uci.edu/~pattis/ICS-33/lectures/treesi.txt class Node(): def __init__(self, key, left=None, right=None, parent=None): self.key = key sel...
19f4c2bc73df0fe69092b3ec9510c90b1e6a7f53
nickbonne/code_wars_solutions
/num_ppl_on_bus.py
221
3.75
4
# https://www.codewars.com/kata/number-of-people-in-the-bus/train/python def number(bus_stops): riders = 0 for stop in bus_stops: riders = riders + stop[0] - stop[1] return riders
389627cb58aab2830218f281631d9dbd4258e83b
nickbonne/code_wars_solutions
/decode_morse_code.py
538
3.671875
4
# https://www.codewars.com/kata/54b724efac3d5402db00065e decodeMorse(morseCode): solution = '' if len(morseCode.split(' ')) == 1: return ''.join([MORSE_CODE[char] for char in morseCode.split()]) for item in morseCode.split(' '): for char in item.split(): ...
f99b74da1df3867190d6d81f396d3126cd7c2d7a
nickbonne/code_wars_solutions
/get_middle_char.py
225
3.8125
4
# https://www.codewars.com/kata/get-the-middle-character/train/python def get_middle(s): s_len = len(s) mid = int(s_len / 2) if s_len % 2 == 0: return s[mid-1:mid+1] else: return s[mid]
6f46ac550d63f7aeb3658a5e508a9a361f5dc698
Kodoh/Edabit
/boolList.py
450
3.640625
4
def to_boolean_list(word): word = word.lower() valuelist = [] bina = [] YesNo = [] for i in word: valuelist.append(ord(i)-96) for x in valuelist: if x % 2 != 0: bina.append(1) else: bina.append(0) for e in bina: if e == 0: ...
f9d47f85762c6f41b58d0c364c99daed2cbb712b
sagarchand9/Multiuser_Chat
/client/client.py
2,428
3.984375
4
# Python program to implement client side of chat room. import socket import select import sys server1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if len(sys.argv) != 4: print "Correct usage: script, IP address, port number, username:password" exit() userpass = str(sys.argv[3]) #passname = str(sys.ar...
91a5122f9957141be0966121bf67ac11ae2a2f22
Pranitha-J-20/Fibonacci
/Fibonacci series.py
306
4.21875
4
num=int(input("enter the number of terms: ")) n1=0 n2=1 count=0 if num<=0: print("enter a positive integer") elif num==1: print('fibonacci seies: ',n1) else: print("fibonacci series: ") while count<num: print(n1) nth=n1+n2 n1=n2 n2=nth count=count+1
cd3b754dbe9309c766f99833b8f7e41da6ea4702
Martoxdlol/programacion
/algo1/parcial1/ej2.py
1,814
3.6875
4
# Escribir una funcion `dar_vuelta` que reciba una lista de tuplas de numeros y que # devuelva una nueva lista de tuplas, donde la primer tupla tendra el primer elemento # de todas las tuplas originales; la segunda, los segundos, etc. # Ejemplo: # [(1,2,3), (4,5), (6,), (7,8,9,10)] # => # [(1,4,6,7), (2,5,8), (3...
1ade809b4e80d779f5b09cf5b03bf018519f2788
Martoxdlol/programacion
/algo1/tp1/main.py
11,350
3.59375
4
import sudoku import random from mapas import MAPAS TEST_MODE = False #Esta linea sirve para desactivar test (ver final del archivo) <<<<<<<<<<<<<<<<<<<<<<< COLOR_REST = "\x1b[0m" COLOR_INPUT = "\x1b[36m" COLOR_ROJO = "\x1b[31m" COLOR_VERDE = "\x1b[32m" INSTRUCCIONES = ('','valor','borrar','salir') DESACTIVAR_COLORES...
3945a03fd8a7ee3aeddafb8ea7e6297be0ea720e
maigahurairah15/Hurairah-GWC-2018
/data_2.py
508
3.546875
4
import json from pprint import pprint # Open a json file and append entries to the file. f = open("allanswers.json", "r") data = json.load(f) print(type(data)) print(data) f.close() count = 0 oppcount = 0 count_2 = 0 for d in data: if d['color'] == "red": count += 1 elif d['color'] == ...
8a611b9924a63e2184b0476e88e2b3298a5468f8
sayan1995/Trees-2
/problem2.py
1,097
3.625
4
''' Time Complexity: O(n) Space Complexity: O(n) Did this code successfully run on Leetcode : Yes Explanation: Iterate through the tree until you reach the leaf node, while iterating through till the leaf create the number. Once you reach the leaf node add the number to the variable sum. Do this for left and right, ret...
fbf0c2db1a6db137d0248bcde62f2df6f0a88124
WorleyD/Small-Scripts
/pauleigon.py
174
3.546875
4
N, paul, opp = input().split() N, paul, opp = int(N), int(paul), int(opp) turn = (paul + opp) // N if turn % 2 == 0: print("paul") else: print("opponent")
557dd823f5842595cf89e5913043fe2de6b19efb
vishwasbeede/Python3-Programs-examples
/Guess_number.py
1,052
3.9375
4
#Used random module to select a number from your input and this will match to yours input import random list_int = [] char_sep='-' for i in range(0,6): list_int.append(i) print ("{:<30} {} ".format(" ",(char_sep*100))) print ("\n\n{:<30} Enter charecters for input to stop execution\n\n".format(" ")) print (...
15e37aae65af448243383d67e58968662a563b11
kaczy-code/qpbe3e
/exercise_answers/word_count/cleaning.py
592
3.625
4
# cleaning.py from word_count.exceptions import EmptyStringError punct = str.maketrans("", "", "!.,:;-?") def clean_line(line): """changes case and removes punctuation""" # raise exception if line is empty if not line.strip(): raise EmptyStringError() # make all one case cleaned_line...
36c2198e5cd512b4fd029ee0c0ca148ffec6ca74
FDELTA/data-investments-analysis
/src/operaciones.py
1,907
3.609375
4
def price_distribution(df, x): ''' Esta función esta diseñada para recibir uno de los cinco barrios de NY y te devuelve su distribución por precios ''' import seaborn as sns import matplotlib.pyplot as plt print('Please select the neighbourhodod: ') x=input() df1 = df[df.neighbourhood_group == x][["neighbourhoo...
f116c26e1ee37fb0b6418ca6391c606f1dba882f
helen5haha/pylee
/string/StringtoInteger.py
2,132
4.0625
4
''' Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. Requirements for atoi: The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or ...
523de77dc6cfa1910c76b666b90ef7dd7795d609
helen5haha/pylee
/number/PlusOne.py
676
3.84375
4
# Given a non-negative number represented as an array of digits, plus one to the number. # The digits are stored such that the most significant digit is at the head of the list. ''' Use a int array to represent the number, leftest is the highest bit. Space complexity O(1) - Time complexity O(N) Like 99, 999, please rem...
3e687a4ef9403cd1ab70b4d5e7a349f9d8dfb1cb
helen5haha/pylee
/game/EditDistance.py
1,039
3.984375
4
# Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. # Each operation(insert/delete/replace a character is counterd as 1 step) # Classical Dynamical Planning. Most DP problems can be optimized for space complexity. def minDistance(word1, word2): if "" == word1 and...
4e8bd8aaa604889745c461244c773a9ca8fc24b4
helen5haha/pylee
/game/Candy.py
1,238
3.921875
4
''' There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: Each child must have at least one candy. Children with a higher rating get more candies than their neighbors. What is the minimum candies you must give? G...
11e398caeba36ad2cf970e7e9d96067ebc9c203d
helen5haha/pylee
/game/GasStation.py
1,358
3.953125
4
''' There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an empty tank at one of the gas stations. Return the starting gas stat...
d7712ac2adbb87b2fa2e55da4608bbb8a27d095d
helen5haha/pylee
/tree/SumRoottoLeafNumbers.py
2,119
4.09375
4
# Given a binary tree containing digits from 0-9 only, each root-to-lead path could represent a number. # An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers ''' For example, 1 / \ 2 3 The root-to-leaf path 1->2 represents the number 12....
b82e275828c10a818ba3c653e59f76ab12a128f5
helen5haha/pylee
/array/RemoveDuplicatesfromSortedArray.py
721
4
4
''' Given a sorted array, remove the duplicates in place such that each element appear onlyonce and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. For example, Given input array A = [1,1,2], Your function should return length = 2, and A is now [1,2]...
b4c8c18405a914afecee69a0d7f55f57bca6aed5
helen5haha/pylee
/game/CountandSay.py
1,012
4.15625
4
''' The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or 1211. Given an integer n, generate the nth sequence. Note: The sequence of integers will be represented...
84806db8304b6bb9b25f9aced5bcb078492bae2a
helen5haha/pylee
/matrix/SpiralMatrix.py
827
4.21875
4
''' Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You should return [1,2,3,6,9,8,7,4,5]. ''' def spiralOrder(matrix): m = len(matrix) if 0 == m: return [] ...
2f9bec07df890c4216fa7d1c54b4213bd31a22e4
Keerthanavikraman/Luminarpythonworks
/data collections/List/duplicate_elements.py
116
3.671875
4
a=[4,5,7,8,7,9,5,4,90,86,2] b=[] for i in a: if i not in b: b.append(i) else: print( i )
0b7d12e99bbad7b7b9b528ed1983782b2e756027
Keerthanavikraman/Luminarpythonworks
/recursion/pattern_prgming4.py
358
3.890625
4
# 1 # 1 2 # 1 2 3 # 1 2 3 4 # 1 2 3 4 5 # n=int(input("enter the number of rows")) # for i in range(0,n+1): # for j in range(1,i+1): # print(j,end="") # print() # def pattern(n): num=1 for i in range(0,n): num=1 for j in range(0,i+1): print(num,end="") ...