blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4aa013e39ab3c11d16645c41640d425f05b927b0
LukeCZ98/Domjudge
/N7b.py
188
3.625
4
X=int(input()) N=int(input()) cont=0 somma='' while(cont<N): cont+=1 num=int(input()) if((num%2==0) and num<X): somma+=str(num) if(somma!=""): print(somma,end="")
e7eec6bdb9b386fca1c53e2d3ae0e41d998e784c
LukeCZ98/Domjudge
/N1e.py
544
3.75
4
X=float(input()) #inserisco saldo mese iniziale CanM=float(input()) #inserisco canone mensile inter=float(input()) #inserisco la percentuale d'interesse Y=(X-CanM) #detraggo il canone a partire dal secondo mese Y=round(Y+((inter*Y)/100)) #dal canone residuo,calcolo e aggiungo gli interessi Z=(Y-CanM) ...
4e4b7ad2587d286736f21ac8f843b2b0c094dcee
LukeCZ98/Domjudge
/A44.py
273
3.640625
4
bigl=int(input()) b=str(bigl) primasomma=0 seconsomma=0 for i in range(0,int(len(b)/2)): primasomma+=int(b[i]) for c in range(int(len(b)/2),len(b)): seconsomma+=int(b[c]) if(primasomma==seconsomma): print("FORTUNATO",end="") else: print("SFORTUNATO",end="")
d449513af84bf3abaece82f464d91acac67d34ad
LukeCZ98/Domjudge
/N9.py
117
3.78125
4
N=int(input()) cont=0 while(N!=0): N=int(input()) if((N%2)!=0 and N%3==0): cont+=1 print(cont,end="")
50bca58d9722d6bd498c85a000b41bb91a0c8018
LukeCZ98/Domjudge
/N23.py
254
4
4
strn="" vocale=0 while(strn!='*'): strn=str(input()) if(strn=='a' or strn=='e' or strn=='i' or strn=='o' or strn=='u'): vocale+=1 if(vocale>=1): print("ALMENO 1 VOCALE",end="") elif(vocale==0): print("NESSUNA VOCALE",end="")
31dd1bf8a1d6b5ce22740dbec479c690eca233eb
LukeCZ98/Domjudge
/N4b.py
156
3.59375
4
costomat=int(input()) orelav=int(input()) spesetot=(orelav*40)+costomat if(spesetot<=100): print("100",end="") elif(spesetot>100): print(spesetot,end="")
23a949e61ac93e9a6750dd7edfdb7230659c194e
EthanVV/p4p
/class_03/list_comprehension.py
504
4
4
# numbers = [9, 3, 6, 1] # square_numbers = [number**2 for number in numbers] # print(square_numbers) # numbers = [0, 8, 9, 4, 1, 3] # squared_even_numbers = [number**2 for number in numbers if % 2 == 0] # print(squared_even_numbers) emails = ['alice 12@gmail.com', 'alice123', 'bob@abc.com', 'alice@gmail.com'] valid...
2151c8415472e9ff2adf1289c201153d4f813c1e
stefanchoo/PythonStudy
/Day2/02_file_io.py
719
3.734375
4
#!usr/bin/env python # -*-coding:utf-8-*- ''' 工欲善其事,必先利其器! 运维:IT自动化 ''' # python 的文件处理 ''' r 以只读模式打开文件 w 以只写模式打开文件 || 没有创建,有则覆盖 a 以追加模式打开文件 || 在最后追加 一般是写在缓冲区中,需要调用flush写入 r+b 以读写模式打开 w+b 以写读模式打开 a+b 以追加及读模式打开 ''' # f = file('myfile.txt') # 默认是读模式 f = file('myfile.txt', 'r') for line in f.readlines(): # strip() ...
97da12ed6034975c9c9256dbd01f56caedcc81c6
umeshw77/pyprojects
/keywordargs.py
1,835
4.6875
5
# Positional and keyword (named) arguments in function usage example # positional args def calcSI(p, r, t): si = p * r * t return si si = calcSI(100, 0.05, 1) print("SI for {} yrs is {}".format(1, si)) # keyword/named args def calcCI(p, r, t): return p * (1 + r) ** t # ci = calcCI(p=200, r=0.05, t=2)...
46d612a5ef2df4fe6c3ddf5fa6d533d7b727d61b
pammirato/RPS
/patternPlayer1and1Skeleton.py
1,809
4.15625
4
import random #this player uses history to try to predict the opponents #next move. #Remember the input variable is given to us with our opponents #last move. We will find the last time they made the same throw, #and then throw what will beat whatever they threw next. #Example. Input = "R" - our opponent just thre...
06300df129479f18d1bd2a467a7db670ae2ecc0f
wu-rymd/spring-softdev-workshop
/19_listcomp/listcomp_setops.py
2,078
3.75
4
# team RayJay (Jeffrey Wu, Raymond Wu) # SoftDev2 pd7 # K19 -- Ready, Set, Math! # 2019-04-16 listA = [1, 2, 3] listB = [2, 3, 4] listC = [12,23,34] listD = [34,45,56] listE = [] listF = [1,2,3] # add elements in listA by listcomp # add elements in listB that are not in listA by listcomp # add both lists def union(...
b95cf56897c8aab35f5909becbdc6e682678b7d9
mge15/testing-1-2-3
/app/my_script.py
372
3.84375
4
# testing-123/my_script.py def enlarge(i): return i * 100 # "if this script is run from the command-line, then ..." if __name__ == "__main__": original_number = int(input("Please select a number to be enlarged (e.g. 400): ")) print("You chose:", original_number) bigger_number = enlarge(original_numb...
357ea1c07d99821df0a90be9e7a8d69989c2d6f4
vdhulappanavar/SencondSemEngg
/python/homepractice/flames1.py
653
3.609375
4
"""n1=input("Enetr 1st name:") n2=input("Enter 2nd name:") efflen=len(n2)+len(n1) print(efflen) n3,n4=n1,n2 for i in n3: for j in n4: #print("i=" , i , "j=" , j) if i==j:# and n4.count(j)==1: efflen-=2 break else: print(i,j,end=' ') print() print("Efflen=" , efflen) """ """"c=list(n1+n2) d=set(c)...
3bfb5eadda832df4eea4226166342ff548bfdac6
vdhulappanavar/SencondSemEngg
/python/colLab/tutorial/Q1/point.py
1,889
3.71875
4
import random pointlist=[] def gen_point(ll , ul): return random.randint(ll , ul) def gen_points(): n=int(input("how many number of points do you want to generate? : ")) for i in range(0,n): ll=int(input("Enter Lower Limit for genration of points: ")) ul=int(input("Enter Upper Limit for genration of points: "))...
a938b32f0f5dbc3f5ac88bf13e8c1d7f7ed59f88
vdhulappanavar/SencondSemEngg
/python/colLab/Lab1-3/pattern1.py
159
4.0625
4
n=int(input("Enter the number of rows you want to print:")) i=0 j=n m=n while i<=n: while j>=0: print(' ' , end=' ') j=j-1 m=m-1 j=m print("1") i=i+1
608fa3d8160120d6b29b5b7d62faea9debfc0311
CompTools/Class_Files
/Py4E_files/search7.argparse.py
543
3.65625
4
#!/usr/bin/env python3 # A modified version of script using argparse import argparse parser = argparse.ArgumentParser( description="Count the Subject: lines in a mbox file") parser.add_argument("file", help="File to count Subject: lines") args=parser.parse_args() try: fhand = open(arg...
a8519063b92db3292172795d31ce326bd968ba85
dalalsunil1986/python_the_hard_way_exercises
/ex13.py
321
3.828125
4
from sys import argv script, first, second, third = argv first = raw_input("Add the name of the first variable: ") print "The script is called:", script print "Your second variable is:", second third = raw_input("add the name of your third var here: ") print "You typed: %r" % first print "You also typed: %r" % third...
8c984dec38bbd8089ed39f1d0051680a56e6d752
dalalsunil1986/python_the_hard_way_exercises
/ex36.py
393
3.8125
4
def begin(): print("You look out at a snowy peak.") print("You ponder whether to grab your skiis or your board.") print("Which do you grab?") grab = input("Skiis or Board?") if "Skiis" in grab: skiing() elif "Board" in grab: boarding() def skiing(): print("You are going ...
67125c904e96bd4c78c56ab80a2f3016ddadd7f6
we1l1n/ch2sql
/ch2sql/tools/date_pro.py
8,547
3.65625
4
# -*- coding: utf-8 -*- """ Author: Rob contributor: This is a script file processing string about date. 这个版本目前只支持阿拉伯数字 """ from datetime import date import datetime import calendar # 获取当前季度 # 将字符日期转换为数字日期 def ch2date(str_in): # 记录返回结果是否按月 byMon = False # 记录返回结果是否按年 byY...
bbcc2116d6335618ac8dddcf36504f2b1999517c
chaiyuntian/Python-Renderer
/Matrix.py
850
3.5625
4
#MATRIX.PY - two functions that multiply a vector by a matrix and a matrix by #a matrix import Vector X = 0 Y = 1 Z = 2 W = 3 def VectorMatrixMult(Vec,aMatrix): row = 0 col = 0 total = 0 newList = [] while row < 4: while col < 4: total += Vec[col] * aMatrix[col][row] col = col + 1 new...
20d389c3009cd42149864b75c75a6cd0a0503226
pvoznenko/Puzzles
/dancing_with_the_googlers/dancing_with_the_googlers.py
3,121
3.96875
4
#!/usr/bin/env python """Dancing with the Googlers Puzzle provided by Google Code Jam at: https://code.google.com/codejam/contest/1460488/dashboard#s=p1 Author: Matheus Victor Brum Soares Email: caneca@gmail.com Date: April 14th, 2012 """ from sys import stdin def calculate(S, p, t): """Get the total score of t...
90d275c1220a029602c76e66ac405c6861425978
pvoznenko/Puzzles
/theme_park/theme_park.py
3,650
3.78125
4
#!/usr/bin/env python """Theme Park Puzzle provided by Google Code Jam at: http://code.google.com/codejam/contest/433101/dashboard#s=p2 Author: Matheus Victor Brum Soares Email: caneca@gmail.com Date: April 12th, 2012 """ from sys import stdin def calculate_money(R, k, g): """Check how much money the roller coa...
3dbd2008aef8294795a59c06e76f47472d44ab87
JB-Tellez/data-structures-and-algorithms-python
/data_structures_and_algorithms/data_structures/stacks_and_queues/stacks_and_queues.py
1,158
3.90625
4
class Stack: def __init__(self): self.top = None def push(self, value): self.top = Node(value, self.top) def pop(self): if self.top: popped = self.top self.top = self.top.next return popped.value def is_empty(self): return self.top =...
f8c080b9fa083b9b10f5ef364babafc12a7b8399
tlittle2/Kattis-Solutions-Python
/Arrangement/arrange.py
948
3.78125
4
#!/usr/bin/env python3 def split(a, n): #find the number of teams we should split into that would yield the most evenly distributed teams k, m = divmod(len(a), n) #use range() in such a way in order to figure out which part of the range should go into each room # do this because we can ...
81c8edf35cb4c06d93084e05582ab26f736d8a63
tlittle2/Kattis-Solutions-Python
/zamka/zamka.py
480
3.53125
4
#/usr/bin/env python3 import sys def main(): low= int(sys.stdin.readline()) high= int(sys.stdin.readline()) value= int(sys.stdin.readline()) listOfNums= list() for i in range(low, high+1): ourList= [int(i) for i in str(i)] for j in ourList: if sum(ourList)...
ed28a0161720b138fd41bfba77f25e2f794042ca
tlittle2/Kattis-Solutions-Python
/Okviri/Okviri.py
1,304
4
4
#/usr/bin/env python3 def main(): word= str(input()) #first line print('.', end='') for i in range(0, len(word)): if((i+1) % 3==0): print (".*..", end= '') else: print(".#..", end= '') print() #second line print('.', end='') for ...
a050d0123feb900f900e9f9fef3bb66324eb10d2
tlittle2/Kattis-Solutions-Python
/AboveAverage/AboveAverage.py
696
3.578125
4
#/usr/bin/env python3 import sys numOfCases= int(sys.stdin.readline()) grades= " " average=0 masterGrades=[] masterAverage= [] for i in range(numOfCases): grades= list(map(int, sys.stdin.readline().split())) total= 0 masterGrades.append(grades) for i in range(1, len(grades)): t...
2b6c3b4dcb21d8d81548af7619b4974b46034fe0
tlittle2/Kattis-Solutions-Python
/OwlandFox/main.py
979
3.5
4
#!/usr/bin/env python3 #delete all leading 0s import sys def convertToInt(lst): vals = [str(i) for i in lst] s = "".join(vals) return int(s) def main(): for num in sys.stdin: num = num.strip() if len(num) == 1: continue else: ori...
46b5c100f2a22c69c37016a6da1db4d8888a1169
tlittle2/Kattis-Solutions-Python
/EasiestProblem/easiest.py
806
3.71875
4
#/usr/bin/env python3 #read input 'n' #find the sum of digits of the input #loop going from 2 until we find a number 'o' #if sum of digits n * o == sum of digits of input, print out number def getSum(m): sum = 0 for digit in str(m): sum += int(digit) return sum ...
4c8ee4d2419b8a22cfac9cae7ea9a0a58d4b673f
tlittle2/Kattis-Solutions-Python
/Homework/Homework.py
814
3.640625
4
#/usr/bin/env python3 import sys def splitFurther(indice): #print(indice) dash = 0 for i in range(0, len(indice)): if indice[i] == '-': dash = i #print(dash) firstNumber = int(indice[0:dash]) secondNumber = int(indice[dash+1::]) #print("First Numb...
7e012e013a4a94e61cd11d1b3c4654789e12a246
tlittle2/Kattis-Solutions-Python
/Tree_Insertion/Tree_Insertion.py
1,687
3.515625
4
#/usr/bin/env python3 ''' Created 9/24/2019 @author Ben Mason, Trevor Little, Fin Carter A solution for kattis problem Tree Insertion https://open.kattis.com/problems/insert ''' import sys class TreeNode(object): """a BST node""" def __init__(self, data): self.data = data self.l = None self.r...
1efa94d9ad28c1a4e5893dee5d551beaf4c672db
tlittle2/Kattis-Solutions-Python
/Plania/Plania.py
200
3.5
4
#/usr/bin/env python3 import sys def main(): numOfIterations= int(sys.stdin.readline()) value= 2**numOfIterations+1 print(value ** 2) if __name__ == "__main__": main()
a969cfd8fba1aed393f7b30d7dba6317e28f56b0
tlittle2/Kattis-Solutions-Python
/Bijele/Bijele.py
212
3.640625
4
#/usr/bin/env python3 def main(): import calendar yy = 2017 mm = 11 # display the calendar print(calendar.month(yy, mm)) if __name__ == "__main__": main()
9dde7e116903f779b520a722ac878f042afdea3e
tlittle2/Kattis-Solutions-Python
/BinaryWatch/binarywatch.py
1,076
3.59375
4
#/bin/usr/env python3 binaries = { '0': '....', '1': '...*', '2': '..*.', '3': '..**', '4': '.*..', '5': '.*.*', '6': '.**.', '7': '.***', '8': '*...', '9': '*..*' } def rowstoColumns(l, counter): pass def main(): ip = input() lst = list() #get all of the correct binary...
d9a61525b3ca094f3cd0ec50d664211e4c3a27a9
bilash-biswas/1133
/Python.py
169
3.78125
4
a=int(input()) b=int(input()) if a>b: x=b y=a elif b>a: x=a y=b for i in range(x+1,y): if(i%5==2): print(i) if(i%5==3): print(i)
fce68b94dede78d5c6d25927465ccb34c21480a1
genardginoy/interview_test
/check_divisible.py
2,047
4.3125
4
'''Question 1. Wonderhood kids love to play with really big numbers. One of the teachers asked students to find if a given number(let's say X) is divisible by 3 or 9. Can you help out the kid?''' #Function to find if x is divisible by 3 or 9 def check_divisible(x): if x%3==0: print("{} is divisible by 3".format(...
6d80e0a0c3d32efe5d59fffe3a9cd6a43a8c9011
jbcoe/sudoku_solver
/sudoku/transformer.py
6,031
4.34375
4
import sudoku from sudoku import Sudoku import numpy as np def switch_rows( s: Sudoku, row_block: int, first: int, second: int, inplace: bool = False ) -> Sudoku: """Switch the rows specified within the specified block. Maintains Sudoku invariants. Args: s: Sudoku, the sudoku to transform ...
235d71644fc14093e41e5c2b0ff379ad403318f9
Gyaha/AOC2015
/day11.py
1,564
3.5
4
def letter_to_int(c: chr) -> int: return ord(c) - 97 def int_to_letter(i: int) -> chr: return chr(i + 97) def convert_to_p(s: str) -> list: return [letter_to_int(a) for a in s] def convert_to_s(p: list) -> str: return "".join([int_to_letter(a) for a in p]) BANNED_LETTERS = [letter_to_int(a) for ...
ef1e41fb9a11f17c2e8a11513428d3143aefea27
NiranjanRaaj/Python
/addition of 2 numbers even or odd .py
86
3.6875
4
N,M=input().split() t=int(N) + int(M) if((t%2)==0): print("even") else: print("odd")
c61ab499da3836ff3fde3fe2cf3965d7b3de29ee
rfigueror1/route_optimization_kruskal_maps
/kruskal.py
3,022
3.75
4
#!/usr/bin/python import fileinput import csv from sets import Set def ordered_insert(element, lista): i = 0; # print element while i < len(lista) and lista[i][2] <= element[2]: i += 1 lista.insert(i, element) # lista.append(element) # return lista def add_node(graph, node_f, node_t): # print "-" * 5, "de...
a4c3744ff7ad47aedca50057331500cb9ea30a12
ncpalmie/Fuzz
/manipulators.py
2,098
4.0625
4
from PIL import Image from typing import Tuple import numpy as np import random as rnd def random_from_all(img: np.ndarray, times: int = 1) -> np.ndarray: """ Accepts a numpy array representing an image and a number of times to perform the random operation. This operation replaces each pixel in t...
ef9a839b333b07b718ec7285730f021ccc05b9ef
HarrrrryLi/LeetCode
/762. Prime Number of Set Bits in Binary Representation/Python 3/solution.py
595
3.546875
4
class Solution: def countPrimeSetBits(self, L: int, R: int) -> int: seen = {} result = 0 for num in range(L, R + 1): bits = bin(num).count('1') if bits not in seen: seen[bits] = self.isPrime(bits) result += seen[bits] ...
a40ed4b80dacabd817e8a597bd4dc26ae1d0460e
HarrrrryLi/LeetCode
/855. Exam Room/Python 3/solution.py
1,452
3.5625
4
class ExamRoom: def __init__(self, N: int): self.seated = [] self.total = N def seat(self) -> int: if not self.seated: self.seated.append(0) return 0 size = len(self.seated) if size == 1: if self.seated[0] >= self.total - 1 - self.sea...
3210082f8dfc033f15c969522f5b79db4505ad4b
HarrrrryLi/LeetCode
/1166. Design File System/Python 3/solution.py
941
3.625
4
class FileSystem: def __init__(self): self.fs = {} def create(self, path: str, value: int) -> bool: directories = path.split('/') size = len(directories) current = self.fs print(directories) for idx in range(1, size - 1): directory = directories[idx...
cd99ab09bcd5d2705a4fb17fa8eb64de57a5bccc
HarrrrryLi/LeetCode
/640. Solve the Equation/Python 3/solution.py
1,348
3.6875
4
class Solution: def solveEquation(self, equation: str) -> str: left, right = equation.split('=') leftv, leftc = self.str2equ(left) rightv, rightc = self.str2equ(right) if leftv == rightv: if leftc == rightc: return 'Infinite solutions' else: ...
d4fc2189b7b8f1751374024e90302781b6543aa4
1000monkeys/dobbel
/main.py
2,772
4.375
4
import sys import time import random def handle_dice_input(): """ Ask's for input on how many dice you want. If you input Q it will exit the program if your input is 3/4/5 it will return your input to the caller. if it is not 3/4/5 it displays a message on what you can input and restarts the funct...
621e98f0aba22e4916d6c33bfba9d46cc4daade4
lunerip/Rick-Morty-Bomberman-FINAL-PROJECT
/Tortugas.py
3,251
3.53125
4
# encoding: UTF-8 # Autor: Luis Enrique Neri Pérez # Una carrera de tortugas, ¡prohibido apostar dentro del campus! :) import pygame from random import randint # Dimensiones de la pantalla ANCHO = 800 ALTO = 600 # Colores BLANCO = (255,255,255) # R,G,B en el rango [0,255] VERDE_BANDERA = (0, 122, 0) ROJO = (255, 0, ...
f9a4530a4d739f9d3f4cac2d4c3d1782f8da8bc9
sahil-sahu/cs-proj
/set_B/q2.py
919
3.65625
4
import mysql.connector con = mysql.connector.connect( host="KV-LL-22", user="kv6", password="kv6", database="CBSE") c = con.cursor() c.execute('create table if not exists employee (employee_id int AUTO_INCREMENT PRIMARY KEY,employee_name varchar(30),employee_address varchar(255),employee_city varchar(30))') ch...
d290deade9045d9b689f006bf03954d105e6c974
MPuzio15/Python
/syntax/solfege_list_exercise1.py
622
3.734375
4
solfege = ["do", "re", "mi", "fa", "sol", "la", "si", "Do"] print(solfege) for a,b in list(enumerate(solfege)): print(a,b) for i, v in reversed(list(enumerate(solfege))): print(i, v) print(solfege[::1]) C = [solfege[0], solfege[2], solfege[4]] print("C: ", C) G = [solfege[-2], solfege[1], solfege[4]] print("...
589a5905b8fd4a31e043241220066743979bad50
WhoD/p4e
/ex4/ex47.py
378
4.125
4
def computegrade(score): if score > 1 or score < 0: grade = "Bad score" elif score > 0.9: grade = "A" elif score > 0.8: grade = "B" elif score > 0.7: grade = "C" elif score > 0.6: grade = "D" else: grade = "F" return(grade) try: score = input("Enter score: ") score = float(score) grade = comput...
9e08eb62a0cef374294b1838b8547d00c94ddce4
dariadec/kurs_python
/11/zad1_klasy_rodzicow.py
623
3.828125
4
class Animals: def __init__(self): print('Im an Animal!') class Mammals(Animals): kingdom = 'Mammals' def Milk(self): print('Mammals are vertebrate animals which produce milk for feeding (nursing) their young') class Dog(Mammals): pass # def __init__(self): # print('Dog ...
d4eeb0cbdc3fe4a8dc1f9672c1c23f19ffcdb170
dariadec/kurs_python
/04/funkcje.py
390
3.59375
4
def mood(): print("how are you?") mood() print("________________________________________") def my_mood(answear): print("My mood today:") print(answear) resp = input("how are y?") my_mood(resp) print("_________________________________________") def my_mood(answear): return answear * 2 resp = input("H...
3f98f571efc77b10c443d498c9d65f2148074ce1
dariadec/kurs_python
/02/ins_war_zad5.py
704
3.96875
4
# Stwórz zmienną password. Hasło powinno składać z liter i cyfr, zwierać conajmniej 1 dużą literę i mieć długość conajmniej 8 znaków. Poinformuj użytkownika, jeśli wpisane hasło jest nie poprawne. Wyświetl różne komunikaty w zależności od rodzaju błędu pw = input("gimme password: ") alphanum = pw.isalnum() condition_...
5f8ec825971fd00307e88247d38bbbb1a784510d
dariadec/kurs_python
/03/cw_list.py
236
3.859375
4
sent = input("Sentence:").split() lkupwrd = str(input("What word do you want to look up?")).lower() wordList = [word.lower() for word in sent] if lkupwrd in wordList: print([i for i,j in enumerate(wordList) if j == lkupwrd])
6ea6f1a486c5b156b295e9067e485235c519a785
dariadec/kurs_python
/02/ins_war_zad6.py
306
3.6875
4
# Zapytaj użytkownika o numer od 1 do 100, jeśli użytkownik zgadnie liczbę ukrytą przez programistę wyświetl komunikat “gratulacje!”, w przeciwnym razie wyświetl “pudło!”. nr = int(input("give me 1-100 number: ")) if nr == 8: print("congratulation!") else: print("wrong!")
77e2c9437a38d645163858e9768828d6eeb4d0e9
dariadec/kurs_python
/01/stringi.py
1,001
3.796875
4
nr = "123887" print(nr.isdecimal()) nienr = "asd123" print(nienr.isdecimal()) text = "looLoo" print(text.isalpha() and not text.islower()) txt = "banana" print(txt.count("na")) print("Zadania nieparzyste") print("Zad.1") wyraz = "ciastko" print(wyraz[2:5:]) print(len(wyraz)) # sposób z len() middle = len(wyraz) / 2...
bdb19d7d6fa0eb3b2af8b338bd46a0dd7599bfdc
dariadec/kurs_python
/08/wyjatki_test.py
224
3.578125
4
w = float(input("podaj wage")) h = float(input("podaj wzrost")) bmi = "nie zdefiniowano" try: bmi = w / h ** 2 except ZeroDivisionError as e: print("Wzrost ni emoze byc zerem") bmi = 0 print("twoje bmi:", bmi)
0f1a79fe29736f9ad50263560739142dbc9e4098
dariadec/kurs_python
/04/funkcje_cd_zad3_wg_Rity.py
357
4.0625
4
#maximum_of(a, b, c) def max_of_2(first, second): return first if first > second else second def maximum_of(a, b, c): return max_of_2(max_of_2(a, b), c) def read_value(): return int(input("Put integer value :")) x = read_value() y = read_value() z = read_value() result = maximum_of(x, y, z) print...
e160cc2d3531d4350273a1e4070bf6cb0d2a290e
AnaGuerreroA/pythonPlatzi
/Introducción al Pensamiento Computacional con Python/excepciones.py
537
3.765625
4
def divide_elementos_de_lista(lista, divisor): try: return [i / divisor for i in lista] except ZeroDivisionError as e: # ahora que conocemos el nombre del error podemos usarlo para manejar la excepcion print(e) return lista lista =list(range(10)) divisor = 0 print(divide_elementos_de_l...
1f25f60504e551802ea00142aebfc17cdfc917d4
AnaGuerreroA/pythonPlatzi
/Introducción al Pensamiento Computacional con Python/clonacionListas.py
582
4.125
4
my_list = [1, 2, 3] my_cloned_list = list(my_list) #ambas tienen los mismos valores([1,2,3]) print(my_list) print(my_cloned_list) #pero tienen distinto ID gracias a que añadimos "list()" print(id(my_list)) print(id(my_cloned_list)) my_second_cloned_list = my_list[::] #[::]los puntos dobles(:) en este caso indican "...
72d7de8c9fa9ac92324cfc3b421a48a39d54bafd
AnaGuerreroA/pythonPlatzi
/POO y algoritmos con python/Automovil.py
1,505
3.59375
4
class Automovil: def __init__(self, modelo, marca, color): self.model = modelo self.marca = marca self.color = color self._estado = 'en reposo' self._motor = Motor(cilindros=4) def acelerar(self, velocidad = 0): if velocidad >= 50: ...
14eff65acec3410aa02ffed70c28b48f68a244a5
AnaGuerreroA/pythonPlatzi
/POO y algoritmos con python/busquedaBinaria.py
1,068
3.734375
4
import random #meta: impleentar contador def busqueda_binaria(lista, comienzo, final, objetivo, contador): print(f'Vuelta :{contador} \nBuscando {objetivo} entre elemento {comienzo} y elemento {final - 1}') if comienzo > final: return False medio = (comienzo + final) // 2 contador = conta...
c433cb2011707673d5282e2661190ba5bcafa01f
maartenberg/chatbotworkshop
/bot_behaviour.py
2,186
3.5
4
import random import enum import pybattleships from pybattleships.ship import Ship from pybattleships.board import Board from pybattleships.game import Game import pybattleships.game def initialize(bot): ''' This function will be called before any others, use this to define a starting state or taunt the pl...
d011738b9f2b907335a721323181919c7e3e4d29
fabryandrea/dsi-project
/Holt_class.py
3,476
3.828125
4
from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error from math import sqrt class HoltSmoothing(object): """ Holt Smoothing that smoothes over level by a factor of alpha. Parameters ---------- alpha: float, required, default=0.1 smoothing constan...
1affc303781bae7c0d1b65c29c9b62ec0454d6d8
geeklili/topk-problem
/bubble_sort/bubble_sort.py
457
3.890625
4
def bubble_sort(li): """ 选择排序,选最大值 :param li:数组 """ # 倒序遍历数组的index for ind in range(len(li))[::-1]: # 令本次数组的最大值的index为0 # 去出数组的前ind+1个,即i的取值为0-ind for i in range(ind): # 如果大于,则与相邻的交换 if li[i] > li[i + 1]: li[i], li[i + 1] = li[i + 1], li[i] if __name__ == '__main__': li = [5, 2, 9, 10, 7, 3, 1]...
87fa8519ffe3f4663d9b2b773f05a352adc238de
tescalada/npyscreen-restructure
/npyscreen/utils/__init__.py
7,547
3.671875
4
# encoding: utf-8 import curses import curses.ascii import sys class InputHandler(object): "An object that can handle user input" def handle_input(self, _input): """ Returns True if input has been dealt with, and no further action needs taking. First attempts to look up a m...
8938bbe21c2dd72aa3586da0000689327a196351
Shruthi21/Algorithms-DataStructures
/20_Acronyms_stilltodo.py
180
3.546875
4
def abbreviate(sentence): acronym = '' sen_list = sentence.split() for s in sen_list: acronym = acronym + s[0] return acronym.upper()
ca78c9b24236ed8c619d3f089bcf1920ab752ff0
Shruthi21/Algorithms-DataStructures
/17_Anagrams.py
647
3.78125
4
def detect_anagrams(word, sentence): anagram_list = [] i = 0 word_list = list(word) for every_word in sentence: if every_word == word: break if len(word) == len(every_word): for i in range(0,len(word_list)): if word_list[i] in every_wo...
62c49a618845ff01792e67081e0f36be0a7afa99
Shruthi21/Algorithms-DataStructures
/23_FinalDestination.py
514
3.625
4
def main(): dict_direction = { 'L': -1,'R': 1,'D': -1, 'U':1 } direction = list(raw_input()) start_position = [0,0] for d in direction: if d == 'L' or d == 'R': start_position[0] = start_position[0] + (dict_direction[d]) else: start_position[1] = start_pos...
59c08dfba5361a4c3890df2f524752e70887ad91
Shruthi21/Algorithms-DataStructures
/2_BitWiseOperation.py
325
3.515625
4
binary = [] testcase = int(raw_input()) result = [] while testcase != 0: count = 0 number = int(raw_input()) binary = list(bin(number)) for b in binary: if b == '1': count = count + 1 result.append(count) testcase = testcase - 1 for r in result: prin...
336c61931282d77c18f20a6e36831d26603e1b2a
Shruthi21/Algorithms-DataStructures
/7_RansomNotes.py
492
3.796875
4
def ransom_note(magazine, ransom): for r in ransom: if r not in magazine: return False else: magazine.remove(r) if ransom != []: return True m, n = map(int, raw_input().strip().split(' ')) magazine = ...
67c8602ac52199a1551d22b03bc103f789161f3d
Shruthi21/Algorithms-DataStructures
/4_Sum.py
448
3.609375
4
import sys import os def sum(num): sum_num = 0 for n in num: sum_num = sum_num + n return sum_num f = open(os.environ['OUTPUT_PATH'],'w') _numbers_cnt = 0 _numbers_cnt = int(raw_input()) _numbers_i=0 _numbers= [] while _numbers_i < _numbers_cnt: _numbers_item = int(r...
b31f11bec696acd6f38a99ceec2218a2a1b11eb5
Shruthi21/Algorithms-DataStructures
/splitstring.py
1,865
4.0625
4
def split_string(source,splitlist): result = [] space = ' ' split_lsit = [] print source for seperator in splitlist: for each_string in source.split(seperator): print seperator print each_string if seperator in each_string: ...
ca5660d664700d7af887edd07f77a228ff62fd6c
online-code-bite-md-tanvir-mahtab/python_basic_calculator
/src/main.py
1,420
4.03125
4
from art import logo from replit import clear print(logo) # Addition def add(n1,n2): return n1 + n2 # substraction def sub(n1,n2): return n1 - n2 # Multiplication def mul(n1,n2): return n1*n2 # divition def div(n1,n2): return n1/n2 # Calculator def calculation(): clear() choose = True # creting th...
e73dd0d17c62c8c241bf1756f4499d2a7d85dce5
NikMos933/pracwork4
/prwk4.py
2,661
3.5
4
def check(a): try: int(a) except ValueError: return False return True def pagecheck(s): l = len(s) integ = [] i = 0 r1 = 0 r2 = 0 i1 = 0 while i < len(s): s_int = '' a = s[i] while '0' <= a <= '9': s_int += a i += ...
d9f2261048b6b80a0de78033fc8e1c9533564e0b
danyjoelemc2/CURSOPYTHON
/Modulo2/Ejercicios/PROBLEMA1.py
198
3.9375
4
alt = int(input('Altura específica de la pirámide:')) for piramide in range(1, alt+1): print(' '*(alt-piramide)+'#'*piramide) if alt is str: break
3f6343aceaa2a319ed1788c554e26b1110a2ede7
cjense77/python_oop
/assign04/order.py
936
3.65625
4
""" File: order.py Author: Colin Jensen This file supplies an Order class with various methods and member variables handle a customer's order. """ class Order: def __init__(self): self.id = '' self.products = [] def get_subtotal(self): return sum([product.get_total_price() for product...
6eb611a803317d7f57f075363d21ced49e86a360
cjense77/python_oop
/ta06.py
660
4.03125
4
class Point: def __init__(self): self.x = 0 self.y = 0 def prompt(self): self.x = input("Enter x: ") self.y = input("Enter y: ") def display(self): print("Center:\n({}, {})".format(self.x, self.y)) class Circle: def __init__(self): self.radius = 0 ...
b0cdae45f3b077c0aada2bb39f084dbc1d53aa44
cjense77/python_oop
/asteroids/asteroids.py
7,170
3.875
4
""" File: asteroids.py Original Author: Br. Burton Designed to be completed by others This program implements the asteroids game. """ import arcade from bullet import Bullet from death_blossom import DeathBlossom from ship import Ship from rocks import * from point import Point from velocity import Velocity # These a...
4de3794a02213153fba35fc41b20ed3220f408ca
YuThrones/PrivateCode
/LeetCode/88. Merge Sorted Array.py
729
3.859375
4
# 数组归并,注意下把数组多余的位抹去就行 class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. """ length = len(nums1) index1 = 0 index2 = 0 for _ in range(m): while(ind...
e603a2976bd38318e4a9249533cdb3c4a3b2b1be
YuThrones/PrivateCode
/LeetCode/117. Populating Next Right Pointers in Each Node II.py
1,897
4.125
4
# 使用上道题无额外空间的方式,主要就是注意判断子节点缺失的情况 """ # Definition for a Node. class Node: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val = val self.left = left self.right = right self.next = next """ class Solution: def connect(self, r...
c3a8a787236f4fbdff31b81a5fd0a0cb3dbece0b
YuThrones/PrivateCode
/LeetCode/86. Partition List.py
1,043
3.96875
4
# 这道题思路是很简单的,用两个列表记录小于分隔值的点和大于等于分隔值的点,然后拼接起来就可以了 # 需要注意的是可以先用两个哑节点来记录两个列表的头,最后拼接前再去掉,这样不用处理特殊情况,判断少很多,效率更高 # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def partition(self, head: ListNode, x: int) -> ListNode: ...
e9354e077a244b516665c59cdd84c9e1032eca0d
YuThrones/PrivateCode
/LeetCode/24-Swap Nodes in Pairs.py
763
3.765625
4
# 思路很简单,直接从头遍历一次,然后改变节点的连接就行,加入哑节点简化情况即可 # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def swapPairs(self, head: ListNode) -> ListNode: dumpyNode = ListNode(0) dumpyNode.next = head first...
23a04bce35c7f4b74de03b0d02eeeb56e57b986e
YuThrones/PrivateCode
/LeetCode/81. Search in Rotated Sorted Array II.py
871
3.5
4
# 这道题本质上还是二分搜索,只是因为有旋转的存在,可能要判断下左右两边是否存在旋转,有可能两边都要搜索 class Solution: def search(self, nums: List[int], target: int) -> bool: if (len(nums) == 0): return False if (len(nums) == 1): return nums[0] == target length = len(nums) start = 0 end = length - 1 ...
2352c5f996f83a8157b9f2119b862cf3a135e584
YuThrones/PrivateCode
/LeetCode/55. Jump Game.py
452
3.765625
4
从前往后遍历,遇到第一个还没到达的节点,或者达到终点就返回结果 class Solution: def canJump(self, nums: List[int]) -> bool: max_index = 0 length = len(nums) for index, num in enumerate(nums): if (index > max_index): return False max_index = max(max_index, index + num) if ...
b0ff42aeeef54c05fc9c2984902369acdd0a424f
YuThrones/PrivateCode
/LeetCode/36. Valid Sudoku.py
1,140
3.546875
4
# 就是一个查重问题而已,唯一注意的就是不要想太多,他不要求数独可解。。。。 class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: row_dict = {} col_dict = {} box_dict = {} for index in range(9): row_dict[index] = set() col_dict[index] = set() box_dict[index] = set()...
2309ec1f2ab9e02c889943ec0b851c40481785c0
YuThrones/PrivateCode
/LeetCode/25-Reverse Nodes in k-Group.py
1,182
3.8125
4
# 单次遍历,一边遍历一边改变节点的顺序,注意边界即可 # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def reverseKGroup(self, head: ListNode, k: int) -> ListNode: if (head == None or k <= 1): return head dummy ...
a49382b8f1e7bbae944e2b2d92be66517f936d33
jshota/cs539-individual_assignments
/ex2/ex2-data/make_tri.py
4,580
3.53125
4
from sys import stdin from typing import List, Dict import numpy as np character_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '_', '\n'] def read_line(): list = [] for line in stdin: list.append(line.replace...
621b96ce599286b98df2e19f9c0f952ec065b62b
Helaluzzaman/python_practice1
/All,any.py
310
3.71875
4
x= [23, 34, 33] #n = input("Enter list value") #x.append(n) if all([i%2 == 1 for i in x]): print("True") else: print("False") x = [ i for i in enumerate(x[::-1])] print(x) #n= [ i,v for i,v in x] ddd = dict() for i,v in x: ddd[i] = v n = [ (v,i) for i,v in ddd.items()] print(n)
1a0ee9d780094f6367751937d7446e35b83c6485
izzatamar/Justify-Text-in-Files-with-Python
/JustifyText.py
1,036
3.78125
4
import time actions = input("Enter 'l' to Left Justify || Enter 'r' to Right Justify :") with open('Paragraph.txt','r') as f: #Open text file and assign 'f' as its name text = str(f.read()) #read text file into a variable fileOutput = open('JustifiedParagraph.txt', 'w') if (actions =='l'...
e1bd293dd33abc92681f79179cf82822194d90ba
alex-vegan/100daysofcode-with-python-course
/days/day078/exercises/100/tail.py
283
3.609375
4
def tail(filepath, n): """Similate Unix' tail -n, read in filepath, parse it into a list, strip newlines and return a list of the last n lines""" with open(filepath) as f: file = f.read() tail_result = file.split('\n')[-n:] return tail_result
f64a48577099d52aa3cab8e0503805be4dcf7dd9
alex-vegan/100daysofcode-with-python-course
/days/day101/Bite 111. Use the ipinfo API to lookup IP country/ipinfo.py
544
3.578125
4
import json import requests IPINFO_URL = 'http://ipinfo.io/{ip}/json' def get_ip_country(ip_address): """Receives ip address string, use IPINFO_URL to get geo data, parse the json response returning the country code of the IP""" with requests.Session() as s: resp = s.get(IPINFO_URL...
20bd7dca554f35f614a2b71e8d6c44b5f34f7140
alex-vegan/100daysofcode-with-python-course
/days/day101/Bite 123. Find the user with most friends/friends.py
1,165
3.8125
4
from collections import defaultdict names = 'bob julian tim martin rod sara joyce nick beverly kevin'.split() ids = range(len(names)) users = dict(zip(ids, names)) # 0: bob, 1: julian, etc friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), (4, 5), (5, 6), (5, 7), (5, 9), ...
b182a355acc29f1b14cf37d27d6988c82561dd8d
alex-vegan/100daysofcode-with-python-course
/days/day101/Bite 78. Find programmers with common languages/common.py
765
4.03125
4
programmers = {'bob': ['JS', 'PHP', 'Python', 'Perl', 'Java'], 'paul': ['C++', 'JS', 'Python'], 'sara': ['Perl', 'C', 'Java', 'Python', 'JS'], 'tim': ['Python', 'Haskell', 'C++', 'JS'], 'sue': ['Scala', 'Python'], 'fabio': ['PHP']} def...
7f5233646f5045a076d1169d698c565237db2efa
alex-vegan/100daysofcode-with-python-course
/days/day068/exercises/066/running_mean.py
426
4.15625
4
def running_mean(sequence): """Calculate the running mean of the sequence passed in, returns a sequence of same length with the averages. You can assume all items in sequence are numeric.""" averages = [] for num in range(1,len(sequence)+1): sum = 0 for item in sequence[...
dfef1033df4c24b10566c7e5ec119248f7f49d3c
alex-vegan/100daysofcode-with-python-course
/days/day101/Bite 47. Write a new password field validator/password.py
977
3.640625
4
import string PUNCTUATION_CHARS = list(string.punctuation) used_passwords = set('PassWord@1 PyBit$s9'.split()) def validate_password(password): validator = {'leng':False,'digit':False,'lowch':False,'upch':False,'punc':False,'unused':False} _lowch = False if len(password) > 5 and len(password) < ...
9b0dd7989e8c39a489c349e5d9af1deb2db64822
alex-vegan/100daysofcode-with-python-course
/days/day057/program.py
1,606
3.71875
4
from api import MovieSearchClient def main(): val = "RUN" while val: print("Would you like to search something?") val = input("movies by [k]eyword, by [d]irector or by imdb [c]ode: ") if val == "k": search_movies() elif val == "d": movies_by_director() ...
95974a88c35e2e6202801312e4a2d1ca10a064cb
jamespeapen/cs344
/lab02/sine.py
3,330
3.546875
4
""" This module implements local search on a simple abs function variant. The function is a linear function with a single, discontinuous max value (see the abs function variant in graphs.py). @author: kvlinden @version 6feb2013 """ from search import Problem, hill_climbing, simulated_annealing, \ exp_schedule, ge...
17e82731c3eae2616b9bf9f7d3b456f4925ac67d
newbie-13/lecture2-flask
/hello.py
265
3.90625
4
def square(x): return x*x class Point: def __init__(self,x,y): self.x=x self.y=y def main(): name=input("what is your name?") print("hello,",name) p=Point(3,5) print(p.x) print(p.y) if __name__=="__main__": main()
51c92333e572e985067219bf6df30e24072b7ee4
808basssrjj/Python-study
/08_面向对象基础/hm_04___del__方法.py
266
3.734375
4
class Cat: def __init__(self, new_name): self.name = new_name print("%s被创建了" % self.name) # 对象销毁时最后调用的方法 def __del__(self): print("%s被销毁了" % self.name) tom = Cat("Tom") print(tom.name)