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
2ec57df4da4ccfb86347ba2ebe42ef8b00cc3ba4
nehasutay/Technical_Test_4
/que_25.py
122
3.75
4
dictionary={} dictionary[1]=1 dictionary['1']=2 dictionary[1]+=1 sum=0 for k in dictionary: sum+=dictionary[k] print(sum)
e0d4d2fa6dd90d401921ddb9bc1cb19586ebf836
phpmypassion/restaurant-simulation
/Waiter.py
3,030
4.28125
4
# Waiter.py # Goal: This class will represent the restaurant's waiter. The waiter maintains a list of the dines it is currently taking care of, and progresses them through the different stages of the restaurant. The waiter in the simulation will repeat multiple cycles of attending to the diners. In each cycle, the wait...
11a93dee71081247fa8b62a48fc4ccbcfbc5563f
RubennCastilloo/master-python
/06-bucles/bucle-for.py
884
4.3125
4
""" # FOR for variable in elemento_iterable (lista, rango, etc) BLOQUE DE INSTRUCCIONES """ numeros = [1, 2, 3, 4, 5] for numero in numeros: print(f"El número iterado es {numero}") contador = 0 resultado = 0 for contador in range(0, 10): print(f"Voy por el {contador}") resultado += contador prin...
f8b0a54d5796ebf3965b8d8572403b550dc5e121
RubennCastilloo/master-python
/04-entrada-salida/entrada-salida.py
142
3.84375
4
nombre = input("¿Cual es tu nombre?: ") edad = input("¿Cual es tu edad?: ") print(f"¡Hola {nombre}, veo que tienes {int(edad) + 2} años!")
fa3e1e85f874da419b4e0759956a2b66fc87cdf3
barvinda/ProgramPy
/Book Store/backend.py
1,473
3.53125
4
import sqlite3 def create_table(): conn=sqlite3.connect("lite1.db") cur=conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS store (id INTEGER PRIMARY KEY, title TEXT, author TEXT, year INTEGER, rating INTEGER)") conn.commit() conn.close() def insert(title,author,year,rating): conn=sqlite3.co...
190a36ccde0b96f5d8c9bbe486124039b8ce2dd9
iago-ribeiro28/calculadora
/variavel.py
863
4
4
def variavel(): front = [] back = [] var: dict = {'sinal': '', 'operator': '', 'x_val': 0.0, 'y_val': 0.0, 'result': 0.0, 'decimal': False, 'apagar': False} return var, front, back # -------Significado de cada variável---------------- # front = é uma lista que arma...
095d7d713c0fa69ca663e4bfac17b09d9d1f97c7
leledada/LearnPython
/test_code/20180327-6-11test.py
401
4.125
4
# 用符号的组合在控制台输出不同大小的矩形图案。 # 要求:写一个输出矩形的函数,该函数拥有三个默认参数,矩形的长5、宽5和组成图形的点的符号“*”,为函数添加不同的参数,输出三个不同类型的矩形; def myRact(l=5, h=5, p='*'): for i in range(l): print(p * h) myRact() myRact(4, 3, '#') myRact(2, 6, "!")
0c82446fcca192ae44e1fcd9c3b0ddba6a9639f7
leledada/LearnPython
/excercise_code/20180331-exercise.py
2,759
3.796875
4
# get_after 函数的输入是一个整数 # 返回值是这个数的后面 相邻的 两个数 # 提示:使用元组作为函数的返回值 def get_after(n): return n + 1, n + 2 # 不打括号也是返回的元组 # 调用 get_after after = get_after(10) print(after) # 输出 after 的第二项值 print(after[1]) # 参考输出: # 12 # 左中右三个方向,用字符串来表示。射门或者扑救的时候,直接输入方向;脑随机挑选方向,如果用数字表示,就用randint来随机。 # 用random的另一个方法:choice。它的作用是从一个l...
824bddfaf9a7a4272732ac3002a6a210bd2a9851
leledada/LearnPython
/test_code/20180326-5-6test.py
1,758
3.984375
4
# 程序随机一个结果,用户通过命令行输入去猜。程序会告诉你猜大了还是小了,直到猜中为止。 # 1.游戏可以反复进行,猜中了之后可以重新开始 # 2.统计用户猜了几轮,平均几次猜中 # 3.限制每轮猜的次数,判定输赢 import random rounds = 0 # 记录游戏轮数 num = 0 # 记录猜的总次数 numPerRound = 0 # 记录每轮猜的次数,猜中后清零 bingo = 0 # 记录猜中的次数 Flag = True while Flag: selected = input("请输入\n【1】开始游戏\n【0】结束游戏") if (str(selected) == '1'): ...
a3380172fe9758ad15db3fea3e1b95fc0f21dc83
nabilarbouz/DataStructuresAndAlgorithms
/fibonacci.py
1,422
3.953125
4
""" Nabil Arbouz Algorithms Spring 2020 Fibonacci Class """ class Fibonacci: def __init__(self): # we will seed the first two values for 0 and 1 self.calculated_n_list = [0, 1] def calculate_fibonacci(self, n): # Check the base cases if n < 0: return...
8974f5dbf0939a69e7cbfe8523fb2878ff6c7ffd
kirpastuhov/PADS
/OpenEDU/Week 2/week2_lab3.py
611
3.640625
4
def read_file(): with open('input.txt', 'r') as file: size = int(file.readline()) return size def main(): size = read_file() numbers = [i for i in range(1, size + 1)] print(numbers) for i in range(size): if (i > 1): numbers[i], numbers[i // 2] = numbers[i // 2], num...
fee3db675f2abb04dfb26fa56dcc4507d5dee671
RuslanGorokhov/lesson1
/lesson_for2.py
123
3.5625
4
# Задание 2 по for user_name = input('Введите Имя: ') for last_name in user_name: print(last_name)
38f7455137b53d8769d6cb5fade5823ba7513739
sanketsudake/data-science
/queen_problem_solution.py
985
3.65625
4
from itertools import permutations, combinations chess_size = 8 n = int(chess_size) x = range(0, n) def is_diagonally_present(point1, point2): x1 = point1[0] y1 = point1[1] x2 = point2[0] y2 = point2[1] gradient = (y2-y1)/(x2-x1) if gradient == -1 or gradient == 1: return(Tr...
3d9db3e0fddefe2a43fe839fa1dddd042d06950c
ajmatkovich/CS3910
/DataClean.py
1,740
3.890625
4
import pandas as pd ''' A function which takes the marriage and divorce data (as input.csv), switches it from wide to long format, cleans and structures it correctly, and exports it to a new file (output.csv). Code will run as the Python file is run. ''' def dataClean(): # read the original CSV file with uncleane...
ce024cefc7550a1f19c444167c490a6b3f868c37
hajdaini/Games
/Python/games/Plus-ou-moins/plusoumoins.py
2,633
3.953125
4
""" @Author : AJDAINI Hatim @Github : https://github.com/Hajdaini """ TRY = 5 DEFAUT_MONEY = 200 class PlusouMoins: def __init__(self, hidden_number): with open('money.txt', 'r') as file: self.money = int(file.readline()) self.current_try = TRY self.hidden_number =...
ec27906c2aebcfae6eeccdc7721c117b45c36a5d
hajdaini/Games
/Python/games/Space-invaders/main.py
4,861
3.65625
4
""" @Author : AJDAINI Hatim @GitHub : https://github.com/Hajdaini """ from tkinter import * from projectile import Projectile from player import Player from enemie import Enemie from wall import Wall import global_var import time, random def draw_enemies(): number_enemies_variable = 36 # PLEASE D...
b8aee50e53250259fce896b6a9a5eb421d755285
jr31112/TIL-1
/python/예시문제1/서울_1반_홍길동/ex02.py
760
3.703125
4
# 파일명 및 함수명을 변경하지 마시오. def calc(equation): """ 아래에 코드를 작성하시오. equation은 덧셈 뺄셈으로 이루어진 수식 문자열입니다. 계산된 결과를 정수로 반환합니다. """ result = 0 tmp = '' for char in equation: if char in '+-' and tmp: result += int(tmp) tmp = char else: tmp += ch...
3382f0a70e58b975f094536d891741fda88b347b
DaGuich/RustPython
/tests/snippets/dismod.py
320
3.671875
4
import dis dis.disassemble(compile("5 + x + 5 or 2", "", "eval")) print("\n") dis.disassemble(compile("def f(x):\n return 1", "", "exec")) print("\n") dis.disassemble(compile("if a:\n 1 or 2\nelif x == 'hello':\n 3\nelse:\n 4", "", "exec")) print("\n") dis.disassemble(compile("f(x=1, y=2)", "", "eval")) print("\n")
939d80615487870522d5ea50763eb1d0fa29706c
ChocoShell/Data-Manipulation-Notebook
/Section 1/lesson9.py
4,702
4.03125
4
# Optimizers # What is an Optimizer? """ Can be used to find minimum values of functions Build Parametrized models based on data Refine allocations to stocks in portfolios """ # How to use an optimizer """ 1) Prove a function to minimize 2) Provide an initial guess 3) Call the optimizer """ # Minimization exampl...
30e0997cb7359cd6f14b98717c68d409c6f68aec
dalexach/holbertonschool-machine_learning
/supervised_learning/0x04-error_analysis/1-sensitivity.py
684
4.3125
4
#!/usr/bin/env python3 """ Sensitivity """ import numpy as np def sensitivity(confusion): """ Function that calculates the sensitivity for each class in a confusion matrix Arguments: - confusion: is a confusion numpy.ndarray of shape (classes, classes) where row indices represe...
297b10098f7991d86bdcf33a1d8d50962b6e152c
dalexach/holbertonschool-machine_learning
/supervised_learning/0x0D-RNNs/3-lstm_cell.py
2,868
3.6875
4
#!/usr/bin/env python3 """ Class LSTMCell """ import numpy as np # Function def sigmoid(x): """ Sigmoid function """ sigmoid = 1 / (1 + np.exp(-x)) return sigmoid class LSTMCell(): """ Class LSTMCell that represents an LSTM unit """ def __init__(self, i, h, o): """ ...
2db751b4a33c9029021707ca8064a233e5f7a925
dalexach/holbertonschool-machine_learning
/pipeline/0x01-apis/4-rocket_frequency.py
793
3.65625
4
#!/usr/bin/env python3 """ How many by rocket? Displays the number of launches per rocket """ import requests if __name__ == '__main__': url = "https://api.spacexdata.com/v4/launches/" rockets = {} res = requests.get(url) launches = res.json() for idx, launch in enumerate(launches): rId =...
4be20b30150f86b6dd66394072ec04c1da324e78
dalexach/holbertonschool-machine_learning
/supervised_learning/0x06-keras/1-input.py
1,435
3.84375
4
#!/usr/bin/env python3 """ Buiding a model with Keras using Input """ import tensorflow.keras as K def build_model(nx, layers, activations, lambtha, keep_prob): """ Function that builds a neural network with the Keras library Arguments: - nx is the number of input features to the network - lay...
56fab6552141c377f2886b4edc7129d65dc59f07
dalexach/holbertonschool-machine_learning
/supervised_learning/0x00-binary_classification/6-neuron.py
5,542
4.28125
4
#!/usr/bin/env python3 """ Class Neuron """ import numpy as np class Neuron: """ Class Neuron that defines a simple neuron performing binary classification """ def __init__(self, nx): """ Constructor for the class Arguments: - nx (int): is the number of input featur...
e62b085add02d42761f087761eeccfe1c55b53d4
dalexach/holbertonschool-machine_learning
/supervised_learning/0x03-optimization/4-moving_average.py
608
4.1875
4
#!/usr/bin/env python3 """ Moving average """ def moving_average(data, beta): """ Function that calculates the weighted moving average of a data set: Arguments: - data (list): is the list of data to calculate the moving average of - beta (list): is the weight used for the moving average Retu...
af80cf482ee21ca7a7d1b22c49bc3072b02f559d
dalexach/holbertonschool-machine_learning
/supervised_learning/0x07-cnn/4-lenet5.py
2,218
3.546875
4
#!/usr/bin/env python3 """ LeNet-5 (Tensorflow) """ import tensorflow as tf def lenet5(x, y): """ Function that builds a modified version of the LeNet-5 architecture using tensorflow Arguments: - x is a tf.placeholder of shape (m, 28, 28, 1) containing the input images for the network ...
9e637c773c85f2482379224cf50fed4de0fe9027
dalexach/holbertonschool-machine_learning
/supervised_learning/0x03-optimization/12-learning_rate_decay.py
822
3.84375
4
#!/usr/bin/env python3 """ Learning Rate Decay upgraded """ import tensorflow as tf def learning_rate_decay(alpha, decay_rate, global_step, decay_step): """ Function that creates a learning rate decay operation in tensorflow using inverse time decay Arguments: - alpha is the original learning r...
079073d5f37f19741496b6c0f62805806ac5b1d6
dalexach/holbertonschool-machine_learning
/supervised_learning/0x0D-RNNs/7-bi_output.py
3,335
3.765625
4
#!/usr/bin/env python3 """ Class BidirectionalCell """ import numpy as np # Function def softmax(x): """ Function to compute softmax values for each sets of scores in x """ return np.exp(x) / np.sum(np.exp(x), axis=1, keepdims=True) class BidirectionalCell(): """ Class BidirectionalCell tha...
43ac2ae34497f3065bda26d3e7099a913574062f
dalexach/holbertonschool-machine_learning
/unsupervised_learning/0x04-autoencoders/2-convolutional.py
3,210
3.546875
4
#!/usr/bin/env python3 """ Convolutional Autoencoder """ import tensorflow.keras as keras def autoencoder(input_dims, filters, latent_dims): """ Function that creates a convolutional autoencoder Arguments: - input_dims is a tuple of integers containing the dimensions of the model input ...
718ae91f509f4d0a9f8053826f95574278c4c2ec
dalexach/holbertonschool-machine_learning
/math/0x04-convolutions_and_pooling/6-pool.py
2,010
3.796875
4
#!/usr/bin/env python3 """ Pooling """ import numpy as np def pool(images, kernel_shape, stride, mode='max'): """ Funtion that performs pooling on images Arguments: - images is a numpy.ndarray with shape (m, h, w, c) containing multiple images * m is the number of images ...
d85b113c2e268edb16254a6839d728098248caeb
dalexach/holbertonschool-machine_learning
/reinforcement_learning/0x00-q_learning/0-load_env.py
792
3.859375
4
#!/usr/bin/env python3 """ Load the Environment """ import gym def load_frozen_lake(desc=None, map_name=None, is_slippery=False): """ Function that loads the pre-made FrozenLakeEnv evnironment from OpenAI’s gym Arguments: - desc is either None or a list of lists containing a custom descript...
d9d540c497b46f3959778659138d2d1873a13726
dalexach/holbertonschool-machine_learning
/supervised_learning/0x08-deep_cnns/6-transition_layer.py
1,091
3.6875
4
#!/usr/bin/env python3 """ Transition Layer """ import tensorflow.keras as K def transition_layer(X, nb_filters, compression): """ Function that builds a transition layer as described in Densely Connected Convolutional Networks: Arguments: - X is the output from the previous layer - nb_fi...
2a38c4c34a8e2b95a859904318a764222f1a6935
dalexach/holbertonschool-machine_learning
/pipeline/0x00-pandas/9-fill.py
937
3.59375
4
#!/usr/bin/env python3 """ Fill script """ import pandas as pd from_file = __import__('2-from_file').from_file df = from_file('coinbaseUSD_1-min_data_2014-12-01_to_2019-01-09.csv', ',') # YOUR CODE HERE """ Fill in the missing data points in the pd.DataFrame - The column Weighted_Price should be removed - missing val...
b01b43fb042dd2345fd2778fd4c75418b95b7a97
dalexach/holbertonschool-machine_learning
/supervised_learning/0x03-optimization/1-normalize.py
621
4.28125
4
#!/usr/bin/env python3 """ Normalize """ import numpy as np def normalize(X, m, s): """ Function that normalizes (standardizes) a matrix Arguments: - X: is the numpy.ndarray of shape (d, nx) to normalize * d is the number of data points * nx is the number of features - m: is a ...
144884496a168c70d6d3227802b5e5a170986bf1
dalexach/holbertonschool-machine_learning
/supervised_learning/0x02-tensorflow/1-create_layer.py
634
3.5
4
#!/usr/bin/env python3 """ Function create_layer """ import tensorflow as tf def create_layer(prev, n, activation): """ Function create_layer Arguments: - prev: is the tensor output of the previous layer - n: is the number of nodes in the layer to create - activation: is the activation fu...
77dd8313b4a98a1dd199f083dbf233dc21a5964a
dalexach/holbertonschool-machine_learning
/math/0x00-linear_algebra/7-gettin_cozy.py
1,210
4.03125
4
#!/usr/bin/env python3 """ This file contains cat_matrices2D function """ def cat_matrices2D(mat1, mat2, axis=0): """ Function that concatenates two matrices along a specific axis Parameters: - mat1 (list of lists of ints/floats): 2D matrix to concatenate - mat2 (list of lists of ints/floats): 2D...
2e7755488ee4f5f74d8120d2d10ef04b0446c37b
Wet1988/ds-algo
/algorithms/sorting/quick_sort.py
1,132
4.21875
4
import random def quick_sort(s, lower=0, upper=None): """Sorts a list of numbers in-place using quick-sort. Args: s: A list containing numbers. lower: lower bound (inclusive) of s to be sorted. upper: upper bound (inclusive) of s to be sorted. Returns: s """ if upper is...
54b2a4946344d265f4e6e4b8fc447a5c19ed6d73
Wet1988/ds-algo
/algorithms/graphs/dag_shortest.py
590
3.546875
4
from algorithms.graphs.topological_sort import * import math def dag_shortest(g, s): order = topological_sort(g) if order is False: # digraph has a directed cycle return distances = {} for vertex in g.get_vertices(): distances[vertex] = math.inf distances[s] = 0 f...
17216263f4ce0238a010a09068daad42f968cae9
Wet1988/ds-algo
/data_structures/Queue.py
1,550
4.09375
4
class Queue: """ Implementation of a queue using a simulated circular array. Not optimized for production use. """ def __init__(self, initial_capacity=3): self.queue = [None] * initial_capacity self.front = 0 # index to first item self.rear = 0 # index to next available s...
6d5fa9841aaed33cade266f564debefbd97e82a0
JustinCee/tkinter-handout
/handout exercise.py
1,103
4.375
4
# this is to import the tkinter module from tkinter import * # this function is to add the numbers def add_numbers(): r = int(e1.get())+int(e2.get()) label_text.set(r) def clear(): e1.delete(0) e2.delete(0) root = Tk() # the below is the size of the window root.geometry("600x200") root.title("Justin...
aeb6fab5e05245fa0b6868e3fcbbbde6ac6bd6b7
kushal-verma/FSDP_2019
/Day07/json.py
540
3.53125
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 11 16:31:39 2019 @author: kushal import json import requests city=input("Enter the city name") url1 = "http://api.openweathermap.org/data/2.5/weather" url2 = "?q="+city url3 = "&appid=e9185b28e9969fb7a300801eb026de9c" url = url1 + url2 + url3 print (url) response = r...
55289b0a46a87f206c570389b9a5c9a1e81ee2ae
xchrislordx/PythonFundamentos
/Modulo1/scripts/input.py
168
3.515625
4
#CREAR ARCHIVO : CONTROL + N # GUARDAR ARCHIVO : CONTROL + S decimal = float(input("Introduce un número decimal con punto: ")) # imprimiendo valor print(decimal)
490b650ae0f2843b4e7b5f497fd5b4deeda5361a
mwshinn/blog
/res/buffet/buffet_model.py
15,293
3.671875
4
# Model code for "Are buffets efficient?" # Copyright 2019 Max Shinn <max@maxshinnpotential.com> import paranoid as pns import numpy as np import scipy as sp import scipy.stats import random import names import pandas import matplotlib.pyplot as plt import seaborn as sns @pns.returns(pns.Positive) def get_random_dish...
147dea146734b48e6d0b8a56ec7c1f4e0ac8466c
lbeuk/baseconverter
/compact.py
1,258
4.03125
4
allbases = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "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"] base_from = input("BASE TO CONVERT FROM: ") base_to = input("BASE TO CONVERT TO: ") def run(): opts = allbases[0:base_from] ...
a035da5a6f1f37fee4453231c7943fe9fa1610d8
iammerus/simple-link-extractor
/program.py
1,761
3.65625
4
from utils import read_url_as_string, download_file from re import findall as regex_search from os.path import isdir ## Is this ugly? Yes! Should you use it? Depends ## ## I wanted something to do ugly things so this did the trick ## Probably could be better but... Maybe later # Base URL base = "URL" # The regula...
10cb96d0f5b8f598d4974d93085628e244a75fce
antony10291029/lxfpyanswer
/mxdx.py
552
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class student(object): def __init__(self,name,score): self.name = name self.score = score def print_object(self): print(self.name,self.score) def get_grade(self): if self.score >= 90: return "A" if self.scor...
c1a165174ddc6f5dc927a5855a109b647e920cdf
antony10291029/lxfpyanswer
/20oop_program.py
706
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #设计一个计算学生成绩的类,并且用实例表现出来 class Student(object): def __init__(self,name,score): self.name = name self.score = score def print_score(self): print('%s: %s' % (self.name, self.score)) #这里直接定义print方法的意义在于,调用这个类的实例的时候,可以直接输出内容 #否则的话要print一次内容 std1 ...
0e3b1c059cd3886a1ea31397db26f9225ee06223
antony10291029/lxfpyanswer
/31handelerror.py
2,745
4.09375
4
# -*- coding: utf-8 -*- def foo(): r = some_function() if r == (-1): return(-1) return r def bar(): r = foo() if r == (-1): print('Error') else: pass #一旦出错,还要一级一级上报,除此之外,可以使用try..except..finall try: print('try...') r = 10 / 0 print('result',r) except ZeroDivi...
a3a84a5480f8a08d854ef636a7137fc0cecf7631
antony10291029/lxfpyanswer
/13sorted.py
1,045
3.953125
4
# -*- coding: utf-8 -*- #假设我们用一组tuple表示学生名字和成绩: #L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)] #请用sorted()对上述列表分别按名字排序: L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)] def by_name(t): return t[0].lower() L2 = sorted(L,key = by_name)#排序的核心就是key=后面是排序函数,可以用lambda也可以用自定义的def #L2 = sorted(L,ke...
3fe64838c355733aac2e809a9848ae140cb5b56d
itsdeepakverma/python
/Demopandas/Deepak_verma_60.py
2,019
3.640625
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 29 22:02:13 2019 @author: Admin """ """ Import deliveryfleet.csv file Here we need Two driver features: mean distance driven per day (Distance_feature) and the mean percentage of time a driver was >5 mph over the speed limit (speeding_feature). Perform K-means clusteri...
c33e9d143701ae1d0e097180eb00ee2cebe6eee1
itsdeepakverma/python
/test1.py
920
3.609375
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 11 17:50:34 2018 @author: Admin """ def main(): #name = input("enter your name") #print(type(name)) #print(name) a="""hi this is deepak verma form Ju """ print(a) main() "hello"+str(5) "Deepak"*5 print("Deepak's") print("\"Deepak\...
be387cbdac9530fd016138c72fb307fae55ccfc5
itsdeepakverma/python
/Day2.py
1,441
3.84375
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 13 17:03:44 2018 @author: Admin """ if (5>6): print("yes") #eilf(): #eilf(): else: print("NO") # and or ! used for logical operator x=None bool(x) n=0 while (n<10): print(n) n=n+1 #List empty_list=[1,2,3,4,5,2.3,"hi"] #em...
a94d631db0b056538f0a48dd7f0ca2402543a241
brenir/bi_ilp
/scripts/select_top.py
764
3.71875
4
import random import sys def read_sentences(sentences, filename): with open(filename) as file: sentence = '' for line in file: if line.strip() == '': sentences.append(sentence) sentence = '' else: sentence += line file.clos...
712592692b65d192585602830b78b6fd29ddacae
Rkluk/uri
/2633 Churras no Yuri.py
583
3.5625
4
while True: try: n = int(input()) dic = {} lista = [] for c in range(n): carne, num = input().split() num = int(num) if num not in dic: dic[num] = carne lista.append(num) else: ...
c04d4c1ed856d0c13d98ffd12a0deacca79a4741
Rkluk/uri
/1012 Area.py
287
3.71875
4
abc = input().split() A = float(abc[0]) B = float(abc[1]) C = float(abc[2]) a = (A * C) / 2 b = 3.14159 * C ** 2 c = (C * (A + B)) / 2 d = B ** 2 e = A * B print('TRIANGULO: {:.3f}\nCIRCULO: {:.3f}\nTRAPEZIO: {:.3f}\nQUADRADO: {:.3f}\nRETANGULO: {:.3f}'.format(a, b, c, d, e))
23eecda39773cd4064f13dc5d0f24d7eedabcd25
Rkluk/uri
/1101 Sequence of Numbers and Sum.py
445
3.515625
4
som = 0 lista = [] while True: vv = input().split() v1 = int(vv[0]) v2 = int(vv[1]) if v1 <= 0 or v2 <= 0: break if v2 > v1: v1 = int(vv[1]) v2 = int(vv[0]) for c in range(v2, v1 + 1): lista.append(c) som += c lista.append('Sum={}'.format...
e836d8b97ce36142280e5014ffed2742b487a5f3
Rkluk/uri
/1168 LED.py
305
3.59375
4
dic = {'1' : 2, '2' : 5, '3' : 5, '4' : 4, '5' : 5, '6' : 6, '7' : 3, '8' : 7, '9' : 6, '0' : 6} user = int(input()) results = [] for c in range(user): num = list(input()) soma = 0 for c in num: soma += dic[c] results.append(soma) for c in results: print(c, 'leds')
0310390efcac95f5a64738d26def97ab7aa98779
Rkluk/uri
/1051 Taxes.py
459
3.9375
4
salary = float(input()) salary = round(salary, 2) if salary <= 2000: taxe = 'Isento' print(taxe) elif 2000 < salary <= 3000: taxe = ((salary - 2000) * 0.08) print('R$ {:.2f}'.format(taxe)) elif 3000 < salary <= 4500: taxe = ((salary - 3000) * 0.18 + (1000 * 0.08)) print('R$ {:.2f}'.for...
5b8a2d2d4e1e5df83b4e4e362a76e55f48cdc6a2
Rkluk/uri
/1140 Flores Florescem na França.py
261
3.59375
4
while True: sentenc = input().lower() if sentenc == '*': break sp = sentenc.split();k = '';taut = 'Y' for c in sp: if k == '': k = c[0] elif k != c[0]: taut = 'N' break print(taut)
11348f876d927864fad9dc75f42cfb94848586d4
Rkluk/uri
/1052 Month.py
467
3.921875
4
month = int(input()) if month == 1: m = 'January' elif month == 2: m = 'February' elif month == 3: m = 'March' elif month == 4: m = 'April' elif month == 5: m = 'May' elif month == 6: m = 'June' elif month == 7: m = 'July' elif month == 8: m = 'August' elif month == 9: ...
f05d2fae6e617e212a1683a7b82071f6de6449e0
Rkluk/uri
/1249 Rot13.py
557
3.625
4
def converter(a): if 97 <= ord(a) <= 122: if (ord(a) - 13) < 97: b = chr((123 - (97 - (ord(a) - 13)))) else: b = chr(ord(a) - 13) elif 65 <= ord(a) <= 90: if (ord(a) - 13) < 65: b = chr((91 - (65 - (ord(a) - 13)))) else: b...
0705402992da16fae1a30b645829388a0080dee1
Rkluk/uri
/1048 Salary Increase.py
604
3.578125
4
salary = float(input()) salary = round(salary, 2) if 0 <= salary <= 400: newsalary = 0.15 percentual = '15 %' elif 400 < salary <= 800: newsalary = 0.12 percentual = '12 %' elif 800 < salary <= 1200: newsalary = 0.10 percentual = '10 %' elif 1200 < salary <= 2000: newsalary = 0.0...
550029045b16413848c2e622ba6d459253639d65
Rkluk/uri
/1113 Ascending And Descending.py
267
3.65625
4
lista = [] while True: vv = input().split() v1 = int(vv[0]) v2 = int(vv[1]) if v1 == v2: break elif v1 > v2: lista.append('Decrescente') elif v1 < v2: lista.append('Crescente') for b in lista: print(b)
cd1f911059034068fa74c3e4ae9ddaa5011cb43b
Sudin-Shrestha/Library-Management-System
/display.py
2,735
3.78125
4
def heading(text): text = text.upper() print("\n\n\n",'{:^80}'.format(text)) def input_warning(): print("WARNING: INVALID INPUT") def new_here_msg(): print('{:_<80}'.format(""),"\n") print( '{:10}'.format("S.N."), '{:70}'.format("ACTION") ) print( '{:10}'.format...
12bf1a4651d852906b07aeab840eb2cf408e4bde
ghagintonbear/lotto-manager
/manager/tools.py
3,950
3.578125
4
import os from datetime import timedelta, date import pandas as pd def get_last_friday_date(run_date: date) -> (date, str): """ User only runs on fridays. Therefore, given any date, function determines the date which the last friday occurred on. """ weekday_num = run_date.isoweekday() if week...
89cd81d0577b6c8ccd69eaed5198cce91d34bed2
ACMCSUS/DebugJudge
/data/problems/fizzbuzz.dbg.py
392
3.515625
4
# @DBG:PRECODE def fizzbuzz(): n = int(input()) mul3 = n % 3 == 0 mul5 = n % 5 == 0 # @DBG:CODE if mul3: return 'Fizz' if mul5: return 'Buzz' if mul3 and mul5: return 'FizzBuzz' # @DBG:ANSWER if mul3 and mul5: return 'FizzBuzz' if mul3: return 'Fiz...
19ab96aa30c11a84f97cf88cb2e268777385219e
svensonidis/project_euler
/largest_product_in_a_series.py
445
3.6875
4
file = open('1000-digit', "r") num = file.read() i = 0 multiple = num[i] + num[i+1] + num[i+2] + num[i+3] product = 0 def calculation(string): counter = 0 prod = 1 while counter < len(string): prod = prod * int(string[counter]) counter = counter + 1 return prod while i < len(num) - 3:...
afc206dd6d2fc17ce08124acc68dfa7d7c1a5231
ehickey08/Intro-Python-II
/src/adv.py
2,404
3.84375
4
from room import Room from player import Player # Declare all the rooms room = { 'outside': Room("Outside Cave Entrance", "North of you, the cave mount beckons"), 'foyer': Room("Foyer", """Dim light filters in from the south. Dusty passages run north and east."""), 'overlook': Room("...
91811c9de27db9068089ec687530dfc576cc0fea
yaosong-zhan/MyLeetcode
/108.py
895
3.515625
4
# 题目:将升序数组,转换为高度平衡二叉搜索树 # 给定有序数组: [-10,-3,0,5,9], # 一个可能的答案是:[0,-3,9,-10,null,5],它可以表示下面这个高度平衡二叉搜索树: # 0 # / \ # -3 9 # / / # -10 5 # 思路:高度平衡二叉树,那么根节点最直接的想法就是中位数,然后用递归可以得到左右两个分支的subtree class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.l...
462f6efc9c3017d82cbf9d178f5bad3613e51921
gui-csilva/python
/Python/Empresa/pessoa.py
2,080
3.921875
4
class Pessoa: #construtor que cria o objeto da classe pessoa. Toda vez que alguém chamar "Pessoa("Junior", "M", 13)" essa função é executada. def __init__(self, nome = None, sexo = None, idade = None, cep = None, cpf = None, rg = None, telefone = None, salario = None, cargo = None): self.nome = nome self.sexo = ...
503906619ac26b5f2aaa6fb95850ff4142f54737
gui-csilva/python
/Python/BonusDef.py
995
3.921875
4
def pedirNumeros(): pergunta = input("Montar a tabuada de: ") iniciando = input("Começar por: ") terminando = input("Terminar em: ") resposta = {} resposta["pergunta"] = int(pergunta) resposta["iniciando"] = int(iniciando) resposta["terminando"] = int(terminando) if resposta["iniciando"] > resposta["ter...
7bbc137569534407c0994ff34dc78bcc63b2b5cc
gui-csilva/python
/Python/Sétimo_programa.py
1,013
4.3125
4
#nessa linha criamos a variavel par par = [] #nessa linha criamos a variavel a a = [1,2,3,4,5,6,7,8,9,10] #nessa linha criamos a variavel impar impar = [] #nessa linha iniciamos um loop for v in a: #nessa linha imprimimos a string par print("par") #nessa linha mostra os números pares print(par) #nessa...
c67b2bf6e21cdd5f983b878a5967611884a1d8bd
gui-csilva/python
/Python/Bonus.py
622
3.9375
4
def Multiplicar(): pergunta = input("Montar a tabuada de: ") iniciando = input("Começar por: ") terminando = input("Terminar em: ") pergunta = int(pergunta) iniciando = int(iniciando) terminando = int(terminando) if iniciando > terminando: print("O número final tem que ser maior que o número inicial. "...
c96975836d9fc7e0fe4c1b99f93ad192622faf8c
gui-csilva/python
/Python/Anotações.py.py
2,379
4.21875
4
#IDE (programa que nos ajuda a escarever códigos) #String ou str (qualquer coisa escrita entre duas aspas) #single quote = apostrofe = 1 aspa; quote = aspas = " " #"conversa";#string #'F'; #caracter #-10 até 10 int = Integer = numero inteiro #10; #-10; #Float= número decimal= 10.9 #3.4; #String"10" #Variav...
3a6c8410438722d1e1f2795053949411559a31f2
gui-csilva/python
/Python/Temp.py
382
3.734375
4
# a = 10 # b = 5 # if a < b: # print("estou no if") # elif a == b: # print("estou no elif") # else: # print("estou no else") # a = "ola" # for value in a: # print(value) # print("feito") # a = [1,2,3,4,5] # for v in a: # print(v) a = [1,2,3,4,5,6,7,8,9,10,11,1...
84e78624aa3c0171d05b430576946cad18360fdf
BC-CSCI-1102-S19-TTh3/example_code
/week10/dictionarydemo.py
507
4.40625
4
# instantiating a dictionary mydictionary = {} # adding key-value pairs to a dictionary mydictionary["dog"] = 2 mydictionary["cat"] = 17 mydictionary["hamster"] = 1 mydictionary["houseplant"] = 5 # getting a value using a key mycatcount = mydictionary["cat"] # looping through keys in a dictionary for k in mydiction...
588fa7ada37380a62e1102acb802b1c49613d14a
joomab/python-basics
/pensamiento_computacional/list_comprehension.py
303
3.734375
4
my_list = list(range(100)) # una lista de 0 a 100 [0,1,...99] print(my_list) #doblamos cada valor de la lista double = [i * 2 for i in my_list] #Esto es una list comprehension print(double) #ahora queremos sacar solo los valores pares de my_list pares = [i for i in my_list if i%2 == 0] print(pares)
5d2f1ad4f143a074909e5fc75141e1e327df0161
chaithragowda86/bootcamp-
/pg8.py
130
3.953125
4
n = int(input()) dic={} for usn,name in dict.dic(): name=input("enter the") usn=input("enter usn") dic[usn]=name print(dic)
afff22a5a0c31ec5279ca41b66f50f8da6986cf5
githubMay/myTest
/truple/five_star.py
250
3.71875
4
import turtle def draw(t,b): #t.pendown() t.begin_fill() t.fillcolor('yellow') for i in range(0,5): t.speed(1) t.forward(b) t.left(72) t.forward(b) t.right(144) t.penup() t.end_fill()
e3d3eea48b736f29f744ed81f08da1759d42b9bc
Fran8/CursoLeonEoiPythonDjango
/python/2_asignacion_variables.py
535
3.921875
4
TEXTO= 'Esto es un texto de una linea' print(TEXTO) PRINT(TYPE(TEXTO)) NUMERO_SIMPLE = 4 print(NUMERO_SIMPLE) print(type(NUMERO_SIMPLE)) NUMERO_COMA_FLOTANTE = 100.4 print(NUMERO_COMA_FLOTANTE) print(type(NUMERO_COMA_FLOTANTE)) MAYOR_DE_EDAD = True print(MAYOR_DE_EDAD) print(type(MAYOR_DE_EDAD)) PARRRAFO = """Esto ...
e4115b28becf092303d8ce51842b1aafbefd8add
Fran8/CursoLeonEoiPythonDjango
/python/12_bucles.py
553
4
4
def print_everything(*args): for n in args: print(n) print_everything('manzana', 'platano','pera') def print__all_with_positions(*args): for count, thing in enumerate(args): print(count,thing) print__all_with_positions('manzana', 'platano','pera') counter = 0 """while True: counter +=1 ...
8580fad8b409b4eaae0fc425df5f13c4aca45f47
chrmux/cse210-tc06
/mastermind/game/director.py
2,194
3.953125
4
from code import Code import random class Director: """Sets up the board with an entry for each player. Args: self (Board): an instance of Board. """ def __init__(self): """The class constructor. Args: self (Director): an instance of Direct...
53d502b56024f9a23377ca0dd7867904678b70eb
emblu3/MockATM
/atm.py
1,939
3.828125
4
from datetime import datetime name = input('What is your name? \n') allowedUsers = ['Seyi', 'Mike', 'Love'] allowedPassword = ['passwordSeyi', 'passwordMike', 'passwordLove'] if (name in allowedUsers): password = input('Your password: \n') userID = allowedUsers.index(name) if(password == allowedPassword...
d331dea8f7f7fe3bbac8088483df3cd86de3a355
singcl/pypy
/python_100_days/1.69_asyncio_coroutine.py
526
3.78125
4
#!usr/bin/python # -*- coding: utf-8 -*- """ Python 并发下载 异步I/O - 非阻塞式I/O操作 Version: 0.1 Author: singcl Date: 2019-5-17 """ import asyncio @asyncio.coroutine def countdown(name, n): while n > 0: print(f'Countdown[{name}]: {n}') yield from asyncio.sleep(1) n -= 1 def main(): loop = a...
2116b04266c114780d3110b0230c72b9a9647331
singcl/pypy
/python_100_days/1.1_hello.py
747
3.6875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- """ 第一个Python程序 问候世界 Version: 0.1 Author: singcl Date: 2018-11-25 请将该文件命名为hello.py并在终端中通过下面的命令运行它 python hello.py """ # print 基本用法 print("hello world!") print("您好", "中国") print('hello', 'world', sep=',', end='!') print('goodbye', 'world', end='!\n') # print 格式化输出用法 # % 来格式...
d61ab15c3cc57065d11c03a08ce9d22ed7976e9d
singcl/pypy
/python_100_days/1.5_9x9.py
233
3.734375
4
#!usr/bin/python # -*- coding: utf-8 -*- """ 九九乘法 Version: 0.1 Author: singcl Date: 2018-11-29 """ for x in range(1, 10): for y in range(1, x + 1): print("%d x %d = %d" % (y, x, y * x), end="\t") print()
8f30b59158e958155b035073b9ac69007550c716
singcl/pypy
/python_100_days/1.7_scoretable.py
515
3.75
4
#!usr/bin/python # -*- coding: utf-8 -*- """ Python 学生考试成绩表 Version: 0.1 Author: singcl Date: 2019-01-02 """ def main(): names = ['zhangsan', 'lisi', 'wanger', 'lijing', 'hekai'] subjs = ['语文', '数学', '英语'] scores = [[0] * 3] * 5 for row, name in enumerate(names): print("请输入%s的成绩" % name) ...
b9dc787f43ec2a898ffe0bb408fc56dfef80c3d7
singcl/pypy
/python_100_days/1.4_while_sum.py
334
3.84375
4
#!usr/bin/python # -*- coding: utf-8 -*- """ 用while循环实现1~100 偶数求和 Version: 0.1 Author: singcl Date: 2018-11-28 """ sum = 0 num = 1 while num <= 100: if num % 2 == 0: sum += num num += 1 print(sum) # 第二种 sum2 = 0 num2 = 2 while num2 <= 100: sum2 += num2 num2 += 2 print(sum2)
3840ce38e5c9cdcd3b51cd5029d861cbc27ae8bb
singcl/pypy
/python_100_days/1.5_palindrome.py
460
3.6875
4
#!usr/bin/python # -*- coding: utf-8 -*- """ 判断输入的正整数是不是回文数 回文数是指将一个正整数从左往右排列和从右往左排列值一样的数 Version: 0.1 Author: Singcl Date: 2018-12-1 """ num = int(input("请输入一个正整数:")) temp = num num2 = 0 while temp > 0: num2 *= 10 num2 += temp % 10 temp //= 10 if num == num2: print("%d是回文数" % num) else: print...
a7ac9d0eb3e5296e8a56c53831af2d49c04e3a40
llamington/COSC121
/superquiz_1.py
2,270
4.03125
4
"""Prints student report""" def invigilated_percent(test_percent, exam_percent): """Calculates invigilated percent""" return (test_percent * 0.15 + exam_percent * 0.60) / 0.75 def course_total(labs, superquiz, test, exam): """Calculates total percentage""" return labs * 0.1 + superquiz * 0.15 + test...
3df5c17e536ddf072745ff1dca3aae6a7f265c51
llamington/COSC121
/lab_8_5.py
1,783
4.34375
4
"""A program to read a CSV file of rainfalls and print the totals for each month. """ from os.path import isfile as is_valid_file def sum_rainfall(month, num_days, columns): """sums rainfall""" total_rainfall = 0 for col in columns[2:2 + num_days]: total_rainfall += float(col) return month...
19cf662f2e0d62d8ce3977ca1a10f22d96746682
laura-wang/my_leetcode
/leetcode/561 Array Partition I.py
434
3.71875
4
class Solution: def arrayPairSum(self, nums): """ :type nums: List[int] :rtype: int """ nums.sort() # sort function is in-place function, no return result=0 for i in range(len(nums)): if i % 2 == 0: result=result+nums[...
04d09b5e77db2cc1fdd962e749aa63c4ff307f70
gitter-badger/FOSSALGO
/doubly_linked_list/doubly_linked_list.py
1,238
3.890625
4
class Node: def __init__(self,data): self.data = data; self.previous = None; self.next = None; class DoublyLinkedList: def __init__(self): self.head = None; self.tail = None; def addNode(self, data): ...
2664a4ee2fd82c285625a1bc8ca4b0a0ef132135
Nicholai55/aulagisele
/exercicio1_vermelho.py
1,516
4.09375
4
def conta(notaUM, notaDOIS, notaTRES): print("A media do aluno foi: ") calculo = (notaUM + notaDOIS + notaTRES) / 3 print(calculo) if calculo >= 6: print("APROVADO!") else: print("REPROVADO!") aluno1 = input("Digite o nome do aluno: ") notaAluno1_1 = int(input("digite uma nota: "))...
166b6ea66e200dc389e2aacbc72c7fad7b1a2300
Nicholai55/aulagisele
/N1_4.py
1,552
3.84375
4
import datetime from random import randint def calculo_tempo(function): def calculo(): print(datetime.datetime.now()) function() print(datetime.datetime.now()) return calculo() lista = [] while len(lista) < 4: numero = randint(1, 100) lista.append(numero) print(lista) @calc...
64c8e584493a5dfb7afb2a773dbd60ee948f0342
Nicholai55/aulagisele
/exercicio3_vermelho.py
590
3.90625
4
class Calculadora(): def inicio(self): print("INICIANDO") def calculo(self, numero1, numero2): calculo1 = numero1 + numero2 calculo2 = numero1 - numero2 calculo3 = numero1 / numero2 calculo4 = numero1 * numero2 print("soma + 1:", calculo1 + 1, "\n""subtração + 1...
83048f90791df8e7a837ebd80bd9a29a2456c3a1
samjbasak/advent-of-code-2019
/day4.py
773
3.890625
4
def consecutive_digits(number): string_num = str(number) for i in range(len(string_num) - 1): if string_num[i] == string_num[i+1]: return True return False def max_two_same_digits(number): string_num = str(number) checker = 0 for i in string_num: if string_num.count(...
eac933271642fbbed9afb838cff77f24f32b4ceb
junho5/python
/baseball/main.py
800
3.90625
4
from random import randint def generate_numbers(): numbers = [] while len(numbers) < 3: num = randint(0, 9) if num not in numbers: numbers.append(num) print("0과 9 사이의 서로 다른 숫자 3개를 랜덤한 순서로 뽑았습니다.\n") return numbers def take_guess(): print("숫자 3개를 하나씩 차례대로 입력하세요.") ...
44d2d623a717b97790a45bb2d04528c1c6ca9504
junho5/python
/list_tip.py
969
3.6875
4
# 리스트 안에 해당 값있는지 확인하는 함수 (in) 반대는 (not in) primes = [2, 3, 5, 7, 11, 13, 17, 19, 23] print(7 in primes) print(12 in primes) primes = [2, 3, 5, 7, 11, 13, 17, 19, 23] print(7 not in primes) print(12 not in primes) # 중첩 리스트 # 세 번의 시험을 보는 수업 grades = [[62, 75, 77], [78, 81, 86], [85, 91, 89]] # 첫 번째 학생의 성적 print(grades...
d84fa8531ce4481a2420b1721089ef4bc83dc6c6
junho5/python
/alias.py
156
3.8125
4
x = 5 y = x y = 3 print(x) print(y) x = [2, 3, 5, 7, 11] y = x y[2] = 999 print(x) print(y) x = [2, 3, 5, 7, 11] y = list(x) y[2] = 999 print(x) print(y)