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
4d46d462085d8678419458d860be3de45adefea4
Neves-Roberto/python-course
/poo03.py
1,185
3.90625
4
def main(): carro1 = Carro('brasilia', 1968, 'amarala', 80) carro2 = Carro('fusção', 1981, 'preto', 95) carro1.acelere(40) carro2.acelere(50) carro1.acelere(80) carro1.pare() carro2.acelere(100) class Carro: def __init__(self, modelo, ano, cor, velocidade_max): #metodo init pa...
77f2490fd15252245c59bd7988da65120131b7be
Neves-Roberto/python-course
/maximo_3.py
638
3.71875
4
''' Exercício 2 - Máximo com 3 parâmetros Reescreva a função 'maximo' do outro exercício, que devolve o maior valor dentre dois inteiros recebidos, para que ela passe a receber 3 valores inteiros como parâmetros e devolva o maior dentre eles. Note que maximo(30,14,10) deve devolver 30 maximo(0,-1, 1) deve devolver ...
8c3568887faf1683f43f2b8fce66ab007f98be63
Neves-Roberto/python-course
/pontos.py
858
4.125
4
'''Exercício 1 - Distância entre dois pontos Receba 4 números inteiros na entrada. Os dois primeiros devem corresponder, respectivamente, às coordenadas x e y de um ponto em um plano cartesiano. Os dois últimos devem corresponder, respectivamente, às coordenadas x e y de um outro ponto no mesmo plano. Calcule a distâ...
492aa9db9bdcc69e6fe35bf4038ff09a8e16a305
Neves-Roberto/python-course
/desafio_adjacentes.py
795
3.9375
4
# checa se numero tem adjacente igual ''' Exercício 2 - Desafio do vídeo "Repetição com while" Escreva um programa que receba um número inteiro na entrada e verifique se o número recebido possui ao menos um dígito com um dígito adjacente igual a ele. Caso exista, imprima "sim"; se não existir, imprima "não". Exemplos...
ac49c2153ec7872c9d5673d342656d7fd38be923
Neves-Roberto/python-course
/desafio6.py
215
3.84375
4
#Crie um algoritimo que leia um numero e mostre o seu dobro, triplo e a raiz quadrada n = int(input('Digite um numero: ')) print('O dobro é {}, o seu triplo e {} e sua raiz quadrada é {}'.format(n*2,n*3,n**(1/2)))
865696a6a53b16791f66c23ab994e3d607442945
Neves-Roberto/python-course
/desafio3.py
249
4.09375
4
#!/usr/bin/env python3 num1 = int(input('Digite o primero numero: ')) num2 = int(input('Digite o segundo numero: ')) soma = num1 + num2 # print('A soma dos valores é: {} '.format(soma)) print('A soma entre {} e {} é {}'.format(num1, num2, soma))
b6429bd8de226a490e6358538cd7da92b739ae78
Neves-Roberto/python-course
/desafio17.py
411
4.09375
4
#Faça um programa que leia o comprimento do cateto oposto e do cateto adjacente de um triangulo retangulo #e calcule e mostre o comprimento da hipotenusa. #cateto oposto #cateto adjacente #hipotenusa import math ca = float(input('Digite o cateto adjacente: ')) co = float(input('Digite o cateto oposto: ')) hi = math.sqr...
56a9dd4b7eb22e26630ff8a152f9d1f8f643c081
Neves-Roberto/python-course
/fizzbuzz_func.py
1,149
3.90625
4
''' Exercício 1 - FizzBuzz Escreva a função fizzbuzz que recebe como parâmetro um número inteiro e devolve 'Fizz' se o número for divisível por 3 e não for divisível por 5; 'Buzz' se o número for divisível por 5 e não for divisível por 3; 'FizzBuzz' se o número for divisível por 3 e por 5; Caso a função não seja d...
eb0efdaf41291140d1bce3ee35f4c61fede42137
SSGrady/DSA-Python
/Leetcode/Twosum.py
816
3.546875
4
def twoSum(nums, target): prevMap = {} for i, n in enumerate(nums): if target-n in prevMap: return [prevMap[target-n], i] #returns index of difference, index current prevMap[n] = i return ## O(N) def twoSumII(numbers, target): prevHash = {} for i,n in enumerate(numbers): if target-n in prevHash: retur...
2abec51d8ae7ac9e05ba39e647b2f6e6b1a545f2
SSGrady/DSA-Python
/Linked List/insertionsort_LL.py
1,077
3.859375
4
def insertionSort(arr): for i in range(1, len(arr)): key = arr[i] j = i-1 while j >= 0 and arr[j]> key: arr[j+1] = arr[j] j -= 1 arr[j+1] = key return arr class Node: def __init__(self, data=None, next=None): self.data = data self.next = next class LinkedList: def __init__(self): se...
70a300ab5234fa1c5425bae9f9f3c6c7a547b1b6
uliseshrrs/CYPUlisesHS
/Libro/EJEMPLO1.15.PY
306
3.859375
4
BASE = float (input("INGRESA LA BASE DEL RECATANGULO:")) ALTURA = float (input("INGRESA LA ALTURA DEL RECTANGULO:")) SUP = (BASE * ALTURA) PER = 2 * (BASE + ALTURA) print(f"LA BASE {BASE} Y LA ALTURA {ALTURA} SU DUPERFICIE ES {SUP}") print(f"EL PERIMETRO DE LA BASE: {BASE} Y DE LA ALTURA ES: {ALTURA}")
87562af12f2e43fb149cceb22720a20481a47d98
uliseshrrs/CYPUlisesHS
/Libro/problemas_resueltos/EJEMPLO_1.4.py
298
3.734375
4
print(f"ESTE PROGRAMA SIRVE PARA QUE EL USUARIO PUEDA SABER CUANTOS LITROS DE GASOLINA PAGARA") GAL = float(input("INGRESA EL NUMERO DE GALONES DE GASOLINA:")) TOTAL = GAL * 3.785 *8.20 print(f"EL NUMERO DE GALONES INGRESADOS SON: {GAL}. EL PRECIO QUE DEBERA PAGAR EL CLIENTE ES DE:${TOTAL}$")
a014ba108cde934887519811ffe1bc098dc32403
uliseshrrs/CYPUlisesHS
/if.py
206
3.765625
4
edad = int (input("DAME TU EDAD:")) INE = bool(int(input("TIENES INE ( 0 NO/ 1 SI):"))) if edad >= 18 and INE == True: print("ES MAYOR DE EDAD") print("AUN DENTRO DEL IF") print("FIN DEL PROGRAMA")
c4860aeeece25c70675f4711ef9c528ba7c13248
KazuoKitahara/challenge
/cha134.py
243
3.5625
4
class Horse: def __init__(self,name, rider): self.name=name self.rider=rider class Rider: def __init__(self, name): self.name=name take=Rider("Take Yutaka") Dee=Horse("Deep Impact",take) print(Dee.rider.name)
1d71ab1f3585ef7d344998afffe54b01ab443c59
KazuoKitahara/challenge
/cha45.py
275
4.125
4
def f(x): """ Returns float of input string. :param x: int,float or String number try float but if ValueError, print "Invalid input" """ try: return float(x) except ValueError: print("Invalid input") print(f(10)) print(f("ten"))
ae6ed76fbec24a8da69644e48a975742332278b8
KazuoKitahara/challenge
/cha62.py
165
3.671875
4
what = input("昨日書いたのはなに?:") who = input("誰に送ったの?:") str="私は昨日{}を書いて{}に送った!".format(what, who) print(str)
0b2ced771fdaa25c3fbad08f34805bfef45987bc
KazuoKitahara/challenge
/cha44.py
302
3.59375
4
def halfint(x): """ Returns x/2. :param x: int. :returns int half of x. """ return int(x / 2) def fourt(x): """ Returns x * 4. :param x: int. :returns int product of x and 4. """ return int(x * 4) result=halfint(100) print(result) print(fourt(result))
de72c73e7362a9ea7f48b0941996624424d0a156
singhkunal2050/PythonNotebooks
/day6.py
4,074
3.671875
4
#!/usr/bin/env python # coding: utf-8 # In[4]: # file handling # modes of opening # r => read # w => write # a => append # r+ => read & write # In[31]: f = open('t1.txt' , 'w') # some file object attributes print(f.closed) print(f.name) print(f.mode) for i in range(10): f.write("Line {0:d} \n".format(i)) ...
84af92d1b2dde9f821d0211969e632f7c6574a11
singhkunal2050/PythonNotebooks
/day4.py
2,680
3.984375
4
#!/usr/bin/env python # coding: utf-8 # # Range # # In[7]: range(1,5) # In[11]: for i in range(4): print(i) # In[9]: for i in range(3,24): print(i) # In[10]: for i in range(2,72,12): print(i) # In[14]: for i in range(25,33,7): print(i,end=" ") # In[20]: sum=0 for i in range(10):...
8f1ad18bbdb5cdbf4e2bc8b2aed1af57d9dfb13c
tharunShiv/python-GUI-tkinter-Quick-Start-Basics
/Login-form-example.pyw
1,173
3.765625
4
from tkinter import * import sqlite3 con=sqlite3.connect('lodinpage.db') cur=con.cursor() cur.execute('create table login(uname text not null primary key,pword text not null)') con.commit() top = Tk() def onclick(): uname=E1.get() pword=E2.get() cur.execute('insert into login values (?,?)',(uname,pword))...
032c15c09a67af786923040952a069f9c531babb
sonapatidar/python-project
/final project.py
146
3.96875
4
celsius=int(input("enter temperature in celsius: ")) fahrenheit = (celsius * 9/5) + 32 print("The temperature in fahrenheit is",fahrenheit)
dcdf51f2bf691ec442d23ae952956497d84e70ff
shincling/MyCommon
/test_for_python/findallindex.py
401
3.546875
4
def findallindex(string,seq): start=0 end=len(string) position=[] while True: index=string.find(seq,start,end) #print index if index!=-1: position.append(index) start=index+1 else : break return position if __name__=='__main__': ...
c58f167c9cc3a125143a2b29a7183b39fc8ad20d
janavarro8/Lab-6
/GraphProp.py
1,881
3.75
4
""" Course: CS2302 Data Structures Author: Javier Navarro Assignment: Lab 6 Instructor: Diego Aguirre TA: Manoj Saha Last modified: 12/5/18 Purpose: Holds Vertex and Graph classes (GraphProperties) """ class Vertex: def __init__(self, label): self.label = label class Graph: def __init__...
792ed40a09e70eda232f9234884ab52931c23bf2
AleksDrumov/Lesson2
/Amerika.py
973
4.09375
4
one_presidential_term = 4 George_Washington = 2 Thomas_Jefferson = 2 Herbert_Hoover = 1 Barack_Obama = 2 input_count_presidential_term = int(input('Сколько терминов был на посту президент?(больше 2 нельзя)')) if input_count_presidential_term > 2: print('Президент не може бути на посту президента більше 2 термінів')...
056534e390d038ad362f52451efeb9415e4230d1
CoraZhang/Object-Oriented-Programming
/tester/scripts/lab3-06-get.py
2,490
3.546875
4
#!/usr/bin/python3 # # easydb get command test for assignment 3 # Assume student's db constructor, connect, and close are working. # import asst3 import socket TOTAL_MARK = 3 def main(): # Set up the tester. test = asst3.start_test('easydb get command test', TOTAL_MARK) # Import student's code. from...
3852c77f746e52ae4a2c1899bf9c566cddfb7f76
project-mlx/ADS
/BinaryTree/binary_tree_ops.py
230
3.828125
4
from BinaryTree import Node #create Binary Tree Object binaryTree = Node(13) #Insert single element binaryTree.insert(5) #Insert a list of numbers binaryTree.insertList([1,15,3,16,5,20]) #Print the Tree binaryTree.print_tree()
c0e3ac8d9184bbfdc1b4a53857fedd5c7769bd67
pankaj077/MLatScale
/HW1/Draft1.py
2,782
3.78125
4
#HW00 import os os.chdir('/Users/z013sy0/Data science/Day 1/HW00') #Question 1 fhand =open("test.txt","r+") fhand.close() for word in fhand: print word filename = "test.txt" #All words- count wordcount={} with open(filename) as file: for word in file.read().split(): if word not in wordcount: ...
d14fecadef87c5fe1cbb2c7dc1a321e21fa51f60
ReddivariShalini/fibanocci-mycaption
/extension.py
243
4.15625
4
def fibonacci(n): if n<=1: return n else: return(fibonacci(n-1) + fibonacci(n-2)) n = int(input('Enter a number, N, N>=2 : ')) fibo_series = [] for i in range(0,n): fibo_series.append(fibonacci(i)) print(fibo_series)
f51748f0f5f7535a86ac58a0195dd9f75096e01a
abhinavmaurya/InformationRetrieval_Fall2015
/PageRankAlgorithm/PageRank.py
7,623
3.59375
4
##################################################### # Author: Abhinav Maurya # # Course: Information Retrieval CS6200 # # Assignment#: 2 # # Description: Implementation of PageRank algorithm # # Date: 10/11/2015 ...
219993cfabae2d3b52406caa830ad8c44e05559c
DrRuisseau/fp_train
/python/lec4/main/PartiallyApplied.py
247
3.8125
4
from functools import partial def power(base, exponent): return base ** exponent square = partial(power, exponent=2) print(square(2)) powers = [] for x in range(2, 1001): powers.append(partial(power, exponent = x)) print(powers[0](3))
a9fe6163e3e736063b614c23d5f1c90dbbe06de2
alexxxesss/PythonPY1001
/Занятие3/Домашнее_задание/task3/main.py
613
3.96875
4
def func_str_word(a): list_a = a.split() list_size = [] for i in list_a: list_size.append(len(i)) max_size = max(list_size) list_max_word = [] for i in list_a: if len(i) == max_size: list_max_word.append(i) if len(list_max_word) == 1: max_word = list_...
601b4132ac3de34a9e4b7cca77fc23cbc5ad4e86
alexxxesss/PythonPY1001
/Занятие4/Практические_задания/task1_3/main.py
205
3.65625
4
if __name__ == "__main__": list_ = [i ** 2 if i % 2 == 0 else -i for i in range(10)] # TODO print(list_) # list_ = [] # for i in range(10): # list_.append(i) # print(list_)
19e7e1c3c16ff47e94ff443cad8bf8373bcaaf00
alexxxesss/PythonPY1001
/Занятие4/Лабораторные_задания/task1_4/main.py
353
3.90625
4
def func_mean(n, m): arithmetic_mean = sum(range(n, m)) / len(range(n, m)) list_mean = [i for i in range(n, m) if i > arithmetic_mean] return list_mean if __name__ == "__main__": n_1 = int(input("Введите число n: ")) m_1 = int(input("Введите число m: ")) print("-----") print(func_mean(n_...
0ca1c5996c18a7b2d8f93c5223280768b14ba853
alexxxesss/PythonPY1001
/Занятие2/Домашнее задание/task3/main.py
576
3.890625
4
# TODO a = int(input('Введите первое число: ')) b = int(input('Введите второе число: ')) c = int(input('Введите третье число: ')) variant_1 = (a < 45) and (b >= 45) and (c >= 45) variant_2 = (a >= 45) and (b < 45) and (c >= 45) variant_3 = (a >= 45) and (b >= 45) and (c < 45) if variant_1 or variant_2 or variant_3: ...
534829b96c3fe950b13dd9f265a7058613d90a9a
alexxxesss/PythonPY1001
/Занятие3/Лабораторные_задания/task1_3/main.py
620
3.828125
4
if __name__ == "__main__": def prosto_func(n): list_prosto_multiplier = [] for i in range(1, n): count = 0 for x in range(1, i+1): if i % x == 0: count += 1 if count == 2: list_prosto_multiplier.append(i) ...
0c18cda0885ee1b09608f4400a40057e0f6e8cbe
alexxxesss/PythonPY1001
/Занятие3/Практические_задания/task3_1/main.py
311
3.84375
4
def remove_whitespace(str_): words_list = str_with_space.split() new_str_with_space = " ".join(words_list) return new_str_with_space if __name__ == "__main__": str_with_space = " 123. test print test11 " # исходная строка print(remove_whitespace(str_with_space))
6bc8161e439fa244e429c6312545541d5fa28852
DavidCarl/DiscreteMath-Assignments
/Assignment-3/main.py
348
3.984375
4
n = 3 # Set amount of disk here # n is number of disks # f is from # t is to # a is auxiliary def move(n, f, t, a): if n == 1: print('Move disk 1 from', f, 'to', t) return move(n-1, f, a, t) print('Move disk', n, 'from', f, 'to', t) move(n-1, a, t, f) def towerOfHanoi(): move(n, 'A...
1c21f0f97706e7e1ac03e1aa847cd4281b8a2fdd
humuhimi/mathPython
/mathPython/Chapter3/practice3_8.py
912
4.03125
4
import csv import matplotlib.pyplot as plt from Chapter3.practice3_5 import find_corr_x_y def scatter_plot(x,y): plt.scatter(x,y) plt.xlabel('summer') plt.ylabel('swimming-lesson_correlation') plt.show() def read_csv(filename): with open(filename) as f: reader = csv.reader(f) n...
91f223957a34b068b918d4297a319f6645cc8bc4
humuhimi/mathPython
/mathPython/Chapter4/try4_1.py
663
3.890625
4
""" print the series of fraction and calculate it's value """ from sympy import Symbol, pprint, init_printing def print_series(n, x_value): # 次数の低い順から並べる # init_printing(order='rev-lex') x = Symbol('x') series = x for i in range(2, n+1): series = series + (x**i)/i pprint(series,order=...
0dce6afa37c4dd1cd64179f0da39ab5467bdb097
humuhimi/mathPython
/self_taught_python/sample7.py
345
3.75
4
qs = ["what is your name", "what is fav color ", "what is your request"] n = 0 while True: print("Type q to quit") a = input(qs[n]) if a == "q": break n = (n + 1) % 3 print(a) list1 = [1,2,3,4] list2 = [5,6,7,8] added = [] for i in list1: for j in list2: added.app...
8e958414e097730a6b554526b512ae1aaded7957
humuhimi/mathPython
/mathPython/Chapter6/practice6_2.py
992
3.65625
4
import matplotlib.pyplot as plt import random def transform_1(p): x = p[0] y = p[1] x1 = 0.5*x y1 = 0.5*y return x1,y1 def transform_2(p): x = p[0] y = p[1] x1 = 0.5 * x + 0.5 y1 = 0.5 * y + 0.5 return x1, y1 def transform_3(p): x = p[0] y = p[1] x1 = 0.5 * x...
1aba84f4c9ccb999895378980f14101ba10d3adb
Fang-Molly/CS-note
/python3 for everybody/exercises_solutions/ex_09_05.py
897
4.375
4
''' Python For Everybody: Exploring Data in Python 3 (by Charles R. Severance) Exercise 9.5: This program records the domain name (instead of the address) where the message was sent from instead of who the mail came from (i.e., the whole email address). At the end of the program, print out the contents of your diction...
213b49fd5507cd1424caac7ff027109c5d2e79b3
jamarrhill/Assignment-10
/BuildersGame.py
6,736
3.96875
4
# Name: Jamar Hill # Date: 12/2/2020 # Description: Assignment 10 class BuildersGame: def __init__(self): #Establish board on a 5x5 grid of lists, each list contains five empty strings. self.board =[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]] self.current_state = "UNFINISHE...
7ce680bdd8e9f6edd3f11ab0f58b1378ad53b986
ravi3011/addskils
/week-2/PossibleBipartition.py
537
3.5625
4
from collections import defaultdict color = {} graph = defaultdict(list) def dfs(node,c = 0): if(node in color): return (color[node] == c) color[node] = c return all(dfs(i,c^1) for i in graph[node]) def check(n,dislike): for u,v in dislike: graph[u].append(v) graph[v].app...
039bf4159f99ecc1d4833ab6161ffc3360871661
ravi3011/addskils
/week-2/code8.py
528
3.796875
4
from collections import deque class MyStack: def __init__(self): self.q = deque() def push(self, x: int) -> None: self.q.append(x) return None def pop(self) -> int: return self.q.pop() def top(self) -> int: return self.q[-1] ...
80f90b563eee784ebc64bf9816fd749f36ed8dad
jcjcarter/Daily-214-Hard-Python
/Daily 214 Hard Python/Daily_214_Hard_Python.py
2,783
3.515625
4
import math import time TREATS_PER_CELL = 7 # used to estimate the needed number of cells filename = "input.txt" def run(filename): start_time = time.time() with open(filename) as file: n_treats = int(file.readline()) # Number of treats. coords = [[float(xy) for xy in line.split()] for line in ...
537ab14e1654a023e4de4c0cd4c3dc37ab2394e1
paulcockram7/paulcockram7.github.io
/10python/l05/Exercise 2.py
261
4.125
4
# Exercise 2 # creating a simple loop # firtly enter the upper limit of the loop stepping_variable = int(input("Enter the amount of times the loop should run ")) #set the start value i = 0 for i in range(stepping_variable): print("line to print",str(i))
f8df8b8ecd7e6958afde1b8fd33963dac13d614b
paulcockram7/paulcockram7.github.io
/10python/l02/datatype.py
187
4.25
4
# lesson 2.1 - data types year = 2013 # integer number age = 13.75 # decimal number name = "John" # string # now print them out to screen print (year) print (age) print (name)
59584f4bd0a2421b3fb7d12c65d852d05d27856c
slukas111/PythonBootcamp
/forloop/forloop_practice.py
792
3.734375
4
business_list = [1500, 2542, 2001, 3500, 5300, 5555, 17000, 21000, 15001] total_taxes = 0 for single_income in business_list: if single_income >= 1 and single_income <= 2000: tax = single_income * 0.05 elif single_income >= 2001 and single_income <= 5000: tax = single_income * 0.10 elif s...
0289e93b67bbccf95284c620e8e2851d4099d408
slukas111/PythonBootcamp
/collection/set/set.py
231
3.765625
4
fruit_basket = {"lemon", "orange", "grape", "apple"} print("lemon" in fruit_basket) fruit_basket.remove("lemon") print(fruit_basket) fruit_basket.discard("apple") print(fruit_basket) fruit_basket.add("apple") print(fruit_basket)
14a6c956367b9e63ed42698601a34b5074a32018
slukas111/PythonBootcamp
/boolean/boolean_example.py
657
3.9375
4
# comparison_variable = 5 > 6 # print("1 " + str(comparison_variable)) #boolean assignment my_age = 30 sisters_age = 30 mothers_age = 60 my_name = "sasha" phone_name = "onePlus 5T" my_best_friend_name = "Dacia" test_one = sisters_age > my_age print("test one: " + str(test_one)) test_two = sisters_age != my_age ...
c517f8b0f12ffe989f50e67177dd48a4501f1ba6
liuy92/StatisticsBase
/Graph/BFS/广度优先搜索.py
775
3.765625
4
#-*-coding:utf-8-*- """ 广度优先搜索(BFS): 目的:搜索两点之间的最短路径 实质:按照玉器店的距离来遍历所有的点 步骤: 1. 寻找队列中下个顶点v,并进行标记 2. 将与v相邻且未被标记过的点加入队列 """ def BreadthFirstPaths(Graph, start): V = Graph.keys() n = len(Graph) edgeTo = dict(zip(V, [0] * n)) marked = dict(zip(V, [False] * n)) def BreadthSearch(v): marked[v] ...
0999ccaa695b8f40d9c6d2bd35acaf0b89dbbf17
Balint141/Python
/auto/auto/auto/auto.py
356
3.53125
4
auto = input('Egy autónév rendel!') vegsebesseg = int(input('Mi a végsebessége a(z) ' + auto + '-nek' + '? ')) anyag = int(input('Mivel megy a(z) ' + auto + '?' )) orszag = input('Hol készül a(z) ' + auto + '?') mondat2 = '{} készül a {} ami {} km/h végsebességre képes és {} -el megy'.format(orszag,auto,vegsebesseg,an...
190924089259be0dda678c4f021546ed1824f47d
hochr007/ClassProjects
/CSCI1133_Python_IntroProgramming/SnakeGame_Python/hw12_Snake.py
6,142
3.96875
4
from tkinter import * import random class SnakeGUI(): # Constructor: Initialization of UI def __init__(self): # Scaling to lessen magic number pain self.scale = 20 # Canvas self.root = Tk() self.canvas = Canvas(self.root, width=30*self.scale, height=30*self.scale, back...
3a8b1826375404e427d76de96fcf64202ac3d2c6
Nicename123/MathsQuiz
/Code/v4/v4user_details.py
604
4.09375
4
def name(): #To ask for user's name global name while True: name = input("Enter Your Name : ") if name.replace(' ','').isalpha(): break print("Please Only Enter Letters") #Error message if user enters anything other than letters name() def age(): #To ask for user's ...
76119fd38cab6d61d0f248556ada7909ac08511d
casewalker/sudoku-solver
/main.py
528
3.5625
4
from SudokuBoard import Board from Solver import read_input_from_stdin, read_input_from_file, solve import sys DEBUG_LEVEL = "none" # DEBUG_LEVEL = "trace" # DEBUG_LEVEL = "pause" def main(args): """Instantiate the board, populate it, then solve.""" board = Board() if len(args) > 1: file = args...
54c02073a74b7e42431bf8d1b0dd2c231079485f
moriakh/py-tareas
/loops/loops.py
242
3.9375
4
ciudades = ['Lima', 'Iquique', 'Santiago', 'Los Ángeles', 'Guayaquil'] for ciudad in ciudades: if ciudad[0] == 'L': continue print(ciudad) for ciudad in ciudades: if ciudad == 'Santiago': break print(ciudad)
aba6c9d0fe33b2c428277a77fb1ba7f3cee4a3e7
Wummer/MLExam
/NORM.py
1,164
3.671875
4
from __future__ import division import numpy as np """ This function takes a dataset with class labels and computes the mean and the variance of each input feature It returns two lists: [mean of first feature, mean of second feature] [variance of first feature, variance of second feature] """ def mean_variance(data):...
92a8edcc1b4419cda07813c301607d0e036de96f
Biytes/learning-basic-python
/loops.py
749
4.15625
4
''' Description: Author: Biytes Date: 2021-04-12 17:55:57 LastEditors: Biytes LastEditTime: 2021-04-12 18:50:23 FilePath: \python\basic\loops.py ''' # A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). people = ['John', 'Paul', 'Sara', 'Susan'] # Simpl...
8f0a74aa3e345b6d8e79e3236fe40294ba22ccac
Biytes/learning-basic-python
/files.py
717
3.875
4
''' Description: Author: Biytes Date: 2021-04-12 20:53:34 LastEditors: Biytes LastEditTime: 2021-04-13 11:59:51 FilePath: \python\basic\files.py ''' # Python has functions for creating, reading, updating, and deleting files. fileName = 'myFile.txt' # Open a file myFile = open(fileName, 'w') # Get some info print('Na...
baa903a01eac05f67d78e05b9ad7230dea990c3e
gopem121317/AlgoTB
/src/intro/fibonacci_last_digit.py
338
3.890625
4
# Uses python3 import sys def get_fibonacci_last_digit(n): if n <= 1: return n prev = 0 curr = 1 for _ in range(n - 1): prev, curr = curr, (prev + curr) % 10 return curr if __name__ == '__main__': n_in = sys.stdin.read() n_in_int = int(n_in) print(get_fibonacci_last...
56740520755480f2953fee345343c65c23bc64e1
gopem121317/AlgoTB
/src/intro/fibonacci_partial_sum.py
726
3.65625
4
# Uses python3 import sys def fibonacci_partial_sum(from_, to): from_ -= 1 prev = 0 curr = 1 period = [0, 1] while True: prev, curr = curr, (prev + curr) % 10 if prev == 0 and curr == 1: break period.append(curr) period.pop() lprd = len(period) id_f...
48e602aba514f28785ae5f2f13f8f7b5066c3f35
qigege0911/Practise-Together
/Day2 liuxiao/22.py
89
3.59375
4
L1=[1,2,3,4] L2=[2,3,4,5] L3=[] for i in range(0,4): L3.append(L1[i]+L2[i]) print(L3)
308a2e8d66a255f5d4a28267da55ae68e0bdca96
qigege0911/Practise-Together
/Day3/Day3(2).py
235
3.65625
4
L1 = [53, 40, 10, 37, 91, 97, 87, 45, 15, 12, 29, 21, 73, 77, 91, 55, 46, 64, 37, 29] L2=sorted(L1) L3=L2[1:-1] sum=0 for i in range(0,len(L3)): sum+=L3[i] result_average=sum/(len(L3)) result=round(result_average/10) print(result)
ffd76d8b8c786b8faa1f8a6bc1be736827b4460f
qigege0911/Practise-Together
/Day3/Day3(4).py
203
3.734375
4
i=0 def counter(): global i import time a = input() t1 = time.time() b = input() t2 = time.time() T = t2 - t1 i+=1 return T while i<=3: print(counter())
8cfcfe9a44ac53ab259ce0b6edb85ff515a18cf0
seanwatson/pyparts
/src/pyparts/platforms/base_platform.py
977
3.734375
4
import abc class BasePlatform(object): """An abstract class for creating platforms. BasePlatform is what all platforms are created from. Platforms are expected to override the methods of BasePlatform to provide different kinds of peripheral devices like GPIO pins, PWM pins, and communication busses. ...
5f870953d0a43b097d895da4abb67e4a645f3e99
seanwatson/pyparts
/src/pyparts/platforms/gpio/base_gpio.py
4,877
4.1875
4
import abc # Pin values HIGH = True LOW = False class GPIOError(Exception): """Error type for exceptions while writing to GPIO pins.""" pass class BaseGPIO(object): """A class for creating GPIO type peripherals. BaseGPIO implements basic GPIO functionality such as reading pin values and settin...
3adab7234fc878aab1a26242e3d06d59e69a509e
qmclouca/PythonCourse
/venv/Named_Tuple.py
756
4.09375
4
""" Módulo Collections - Named Tuple tupla = (1, 2, 3) named_tuple => São tuplas que possuem nome e parâmetros """ from collections import namedtuple #Forma 1 - declarar a tupla cachorro com três variáveis idade raca nome cachorro1 = namedtuple('cachorro', 'idade raca nome') #Forma 2 cachorro2 = namedtuple('cachorro'...
7572be85b7fd9a8b9c213f4dd8280736ee5c0fe9
todokku/hi_its_me_tony
/word2vec/utils.py
381
3.640625
4
def group_by(items, key_func): "itertools.groupby is scary because it can only be iterated over once and I don't need to be super efficient for just preprocessing" grouped_items = dict() for obj in items: key = key_func(obj) if key not in grouped_items: grouped_items[key] = [] ...
a8aa7333af142fb9e7e870bd3e4593782fc0bccf
Viteac/Python-Games
/card_game.py
1,027
3.9375
4
import random wins = [0,0] def random_deal(): rand_cards = random.choices([1, 2, 3, 4, 5 ,6, 7, 8, 9, 10], k=3) return rand_cards def calc(who,cards): cards_sum = sum(cards) print(who,str(cards_sum)+",",'Cards:', end = ' ') print(*cards,sep=',') return cards_sum while True: print('=' ...
ca4aabd62635f10edb934d941c09e1865b02f5b2
applepie787/Cloud_AI_Study
/python_workspace/tuple_test.py
608
4.15625
4
# 튜플 - 리스트와 유사한 자료형 # 한번 결정된 요소는 바뀔 수 없습니다. tuple_data = (10, 20, 30) tuple_data2 = 10, 20, 30 # 괄호가 없어도 튜플로 선언됩니다. print(tuple_data) print(tuple_data2) print(type(tuple_data)) print(type(tuple_data2)) # tuple_data[0] = 100 튜플에 새로운 값을 할당 할 수는 없다. name, age, major = "이루다", 28, "전자전기공학" print(name,"|", age,"|", major...
aaca1b6ad8406d840e6ac2950a1f97c1d16aae8b
applepie787/Cloud_AI_Study
/product-master-gui_study/gui_study/gui_03.py
433
3.703125
4
import tkinter as tk w = tk.Tk() # 모델 counter = tk.IntVar() counter.set(0) # 컨트롤러 def click(var, value): var.set(var.get()+value) # 뷰 frame = tk.Frame(w) frame.pack() button = tk.Button(frame, text='Up', command = lambda:click(counter,1)) button.pack() button = tk.Button(frame,text='Down',command=lambda:click(...
1d1795475f2656f95beaaeadcc30daca4d5c5c67
applepie787/Cloud_AI_Study
/python_workspace/loops.py
963
4.3125
4
array_ = [1, 2, 3, 4, 5] for data in array_: print(data, end="") # print로 인한 라인 변경을 막아준다. print("") for data in array_: print(data) print("_______________________________________________") for i in range(len(array_)): print(array_[i]) print("_______________________________________________") for i in ...
ed315695c3f634a1bc01999d9b525a787340d20e
applepie787/Cloud_AI_Study
/python_workspace/operator.py
483
3.890625
4
# 단항연산자 value = 0 print(++value) # 이항연산자 : 산술연산자 -, +, *, /, //, % # 논리연산자 AND, OR # 관계연산자 >, <, # 대입연산자 =. +=, -=. # PI = 3.14159265 원주율과 반지름 제공 원의 넓이, 둘레 구하는 연산 pi = 3.14159265 r = int(input("반지름을 입력하세요 : ")) print("원주율 = ", pi) print("반지름 = ", r) print("원의 둘레 = ", 2*pi*r) print("원의 ...
c0c254eb447fc14c35187c921e047325b027039e
mandoni/arquitectura
/carro.py
1,809
3.5
4
import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BOARD) def CarForwards(time): GPIO.output(Motor1A,GPIO.HIGH) GPIO.output(Motor1B,GPIO.LOW) GPIO.output(Motor1E,GPIO.HIGH) GPIO.output(Motor2A,GPIO.HIGH) GPIO.output(Motor2B,GPIO.LOW) GPIO.output(Motor2E,GPIO.HIGH) sleep(time) def CarBackw...
6a23de518e705f650969b1c55956de005755c4e9
czauhar/hangman
/hangman.py
2,130
4.0625
4
import random def hangman(): word_list = ["pennsylvania","quintessential","fart", "connecticut","random","haircut","antiquated","antique"] random_num = random.randint(0, 4) word = word_list[random_num] wrong = 0 # use this varibable to keep track of wrong guesses stage...
c04fe86e985569d2ab76a00bc172212b6571cd62
zhonglue/probability_and_statistics
/3-Discrete Random Variables/Poisson_distribution.py
742
3.765625
4
# Poisson distribution # Author: Zhonglue Hu # Date: Feb 20, 2020 import numpy as np from matplotlib import pyplot as plt import math # Set the parameters number = 100 # Total number of tests lamda = 10 # the poisson ratio x = np.arange(number) z_poisson = np.zeros(number) for i in range(number): z_poisson...
825bfa54befc3a0718b9c739182efcace2f95bec
MatthewSwart/Scripting_3
/dataAIT.py
942
3.890625
4
#BeautifulSoup: Parsing data from AIT timetable website. #Libraries: # urlLib: # Documentation: https://docs.python.org/2/library/urllib.html # bs4: # Download: https://www.crummy.com/software/BeautifulSoup/ # Documentation: https://www.crummy.com/software/BeautifulSoup/bs...
0a489a17ce070c3c3b9f1b2f7ee047329a2ecf33
22Rahul22/Codechef
/Primality Test.py
256
3.5
4
import math t = int(input()) for _ in range(t): n = int(input()) flag = 0 for i in range(2, int(math.sqrt(n))+1): if n % i == 0: flag = 1 break if flag == 0: print("yes") else: print("no")
a094e0669474878bdc082dbe467b040e0da865fb
22Rahul22/Codechef
/Chef and An Ideal Problem.py
130
3.671875
4
n = int(input()) print(n) a = int(input()) if (n != 1 and a != 2) or (n != 2 and a != 1): print(abs(a - n)) else: print(3)
551b92b975ab2b45aa3f5ca0ffc3e120cba2b386
Nkafu237/Dictionary
/DictionarySearch.py
1,045
3.8125
4
# Nkafu's Search Dictionary # This function is responsible for separating # the words from the definitions in the given # line from the dictionary def split(line): w = line.split(" ", 1) nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] if len(w) != 1: for i in nums: if i ...
18ea34cb33dd3c93fa169a700eafc566ecaa1a81
FakhrulHasan/Python_Basics
/Python Indentation.py
377
3.796875
4
""" Indentation refers to the spaces at the beginning of a code line. The indentation in Python is very important. Python uses indentation to indicate a block of code. """ if 8 > 4: print("Eight is greater then four!") """ Python will give you an error if you skip the indentation: """ """ ...
3405e8ecbc5b0e554595c23c47cee04f1d205701
Nirnay7/Nirnay7
/#WAP to find area of circle.py
78
3.90625
4
#WAP to find area of circle r = 6 pi = 3.14 area = pi * (r**2) print(area)
8d4818c483abb755d2e97778f497e1ae06531963
nikasha89/MC
/Tarea1/Tarea1/processing_operation/ToGrayScale/adaptive_smooth.py
1,315
3.703125
4
# USAGE # Import the necessary packages import numpy as np import argparse import cv2 # Load the image, convert it to grayscale, and blur it slightly image = cv2.imread('leoJimenez.jpeg') image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.imwrite('grayScale.jpg',image) blurred = cv2.GaussianBlur(image, (5, 5), 0) cv2...
f5d1f53ff31141a8c9f3704bfb3463f0f2ba4bf5
kylethebaker/python-advent-of-code-2015
/day-13/day13-part1.py
1,668
3.859375
4
#!/usr/bin/env python import sys import itertools class RoundTable(object): def __init__(self): self.people = set() self.happiness = {} def parse_instruction(self, instruction): split = instruction.split() person = split[0] neighbor = split[-1].strip('.') po...
5edc064da750615abacada0e181aecaa3864c591
kylethebaker/python-advent-of-code-2015
/day-11/day-11-part1.py
1,229
3.953125
4
#!/usr/bin/env python import string alphabet = list(string.ascii_lowercase) def increment_password(pw): password = list(pw) password.reverse() for index, char in enumerate(password): new_index = (alphabet.index(char) + 1) % len(alphabet) password[index] = alphabet[new_index] i...
c0bfee07c7e88575284533dd2bf0bcd2e0eddf53
kylethebaker/python-advent-of-code-2015
/day-7/day7-part2.py
2,439
3.515625
4
#!/usr/bin/env python import sys class Circuit(object): def __init__(self): self.wires = {} def add_wire(self, wire): self.wires[wire.id] = wire def get_signal(self, wire_id): if isinstance(wire_id, int): return wire_id if wire_id not in self.wires: ...
1d646d062517b92a4e8c5e640fdabfa44aaa263b
otitoju/physic-prob
/mike.py
1,426
4.0625
4
#conditions # D depends on V # Re depends on D and V # F depends on the value of Re # hl depends on the value of D V F import math # note that # e = density # Q = discharge # L = length # U = viscousity # g = gravity which is 9.81 check = str(input("Is the value for D given? ")) if check == 'yes': print("Since th...
d81b2407db976d82dd9e375be7fc0c67a8354b88
Crimack/ctci
/c2/palindrome.py
562
4.09375
4
from linked_list import LinkedList def is_palindrome(linked): stack = [] curr = fast = linked.head while fast is not None and fast.next is not None: stack.append(curr.value) curr = curr.next fast = fast.next.next if fast is not None: curr = curr.next while curr is not None: if curr.value != stack.pop()...
8ff921bffc3658f4c00b0eb862e4f0275867e91f
justinba1010/Pen-Academy-Python
/CoolStuff/stringtrie.py
1,058
3.5
4
class StringTrie: class Node: def __init__(self, key, value): self.key = key self.value = value self.children = [] def __init__(self): self.head = Node(None,None) def add(self, key, value): self.__add(self.head, key, value) def __add(self, Node...
a62f4ce1d1f9c35e7a8de4f814ee02289d32aab9
justinba1010/Pen-Academy-Python
/Critters/ReproductiveCritter.py
832
3.734375
4
from Critter import Critter import random class ReproductiveCritter(Critter): def __init__(self,x,y,hunger): Critter.__init__(self,x,y,0) self.char = "✈" def update(self): Critter.update(self) self.hunger = 0 def collision(self, othercritter): if(self.x == othercritte...
c0198e15f608d511f66927b4b7e07989f85b02bc
yunhsiang0308/Python200804
/day2-7.py
721
3.828125
4
names=[] scores=[] total=0 avg=0 n=int(input('請輸入班級總人數:')) for a in range(n): name=input('請輸入你的名字:') score=int(input('請輸入你的分數:')) names.append(name) scores.append(score) print(scores) for i in scores: total=total+i avg=total/n print('平均:',avg,'分') highest=0 highest_name='' ...
e690dad132239e95a67f7d735ea872ba9f2da917
anik511/My_Python
/Basic/25_list_comprehensions.py
671
4.28125
4
# normal method # making double of list li = [1, 2, 3, 4, 5, 6, 7, 8, 9] NewLi = [] for x in li: NewLi.append(2*x) print("New List:", NewLi) # List Comprehension Method Comprehension = [2 * x for x in li] print("List Comprehension: ", Comprehension) # Finding Even Numbers # normal method even = ...
347c3d328420e6e616a4005beb53e4b220494a28
anik511/My_Python
/Basic/26_basic_datastructure_2_mindgame.py
565
3.546875
4
# set = {1, 2, 3} # dic = {'Name': 'Anik', 10: 'Id'} # print(type(set), type(dic)) # set = {} # dt = {} # list = [] # tuple = () # print(type(set), type(dt), type(list), type(tuple)) # # imposible # # dic[{1, 2, 3}] = 'set' # # dic[set] = {1, 2, 3} # # print(dic) # result = {'Ratul': 89, 'Ratan': 67, 'Nisha...
e97ba6865296c49b23fa3fb5eb59a6e935987184
LeoLiu1999/NeedlessYouthUnemployment
/NeedlessYouthUnemployment/util/db_builder.py
6,249
3.53125
4
# enable control of an sqlite database import sqlite3 import os # facilitates CSV I/O # import csv from hashlib import sha256 path = os.path.abspath(os.path.join( os.path.dirname(__file__), '..', 'data')) f = os.path.join(path, 'db.db') def create_db(): """ Initializes tables in d...
0099ea1a24cd0a7e27e7caa9bcd30ad25bb5fc29
Timur597/First6team
/6/Tema3(Циклы)/6.c_6.py
270
3.609375
4
6 Задание names = ('Максат','Лязат','Данияр','Айбек','Атай','Салават','Адинай','Жоомарт','Алымбек','Эрмек','Дастан','Бекмамат','Аслан') i = 0 while i < 12: print (names [i]) i = i + 2
1f978bade54fa7036d0887b0880e0271be5459ee
Timur597/First6team
/6/Tema3(Циклы)/2.c_2.py
187
3.828125
4
2 ЗАДАНИЕ lang = "Rust" languages = ["go","mo","do","Rust","fo","bo"] i = 0 while languages [i] != lang: print (languages [i]) i = i + 1 if languages [i] == lang: print (lang)
7e63938beeccc2a8fe562817ab553da2cde8c919
Timur597/First6team
/6/Tema2(if,elife,else)/8.if_9.py
185
3.578125
4
c=341 d=62 e=7 if c**2 > d**2: print("с больше д") if d**2 > e**2: print("д больше е") if c**2 > e**2: print("значит с естественно больше е")
95e7bd378c5f663f2a4f288bda83d8cc57b6f818
Timur597/First6team
/6/Tema3(Циклы)/4.c_4.py
457
3.890625
4
4 ЗАДАНИЕ 1 Метод languages = ["go","mo","do","Rust","fo","bo"] i = 0 while languages [i] != 6: print (i, languages [i]) i = i + 1 #Выдает ошибку индексации 2 Метод languages = ["go","mo","do","Rust","fo","bo"] for i in range (0, 6): print(i, languages [i]) 3 Метод languages = ["go","mo","do","Rust","fo","bo...
adb3b7b3f05fe81c547565d94e98f3953f3c017f
Timur597/First6team
/6/Tema3(Циклы)/3.c_3.py
73
3.703125
4
3 ЗАДАНИЕ num = 7 i = 0 while i != 1: print (num ** 5) i = i + 1