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
6a3ca57e16621b671baeb4343ed1a82c6da2f4c9
jonathanjaimes/python
/5.7_perimetro.py
1,564
4.15625
4
#En esta primera función se ingresan los datos necesarios. def tomaDatos(): punto1 = input("Ingrese el nombre del primer punto: ") x1 = float(input(f"Ingrese la primera coordenada del punto {punto1}: ")) y1 = float(input(f"Ingres la segunda coordenada del punto {punto1}: ")) punto2 = input("Ingrese el nomb...
b4ed4d187853b59aea9b3aa0bb7b8197f306dabe
jonathanjaimes/python
/6.17_sumaDiagonales.py
1,075
3.890625
4
matriz = [] orden = int(input("Introduce el orden de la matriz: ")) for f in range(orden): matriz.append([]) for c in range(orden): dato = int(input(f"Introduce el número para la celda ({f}, {c}): ")) matriz[f].append(dato) for f in matriz: print(f) c = 0 f = 0 suma = ...
2f9be3d2f474908ae077cdb325ddf5c9f8f09898
jonathanjaimes/python
/7_TresIntervalos.py
1,805
4.0625
4
def tresIntervalor(): a = float(input("Por favor, ingrese el valor mínimo del primer intervalo: ")) b = float(input("Por favor, ingrese el valor máximo del primer intervalo: ")) c = float(input("Por favor, ingrese el valor mínimo del segundo intervalo: ")) d = float(input("Por favor, ing...
07e76226c166157c31a0b08a1aeac34e9a8789ff
jonathanjaimes/python
/14_ejerciciosFinalCapitulo_caminata.py
1,012
3.828125
4
mayor = 0 menor = 9999 for mes in range(1, 5): print(f"Mes {mes}") sumaPromSemana = 0 sumaDiasMes = 0 for semana in range(1, 5): print(f"Semana {semana}") sumaDias = 0 diasCaminataTrue = 0 for dia in range(1, 8): tiempoDia = int(input(f"Ingrese el tiempo de caminata en minutos para el ...
b575ffad5a48efdc7f7275fb8f7ba0b283c43d13
jonathanjaimes/python
/7_FinalCapVecMat_recorridoMatriz.py
402
3.890625
4
orden = 5 matriz = [] for f in range(orden): matriz.append([]) for c in range(orden): numero = int(input(f"Ingrese el número de la celda ({f}, {c}): ")) matriz[f].append(numero) for i in matriz: print(i) """ matriz = [[1,2,3], [4,5,6], [7,8,9]] for i in matriz: print(i) """ for c i...
22899419fcc57ed2b40a558cd800e43f8fb013a2
jonathanjaimes/python
/6_ejerciciosFinalCapitulo_multiplos3.py
156
4.03125
4
while True: n = int(input("Ingrese la cantidad de terminos mayor a 6: ")) if n > 6: break for i in range(6, n+1): if i%3 == 0: print(i)
4c6ace9b997f36283d2a61a15ede7cdafdd90822
jonathanjaimes/python
/8_FinalCapFunc_Cuadratica.py
908
3.90625
4
#En esta función se ingresan los datos def tomaDatos(): a = float(input("Ingrese el valor de a: ")) b = float(input("Ingrese el valor de b: ")) c = float(input("Ingrese el valor de c: ")) return a, b, c a, b, c = tomaDatos() #En esta función se toman los datos ingresados y se ejecuta la operación. ...
19105d389856994f07b38576682ac900ba71f9ee
jonathanjaimes/python
/4.13_Malditos_Rusos.py
355
3.765625
4
while True: a = int(input("Ingrese un número: ")) b = int(input("Ingrese otro número: ")) if a >= 0 and a <= 10000 and b >= 0 and b <= 10000: break a2 = a b2 = b sumar = 0 while True: if b%2 != 0: sumar = sumar + a a = a*2 b = b//2 if b < 1: break print(f"El produ...
62c493a1f406e966731bbdedb5cc5a5cc1dca972
jonathanjaimes/python
/7_FinalCapFunc_notas.py
1,078
3.84375
4
def ingresoNotas(): while True: nota1 = float(input("Ingrese su primera nota: ")) if nota1 >= 0 and nota1 <= 5: break while True: nota2 = float(input("Ingrese su segunda nota: ")) if nota2 >= 0 and nota2 <= 5: break while True: nota3 = float(input("Ingrese su tercera no...
725ebf8e4e57b9366913d00a043970c8753a50b7
jonathanjaimes/python
/15_ejerciciosFinalCapitulo_multiplos.py
614
3.96875
4
numero = int(input("Ingrese un número: ")) #Pregunta, si el número es multiplo de tres, quedese quieto. if numero%3 == 0: pass #Si no es múltiplo de tres, transformese en el múltiplo de tres mayor más cercano else: mod = numero%3 numero = numero - mod numero = numero + 3 #Al múltiplo de tres, sum...
800d80230ab26fc9c7994685d1f9aa5a18280b65
jonathanjaimes/python
/4.22_Abecedario.py
298
3.984375
4
""" for i in range(90, 64, -1): print(chr(i)) lista = [] for i in range(90, 64, -1): car = chr(i) lista.append(car) print(lista) """ contador = 90 for i in range(90, 64, -1): contador = contador - 1 for h in range(90, contador, -1): print(chr(h),end=" ") print()
49ee0330a1ca2a9f78b71b8040d233d2c6c3e500
hafizyunus/GCI2018_Practice_1
/GCI2018_Practice_1.py
223
3.8125
4
task = "GCI is great" n = 1 while n <= 10: print(task) n += 1 name = input("Tell me your name please ") print("Hello " + name + ", pleased to meet you! Did you know that your name spelt backwards is " + name[::-1])
6c795e80e678adbdadc19957477990b2d6ccdd86
Bhavya6187/practice
/trig_short/code.py
191
3.59375
4
k=input() for i in range(k): x=float(input()) print round(x-pow(x,3)/6+pow(x,5)/120-pow(x,7)/5040+pow(x,9)/362880,3) print round(1-pow(x,2)/2+pow(x,4)/24-pow(x,6)/720+pow(x,8)/40320,3)
8fd0430fe2f4147f41d8baadcf01d4fdccd8dd97
Bhavya6187/practice
/Project Euler/38_pandigital.py
312
3.734375
4
def is_pandigital(a): main_str = ""; maxim = 0; for i in range(1,9): main_str = main_str + str(i*a); if(len(main_str) == 9): if(sorted(main_str) == ['1','2','3','4','5','6','7','8','9'] and int(main_str) > maxim): maxim = int(main_str) print maxim,a for i in range(6,49999): is_pandigital(i)
2300e2a3c3ccb603907e2bcbd895f25cbbca504d
Enfioz/enpands-problems
/weekdays.py
535
4.34375
4
# Patrick Corcoran # A program that outputs whether or not # today is a weekday or is the weekend. import datetime now = datetime.datetime.now() current_day = now.weekday weekend = (5,7) if current_day == weekend: print("It is the weekend, yay!") else: print("Yes, unfortunately today is a weekd...
85130f76eb416debee4c11276aeae679eabe9f8c
sophiegribben/EM401
/python_learning/NumpyTutorial.py
1,043
3.859375
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 20 11:26:13 2020 Following this tutorial: https://youtu.be/GB9ByFAIAH4 @author: Sam """ import numpy as np a = np.array([1,2,3]) b = np.array([[9.0, 8.0, 7.0], [6.0, 5.0, 4.0]]) a_dim = a.ndim #get shape b_shape = b.shape #accessing/changing specific elements #get a s...
aecd7468749faf911c5be160ad6d396f5a8ade96
CelticSgc80/A-Technologies_Assignment_Datasc
/3_bank_details_use_class.py
1,026
3.921875
4
#Create a class Bank: class Bank: def __init__(self, Customername, ac_no, credit,debit, total_balance): self.customername = Customername self.ac_no = ac_no self.credit=credit self.debit=debit self.total_balance= total_balance def printdetails(self): p...
318d4e2ed6963fda80517fe0736b8a4c92656f07
jeff-lund/CS350
/DynamicProgramming/memofib.py
530
3.953125
4
from sys import argv count = 0 memo = {} def fib(n): global count global memo count += 1 if n not in memo: if n == 0: memo[0] = 0 elif n == 1: memo[1] = 1 else: memo[n] = fib(n - 1) + fib(n -2) return memo[n] if __name__ == '__main...
1d97bf0f52872d02a5a646fdb61a5fd0ea58e83b
jeff-lund/CS350
/Shellsort/shellsort.py
1,556
3.75
4
from sys import argv import random import math import argparse def tokuda(n): ''' Generate the nth value of the Tokuda Sequence ''' return math.ceil( (9 * (9 / 4)**n - 4) / 5) def generate_sequence(n): ''' Generates the full Tokuda sequence with values less than the size of the array ...
5121280ad9b23c20465ed7ff88f587248815aedb
kizombaciao/Python_Snippets
/contextmanager.py
466
3.8125
4
# note, context manager is not just for opening files, but also for threads and open/close database # think of situation where context manager is useful, allowing python to handle closing of resources # https://www.youtube.com/watch?v=Lv1treHIckI # https://www.youtube.com/watch?v=C-gEQdGVXbk f = open('file.txt', 'w'...
9622d51183098126f15243f96206f37f51f394fb
kizombaciao/Python_Snippets
/max_frequent_element.py
102
3.828125
4
x = [1, 2, 3, 4, 1] print(max(set(x), key=x.count)) # find the most frequent element from the list
978164be419b9087634b79cd336f936e1cb3aa6f
Helianus/Data-Structures-and-Algorithms-Coursera
/1-Algorithmic-Toolbox/week2/assignments/fibonacci_sum_last_digit.py
898
3.90625
4
# Uses python3 def fibonacci_sum_naive(n): if n <= 1: return n previous = 0 current = 1 sum = 1 for _ in range(n - 1): previous, current = current, previous + current sum += current return sum % 10 def fib_sum_fast(n): if n <= 1: return n p...
29776b5e500bf019270c50eb9084de64130029fc
Helianus/Data-Structures-and-Algorithms-Coursera
/1-Algorithmic-Toolbox/week2/assignments/fibonacci_partial_sum.py
653
3.953125
4
# Uses python3 def fibonacci_partial_sum_naive(from_, to): sum = 0 current = 0 next = 1 for i in range(to + 1): if i >= from_: sum += current current, next = next, current + next return sum % 10 def fib_partial_sum_fast(from_, to): m = int(from_ % 60) n =...
5455fefab8b7722aa8164e156ec1e29037f40ded
RolandMtsariashvili/Aline-Invasion
/ship.py
1,395
3.640625
4
import pygame class Ship(): def __init__(self, ai_settings, screen): """initializes the ship and gives start pozition""" self.screen = screen self.ai_settings = ai_settings # load image and getting rect. self.image = pygame.image.load('images\ship.bmp') self.rect ...
624ebdb6f1eeffdd78e85b1111b7d890e8a8461f
sajeevnair/coding_practice
/codeeval/python/palindrome.py
558
3.65625
4
from math import sqrt for i in range(999,1,-1): u=i%10 th=(i/100) t=(i/10)%10 digit_sum = u+t+th last_two=t*10+u prime =True # is divisible by 2? if u!=th: pass else: for x in range(2,int(sqrt(i))): ...
2fbd2ed10facbe839473257418b92ce527351a41
sajeevnair/coding_practice
/codeeval/python/test.py
115
3.96875
4
def factorial(n): if n ==1: return 1 else: return n*factorial(n-1) def reversal(str): print factorial(1)
3d8a862ac93c8ef55c9dc088d97fbe47edc97dc4
sajeevnair/coding_practice
/codeeval/python/fib2.py
325
3.71875
4
import sys def fib(n): count=0 a=0 b=1 n1=0 if n==0: return 0 if n<0: n1=n n=n*-1 while count<n-1: temp=a a=b b=temp+a count=count+1 if n1<0: return b*(-1)**(n+1) return b n=int(sys.argv[1]) print f...
66f2f0aad086b61f7e7616c358cb2f910d86cd09
TareqJudehGithub/python_spotify
/main.py
1,881
3.71875
4
import requests from bs4 import BeautifulSoup import spotipy from spotipy.oauth2 import SpotifyOAuth import os URL = "https://www.billboard.com/charts/hot-100/" SPOTIFY_CLIENT_ID = os.environ.get("SPOTIFY_CLIENT_ID") SPOTIPY_CLIENT_SECRET = os.environ.get("SPOTIPY_CLIENT_SECRET") # Spotify Authentication: sp = spotip...
4328422b8c5666f45b4b810cf5c490e8f9d644f2
anuvrat/hackerrank-python
/src-py/algorithms/strings/funny_strings.py
374
3.953125
4
def is_funny_string(s): r = s[::-1] is_funny = True for i in range(1, (len(s) + 1) // 2): if abs(ord(s[i]) - ord(s[i-1])) != abs(ord(r[i]) - ord(r[i-1])): is_funny = False break return is_funny if __name__ == '__main__': for _ in range(int(input())): print...
d8bdc525dcaffd972e666740b1e553a2b18a2574
anuvrat/hackerrank-python
/src-py/contests/projecteuler/probs_141_160/euler145.py
844
3.640625
4
def reversability(n, max_num): temp_num, num_reverse = n, 0 skip_factor = 0.1 while temp_num > 0: num_reverse = num_reverse * 10 + temp_num % 10 temp_num //= 10 skip_factor *= 10 val = n + num_reverse if (val % 10) % 2 == 0: return -1 * skip_factor while val > 0: ...
e7199983c06cedf927c30144ad95c699506c0d15
josephcardillo/boring-stuff
/comma_code.py
963
3.6875
4
spam = ['apples', 'bananas', 'tofu', 'cats'] spam1 = ['apples', 'bananas', 'tofu', 'cats', 'oranges', 3] spam2 = ['apples', 'bananas', 'tofu', 'cats', 2, 3] spam3 = [] spam4 = ['apples'] spam5 = [5] def sentence(words): if len(words) == 0: print("Your list is empty.") elif len(words) == 1: prin...
cc2dc97b333d0f882690f1070b39ac19bca5aacd
josephcardillo/boring-stuff
/table-printer.py
865
3.859375
4
# table-printer.py table_data = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goose']] def print_table(table): columns = [] for stuffs in range(len(table)): longest_word = '' # Find the longest word ...
6c511888f1cfcb208e0aa3a03d5c2cbfe2e7b015
Aninda05/Java-only
/lambda.py
308
4.1875
4
print("*****THE SUM OF SQUARES USING LAMBDA*****\n") x=int(input("Enter the first number:")) y=int(input("Enter the second number:")) z=int(input("Enter the third number:")) def fuc(x,y,z): a=lambda x:x*x b=lambda x,y:x+y*y c=lambda y,z:y+z*z return(c(b(a(x),y),z)) print"The result is: ",fuc(x,y,z)
f69f353d86c76c7edebea69f23cacf1ed85c1664
soleilhope/gwcprojects2017
/independent_list.py
666
4
4
from random import * #Create the list of words you want to choose from. meats = ["steak","squid","calamari","roast beef","oxdail","chicken wings","chicken tenders","orange chicken","mongolian beef","barbeque ribs"] sides = ["french fries","rice cake","salad","mashed potatoes","hawaiian roll"] dessert = ["hot ...
50e6db200bb0e689f1a241fc5f432624da0d2ce6
neotycoder/yahoo_finance_example
/pandas_class.py
2,557
3.8125
4
#!/usr/bin/python3 # Description: This script will show various uses of the Pandas module. This version of the script organizes the functions into a class. # Another added example is calling the various methods via an object call. import pandas as pd import ssl import yfinance as yf class stockquery: def __in...
085c3ca97a84c9d7d5bec4d70406af0e1e69de9c
BernardoJimenez/Hangman-Web-App
/app/logic.py
2,694
3.828125
4
import random class GameLogic(): # create new instance of GameLogic() for each new game played by user def __init__(self): self.my_dict = open("app/static/EnglishDictionary.txt") self.random_word = random.choice(self.my_dict.readlines()).strip() while len(self.random_word) < 3: ...
948fab50c3f2382b684037f5bc35b4f7f8b6becf
RaineShen/collaborative_project_part3
/Fittness/calories_burn/.ipynb_checkpoints/records-checkpoint.py
3,151
4.1875
4
class Records: """ please enter your name, age,height in cm and weight in kg """ def __init__(self,name,gender,age,height,weight): self.gender=gender self.height=height self.weight=weight self.name=name self.age=age self.bmi_range="n" de...
9fc7efb761b3d67fbbc4d4947721dbb16db6e96f
RaineShen/collaborative_project_part3
/unittest_Records.py
2,106
3.5
4
#!/usr/bin/env python # coding: utf-8 # In[2]: import unittest from Fittness.calories_burn import records as re # In[1]: class TestRecords(unittest.TestCase): @classmethod def setUpClass(cls): print('Set up class') def setUp(self): self.p1=re.Records("Mary","female",21,172,5...
59268b00e78cda450db6d5eb5c872c9faf9f15da
maheshvaikri/pythonpro
/Test/PythonTry/GraphAlgorithm/shortest_path.py
1,797
3.828125
4
from queue import Queue from graph import * def build_distance_table(graph, source): # A dictionary mapping from the vertex number to the tuple of #(distance from source, last vertex on path from source) distance_table = {} for i in range(graph.numVertices): distance_table[i]=(None, None) # The distance to ...
050a14f4a0e43594dc46d269620192d53e2e4b34
snitz70/workbook
/exercise_4.py
310
3.734375
4
ACRE_SQAURE_FEET = 43560 def acerage(length, width): return round((length*width)/ACRE_SQAURE_FEET, 2) if __name__ == '__main__': length = float(input('Enter length of field: ')) width = float(input('Enter width of field: ')) print('The field is {} acres.'.format(acerage(length, width)))
3869cdf193b34ee6f48b86014073aefb464d638e
snitz70/workbook
/exercise_9.py
513
3.984375
4
INTEREST_RATE = .04 def compound_interest(amount): return amount * INTEREST_RATE if __name__ == '__main__': amount = float(input('Enter starting amount: ')) oneyr = compound_interest(amount) twoyr = compound_interest(amount+oneyr) threeyr = compound_interest(amount+oneyr+twoyr) print('amoun...
2c4fb63b1a19cf7dbcd62c5d72d861486c4244bf
sinanthottan/python_data_algorithm
/TreeGeneral.py
1,435
3.640625
4
class TreeNode: def __init__(self,data): self.data = data self.children = [] self.parent = None def add_child(self,child): self.children.append(child) child.parent = self def printer(self): space = ' ' * self.get_level() * 3 prefix = space + "|__" if...
3c64f1675b13800ecf7c9414861395519eb5a1d1
shimizutm/python
/exception_1.py
217
3.8125
4
try: a = input('type a number:') b = input('input another:') a = int(a) b = int(b) print(a / b) except(ZeroDivisionError, ValueError): # print("b cannot be zero.") print("Invalid input.")
aa58a29ade1b0895c8c16ee7bc07285352a97160
akrs3/Python-para-Jornalistas
/ModuloII/aula2-ythonJornalismo.py
410
3.578125
4
import csv populacao = 0 estado_desejado = input('Qual o estado desejado?') estado_desejado = estado_desejado.upper() arquivo = open('brasil.csv', encoding='utf8') for registro in csv.reader(arquivo): habitantes = registro[2] estado = registro[0] if estado == estado_desejado: populacao += int...
40bce6da2982e0754960ef56507a8b48e01a719a
Anson008/Data_Structures_and_Algorithms_in_Python
/Chapter_04/Examples_C04/binary_sum.py
400
3.90625
4
def binary_sum(S, start, stop): """Return the sum of the number in implicit slice S[start: stop].""" if start >= stop: return 0 elif start == stop - 1: return S[start] else: mid = (start + stop) // 2 return binary_sum(S, start, mid) + binary_sum(S, mid, stop) if __name_...
2d1ef6bf9467e48b1cb7174b9f9534c75e73a343
andreeaanbrus/Python-School-Assignments
/Assignment 1/3_setA.py
1,016
3.734375
4
''' For a given natural number n find the minimal natural number m formed with the same digits. E.g. n=3658, m=3568. ''' def read(): x = (int(input("Give the number: "))) return x def printNumber(a, x): print("the minimal natural number formed with the same digits of", a, "is" ,x) def findDig...
617d4aa7fd56d6511a28954c6bfd384c8b9251d1
andreeaanbrus/Python-School-Assignments
/Assignment 1/8_setB.py
893
4.25
4
''' Determine the twin prime numbers p1 and p2 immediately larger than the given non-null natural number n. Two prime numbers p and q are called twin if q-p = 2. ''' def read(): x = int(input("Give the number: ")) return x def isPrime(x): if(x < 2): return False if(x > 2 and x % 2 ==...
6e1721d1f457deb7a9cdb337468a4608d40c82fb
rayswebpresence/latest
/functions/movie_age.py
946
3.984375
4
#initiate the age to 0 age = 0 age = int(age) # initiate the quitter variable to no. quitter = 'no' while quitter != 'yes': name = input("What is your name?") name = str(name.title()) while True: try: age = int(input("How old are you?")) break except ValueError: print("That was not a number") age =...
dce32bb88ab008383e7a3608b28929508eb0de0c
Rup-Royofficial/Codeforces_solutions
/Codeforces_contest_round.py
294
3.875
4
def isInAlphabeticalOrder(word): for i in range(len(word) - 1): if word[i] > word[i + 1]: return "NO" return "YES" for j in range(int(input())): count = int(input()) word = input() pin_words = isInAlphabeticalOrder(word) print(pin_words)
f96e8a3349f64a9d248184b7aadb7c493f2ea81b
Rup-Royofficial/Codeforces_solutions
/codeforces_AWord.py
171
3.703125
4
a = str(input()) b=0 c = len(a) for i in a: if(i.isupper()): b += 1 d = c-b if d>=b: a = a.lower() print(a) if d<b: a = a.upper() print(a)
78506ebf6cf5ac878032aa362e4902791ca53e1e
paritajohari/TaskPlanner
/utils.py
485
3.75
4
# global functions def read_input(msg, func): value = input(msg) while(not func(value)): print("Invalid input. Please try again") value = input(msg) return value # normal variable/functions (outside class) # access directly using name # class variable/functions (inside class but outside functions and funct...
52e4f6ea01633a08d60006b074b55db20e8ba707
aminhavasi/encoderSample
/encoder.py
413
3.71875
4
#!/usr/bin/env python3 import os fileName=input('plase enter a name of file with filetag like("filename.txt")') target=input('please select a name for target file with type') key=int(input('plese enter a key for lock program .only int')) f=open(fileName,'rb') file=f.read() f.close() file=bytearray(file) for index,value...
cc608e03490880b23f1cb4e53a781670cb898d01
vlad-bezden/py.checkio
/oreilly/reverse_every_ascending.py
1,364
4.40625
4
"""Reverse Every Ascending https://py.checkio.org/en/mission/reverse-every-ascending/ Create and return a new iterable that contains the same elements as the argument iterable items, but with the reversed order of the elements inside every maximal strictly ascending sublist. This function should n...
d0ef4d781f2518afb1210abedf14239e6b06c0e2
vlad-bezden/py.checkio
/oreilly/remove_all_after.py
1,247
4.65625
5
"""Remove All After. https://py.checkio.org/en/mission/remove-all-after/ Not all of the elements are important. What you need to do here is to remove all of the elements after the given one from list. For illustration, we have an list [1, 2, 3, 4, 5] and we need to remove all the elements tha...
123c364fc91318dcae889850c919494ec9f1807c
vlad-bezden/py.checkio
/scientific_expedition/network_attack.py
4,197
3.859375
4
"""Network Attack We are given information about the connections in the network and the security level for each computer. Security level is the time (in minutes) that is required for the virus to capture a machine. Capture time is not related to the number of infected computers attacking the machine. Infection start f...
c47db79eca95cb2de81fb2244b60c00b127c5e60
vlad-bezden/py.checkio
/electronic_station/what_is_wrong_with_this_family.py
3,276
4.03125
4
"""What Is Wrong With This Family? https://py.checkio.org/en/mission/wrong-family/ Michael always knew that there was something wrong with his family. Many strangers were introduced to him as part of it. Michael should figure this out. He's spent almost a month parsing the family archives. He has ...
56e4820a3eb210789a5b4d86cf4386d4028edb91
vlad-bezden/py.checkio
/oreilly/how_deep.py
1,704
4.5625
5
"""How Deep. https://py.checkio.org/en/mission/how-deep/ You are given a tuple that consists of integers and other tuples, which in turn can also contain tuples. Your task is to find out how deep this structure is or how deep the nesting of these tuples is. For example, in the (1, 2, 3) tuple...
c86f3c0373b66aa33f073b7253e07fc076ec1723
vlad-bezden/py.checkio
/github/black_holes.py
4,879
3.828125
4
"""Black Holes https://py.checkio.org/en/mission/black-holes/ You need to help Stephen implement a software model (function) that predicts the state of black holes under a controlled environment. The A&A research team has identified some peculiarities in the behavior of black holes. To create the software model one ...
d0879d8b2ac75200aad6e51e4a1cfe59e1de0594
vlad-bezden/py.checkio
/scientific_expedition/pangram.py
1,350
3.96875
4
"""Pangram https://py.checkio.org/en/mission/pangram/ A pangram (Greek:παν γράμμα, pan gramma, "every letter") or holoalphabetic sentence for a given alphabet is a sentence using every letter of the alphabet at least once. Perhaps you are familiar with the well known pangram "The quick brown fox ju...
4ea6cc426ebeeaf6f594465a48a6bfb836555467
vlad-bezden/py.checkio
/mine/perls_in_the_box.py
2,354
4.65625
5
"""Pearls in the Box https://py.checkio.org/en/mission/box-probability/ To start the game they put several black and white pearls in one of the boxes. Each robot has N moves, after which the initial set is being restored for the next game. Each turn, the robot takes a pearl out of the box and put...
7956966c7aa9ffed8da7d23e75d98ae1867c376a
vlad-bezden/py.checkio
/electronic_station/similar_triangles.py
2,498
4.28125
4
"""Similar Triangles https://py.checkio.org/en/mission/similar-triangles/ This is a mission to check the similarity of two triangles. You are given two lists as coordinates of vertices of each triangle. You have to return a bool. (The triangles are similar or not) Example: similar_triangles...
c58f93eaa4d0257d0588bd142d40de9200507e3c
vlad-bezden/py.checkio
/scientific_expedition/friendly_number.py
4,404
4.34375
4
"""Friendly number. Long numbers can be made to look nicer, so let’s write some code to do just that. You should write a function for converting a number to string using several rules. First of all, you will need to cut the number with a given base (base argument; default 1000). The value is a float number with decim...
d880c75abc5b1980a6e0bd5b2435c647963a08d1
vlad-bezden/py.checkio
/oreilly/median_of_three.py
1,986
4.125
4
"""Median of Three https://py.checkio.org/en/mission/median-of-three/ Given an List of ints, create and return a new List whose first two elements are the same as in items, after which each element equals the median of the three elements in the original list ending in that position. Input: Li...
03d267f1f9b232f96948af0affc06793c0a0d5f0
vlad-bezden/py.checkio
/electronic_station/three_points_circle.py
3,717
4.71875
5
""" Three Points Circle Nicola discovered a calliper inside a set of drafting tools he received as a gift. Seeing the caliper, he has decided to learn how to use it. Through any three points that do not exist on the same line, there lies a unique circle. The points of this circle are represented in a string with the ...
d8803c10cf12c5afb6898dd2c5cce4e7be0adeed
vlad-bezden/py.checkio
/oreilly/chunk.py
1,083
4.4375
4
"""Chunk. https://py.checkio.org/en/mission/chunk/ You have a lot of work to do, so you might want to split it into smaller pieces. This way you'll know which piece you'll do on Monday, which will be for Tuesday and so on. Split a list into smaller lists of the same size (chunks). The last ch...
a1241876f32a8cbcfa522b6393ae8ba20837549b
vlad-bezden/py.checkio
/elementary/split_list.py
885
4.375
4
"""Split List https://py.checkio.org/en/mission/split-list/ You have to split a given array into two arrays. If it has an odd amount of elements, then the first array should have more elements. If it has no elements, then two empty arrays should be returned. example Input: Array. Ou...
d70e12edecff9847d0b2dc19529d938410e378b3
vlad-bezden/py.checkio
/github/power_supply.py
3,353
4.1875
4
"""Power Supply https://py.checkio.org/en/mission/power-supply/ You are given the power grid and power-plant's information (plant-number and supply-range). You should find out which cities blacked out. A power plant can supply itself and connected cities with power, but the range is limited. ...
93b69fd2a07e076c8d968d862e19bb1831aa6aab
vlad-bezden/py.checkio
/mine/skew-symmetric_matrix.py
2,305
4.1875
4
"""Skew-symmetric Matrix https://py.checkio.org/en/mission/skew-symmetric-matrix/ In mathematics, particularly in linear algebra, a skew-symmetric matrix (also known as an antisymmetric or antimetric) is a square matrix A which is transposed and negative. This means that it satisfies the equation ...
bdc824de7ab4494ada16993548ea7bff32601f6e
vlad-bezden/py.checkio
/scientific_expedition/morse_clock.py
1,970
4.09375
4
"""Morse Clock Help Stephen to create a module for converting a normal time string to a morse time string. As you can see in the illustration, a gray circle means on, while a white circle means off. Every digit in the time string contains a different number of slots. The first digit for the hours has a length of 2 whi...
1a0a561efb77082099bb07f4b469f028f4a75403
andres-ml/aoc-19
/run.py
698
3.78125
4
#!/usr/bin/python3 # Entry point for problem executions. # Each day is contained in a file day-<day>.py and should define two methods: first and second, which # should take the input as a parameter and return the solution. # Example usages: # ./run.py 0 # ./run.py 0 one # ./run.py 0 two inputs/custom-input.txt import ...
38b827227c8ed43eb5c1ea5d066903cc01ee27d1
PedroCBonifacio/Python-Central-de-jogos
/forca.py
4,660
3.59375
4
import random def jogar(): mensagem_abertura() palavra_oculta = puxar_palavra_oculta() letras_acertadas = espacos_letras_acertadas(palavra_oculta) print(letras_acertadas) enforcou = False acertou = False tentativa = 0 while(not enforcou and not acertou): chute...
19fafb0e475591a662695b045daadf4e912c0ad8
t3hami/python-assignment
/question13.py
429
3.8125
4
class Generator(): def __init__(self,number): self.number = number def generator_function(self): for n in range(7, self.number+1, 7): yield n input_number = -1 while not input_number > 0: input_number = int(input('Enter range: ')) if not input_number > 0: print('Ple...
5c81de8b8a9397edddcdc2f8871510947d87c700
t3hami/python-assignment
/question5.py
334
3.828125
4
class Shape(): def area(self): return 0 class Square(Shape): def __init__(self, length): self.length = length def area(self): return self.length*self.length my_shape = Shape() print('Area of shape:', str(my_shape.area())) my_square = Square(4) print('Area of square:', str(my_s...
c4bbd5c519d7b5102ff75bf10ef151819072cab6
Mjkim88/data-structure
/menu.py
2,988
4.03125
4
from functions import * from scc import * import numpy as np def read_data_file(user_friendship, tweet_dic): # count number of users user = len(user_friendship) friendship = sum(len(v) for v in user_friendship.itervalues()) tweets = sum(len(v) for v in tweet_dic.itervalues()) # print the results pri...
98827f4e58f3c2bc9095d9c486517ee63335b208
MelonHjy/show-me-the-code
/每天练习/0012.py
406
3.625
4
with open(r'filtered_words.txt', 'r', encoding='utf-8') as f: L = [] for line in f.readlines(): L.append(line.strip()) def changeBadWord(word): for badWord in L: if badWord in word: new_word = word.replace(badWord, '*'*len(badWord)) return print(new_word) ...
a2c5ede07987f622b9cd90172519ec786f1ecd35
oyenny/Tolyas_app
/nuber_of_tens_in_big_nubmber.py
80
3.71875
4
digit = int(input()) last_two_digits = digit % 100 print(last_two_digits // 10)
be4fc8e6805f76dd9d153b5ded480b5e14abbd94
tireub/Project3
/Classes.py
6,201
3.578125
4
import pygame from pygame.locals import * import random #Definition of Labyrinth class Labyrinth: #Game level class #def Initialisation of the level def __init__(self , file): self.file = file self.grid = [] self.char_init_pos = (0, 0) self.char_init_sprite = (0, 0) #def Read th...
a261266b20de610d219d50b70637f5bd1c1cea63
vihu/rmotr
/ass3/calc.py
351
3.515625
4
class Calculator(object): def add(self, *args): return sum(args) def subtract(self, a, b): return a-b def multiply(self, *args): return reduce(lambda x, y: x*y, args) def divide(self, a, b): try: return a/(b + 0.0) except ZeroDivisionError: ...
b85d9b26209a017b168b9982d34fe5392ea14771
vihu/rmotr
/ass3/calc_inheritance.py
3,007
3.78125
4
import unittest class OperationInvalidException(Exception): pass class Operation(object): def __init__(self, *args): self.args = args def operate(self): return NotImplementedError class AddOperation(Operation): # The only method present in this class def operate(self): ...
e65923dac52a57cec7f3291ce88b7b665d8676ea
hacklk/Game-Inventory
/GameInventory/print_table.py
928
3.640625
4
def print_table(inventory, order=None): # sort dict in ascending order if order == 'count,asc': inventory = {k: v for k, v in sorted( inventory.items(), key=lambda item: item[1])} # sort dict in descending order elif order == 'count,desc': inventory = {k: v for k, v in sorted...
e3a43db319becd8dc74a23625265b5415fed182c
Shubhanshu-Nishad/Python-Practice-Programs
/tic-tac.py
3,327
3.90625
4
import re #Greet print(''' Welcome to Tic Tac Toe Game -By TECH_TEJAS Select Player:''') player1=input("For X Enter Your Name: ").capitalize() player2=input("For O Enter Your Name: ").capital...
0d5fb21ee30ca1353b31e33d3706f1a7406c9881
johncanthony/sorts
/Fib/fib.py
87
3.609375
4
def fib(num,a,b): if(num<=2): return b num = num - 1 return fib(num,b,a+b)
41d20cd35e9631d277dae0697dec0164458843dd
johncanthony/sorts
/countSort/Python/countSort.py
1,107
4.03125
4
########################################################### # countSort() # # johncanthony 11.19.16 # # Desc: # Implementaiton of countSort for algorithms study # ########################################################### class countSort(): def run_sort(self,_list): """ Sort list of positive intege...
2edb9f6d0a06817eee0e33f3a1287692b8dad548
DavidCds1/aima-python
/tsp_problem.py
4,345
3.65625
4
from matplotlib import lines from search import * from utils import * from numpy import random import matplotlib.pyplot as plt import numpy as np import networkx as nx class TSP_problem(Problem): """ subclass of Problem to define various functions """ def __init__(self, initial, distances): super...
9ca7b37d4601cd09fe4366a0d739f647b5387966
linkel/MITx-6.00.1x-2018
/Week 1 and 2/alphacount.py
519
3.734375
4
s = 'azcbobobegghakl' longest = s[0] longest2 = s[0] for i in (range(1, len(s))): if s[i] >= longest[-1]: longest = longest + s[i] elif s[i] < longest[-1]: longest2 = s[i] for j in range(i+1,len(s)): if s[j] >= longest2[-1]: longest2 = longest2 + s[j] ...
b1dee53024fb0e1420d3d3443eb26f6f2c949bf1
linkel/MITx-6.00.1x-2018
/Week 1 and 2/alphacount2.py
1,218
4.125
4
s = 'kpreasymrrs' longest = s[0] longestholder = s[0] #go through the numbers of the range from the second letter to the end for i in (range(1, len(s))): #if this letter is bigger or equal to the last letter in longest variable then add it on (meaning alphabetical order) if s[i] >= longest[-1]: longest ...
f26dbb4d9afac2467c364db01d5399e8056f8ec1
linkel/MITx-6.00.1x-2018
/Week 3/dicttest.py
281
3.671875
4
animals = { 'a': ['aardvark'], 'b': ['baboon'], 'c': ['coati']} animals['d'] = ['donkey'] animals['d'].append('dog') animals['d'].append('dingo') print(len(animals.values())) print(animals.keys()) values = animals.values() sum = 0 for i in values: sum += len(i) print(sum)
6336fb1f24b1870bef939cad077e85145b3a8f06
daniel-scholz/setlpy
/setlx/list.py
1,484
3.796875
4
from copy import deepcopy class List(list): """ A list that starts with index one instead of zero""" def __getitem__(self, index): if isinstance(index, slice): if index.start == 0: raise Exception(f"Lower bound '{index.start}' is invalid.") start = index.start ...
7961c3cf77f8b83ee803237891754f047fd50dff
YehonatanLiron/KivyGraph
/utility_functions.py
147
3.5625
4
def linspace(a, b, n=100): if n < 2: return b diff = (float(b) - a)/(n - 1) return [diff * i + a for i in range(n)]
ccc96a09e02c4744c895e55ca17eef28e3c692a5
logg926/Hackathon24march
/jpg.py
3,923
3.59375
4
# with the Tkinter canvas, drawings can only be saved as .ps files # use PIL to draw simultaneuosly to memory and then save to file # PIL allows .png .jpg .gif or .bmp file formats #background_color = 'black' bgcolor = 0x000000 title_text1 = 'Hero French' title_text2 = 'Policeman' font_type_for_title= "Chunkfive.otf"...
73094d2dd8473af6e2df56cdfd3146ab00deaf9b
Shaigift/CompletePythonBootcamp
/ran_check.py
247
4.03125
4
#write a function that checks whether a number is in a given range(inclusive of high and low) def ran_check(num,low,high): if num in range(low,high+1): print(f"{num} is in range of low & high") else: print("not in range")
f7fbd1f968f503fd1475a1888e412b856c270201
Ashish265/Scaler
/Max Sum Array.py
479
3.546875
4
def max_sum_array(arr): max_so_far = float("-inf") maxEndingHere = 0 start =0 end =0 beg = 0 for i in range(len(arr)): maxEndingHere = maxEndingHere + arr[i] if maxEndingHere < arr[i]: maxEndingHere = arr[i] beg =i ...
853a013b782a168466c0fc0af2005c2f84a3c082
shettiadi/problem1
/soln.py
407
3.609375
4
import itertools length=input() length=10 list1=[''.join(x) for x in itertools.product('AP', repeat=length)] list2=[] for x in list1: #print("for"+x) if x.find('AAAA')>-1: #print(x) pass else: list2.append(x) b=len(list2) count=0 for y in list2: if y[-1]=='A': ...
24e903bca6b1444e4c26f3c30779e5061e2e230e
Antobio17/DAI
/Practica4/app/ejercicios/ejercicio1.py
950
3.9375
4
# Ejercicio 1 # Programe un mini-juego de "adivinar" un número (entre 1 y 100) que el ordenador establezca al azar. # El usuario puede ir introduciendo números y el ordenador le responderá con mensajes del estilo # "El número buscado el mayor / menor". El programa debe finalizar cuando el usuario adivine # el número...
aafba8961c0d1f80926c692a209acd43a2adf7d5
GLAU-TND/python-lab-AnujSaxena19
/1stQuestion.py
211
3.546875
4
class Myexception(Exception): pass def xyz(a,b): c=a+b if(c<150): raise Myexception("Custom Exception Occur") else: print("Sum is" +str(c)) a=int(input()) b=int(input()) xyz(a,b)
9659859e3e2c61fa93a7defc7083b888972a8be8
HoroshevaVika/stepik---auto-tests-course
/lesson2_1_step5.py
1,114
3.625
4
from selenium import webdriver import math # Описать функцию def calc(x): return str(math.log(abs(12*math.sin(int(x))))) # Открыть страницу link = "http://suninjuly.github.io/math.html" browser = webdriver.Chrome() browser.get(link) # Считать значение x x_element = browser.find_element_by_css_selector('[id="input_...
fc17ad2770c01b01220527948074999663a5cb0e
amir-mersad/ICS3U-Unit5-01-Python
/function.py
885
4.46875
4
#!/usr/bin/env python3 # Created by: Amir Mersad # Created on: November 2019 # This program converts temperature in degrees Celsius # to temperature degrees Fahrenheit def celsius_to_fahrenheit(): # This program converts temperature in degrees Celsius # to temperature degrees Fahrenheit # Input ce...
d707b60cb01420bcfab9ed438187b9eb17af3619
KhlopotovAI/codewars-py
/cycle/kata.py
279
3.609375
4
# https://www.codewars.com/kata/1-slash-n-cycle/train/python def cycle(n): if n % 2 == 0 or n % 5 == 0: return -1 mod_val = 10 % n curr_mod = mod_val k = 1 while curr_mod != 1: curr_mod = (curr_mod * mod_val) % n k += 1 return k
3f41d041077d208264948107416e07d15b40fd0d
KhlopotovAI/codewars-py
/readable/kata.py
309
3.734375
4
# https://www.codewars.com/kata/human-readable-time/train/python def make_readable(seconds): h = append_0(str(seconds // 60 // 60)) m = append_0(str(seconds // 60 % 60)) s = append_0(str(seconds % 60)) return h + ":" + m + ":" + s def append_0(x): return x if len(x) >= 2 else "0" + x
74436be7d56582b563159ad4d6b22281240b37a6
KhlopotovAI/codewars-py
/hashtag/kata.py
319
3.78125
4
# https://www.codewars.com/kata/the-hashtag-generator/train/python import re from functools import reduce def generate_hashtag(s): hashtag = reduce(lambda x1, x2: x1 + x2, map(lambda x: x.capitalize(), filter(None, re.split("\W", s))), "#") return hashtag if len(hashtag) <= 140 and hashtag != "#" else False