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
88b7c2b539778c54e9ba2072c44b163fda95e785
fis-jogos/2016-2
/python-101/06 funções.py
739
4.3125
4
# Definimos uma função que calcula a soma de todos os números pares até um # certo valor def soma_pares(x): y = 0 S = 0 while y <= x: S += y y += 2 return y # Agora podemos chamar nossa função e recuperar o valor passado para o "return" valor = soma_pares(100) print('A soma de to...
52489878319e534194790e9c44477222cfb87d84
fis-jogos/2016-2
/exemplos/flappy/flappybird.py
1,414
3.546875
4
import random TITLE = 'Flappy' WIDTH = 400 HEIGHT = 708 GRAVITY = 500 JUMPSPEED = 200 SPEED = 3 GAP = 130 OBS_HEIGHT = 500 HEIGHT_RANGE = (-50, 200) bird = Actor('bird0', pos=(100, HEIGHT / 2)) bird.vy = 0 bird.dead = False bottom = Actor('bottom', pos=(-100, 400)) top = Actor('top', pos=(-100, 400)) def set_rando...
00a40a7a31116aa3940051f4f2de3093313ba0dc
sajjad0057/Practice-Python
/DS and Algorithm/Recursion.py
100
3.5
4
def f(n): if n<=1: return n print(n-1,n-2) return f(n-1)+f(n-2) print(f(7))
5f3b579a7b89545a018ad5ed1dae0fb2c6784ead
sajjad0057/Practice-Python
/OOP_class_and_static_method.py
1,536
3.65625
4
class StoryBook: no_of_books=0 discount =0.5 # its called class variable def __init__(self,name,price,author,date): self.name=name self.price=price self.author=author self.p_date=date StoryBook.no_of_books += 1 def applying_discount(self): se...
7a40ab3b75bd4d7a8d23ee6dea231773019b72e7
sajjad0057/Practice-Python
/py_list.py
583
3.859375
4
subject=["c++","java","c","c#","python","basic"] sub=(len(subject)) print("1->",sub) subject.append("assemble") print("2->",subject) subject.insert(2,"sajjad") print("3->",subject) subject.remove("sajjad") print("4->",subject) subject2=subject.copy() print("5->",subject2) pos=subject.index("c#") #To find i...
7ad2419d13fd0ddae7e8bc2320b0aad9ceed1e79
sajjad0057/Practice-Python
/OOP8_multilevelInheritance.py
728
3.875
4
''' Exaple for multi-level Inheritance! ''' class A: def display1(self): print("I am inside A class"); class B(A): def display2(self): super().display1(); print("I am inside B class"); class C(B): def display3(self): super().display2() print("I am inside ...
e9f846f5464649428ec8b7a6cdadc76cde91bd2f
sajjad0057/Practice-Python
/DS and Algorithm/Algorithmic_Tools/Devide-n-Conquer/marge_sort.py
1,092
4.15625
4
def marge_sort(a,b): marged_list = [] len_a , len_b = len(a),len(b) index_a, index_b = 0,0 #print(f'index_a , index_b = {index_a} , {index_b}') while index_a<len_a and index_b<len(b): if a[index_a]<b[index_b]: marged_list.append(a[index_a]) index_a +=1 ...
26414e80300ccbfb508993b00fedb999b20487e0
sajjad0057/Practice-Python
/DS and Algorithm/Algorithmic_Tools/Devide-n-Conquer/quick_sort.py
527
3.671875
4
def partition(L,low,high): pivot = L[high] i = low - 1 for j in range(low,high): if L[j]<pivot: i +=1 L[i],L[j] = L[j],L[i] print(L) L[i+1],L[high] = L[high],L[i+1] return i+1 def quick_sort(L,low,high): if low>=high: return ...
76b834b478b32dc88a2f6f6330da01f349cff490
sajjad0057/Practice-Python
/py_2.py
153
4.0625
4
while 1: a=int(input("Enter the number a: ")) if a>=5 and a<20: print("yes! I am right") else: print("My concept wrong")
d3fdd903219898c91c2fd6bfeb95ae7735d8eba0
aprz512/learn-python
/ex17.py
498
3.671875
4
# -*- coding: utf-8 -*- from os.path import exists print "This script can copy a file to another!" source_file = raw_input("choose a file to copy : ") target_file = raw_input("choose a file to save : ") file_data = open(source_file).read() print "%s length = %d" % (source_file, len(file_data)) print "%s exist? %r" % ...
d0e213dd1e560dd0a7a569c47e1363d83a31387b
memetics19/selenium_scraping
/Browser.py
1,019
3.53125
4
import csv from selenium import webdriver from selenium.webdriver.common.keys import Keys """place your path here in the executable path""" driver = webdriver.Chrome(executable_path = r"C:\Users\Lenovo\Documents\astaqc\selenium\Drivers\chromedriver.exe") BASE_URL = "https://google.com" """ Base_URL is been passe...
205ac964350d0547f90e710e63bf13376f284074
lavalio/ChamplainVRSpecialist-PythonAlgorithms
/Week3/class2/combination_one_zero.py
252
3.9375
4
times = 0 for a in range(2): p1 = a for b in range(2): p2 = b for c in range(2): p3 = c string = str(p1) + str(p2) + str(p3) times = times + 1 print(str(times) + ": " + string)
27cbc84ffd348ab3a9aa0c21d50149e98cc6e940
lavalio/ChamplainVRSpecialist-PythonAlgorithms
/Week3/class1/break_continue.py
187
4.0625
4
# Break for a in range(10): if a == 3: break print(a) # Cnotinue for a in range(10): if a == 3: continue print(a) # for a in range(2,10): # print(a)
21e628b27a954ccfcd7c54fa946a719cab15b522
lavalio/ChamplainVRSpecialist-PythonAlgorithms
/Week3/class1/break_continue_2.py
165
3.875
4
# Cnotinue for a in range(10): if a % 2 == 0: continue print(a) print("---") for a in range(10): if a % 2 != 0: continue print(a)
1bf786a8bebc2f14d45deef9aceb1891c152f21b
lavalio/ChamplainVRSpecialist-PythonAlgorithms
/week16/plot_test.py
364
3.515625
4
import matplotlib.pyplot as plt squares = [1,4,9,16,25] #plt.plot(squares) #plt.show() squares = [10,20,30,40,50] input_value = [10,20,30,40,40] #plt.plot(squares,linewidth = 5) plt.scatter(input_value,squares,linewidth = 5) plt.title("Square Number 虹", fontsize = 24) plt.xlabel("Value", fontsize = 14) plt.ylabel("S...
5cf93df98db5fb6fe7444fffbbd1fa79559607cd
lavalio/ChamplainVRSpecialist-PythonAlgorithms
/Week4/Class1/Homework.py
1,080
4.25
4
#Create a list of numbers, randomly assigned. #Scan the list and display several values:The minimum, the maximum, count and average #Don`t use the “min”, “max”, “len ” and “sum” functions #1. Len : gives the number of elements in array. #2. Min, max: Gives the highest highestor lowest number in the array. #3. Sum: A...
04ad4e7ddc982df2baae2832efa409182c348037
lavalio/ChamplainVRSpecialist-PythonAlgorithms
/Week7/Test/Question_2.py
551
3.9375
4
# Lists my_list = [] while True: element = input("Please enter an element to add to the list[fin = finished] > ") if element != "fin" and element != "": my_list.append(element) elif element == "": print("Wrong! The input should not be empty") else: print() length = len(...
d676b0f0c8fe48d25a1afe03d6f2b2f2572654fe
lavalio/ChamplainVRSpecialist-PythonAlgorithms
/Week7/Exercise/student_collection.py
752
3.796875
4
class Student: #id=0 #name = "" #gpa = 0 #def __init__(self,id,name,gpa): def __init__(self, id:int, name:str, gpa:float): self.id = id self.name = name self.gpa = gpa class StudentClass: def __init__(self): self.students = [] def add_student(self, student:...
cc576900d66498650727d7be7c7d429c0f6c9dc9
DerekSomerville/FakePythonGuessNumber
/src/main/test/RandomInputTest.py
254
3.71875
4
import unittest from src.main.python.RandomInput import RandomInput class RandomInputTest(unittest.TestCase): def testGet(self): randomInput = RandomInput() self.assertTrue(randomInput.getInputInt("") <= randomInput.getMaxNumber())
385c852ea3fcbafe34205fd8e048c1f8235cb77a
Hiroki9759/learning-tensorflow
/session.py
925
3.609375
4
"""sessionは演算グラフの実行単位のようなもの 構成した演算グラフはSession内で実行することとなり、同一のグラフでもSessionが異なれば別の環境としてみなされる このため、Sessionを別にするグラフ間のVariableの値の共有などは行われない """ import tensorflow as tf #変数の定義 counter = tf.Variable(0,name = "counter") step_size = tf.constant(1,name = "step_size") #現在のCOUNTERにstep_sizeを足す increment_op = tf.add(count...
f36cb9863dd96dbf1dfebcc837c8aec18de33967
LXXJONGEUN/Graduation_Project
/web/crypto/RSA2.py
1,398
4.125
4
def gcd(a, b): while b!=0: a, b = b, a%b return a def encrypt(pk, plaintext): key, n = pk cipher = [(ord(char) ** key) % n for char in plaintext] return cipher def decrypt(pk, ciphertext): key, n = pk plain = [chr((char ** key) % n) for char in ciphertext] return ''.join(plain)...
2a37ea50a90ccd9bea92ec07095715f269de7734
Fareshamad/AI
/formatief opdracht/FizzBuzz.py
647
4.03125
4
"""Schrijf een programma dat de getallen 1 tot 100 print, maar print voor veelvouden van drie “fizz” in plaats van het getal en voor veelvouden van vijf print “buzz” in plaats van het getal. Getallen die zowel veelvoud zijn van drie als van vijf worden afgedrukt als “fizzbuzz”""" def FizzBuzz(): for fizzbuzz in r...
bfc716c11ce00d081cb9866d4f38dafabe37cca3
SvjatN/Codewars5
/CodeWarsT19.py
527
4.0625
4
""" Given a string, you have to return a string in which each character (case-sensitive) is repeated once. double_char("String") ==> "SSttrriinngg" double_char("Hello World") ==> "HHeelllloo WWoorrlldd" double_char("1234!_ ") ==> "11223344!!__ " """ def double_char(s): s = list(s) res_list = [] re...
c71bf3f81c3d747b871dfdd4028780085c0356af
AgustGreen/mi_primer_programa
/PokemonCombat.py
1,203
3.953125
4
sel_pokemon = input("contra que pokemon quieres combatir?: (Squirtle / Bulbasaur / Charmander): ") pikachu_hp = 100 enemy_hp = 0 enemy_atk = 0 if sel_pokemon == "Squirtle": enemy_hp = 90 pokemon_name = "Squirtle" enemy_atk = 8 elif sel_pokemon == "Bulbasaur": enemy_hp = 100 pokemon_name = "Bulbasa...
351bfe9883d4b7a1f5b55d191fdbfb6845b6f5e4
AgustGreen/mi_primer_programa
/guess.py
649
3.765625
4
number_guess = 2 user_number = int(input("adivina un numero del 1 al 10 (tienes 3 intentos): ")) if number_guess == user_number: print("has ganado!") elif number_guess != user_number: print("has perdido, reintenta") user_number = int(input("adivina un numero del 1 al 10 (tienes 2 intentos): ")) if number_g...
dfe42d63885c79a64f88d2e15288c107b0926346
mateuspinto/presto
/src/Memories/AbstractMemory.py
1,158
3.640625
4
import abc class AbstractMemory(metaclass=abc.ABCMeta): @abc.abstractmethod def appendProcess(self, pid: int, numberOfVariables: int, processTable, diagnostics) -> int: """ Append a new process and return the memory offset. """ pass @abc.abstractmethod def name(self) ...
5df9bc71268dd9b6c126886c70dce8b0c265a9a7
MissouriMRR/IARC-2019
/flight/tasks/yaw_task.py
1,890
3.8125
4
"""A TaskBase subclass for yawing a amount in degrees.""" from constants import YAW_SPEED from task_base import TaskBase DEGREE_BUFFER = .5 #acceptable error of angle in degrees class Yaw(TaskBase): """ A task to make the drone yaw to a given heading either relative or absolute. Attributes ---------...
2c0dc75b0b88a02ecec2cc27fafdbcd752ddfcdf
MissouriMRR/IARC-2019
/flight/utils/timer.py
2,401
3.9375
4
""""A class that allows for the execution of arbitrary code at set intervals.""" from time import sleep from timeit import default_timer as timer import threading class Timer(): """ Runs code as specified intervals. """ def __init__(self): self._event_threads = [] self._stop_event_map = {} ...
58766b4143459df54f7610db86ca0fa11574af2d
annikaslund/python_practice
/python-fundamentals/48-last_argument/test.py
670
3.671875
4
import unittest # Click to add an import from last_argument import last_argument class UnitTests(unittest.TestCase): def test_input_1(self): # Failure message: # expected last_arguments(1, 2, 3) to be 3 self.assertEqual(last_argument(1, 2, 3), 3) def test_input_2(self): # Fa...
b0daf15869f65fe5058919cfc3095a854059defc
annikaslund/python_practice
/python-fundamentals/18-sum_even_values/test.py
651
3.5625
4
import unittest # Click to add an import from sum_even_values import sum_even_values class UnitTests(unittest.TestCase): def test_input_1(self): # Failure message: # expected sum_even_values([1, 2, 3, 4, 5, 6]) to equal 12 self.assertEqual(sum_even_values([1, 2, 3, 4, 5, 6]), 12) de...
bae6be57308a63bc6063b9e76bd9117bf9f00a7e
annikaslund/python_practice
/python-fundamentals/01-product/product.py
97
3.5
4
def product(a, b): """ takes in two integers and returns the product """ return a * b
5903073956c3a4f5b7e47cf23da710a354ea43ec
annikaslund/python_practice
/python-fundamentals/07-list_manipulation/test.py
2,193
3.953125
4
import unittest # Click to add an import from list_manipulation import list_manipulation class UnitTests(unittest.TestCase): def test_remove_from_end(self): # Failure message: # expected list_manipulation([1, 2, 3], "remove", "end") to equal 3 self.assertEqual(list_manipulation([1, 2, 3]...
28395516a71b1f5c50480ef3274bd2cfb9bd83ff
annikaslund/python_practice
/python-fundamentals/46-three_odd_numbers/solution.py
203
4.0625
4
def three_odd_numbers(nums): """Are any 3 seq numbers odd?""" for i in range(len(nums) - 2): if (nums[i] + nums[i + 1] + nums[i + 2]) % 2 != 0: return True return False
e8cf2f63f38c417981c670689bbb649ccb1f296d
annikaslund/python_practice
/python-fundamentals/04-number_compare/number_compare.py
301
4.15625
4
def number_compare(num1, num2): """ takes in two numbers and returns a string indicating how the numbers compare to each other. """ if num1 > num2: return "First is greater" elif num2 > num1: return "Second is greater" else: return "Numbers are equal"
42c723406fb4e8e3fd00dd2a0f2f2aeb2a283f2a
annikaslund/python_practice
/python-fundamentals/10-flip_case/test.py
500
3.515625
4
import unittest # Click to add an import from flip_case import flip_case class UnitTests(unittest.TestCase): def test_input_1(self): # Failure message: # expected flip_case("Hardy har har", "h") to equal "hardy Har Har" self.assertEqual(flip_case("Hardy har har", "h"), "hardy Har Har") ...
91e08c304bdf2dcade4f00ad513711d7cadde116
annikaslund/python_practice
/python-fundamentals/18-sum_even_values/sum_even_values.py
235
4.15625
4
def sum_even_values(li): """ sums even values in list and returns sum """ total = 0 for num in li: if num % 2 == 0: total += num return total # return sum([num for num in li if num % 2 == 0])
a210057a9ea3677c6b80d6dd5bef785f59d30c28
annikaslund/python_practice
/python-fundamentals/17-calculate/calculate.py
450
3.828125
4
def calculate(op, first, second, make_int=False, msg="Success!"): if op == "add": addition = first + second string_sum = f" {addition}" return msg + string_sum if op == "subtract": subtraction = first - second string_diff = f" {subtraction}" return msg + string_di...
53b0e25540a35c7f25d239582ec7b91437efcea9
annikaslund/python_practice
/python-fundamentals/44-is_odd_string/test.py
963
3.71875
4
import unittest # Click to add an import from is_odd_string import is_odd_string class UnitTests(unittest.TestCase): def test_input_1(self): # Failure message: # expected is_odd_string('a') to equal True self.assertEqual(is_odd_string('a'), True) def test_input_2(self): # Fail...
55064e1933108b59cef7f8ef68c1377c37cd1f0d
samhorsfield96/graph_benchmarking
/gfa_to_fasta.py
529
3.578125
4
def gfa_to_fasta(in_file): """Converts .gfa file to .fasta, using same file name. Args: in_file (str) path for .gfa file to convert. """ base = os.path.splitext(in_file)[0] out_file = base + ".fasta" with open(in_file, "r") as f, open(out_file, "w") as o: f...
09e9772ec25fde7fefacc52d531c195e5fe0b2ff
Davies-Career-and-Technical-High-School/2-1-activity-basic-calculations-JermsterOrtega
/question1.py
77
3.953125
4
num = int(input("Enter a integer: ")) print(num+1) print(num+2) print(num+3)
4a7ae8be053783e401d5bc5cfe999efb4fe5a066
ElinaBarabas/Graph-Algorithms
/Laboratory 4/main.py
4,497
3.828125
4
import random # Write a program that, given an undirected connected graph, constructs # a minumal spanning tree using the Kruskal's algorithm. class UndirectedGraph: def __init__(self, n, m): self._n = n self._m = m self._vertices_list = [] self._cost_dictionary = {} ...
2f31f5055102830f31addc93e260ab4987aa08b9
sumukh31/Algos_DS
/arrays/missing_element.py
339
4.03125
4
import collections def missing_element(arr1,arr2): count = collections.defaultdict(int) for num in arr2: count[num] += 1 for num in arr1: if count[num] == 0: return num else: count[num] -= 1 arr1 = [1,2,3,3] arr2 = [1,2,3] missing = missing_element(arr1,arr...
9787de1d538f6bd0ebd744120567261116825ee7
minkookBae/algorithm_prac
/BOJ_4344.py
500
3.703125
4
import sys def avg(N,target_list): temp = sum(target_list) avg_list = temp / N return avg_list q = lambda : list(map(int,sys.stdin.readline().split())) C = int(sys.stdin.readline()) for i in range(C): count = 0 target_list = q() N = target_list[0] target_list = target_list[1:] ...
32136afe9ae4dcc40002f5af0760f209c7af7beb
minkookBae/algorithm_prac
/BOJ_2110.py
667
3.6875
4
import sys def routerInstall(distance): count = 1 cur_home = target_list[0] for i in range(1,N): if (distance <= target_list[i] - cur_home): count += 1 cur_home = target_list[i] return count N, C = list(map(int,sys.stdin.readline().split())) target_list = [] for ...
a77f55dd11890ba5c479d4c2a9c2daeab0da9b1c
minkookBae/algorithm_prac
/BOJ_9020.py
595
3.515625
4
import sys def prime_list(n): sieve = [True] * n m = int(n ** 0.5) for i in range(2, m + 1): if sieve[i] == True: # i가 소수인 경우 for j in range(i+i, n, i): # i이후 i의 배수들을 False 판정 sieve[j] = False # 소수 목록 산출 return [i for i in range(2, n) if sieve[i] == ...
4eed14ed9ab6d37d0cd52297cf316ab42386072c
minkookBae/algorithm_prac
/탑.py
420
3.65625
4
def solution(heights): answer = [0 for _ in range(len(heights))] for i in range(len(heights)-1,-1,-1): flag = False for j in range(i-1,-1,-1): if(heights[i] < heights[j]): flag = True answer[i] = j+1 break ret...
1bed83194912d27581e2a8485d12f8835fcf7f5d
zewa1999/PythonExamples
/1/Cursul 1/26. CheileDictionarului.py
897
4
4
# Un dictionar poate fi format din mai multe chei si valori # O valoare nu poate exista fara o cheie dictionar = { "cheie" : "valoare" } # Practic cheia este elementul cu care accesam valoarea # Dar o cheie poate fi doar de tipul string? # Hai sa vedem dictionar2 = { 1 : "valoare", True : "alta valoare"...
2a8cac67a41ef3373963129190c540fb2fd1b70e
zewa1999/PythonExamples
/1/Cursul 1/30. FunctiSet.py
1,156
3.515625
4
# De decomentat daca doresti sa vezi ce fac functiile setul_meu = {1, 2, 3, 4, 5} setul_tau = {4, 5, 6, 7, 8, 8, 9} # Diferenta dintre setul_meu si setul_tau. Ce se afla in setul meu si nu se afla in setul tau. Returneaza un nou set # set_nou = setul_meu.difference(setul_tau) # print(set_nou) # Stergerea unui element...
a248e88ef3202892eb8e8109174aa6f04768cde2
zewa1999/PythonExamples
/1/Cursul 2/23. FunctiivsMetode.py
438
3.984375
4
# metodele sunt cele ce sunt determinate de un tip de date # EX: string = "andreea" print(string.capitalize()) # Face prima litera a propozitiei una mare # .capitalize este determinata de un string, practic metodele sunt cele care vin cu un punct dupa tipul de date # Forma: tip_date.metoda() # Functiile sunt cele ce ...
86bd5e64245d9f3fb7d87810b84a076ecc0ff6e5
zewa1999/PythonExamples
/1/Cursul 2/5. OperatoriLogici.py
724
4.03125
4
# Urmatorii sunt operatori logici: # and, or, not, >, <, ==, >=, <=, != # Exemple: print(4>5) print(4<5) print(4 == 5) print("salut" == "salut") print('a' > 'b') # False print('a' > 'A') # True print(5>=5) print(5<=6) print(0 != 0) # != inseamna nu e egal print(not True) # negatie # Ultimele 2 valori afiseaza rezultat...
922ee381b05ee6b59b2c933a86ba65a1be7894ea
zewa1999/PythonExamples
/1/Cursul 2/2. TruthyVSFalsey.py
1,145
3.859375
4
# Atunci cand folosim un if, avem nevoie de valori booleene pentru a putea rula if-ul # De aceea Python, face conversie la bool in ciuda faptului ca poate variabila noastra este una de tip string # Exemplu: am_mancat = "Da, am mancat" # Daca afisam aceasta variabila, dupa ce am facut conversia la bool, am_mancat v-a ...
e049fe76f4ada3de64bd80d79c162137bf4bc9ed
TigranShukuryan/gittest.1
/github_test.py
471
3.578125
4
class Money: def __init__(self, amount, currency, amount_2): self.amount_1 = amount self.currency_1 = currency self.amount_second = amount_2 def __repr__(self): return str(self.amount_1) + " " + self.currency_1 def represetation(self): return str(self.amount_1 - self....
623ffe41f56ba094c9e3fd741aff49cd384b49ba
fyngyrz/wtfm
/aa_formboiler.py
12,217
3.640625
4
# # Contains routines to make building and reading forms much simpler # ----------------------------------------------------------------- import time import re months = ['Jan','Feb','Mar','Aprl','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] fmonths = ['January','February','March','April','May','June','July','Augus...
3788f9f7ebbc70b497996b8c77512844a3181bb2
allanfarrell/deakin
/SIT210-Task5.3D-Morse_GUI/morse_gui.py
1,118
3.828125
4
from tkinter import * import tkinter.font import RPi.GPIO as GPIO import morse_code as MC ## Configure pins redPin = 11 # Set configuration to use board pin numbers GPIO.setmode(GPIO.BOARD) GPIO.setup(redPin, GPIO.OUT) # Turn off all lights to start - Not sure why light turns on at start up GPIO.output(redPin, GPI...
46b72c59b9ac526ec066b5be7527d51a212a7647
graemediack/uni-project-networks
/PlotDegreeDist.py
3,955
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 12 22:39:26 2018 @author: graeme """ #function to create some informative plots def plot_graph(G): degree_sequence = sorted([d for n, d in G.degree()], reverse=True) degreeCount = collections.Counter(degree_sequence) deg, cnt = zip(*sorted(de...
53f32a2d944edc230c91dcee9f2fa3f7f7a195e8
denis-nuzhdin/dntest3
/test/lesson7.2.py
2,369
3.796875
4
import sys def open_file(file_name,mode): """открываем файл""" try: the_file = open(file_name,mode,encoding='utf-8') except IOError as e: print("Не возможно открыть файл: ", file_name) sys.exit() else: return the_file def next_line(the_file): """возвращает в формати...
ead524f4ffa1480cbc084a49a8541ece1aab8221
denis-nuzhdin/dntest3
/test/lesson3.1.py
1,100
3.8125
4
#глава №3, страница 103, игра Отгадай число, задание номер 4 import random NUMBER_MIN = 1 NUMBER_MAX = 100 NUMBER = 1 #guess = int(input("num: ")) def ask_number(question): """просит ввести число из диапазона""" responce = None while responce not in range(NUMBER_MIN,NUMBER_MAX): responce = i...
a6cb989bcfb96258bbd2e6213971b1336118e89a
denis-nuzhdin/dntest3
/test/lesson5.6.py
1,711
4.0625
4
#Задание из главы №5 "Кто твой папа" family = {"Олег": {"отец":"Александр", "дед":"Петр"}, "Дмитрий":{"отец": "Михаил", "дед":"Степан"} } choice=None sun="" father="" grandfather="" #sun = input("Имя: ") #print(sun) #print("Дед: ",family[sun]["дед"]) #print("Отец: ",family[sun]["отец"]) while c...
cd0ebfb58d975a582aca3a4eb620eb3b84933e93
roostercrab/CIT104-Python-Answers
/H1P2.py
99
4
4
miles = int(input("Miles? ")) kilometers = miles * 1.609 print(str(kilometers) + " kilometers")
bcd734f683d2951423faf6b1e4324560588dcf30
randomInteger/pytail
/pytail.py
1,566
3.671875
4
#!/usr/bin/env python3 #pytail.py #Very simple tail implementation in python3 #Author: Christopher Gleeson, April 2018 #Note: Need a big enough test file? try: seq 1 100000 > ./file.txt import os import sys #buffer as much as two blocks block_size = 4096 buffer_size = 2 * block_size #This is not great input argu...
82d9c3e50df8a8d0c41a666a0d49ec3e8d025caa
HasibulKabir/MindBot
/mindbot/command/nasa/asteroid.py
2,119
3.609375
4
""" This module provides methods to send user information about closest o Earth asteroids. Powered by https://api.nasa.gov/ User will receive information about 5 closest to Earth asteroids for the current day as well as links for this objects for further reading. API KEY is required. It is free af...
7c96e216dfa09a1efc87ceb204f183e6fb26ac5f
yh97yhyh/ProblemSolving
/backjoon/string/5622.py
296
3.515625
4
''' 다이얼 ''' import sys dials = ['', '', '', 'ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PQRS', 'TUV', 'WXYZ'] string = list(sys.stdin.readline()) sum = 0 for s in string: for d in dials[3:]: if d.find(s) != -1: # print(d, s) sum += dials.index(d) print(sum)
723ea14adc540758ec56aa7432fb55f78f475c96
yh97yhyh/ProblemSolving
/programmers/concept/topology_sort.py
681
3.875
4
from collections import defaultdict adjacency_list = defaultdict() adjacency_list['a'] = ['d'] adjacency_list['b'] = ['d'] adjacency_list['c'] = ['e'] adjacency_list['d'] = ['e'] adjacency_list['e'] = [] visited_list = defaultdict() visited_list['a'] = False visited_list['b'] = False visited_list['c'] = False visit...
4b54aab527e56e694b57aadedfe4211a15a2522e
yh97yhyh/ProblemSolving
/backjoon/brute-force/1436.py
375
3.53125
4
''' 영화감독 숌 ''' import sys n = int(sys.stdin.readline()) number = 666 while(n): if '666' in str(number): n -= 1 number += 1 print(number-1) ''' n = 2일 때, number의 값은 while문에서 666부터 증가 number = 666이니 n은 -1로 인해 1이 됨. number은 667부터 1씩 증가하고 1666일 때, n은 0이 되어 while문이 종료. '''
951fb7af4c39b6698773d327937459e996c8c060
yh97yhyh/ProblemSolving
/backjoon/sort/2750.py
177
3.5625
4
''' 수 정렬하기 ''' import sys n = int(sys.stdin.readline()) arr = [] for i in range(n): arr.append(int(sys.stdin.readline())) arr.sort() for a in arr: print(a)
26b3afe644c821827a9a9e43e651f54a397d4e4a
yh97yhyh/ProblemSolving
/programmers/kit/stack_queue01.py
1,088
3.53125
4
''' < 주식가격 > 초 단위로 기록된 주식가격이 담긴 배열 prices가 매개변수로 주어질 때, 가격이 떨어지지 않은 기간은 몇 초인지를 return 하도록 solution 함수를 완성하세요. - prices의 각 가격은 1 이상 10,000 이하인 자연수입니다. - prices의 길이는 2 이상 100,000 이하입니다. ''' p1 = [1, 2, 3, 2, 3] p2 = [1, 2, 3, 2, 3, 1] p3 = [3, 1] # 효율성 테스트 실패 def solution(prices): answer = [] for i in range(le...
8568ecd1d95b32939869851a50f6bc0b4423f9cf
yh97yhyh/ProblemSolving
/programmers/level1/level1_01.py
934
3.5
4
''' < 체육복 > ''' n1, n2, n3 = 5, 5, 3 lost1, lost2, lost3 = [2, 4], [2, 4], [3] reserve1, reserve2, reserve3 = [1, 3, 5], [3], [1] # 오답 # def solution2(n, lost, reserve): # lend = [] # reserve = list(set(reserve) - set(lost)) # lost = list(set(lost) - set(reserve)) # for i in range(len(reserve)): # ...
a074ed0760295869373910a70a65e12876b9af6b
qq20004604/publish-article-with-tags
/server_python/libs/printcolor_lingling/__init__.py
1,321
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 红色背景 def print_red(str): print("\033[0;37;41m" + str + "\033[0m") # 绿色背景 def print_green(str): print("\033[0;37;42m" + str + "\033[0m") # 白色背景 def print_normal(str): print(str) # 根据测试结果输出 # list形式是可变参数,至少2个参数,否则为错误 # 最后一个参数是一个字符串 # 之前的参数应当都是 True。如果至少有...
6cd5e54c3fd9774d1cc2c7c3661c4c4b891c4e2a
uditiarora/CG-Lab
/lab1/line.py
545
3.5
4
import transform from graphics import * import time def putPixle(win, x, y): pt = Point(x,y) pt.draw(win) def drawLine(coords,x1,y1,x2,y2): x3,y3 = transform.transformPoint(coords,x1,y1) x4,y4 = transform.transformPoint(coords,x2,y2) win = GraphWin("Line") dx = x4-x3 dy = y4-y3 m = 2*dy err = m - dx ...
36e5c1c8fe5533f16dccd4b3600b871264aa72f8
keniel123/netcentric
/server3 real.py
7,452
4.125
4
# Server to implement simplified RSA algorithm. # The server waits for the client to say Hello. Once the client says hello, # the server sends the client a public key. The client uses the public key to # send a session key with confidentiality to the server. The server then sends # a nonce (number used once) to the cl...
3dde83c6e5f6a9f36dfe90f34f39f654304a45b9
jstockbot/jstock
/com/javamix/samples/fibonacci2.py
261
4.09375
4
dictionary = { 1:1, 2:1 } def fibonacci(n): if n in dictionary: return dictionary[n] else: output = fibonacci(n-1) + fibonacci(n-2) dictionary[n] = output return output print("value = {}".format(fibonacci(100)))
1ed2bf08a8167cb744fe9e298e0c130f515ee7d7
jstockbot/jstock
/com/javamix/samples/fibonacci.py
332
3.890625
4
counter = 0 def fibonacci(n) : print("fibonacci({})를 구합니다.".format(n)) global counter counter += 1 if n == 1 : return 1 if n == 2 : return 1 else : return fibonacci(n-1) + fibonacci(n-2) print("value = {}".format(fibonacci(10))) print("덧셈 횟수는 {}".format(counter))
575bb55c33213cb0a1f87ace4fc25753deacba1f
rajgaur98/facedetection
/Facedetect.py
1,462
3.625
4
import cv2 from tkinter import * def fd(): face_cascade = cv2.CascadeClassifier( "C:\\Users\\Gaur\\PycharmProjects\\miniproject\\venv\\Lib\\site-packages\\cv2\\data\\haarcascade_frontalface_alt2.xml") video = cv2.VideoCapture(0) a = 1 while True: check, frame = video....
75d031db7791b051136953a715b4d01876541f4c
n00blet/Project_Euler
/6_SqarDiffernce.py
559
3.859375
4
""" The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640. F...
9b8690aa821b1a1c78d519446248b7257acadec0
pola5pola5/edu90_python
/atcoder002.py
1,537
3.5
4
""" 長さ N の正しいカッコ列をすべて、辞書順に出力してください。 ただし、正しいカッコ列は次のように定義されています : () は正しいカッコ列である S が正しいカッコ列であるとき、文字列 ( +S+ ) は正しいカッコ列である S,T が正しいカッコ列であるとき、文字列 S+Tは正しいカッコ列である それ以外の文字列はすべて、正しいカッコ列でない 4 ()() (()) """ # 小さい制約は全探索 # 二進数に置き換える(bit全探索) # ・(と)の数が同じ # ・全てのiについて左からi文字目までの時点で(の数が)の数以上 # 上記2点を満たすのが必要十分 def hantei(S: str) -> boo...
5782821de302c085dbfd6b3c50c3ec64e581d75f
danrongLi/Advent_of_Code_2020
/Day1/code.py
652
3.515625
4
def readFile() -> list: with open(f"{__file__.rstrip('code.py')}input.txt", "r") as f: # return f.readlines() return [int(line[:-1]) for line in f.readlines()] def part1(vals: list) -> int: for val in vals: if (2020 - val) in vals: return (2020 - val) * val def part2(vals: ...
b39ff4287ef2b0ea8b5ae0ef2a37de198c1a8c91
neonua/Python-Is-Easy-Homeworks
/homework_4_lists.py
1,096
4.0625
4
""" This file describes work with lists """ # Defining lists myUniqueList = [] myLeftovers = [] def append(item): """ Appends item to myUniqueList. If can't - appends item to myLeftovers. """ print(f'Appending {item} ...') # Check if item already in myUniqueList if item in myUniqueList: ...
3873bfded71a3f3ab53374deaab5e7c455d23b7e
CyanYoung/english_chinese_translate
/util.py
356
3.5
4
def load_word(path): words = list() with open(path, 'r') as f: for line in f: words.append(line.strip()) return words def load_word_re(path): words = load_word(path) return '(' + ')|('.join(words) + ')' def map_item(name, items): if name in items: return items[nam...
a8da1d0e0461f15604e9f61b2d7e6b73455bca4e
tobias290/Converter
/helpers.py
1,902
3.921875
4
from typing import Union def set_to_middle(screen_width: Union[int, float], widget_width: Union[int, float]) -> Union[int, float]: """ Gets the value for a widget to be centred :param screen_width: Width of the screen currently :param widget_width: Width of the widget :return: Returns the ...
8f1286d5ffa06aa47f11df2902ccee51e55247f6
19doughertyjoseph/josephdougherty-python
/UnitLab321/Unit321Lab.py
1,384
4.0625
4
def main(): numlist1 = (93.4, 92.5, 93.5, 85.6, 98.9) gradeIn = input('What grade are you in -?') grade1 = getYearInSchool(gradeIn) print('you are a ' + str(grade1)) percent = calcAverageGrade() print('your average grade is ' + str(percent)) grade = getLetterGrade(int(percent)) print('Yo...
884bed1132eb119bee2605c4c79982fbb4c38a93
19doughertyjoseph/josephdougherty-python
/UnitLab4B/Unit Lab 4B.py
313
3.59375
4
for i in range(0,5): print(i) answer=(i+10) skrt= (i*10) print("pause") print( str(i) + "+ 10 =" + str(answer)) print( str(i) + "*10 =" + str(skrt)) print("pause") myList= [10,20,30,40,50] print(myList) for a in range(0, len(myList)): myList[a]=myList[a] *10 print(myList)
4a5ffb428059845f0761201c602942bb964f0e55
19doughertyjoseph/josephdougherty-python
/TurtleProject/Turtle Project.py
939
4.125
4
import turtle turtle.setup(width=750, height=750) pen = turtle.Pen() pen.speed(200) black_color = (0.0, 0.0, 0.0) white_color = (1.0, 1.0, 1.0) red_color = (1.0, 0.0, 0.0) green_color = (0.0, 1.0, 0.0) blue_color = (0.0, 0.0, 1.0) def basicLine(): moveTo(-50, 0) pen.forward(100) #The origin on the screen ...
0ed3044556e7faa1464a480dbe0550b2a22e20c5
leobyeon/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
360
4.28125
4
#!/usr/bin/python3 def append_write(filename="", text=""): """ appends a string at the end of a text file and returns the number of chars added """ charCount = 0 with open(filename, "a+", encoding="utf-8") as myFile: for i in text: charCount += 1 myFile.write(i) ...
782aaed5b483e43ad662f142a885ea19158f2daa
leobyeon/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-read_lines.py
563
4.0625
4
#!/usr/bin/python3 def read_lines(filename="", nb_lines=0): """reads n lines of a text file and prints""" with open(filename, encoding="utf-8") as myFile: linecount = 0 for line in myFile: linecount += 1 myFile.close() with open(filename, encoding="utf-8") as myFile: ...
3350a3f4eb39496974b03fb5df9f49e9dcfbf3e2
leobyeon/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
749
3.953125
4
#!/usr/bin/python3 def matrix_divided(matrix, div): """function divides a matrix""" if ((type(matrix) is not list) or (not all(type(row) is list for row in matrix)) or (not all( type(i) in (float, int) for row in matrix for i in row))): raise TypeError("matrix mu...
1eb07317c0bc8e108a32ab5feb0cdf2c47c33940
leobyeon/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/square.py
1,575
3.6875
4
#!/usr/bin/python3 """rectangle module""" from models.rectangle import Rectangle class Square(Rectangle): """define Square class""" def __init__(self, size, x=0, y=0, id=None): """initialize""" super().__init__(size, size, x, y, id) def __str__(self): """override the default str"...
67c976bd994bb5772e1bbdf3b525c39e9834fefe
OliverSieweke/titanic
/notebooks/model_simon/feature_engineering.py
2,389
3.5625
4
import pandas as pd import numpy as np def name_titles(df, title_list): ''' input: df, cutoff=12 Creates a binary column indicating whether passenger's name contains a certain string (one column per string provided). Based on Name column, removes said column. output: df ''' for title...
2e140bf2f365bcd2c734cb689f44555b9c5de870
Nipuncp/lyceaum
/lpthw/ex9.py
372
3.515625
4
#Here is some new strange stuff, remember type it exactly. days = "Mon Tue Wed Thu Fri Sat Sun" months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJuly\nAug" print("Here are the days:", days) print("Here are the months:", months) print(""" There is something going on here With the three double quotes We'll be able to type as m...
828a52fcf979bb4c8dc3793babbfcf41a71efa2b
Nipuncp/lyceaum
/lpthw/ex3.py
479
4.25
4
print ("I'll now count my chickens") print ("Hens:", 25 +30 / 6) print ("Roosters", 100-25 *3%4) print ("I'll now count the eggs:") print (3 +2 + 1 - 5 + 4 % 2-1 % 4 + 6) print ("Is it true that 3 + 2 < 5 - 7") print (3 + 2 < 5 -7) print ("What is 3 + 2", 3 + 2) print ("What is 5 - 7", 5 - 7) print ("THat is why, it is...
7ce43b9da0bc4c37b8f50d464c3ab1bf8f3e1550
FullStackPark/Python
/demo/004.py
502
3.75
4
#!/bin/python3 import re def get_word_frequencies(file_name): dic = {} txt = open(file_name, 'r').read().splitlines() no_flag=0 for line in txt: line = re.sub(r'[.?!,""/\W]', ' ', line) for word in line.split(): if word.isdigit(): pass else:...
fefe99ae80decc1c40885d81430a651ddbcd3541
anupam-newgen/my-python-doodling
/calculator.py
281
4.15625
4
print('Add 2 with 2 = ', (2 + 2)) print('Subtract 2 from 2 = ', (2 - 2)) print('Multiply 2 with 2 = ', (2 * 2)) print('2 raise to the power 2 = ', (2 ** 2)) print('2 divide by 2 = ', (2 / 2)) # This is a comment. # You can use above concept to solve complex equations as well.
1fec6ac5c98bcac8bff0fc97d37cf7846021a0b8
MathBosco/exPython
/Ex014.py
293
4.375
4
#Enunciado: # Escreva um programa que converta uma temperatura digitando em graus Celsius e converta para graus Fahrenheit. celsius = float(input('Insira a temperatura em grau Celsius: ')) fahrenheit = (celsius * 9/5) + 32 print('A temperatura em Fahrenheit é: {} °F'.format(fahrenheit))
c8ae0a53f5a5c60bbe9422c3b8d2f2c71732dd8f
MathBosco/exPython
/Ex010.py
434
4.03125
4
#Enunciado #Crie um programa que leia quanto dinheiro uma pessoa tem na carteira e mostre quantos dólares ela pode comprar. dinheiro = float(input('Qual o valor que você possui na sua carteira? R$ ')) dolares = dinheiro / 5.41 euro = dinheiro / 6.60 print('Com o valor de R${:.2f} você poderá comprar U${:.2f}'.forma...
7e69eebfecf375005e7f365a3fb8e2ae1941e792
MarcosDihl/corretaza-buscador
/seucorretor/crm/utils.py
791
3.546875
4
# -*- coding: utf-8 -*- from __future__ import unicode_literals from __future__ import absolute_import INVALID_PHONE_CHARS = "()-+." def formata_fone(fone): """ retorna o numero de telefone visualmente melhor para leitura """ if len(fone) == 11: return "(%s) %s %s-%s" % (fone[:2], fone[2:3], fone[3:7...
4fe4a7775fb251e2f7ad3bc0fa8ea490df5066b3
gurudattshenoy/python_guru
/datastructures/searchtechniques/binary_search.py
670
3.9375
4
def binary_search(input:'List',key:'int')->'int': print("The input is : {} and key to search is : {}".format(input,key)) left = 0 right = len(input) - 1 result = -1 while(left <= right): mid = (left + right) //2 if input[mid] == key: result = mid break ...
fd4002dc1278567eca851cf908ccbbe31432fa3f
ramankala/a3_kong9580_kala9110
/startA3/Node.py
1,894
3.75
4
#CP372 Assignment 3 #Raman Kala: 120869110 #Ricky Kong: 180659580 from common import * class Node: def __init__(self, ID, networksimulator, costs): self.myID = ID self.ns = networksimulator num = self.ns.NUM_NODES self.distanceTable = [[0 for i in range(num)] for j in range(num)] ...
a779e15cf7b615cc8b6d3e1adc6a421ba5b2d50a
kalexanderk/GenomeAnalysis
/MinimumSkewProblem.py
670
3.734375
4
def SkewDiagram(text): skew = [] skew.append(0) count = 0 for i in text: if i == "G": skew.append(skew[count] + 1) elif i == "C": skew.append(skew[count] - 1) else: skew.append(skew[count]) count += 1 print skew return skew def...
107615912f6e0ce5b41d70057e3016a912c84973
anoopm031/Box_ball_git
/test2.py
3,811
3.515625
4
from Box_Ball import * from psuedo_box import * def populate_psuedo_box_list(box_agent_list): "creating psuedo box objects-should return a list with psuedo box agents" temp_psuedo=[] for box in box_agent_list: psuedo=Psuedo_box(box.name,box.position,(box.x_vel,box.y_vel,box.z_vel),(box.x_acc,box.y_...
3755f30fe7d962aa723c06c8e24df3a46ca91410
selva86/python
/exercises/concept/little-sisters-essay/.meta/exemplar.py
1,085
4.09375
4
def capitalize_title(title): """ :param title: str title string that needs title casing :return: str title string in title case (first letters capitalized) """ return title.title() def check_sentence_ending(sentence): """ :param sentence: str a sentence to check. :return: bool Tru...
4df2e2270df04452ca0403b08547f2bebad70504
selva86/python
/exercises/concept/guidos-gorgeous-lasagna/.meta/exemplar.py
1,640
4.28125
4
# time the lasagna should be in the oven according to the cookbook. EXPECTED_BAKE_TIME = 40 PREPARATION_TIME = 2 def bake_time_remaining(elapsed_bake_time): """Calculate the bake time remaining. :param elapsed_bake_time: int baking time already elapsed :return: int remaining bake time (in minutes) derived ...