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
8407a85c075e4a560de9a9fbc2f637c79f813c1e
scottbing/SB_5410_Hwk111
/Hwk111/python_types/venv/SB_5410_Hwk4.2.py
2,605
4.15625
4
import random # finds shortest path between 2 nodes of a graph using BFS def bfs_shortest_path(graph: dict, start: str, goal: str): # keep track of explored nodes explored = [] # keep track of all the paths to be checked queue = [[start]] # return path if start is goal if start == goal: ...
9ba155316e8934ce4720d0172e88958c2b509c8a
borjamoll/programacion
/Python/Act_05/09.py
409
3.890625
4
h=int(input('Un lado, un lado !!! ')) l=int(input('Dame la altura, compañero. ')) if l==h: print("Mira jefe, te voy a ser sincero, lo que me has puesto es un cuadrado pero te lo calculo igual, por pena o por burla, como quieras tomártelo.") halt=h*"*" halt2=(h-2)*(' ') halt3=("*"+str(halt2)+("*")) a=l for i in rang...
fd95c56e30ff0465f60196ce1bd80b7fc24dd151
borjamoll/programacion
/Python/Act_05/01.py
422
3.953125
4
#PRACTICA 1 for i in range(10): numero=i+1 print('%s' % numero, end=' ') print(' ') for i in range(10): numero=i+1*i+2 print('%s' % numero, end=' ') print(' ') for i in range(10): numero=20+2*i print('%s' % numero, end=' ') print(' ') for i in range(6): numero=10+4*i print('%s' % numero,...
8f58aeb82b8adad349cc52e1706387dcdcc45e00
borjamoll/programacion
/Python/Act_06/09.py
669
4.0625
4
#Escribe un programa que te pida nombres de personas y sus números de teléfono. # Para terminar debe pulsar “S” cuando te pida el nombre. # El programa termina escribiendo nombres y números de teléfono. Nota: # La lista en la que se guardan los nombres y números de teléfono es # [[nombre1, telef1], [nombre2, telef2...
3e7fab66175f06fc91f0df355499eafc95d9d197
borjamoll/programacion
/Python/Act_07/11.py
660
4.21875
4
#Escribe un programa que te pida una frase, y pase la frase como parámetro a una función. # Ésta debe devolver si es palíndroma o no , y el programa principal escribirá el resultado por pantalla: #salta lenin el atlas #dabale arroz a la zorra el abad print("Ripios") palindromo=True dato=str(input("Dime una palabra o ...
3aea8777e7100b9084286f6922ff5c2cd76af30b
midas-gufei/udacity-mlnd-linear-algebra
/create_unit_matrix.py
645
3.625
4
""" 创建n*n单位矩阵 """ class UnitMatrix(object): def create_unit_matrix(n): unit_matrix = [] for i in range(n): cell = [0 if i != j else 1 for j in range(n)] unit_matrix.append(cell) ret = "" for k in unit_matrix: # 第一行 if k == unit_matri...
029038366637f8e96d63860f8b53049a6b81a00a
Lonni2380/Finalfight
/Goblin.py
1,589
3.515625
4
import random b="enderdragon" bhp = 1500 schaden = 4 maxschaden = 100 runde = 0 kritt = 0.2 drachenaktion = ["feuer", "klaue", "biss"] menu = ["Normaler Angriff", "Ultimativer Angriff", "Deckung gehen", "Ausweichen", "Verstecken", "Heiltrank", ...
bdfbd50066a4fba7c1cbdc0cf774845907450ea3
chuzirui/vim
/link.py
894
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class LinkedNode(object): def __init__(self, value): self.next = None self.value = value def insert_linked(Head, Node): Node.next = Head.next Head.next = Node def print_list(Head): while (Head): print (Head.value) Head = H...
1a9328286a6685428f59e6cdf7c3f16244efa87e
BouBooo/B2-Python
/scripts/1c-moy.py
1,163
3.625
4
#!/usr/bin/python3.6 #1c-moy.py #XIMENES CLEMENT/NICOLAS FLORENT #Demander une saisie utilisateur de plusieurs notes et prénoms + moyenne et top 5 #16/10/2018 #module pour trouver les 5 meilleurs notes import heapq #heapq.nlargest(10,my_dictionary.values()) #regex import re patternUser = re.compile('^[a-zA-Z]*$') pa...
88db9c7a5738f3f95cf318ab6ecf5250c98bf30e
mariamaafreen/python-exploring-battle-1
/reverse_string.py
197
4.375
4
def reverse(string): if len(string) == 0: return string else: return reverse(string[1:]) + string[0] a = str(input("Enter the string to be reversed: ")) print(reverse(a))
043e3cfe9b4674465a0df673e3b20ecbdf60872a
mariamaafreen/python-exploring-battle-1
/split_string.py
79
3.53125
4
string = "a b c d e f g" data = string.split() for i in data: print (i)
5ce904df75a1f165e3f0c79c518a99ff4e3d3819
mariamaafreen/python-exploring-battle-1
/fabonacci.py
304
3.953125
4
number = int(input("enter a number")) i = 0 first_value = 0 second_value = 1 while(i<number): if(i<=1): next_value = i else: next_value = first_value + second_value first_value = second_value second_value = next_value print(next_value) i = i + 1
fd6dbb1e1209b1a2cecd5155f4e678d81d2d5145
mariamaafreen/python-exploring-battle-1
/single_inheritance.py
308
3.75
4
class Parent: parentname = "" childname = "" def show_parent(self): print(self.parentname) class Child(Parent): def show_child(self): print(self.childname) ch1 = Child() ch1.parentname = "fathima" ch1.childname = "sanu" ch1.show_parent() ch1.show_child()
a1e0822e8563af964c3cd952b09c5dd0f1876354
Catarina607/Python-Lessons
/5_33.py
698
3.890625
4
print('====================================') print(' PRODUCT TAX ') print('====================================') value = int(input('Value US$: ')) print(' How much percents ?') print('[5%] for values lesss than U$S50') print('[10%] for values between US$50 and U$S100') print('[15%] f...
7e638211c47623e83d7dc3fce6cd0b162262b32b
Catarina607/Python-Lessons
/6_24.py
201
3.5625
4
num = int(input(' N: ')) soma = 0 for c in range(1, num+1): if c == num: break if num%c==0: soma = soma + c print(f' + {c} ', end='') print(f'| soma = {soma}')
74b987a1539136a383c88b6e86859a375c005dad
Catarina607/Python-Lessons
/exerc01.py
257
3.71875
4
def cyberculture(): for i in range(3,33, 3): if i < 70: print(i) if i > 70: pass def robot(): y = '' while y != 'sim': y = input(' quer saber ? ') x = 1 while x < 10: robot() cyberculture()
a1710ec114c7a5b072bcbb40cefe190fe61bcd03
Catarina607/Python-Lessons
/discount.py
282
4
4
print(' CALCULATER DISCOUNT ') print('------------------------------') value = float(input('write the value of the product in R$: ')) d = (12*value)/100 r = value - d print('this discount in Brazilian Real is equal R$' ,r) print('thank you for your choice!')
4d39bc3cc2f9205db472678e3e384ac384c69e2d
Catarina607/Python-Lessons
/numbbber.py
99
3.796875
4
n = int(input('write a number: ')) s = (n + 1)*3 p = (s - 1)*2 plus = p + s print(plus)
419fffc48518ea5d04cd0f48e003a0db2e9eb140
Catarina607/Python-Lessons
/5_36.py
883
3.546875
4
print('==============================') print(' COMISSION ') print('==============================') value = float(input('US$: ')) if value >= 100.000: p = value * (16/100) c = 700.00 + p print(f'COMISSION: US${c}') elif (value < 100.000) and (value >= 80.000): p = value...
07ecfcdb0861fb3282c94a9502b4a14614e4cc73
Catarina607/Python-Lessons
/6_09.py
506
3.859375
4
cont = 0 num = int(input('Number: ')) bigger_first = num bigger_second = num while cont < 10: num = int(input('Number: ')) cont = cont + 1 if num%2!=0 and num>bigger_first: # Maior numero ímpar bigger_first = num elif num%2!=0 and ((bigger_first>num) and (bigger_second<bigger_first...
1167bfadf21c4e9abf26a62cebef56eb19c8197e
Catarina607/Python-Lessons
/importance.py
405
3.625
4
print('---------------------------------') print(' C A L C U L A T E R ') print('---------------------------------') value = 780.000 dw1 = 46*value/100 print('The first winner receives R$ %.3f' % dw1) rv = value-dw1 # print('it remains R$ %.3f' % rv) dw2 = 36*rv/100 print('The 2th winner receiv...
284367357ee79b347535bf68f45e6436ada6dda4
Catarina607/Python-Lessons
/5_29.py
804
3.859375
4
print('==================================') print(' MATHEMATICS PROOF ') print('==================================') a = int(input('2 + 5 = ')) b = int(input('4 + 5 = ')) c = int(input('5 + 5 = ')) d = int(input('7 + 4 = ')) e = int(input('2 + 9 = ')) if a == 7: a = 1 print('a) Ri...
2cf85657ae485c8f51b2f38c5ada0c1495f59579
Catarina607/Python-Lessons
/5_23.py
293
3.859375
4
print('==================================') print(' L E A P Y E A R R E A D E R ') print('===================================') year = int(input('YYYY: ')) y_c1 = year%4 if y_c1 == 0 and year % 100 > 0: print('It is a Leap Year.') else: print('It Isnt a Leap Year.')
db8e97cdc0ae8faa35700bfb83502a1d8b0c4712
Catarina607/Python-Lessons
/new_salary.py
464
4.21875
4
print('----------------------------------') print(' N E W S A L A R Y ') print('----------------------------------') salary = float(input('write the actual salary of the stuff: ')) n_salary = (26*salary)/100 new_salary = salary + n_salary print(new_salary, 'is the actual salary') print('t...
f90489beb1ae986a9c6a69da68f355cdfc9b0cb0
Catarina607/Python-Lessons
/5_24.py
1,706
3.53125
4
print('=====================================') print(' T A X C A L C U L A T E R ') print('=====================================') print('Choice A States: ') print('MG') print('SP') print('RJ') print('MS') state = input('Which One State: ') value = float(input('Write a Value R$: ')) if state ==...
c57434778b3458195132a66fc089bb9001520f95
Catarina607/Python-Lessons
/recursion01.py
138
3.78125
4
s = int(input(': ')) n = int(input(': ')) def print_n(s, n): if n <= 0: return print(s) print_n(s, n -1) print_n(s, n)
fa78b8abb0bc9ecccc304d302c0873ca97b3a82b
Catarina607/Python-Lessons
/neothing.py
1,050
3.734375
4
''' Física - Cinemática deltaspc = space t = x/60" v = deltaspc / (x/60") s = (deltaspc + v)*(x/60") area = a = a**3 = ((deltaspc**3)+((×/60")**2)) ''' def calc0x(): import math s0= float(input('inicio: ')) t = float(input('tempo final: ')) v = int(s0/t) s = int(s0+v*t) print('='*10) ...
559e17facaadc0f71d8fbdfd3817d73f2bd0acdf
Catarina607/Python-Lessons
/5_40.py
522
3.90625
4
cost_factory = float(input(' COST FACTORY U$S: ')) if cost_factory < 12.000: value = cost_factory + (cost_factory * (5/100)) print(f'TOTAL COST US$: {value}') elif cost_factory == 12.000 or cost_factory <= 25.000: value = cost_factory + (cost_factory + (10/100)) + (cost_factory *(15/100)) pr...
8bdbd252801cb563de08e0fb43b68893355fdb05
SoundsLikeJonny/Game-Audio-Directory-Manager
/dir_.py
4,073
3.765625
4
# # dir_.py # # Author: Jon Evans # Modified: Oct 19, 2020 # # The Dir class works as the engine for the the Game Audio Manager app. # Allows the user to automatically create audio directories, copying files into the lowest sub-path import os import pathlib import shutil from pathlib import Path from DisplayableP...
7d2a52f469cdb0443d6ddf2e22df5768027f713d
uncertainsound/Python
/library.py
392
3.8125
4
import re r = re.compile(r'[a-zA-Z]+') paragraph = raw_input("Input a paragraph: ") paragraph = paragraph.replace("'", "") words = r.findall(paragraph) dicto = dict() for each in words: number = len(each) try: dicto[number] = dicto[number] + 1 except KeyError: dicto[number] = 1 for e...
ce1a43e48e6d34d79708ef2feeab9bcbf1003f70
ml758392/python_tuling
/TUling笔记/oop基础/pycharm/oop_1.py
249
3.71875
4
class Person: name = "yy" __age = 18 # 私有变量 person = Person() print(Person.name) print(Person.__dict__) # 查看__age print(person._Person__age) # 变成_Person__age 可以用_classname_attributename访问
634be2264401ecf5683b607df5665779bdd83177
michaelvincerra/pdx_codex
/wk5/enum3.py
361
3.71875
4
artists = ("DaVinci", "Rembrandt", "Michelangelo", "Beuys", "Warhol") for index, artist in enumerate(artists): print(index, artist) # Use 5 if you wish to set a new START INDEX for index, artist in enumerate(artists, 5): print(index, artist) def enumerator(artists): for index, artist in enumerate(arti...
8bc8817cb27e7dd58964a591e71b52978c719f93
michaelvincerra/pdx_codex
/wk4/scrub.py
3,309
3.71875
4
""" Write functions that accept 'dirty' string input, and ouputs a human readable value. Use a combination of python string methods and regular expressions. Write, test, and refactor as you go. >>> scrub_numbers('Be9autiful9 i4s be2tter th4an ug42ly') 'Beautiful is better than ugly.' >>> gentle_clean('Explicit_is-be...
6a0a0261cf885d0493026a1f5f43004be8557cdd
michaelvincerra/pdx_codex
/wk4/phonebook.py
4,236
4.1875
4
phonebook = {'Kieran': {'name': 'Kieran', 'number': 8456331959, 'nick_name': 'Bomber'}, # dict in dict: Access by keys! 'Michael': {'name': 'Michael', 'number': 8454185633, 'nick_name': 'Lino'}, 'Elizabeth': {'name': 'Elizabeth', 'number': 5031234567, 'nick_name': 'Betsy'}} print('Welcom...
a012d3d2bb69f2022cb115b348a1eb54cfe27822
michaelvincerra/pdx_codex
/wk7/unittest/test_main.py
1,204
3.828125
4
import unittest import main class MainTest(unittest.TestCase): """ Test string methods. """ # def setUp(self): # # self.validate = validate.account_number() # def assert_equal_rev_num(self): # check_dig == 5 # self.assertEqual(check_dig, rev_num) # this will fail and...
1636960c1a8754de6bb0548cb1a679e496a41d9d
michaelvincerra/pdx_codex
/wk5/enum1.py
213
3.765625
4
words = ['complete', 'absolute', 'positive'] def enumerator(adverb: str) -> str: result = list() for index, word in enumerate(words): result.append('ly') print(result) enumerator('word')
200971a40d96428969d8266c603620ec6e59c0c6
michaelvincerra/pdx_codex
/wk1/case.py
852
4.4375
4
""" >>> which_case('this_test_text') 'snake_case.' >>> which_case('this_is_snake_case') 'snake_case.' >>> which_case('ThisIsCamelCase') 'CamelCase.' """ def which_case(words): print('Python uses two types of naming for variables and files.') print('ThisIsCamelCase') print('this_is_snake_case') prin...
e1c6c077d75f28f7e5a93cfbafce19b01586a26d
michaelvincerra/pdx_codex
/wk1/dice.py
419
4.6875
5
""" Program should ask the user for the number of dice they want to roll as well as the number of sides per die. 1. Open Atom 1. Create a new file and save it as `dice.py` 1. Follow along with your instructor """ import random dice = input('How many dice?') sides = input('How may sides?') roll = random.randint(1, 6...
5ee29301f12a706ccf311be48148190f7f511d8a
pchandrag/pythondev
/anagram.py
1,007
3.734375
4
#read file import random loc='/usr/share/dict/words' with open(loc) as f: content=f.read().split('\n') f.close() l=len(content) words=[] for i in range(0,l): if '\'' in content[i] or len(content[i])<5: continue words.append(content[i]) words=words[1:] d=len(words) words=words[:d] #shuffle the word word=words[...
e8c7281e6f6db13b891ad372a8aa311207959d5b
m-javed/test
/Compose_Python_Interface/Breast_Cancer_Classification/Breast_Cancer.py
3,707
3.859375
4
#Breast Cancer dataset import numpy as np import pandas as pd from numpy import mean from sklearn.datasets import load_breast_cancer import matplotlib.pyplot as plt cancer = load_breast_cancer() #print(cancer.DESCR) # Print the data set description #cancer is a disctionary, with following keys cancer.keys() ...
e7c79524c02a06806bb2d43a6a089da12cb3247b
kumarUjjawal/python_basic_problems
/hcf.py
415
3.578125
4
# find the hcf of two numbers def compute_hcf(x,y): if x > y: smaller = y else: smaller = x for i in range(1,smaller + 1): if ((x % i == 0) and (y % i == 0)): hcf = i return hcf num1,num2 = 54,24 print(compute_hcf(num1,num2)) # Euclidean Algorithm def comp_hcf(x,y):...
6d1c263d54542be9c69489ee71759a2b4453a05c
Remaerdeno/Algorithm-Data-Structure
/sort.py
3,535
4.15625
4
#冒泡排序 def bubble_sort(lists): count=len(lists) for i in range(0,count): for j in range(i+1,count): if lists[i]>lists[j]: lists[i],lists[j]=lists[j],lists[i] return lists list=[4,5,2,1,6,8,0] print(bubble_sort(list)) #插入排序 def insert_sort(lists): count=len(lists) f...
9faf1d8c84bdf3be3c8c47c8dd6d34832f4a2b1e
vmueller71/code-challenges
/question_marks/solution.py
1,395
4.53125
5
""" Write the function question_marks(testString) that accepts a string parameter, which will contain single digit numbers, letters, and question marks, and check if there are exactly 3 question marks between every pair of two numbers that add up to 10. If so, then your program should return the string true, other...
8ba77cafce78a6b4b1d4a56114e23b885a1932cb
omerom88/Ebeat
/graphic.py
4,227
3.984375
4
""" Sample Python/Pygame Programs Simpson College Computer Science http://programarcadegames.com/ http://simpson.edu/computer-science/ """ import time import pygame # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) MIX = (150, 150, 255) def draw_stick_figure(kinect,...
15cb41bc206c52536a191a145c7fa97876ecb779
abatilo/typed-json-dataclass
/typed_json_dataclass/utils.py
1,115
3.703125
4
def to_snake(string_to_convert: str): converted = '' for i, c in enumerate(string_to_convert): if c == c.lower(): converted += c else: if 0 < i: converted += '_' converted += c.lower() return converted def to_camel(string_to_convert: str)...
dc377deebc669f4ac8921c74302b398e206e03c2
IICuttingEdgeII/ProjectEuler
/Problem10.py
1,384
4.0625
4
import math import time # method 1 def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_div = math.floor(math.sqrt(n)) for i in range(3, 1 + max_div, 2): if n % i == 0: return False return True def method1...
cf9a5b5e82b50692179b47f452a597289a26e3d8
Juan4678/First-file
/Lección 11 de telusko.py
757
4.375
4
#Tipos de operadores #OPERADORES ARITMÉTICOS #Ejemplos x=2 y=3 print(x,"+",y) print(x+y) print(x,"-",y) print(x-y) print(x,"*",y) print(x*y) print(x,"/",y) print(x/y) #OPERADORES DE ASIGNACIÓN #Ejemplos X=x+2 print(X) X+=2 print(X) X*=3 print(X) a,b=5,6 print(a) print(b) ...
83aaf3a5cd7411889e814ea4f0154698e8cb3df5
kinglarce/U-P1
/problem_4.py
1,855
3.765625
4
class Group(object): def __init__(self, _name): self.name = _name self.groups = [] self.users = [] def add_group(self, group): self.groups.append(group) def add_user(self, user): self.users.append(user) def get_groups(self): return self.groups def ...
fecedd4e2f0317eda22a8dd378f6020805b6737d
Yousef-Nour/pythonstack
/_python/python_fundamentals/user_assignment/user.py
921
3.71875
4
class User: def __init__(self,user_balance,user_name): self.user_balance = user_balance self.user_name = user_name def deposit(self, amount): self.user_balance += amount print(self.user_balance) def make_withdrawal(self, amount=0): if amount <= self.user_balance: ...
92d0aff0191cd5a16ec7ebc70e9a433b33964d71
Yousef-Nour/pythonstack
/_python/python_fundamentals/Users with Bank Accounts/bank_account.py
996
3.765625
4
class BankAccount: def __init__(self, int_rate, balance): self.int_rate=int_rate self.balance=balance def deposit(self, amount): self.balance += amount return self def withdraw(self, amount): self.balance -= amount re...
fbb53bb006bbcb56fd424567b317d493055d2175
bjargud/PythonForHackers
/create_db.py
735
3.828125
4
#!/usr/bin/python3 import sqlite3 import subprocess def create_db(): db = "./students.db" # delete the database if it exists already proc = subprocess.Popen(["rm " + db], shell = True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout,stderr = proc.communicate() #prin...
4f06af7ebd946614c0f8370e2d93c917d57012af
jpars26/Python_Training
/JetBrains/Elif - Index of synthesis.py
156
3.5
4
a = float(input()) if a > 1 and a < 2: print("Analytic") elif a > 2 and a < 3: print("Synthetic") elif a > 3 and a < 4: print("Polysynthetic")
a3e6947a6f0175ec0bf8c5bd01af9a8a2ee8b127
jpars26/Python_Training
/Lambda_Function.py
245
3.828125
4
#Lambda é um tipo difente de função que nao possiu um nome e é usada apenas para retornar valores. São exclusivamente usadas para retornar entrada e saida lista = [1,2,3,4,5,6] doubled = list(map(lambda x: x * 2, lista)) print (doubled)
cbb80ef0d857b89a5e82cf1dfa7315ebfda2b174
jpars26/Python_Training
/URI/1042.py
179
3.65625
4
a,b,c = input().split() a = int(a) b = int(b) c = int(c) lst = [a, b, c] sorted(lst, key=int) for lista in lst: print(lista) print(" ") for lista2 in lst: print(lst)
00ce2b720213ac43e5aa502cb4efc6169b35a462
redramen/project-euler-solutions
/pythonsolutions/largestPrimeFactor.py
845
4.03125
4
""" Question 3. The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? """ def largestPrimeFactor(): currentFactor = 2 ourNum = 600851475143 # the number we are interested in, can turn into a parameter # instead t...
699f40fb647e2f53235be3fcfb8a15d3f3e948c3
sbrugman/deduplipy
/deduplipy/blocking/blocking_rules.py
3,073
3.59375
4
import re from typing import Optional def whole_field(x: str) -> Optional[str]: x_trimmed = x.strip() if len(x_trimmed): return x_trimmed else: return None def first_word(x: str) -> Optional[str]: x_trimmed = x.strip() if len(x_trimmed): return x_trimmed.split()[0] el...
844abbd605677d52a785a796f70d3290c9754cd6
Aishwaryasaid/BasicPython
/dict.py
901
4.53125
5
# Dictionaries are key and value pairs # key and value can be of any datatype # Dictionaries are represented in {} brackets # "key":"value" # access the dict using dict_name["Key"] student = {"name":"Jacob", "age":25,"course":["compsci","maths"]} print(student["course"]) # use get method to inform user if a ke...
cc0bbc28266bb25aa4822ac443fa8d371bb12399
Akrog/project-euler
/001.py
1,384
4.1875
4
#!/usr/bin/env python """Multiples of 3 and 5 Problem 1 Published on 05 October 2001 at 06:00 pm [Server Time] If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ import sys if (2,...
58c64fe42c486139fefeb829323e2d45989fab00
OrestisRo/sample_pesten
/game.py
1,195
3.609375
4
from player import Player from card import * class Game: CONST_PLAYERNAMES = ['Alice', 'Bob', 'Carol', 'Eve'] deck = Deck() players = [] def __init__(self): print("---Starting new game.---") self.deck.deckInit() print("---A deck of 52 cards has been created.---") self.players = [Player(name) for name in ...
6977eef086d87581e2238131b28468c07170153d
massimotassinari/split
/gestion.py
21,933
3.671875
4
from ast import Str from Usuario import Usuario from Empresa import Empresa from Persona import Persona from fecha_y_hora import * def gestion(api,db,dic,solicitudes): primer_while=True while primer_while: print("\n1. Crear una cuenta\n2. Iniciar seccion \n3. Salir\n") seleccio...
d7a978cd32d2d0db3b05c6fc7f7f7176b105c200
kpiatti/pokemon-analysis-and-classification
/Scripts/remove-kanji.py
1,849
3.515625
4
# remove-kanji # removes kanji characters from the pokemon data file # so it will load into MySQL # DVS 7/2/2021 KANJI_FIELD = 29 input_file = "Data\\pokemon.csv" output_file = "Data\\pokemon-filtered.dat" def retrieve_rows(input, skip_header = True): """ Returns a list of rows from the input file, ommit...
7d3428fd768e5bf71b26f6e6472cf9efa8c79e8b
khyati-ghatalia/Python
/play_with_strings.py
387
4.15625
4
#This is my second python program # I am playing around with string operations #Defing a string variable string_hello = "This is Khyatis program" #Printing the string print("%s" %string_hello) #Printing the length of the string print(len(string_hello)) #Finding the first instance of a string in a string print(strin...
d81dd7743f1bf651ba7808c84a91220d200fb471
kreddy0404/sample_python_scripts
/childclass.py
868
3.9375
4
class BankAccount: def __init__(self, initial_balance): self._balance = initial_balance def get_balance(self): return self._balance def deposit(self, amount): self._balance += amount def withdraw(self, amount): self._balance -= amount class SavingsAccount(BankAccount...
630a7b47a30859b08e8e7e185074207c692e3b9c
kreddy0404/sample_python_scripts
/NLP/dict.py
331
3.921875
4
test_dict = {"a": 43, "b": 1233, "c": 8} min_value = min(test_dict.values()) max_value = max(test_dict.values()) min_key = "" max_key = "" for key in test_dict.keys(): if test_dict[key] == min_value: min_key = key if test_dict[key] == max_value: max_key = key print("min:", min_key) print("max:...
9d60a06d210cbc82ad0e1695ce763a052ad082e2
BrichtaICS3U/assignment-1-functions-alex-b15
/main.py
866
3.953125
4
# Assignment 1 # ICS3U # <Alex Baksh> # March 28, 2018 ###### uncomment this when you are ready to work on it def CtoF (C): F=(1.8)*C+32 return F ###### uncomment this when you are ready to work on it def FtoC (F): C = (0.55556)*(F-32) return C #temperature = int(input('Enter your temperature in...
8a3fba1f60b96f199df9e984b0b105504315c072
nihalgaurav/Python
/Python_Assignments/Assignment_8/Ques4.py
127
3.828125
4
# Ques 4. Extract day from the time. from datetime import datetime d= datetime.now() print(d) print("day:",d.strftime("%A"))
962c2ccc73adc8e1a973249d4e92e8286d307bf1
nihalgaurav/Python
/Python_Assignments/Quiz assignment/Ques4.py
385
4.125
4
# Ques 4. Write a program that accepts a sentence and calculate the number of upper case letters and lower case letters. s=raw_input() d={ "UPPER_CASE" :0, "LOWER_CASE" :0} for c in s: if c.isupper(): d[ "UPPER_CASE" ]+=1 elif c.islower(): d[ "LOWER_CASE" ]+=1 else: pass print("UPPER CAS...
9757f326e5f46c35b6763e3397869e671cc811ff
nihalgaurav/Python
/Python_Assignments/Assignment_9/Ques5.py
660
4.09375
4
'''Ques 5. Create a class Expenditure and initialize it with expenditure,savings.Make the following methods. 1. Display expenditure and savings 2. Calculate total salary 3. Display salary''' class Expenditure: def __init__(self,expenditure,savings): self.expenditure=expenditure self.savings=savings def display(...
9074584e5e2299774f5914205a2def231cd5d9e6
nihalgaurav/Python
/Python_Assignments/Assignment_13/Ques4.py
817
3.859375
4
#Ques 4. What will be the output of the following code: # Function which returns a/b # def AbyB(a , b): # try: # c = ((a+b) / (a-b)) # except ZeroDivisionError: # print "a/b result in 0" # else: # print c # Driver program to test above function # AbyB(2.0, 3.0) # AbyB(3.0, 3.0) # Output... # File "C:/User...
67cf2b00392391f6a480fb4bec173403adda3596
nihalgaurav/Python
/Python_Assignments/Assignment_2/Ques2.py
102
3.546875
4
# Ques2. Join two strings using '+' eg. "Acad"+"View" x="Acad" y="View" z=x+y print(z) print(type(z))
b44cd8d204f25444d6b5ae9467ad90e539ace8b3
nihalgaurav/Python
/Python_Assignments/Assignment_7/Ques1.py
219
4.375
4
# Ques 1. Create a function to calculate the area of a circle by taking radius from user. r = int(input("Enter the radius of circle: ")) def area(): a = r * r * 3.14 print("\nArea of circle is : ",a) area()
99df07ac1b2347e63888ddee21b32b0af23ae26c
oklodhi/CS490PythonDeepLearning
/Source/ICP_2/Question2.py
270
4.09375
4
def string_alternative(s): print("Str: ", s) print("Output: ", end="", flush=True) for i, c in enumerate(s): if i % 2 == 0: print(c, end="", flush=True) string = str(input("Enter a string to the program: ")) string_alternative(string)
1cf4c3d1d29ac4e62b9fe168f755424771f68500
antoshkaplus/CompetitiveProgramming
/ProjectEuler/001-050/50.py
1,213
3.8125
4
""" The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equal to 953. Which prim...
7ceccbd4caf0e063ce603c8b25cc7ddad191325c
antoshkaplus/CompetitiveProgramming
/ProjectEuler/001-050/35.py
1,495
3.765625
4
""" The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97. How many circular primes are there below one million? """ from math import sqrt # returns list ...
c981adbff671b25c53068bfec61fdb98110070da
antoshkaplus/CompetitiveProgramming
/ProjectEuler/050-100/51.py
3,826
3.9375
4
""" By replacing the 1st digit of *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime. By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit number is the first example having seven primes among the ten generated numbers, yielding the family: 560...
c51a30a7be51a2a92c7acfee93d04f96794498e4
antoshkaplus/CompetitiveProgramming
/ProjectEuler/001-050/48.py
563
3.828125
4
""" The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317. Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000. """ def power(x,i,p): """ x - number i - power p - quantity of positions of answer """ q = [] while i != 1: if i%2==0: r = 1 i/=2 else: ...
ef4f49af3cb27908f9721e59222418ee63c99022
antoshkaplus/CompetitiveProgramming
/ProjectEuler/001-050/23.py
2,599
4.21875
4
""" A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n. As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be sh...
069cfc3b9017393be087f30817a213acb7b7a323
antoshkaplus/CompetitiveProgramming
/ProjectEuler/001-050/22.py
1,238
3.875
4
""" Using 22.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For exampl...
e6dc27dfeaf193cefe1caf9cfe0d72f5ce3d7520
antoshkaplus/CompetitiveProgramming
/ProjectEuler/001-050/43.1.py
974
3.515625
4
""" The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property. Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this way, we note the following: d2d3d4=406 is divisible by 2...
4175857cb18a958d0b1c64930a81aafac5f3e95d
antoshkaplus/CompetitiveProgramming
/ProjectEuler/001-050/4.py
453
4.0625
4
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. Find the largest palindrome made from the product of two 3-digit numbers. """ n_max = 999 n_min = 100 max_pal = 0 for i in range(n_max,n_min-1,-1): out = False for j in range(n_...
4089b2d6c9a965f33ad6f4d40a87666e6be232f2
ColinPython/SZ-Programming-Education
/code_archive程序归档/Turtle库的学习/绘制字符串螺旋.py
1,027
3.5625
4
# -*- coding: utf-8 -*- # author: ColinPython_榴莲老师 # 关注微信公众号:“ 青联科创 ”获得等多有趣代码教程 # 日期:2020-4-27,使用的工具:PyCharm,文件名:绘制字符串螺旋 # 做一个海龟画图大全,缩短turtle为t import turtle as t import time # 定义控制面板函数 # c = t.textinput('想画什么', '输入数字,0查看菜单') t.color("brown", "yellow") # 定义默认画笔颜色red,填充颜色黄色 t.shape('turtle') # 定义画笔造型为小海龟 t.screensiz...
dfd277afa4f98c19b547c7e689a23d3b40d8a6a2
ColinPython/SZ-Programming-Education
/code_archive程序归档/Turtle库的学习/绘制七色螺旋.py
910
3.84375
4
# -*- coding: utf-8 -*- # author: ColinPython_榴莲老师 # 关注微信公众号:“ 青联科创 ”获得等多有趣代码教程 # 日期:2020-4-27,使用的工具:PyCharm,文件名:绘制七色螺旋 # 做一个海龟画图大全,缩短turtle为t import turtle as t import time # 定义控制面板函数 # c = t.textinput('想画什么', '输入数字,0查看菜单') t.color("brown", "yellow") # 定义默认画笔颜色red,填充颜色黄色 t.shape('turtle') # 定义画笔造型为小海龟 t.screensiz...
cf1c83c8cabc0620b1cdd1bc8ecf971e0902806f
pgavriluk/python_problems
/reverse_string.py
406
4.21875
4
def reverse(string): str_list=list(string) length = len(string) half = int(length/2) for i, char in enumerate(str_list): last_char = str_list[length-1] str_list[length-1] = char str_list[i] = last_char length = length-1 if i >= half-1: break;...
bdfba35bcfe70938a485ec0b47d9eb97266b6e41
ramsayleung/leetcode
/100/binary_tree_level_order_traversal_ii.py
1,384
4.0625
4
""" source: https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ author: Ramsay Leung date: 2020-04-05 Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example: Given binary tree [3,9,20,null,null,15,7]...
289d7890bb914cbe8498d14022946fd4e7fcce7c
ramsayleung/leetcode
/100/sum_root_to_leaf_numbers.py
1,600
4.0625
4
""" source: https://leetcode.com/problems/sum-root-to-leaf-numbers/ author: Ramsay Leung date: 2020-04-11 Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-t...
918c366baca272bcaef30e1e0e1106769b1610fa
ramsayleung/leetcode
/200/ugly_number_ii.py
1,318
4.15625
4
""" source: https://leetcode.com/problems/ugly-number-ii/ author: Ramsay Leung date: 2020-03-30 Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example: Input: n = 10 Output: 12 Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of ...
4ea8e4c4d6971bc40e8c1205f873e09a9bc26057
ramsayleung/leetcode
/500/maximum_depth_of_n_ary_tree.py
1,475
3.921875
4
""" source: https://leetcode.com/problems/maximum-depth-of-n-ary-tree/ author: Ramsay Leung date: 2020-04-07 Given a n-ary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Nary-Tree input serialization is represented in th...
1541cc66fe78c7b67768cd7dc9214774cc30f07b
ramsayleung/leetcode
/400/partition_equal_subset_sum.py
1,102
3.9375
4
""" Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. Note: Each of the array element will not exceed 100. The array size will not exceed 200. Example 1: Input: [1, 5, 11, 5] Output: tr...
38241117af72f53f0fe345e047ccf8935f0c01dd
ramsayleung/leetcode
/600/non_decreasing_array.py
1,367
3.96875
4
""" source: https://leetcode.com/problems/non-decreasing-array/ author: Ramsay Leung date: 2020-03-01 Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element. We define an array is non-decreasing if array[i] <= array[i + 1] holds for every i (1 <= i < n). ...
283a2833be4b42ddae45e0cf9a92a2894e441cb6
ramsayleung/leetcode
/100/minimum_depth_of_binary_tree.py
1,157
3.96875
4
""" source: https://leetcode.com/problems/minimum-depth-of-binary-tree/ author: Ramsay Leung date: 2020-04-05 Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no children. Examp...
40ea117ae9c90e42ed97ab1a00e7fef03470d56d
ramsayleung/leetcode
/100/path_sum_ii.py
1,405
3.921875
4
""" source: https://leetcode.com/problems/path-sum-ii/ author: Ramsay Leung date: 2020-04-10 Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Example: Given the below binary tree and sum = 22, 5 / \ 4 8 ...
c963de87cbf668a579a6de35ed4873c07b64ee90
ramsayleung/leetcode
/600/palindromic_substring.py
1,302
4.25
4
''' source: https://leetcode.com/problems/palindromic-substrings/ author: Ramsay Leung date: 2020-03-08 Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characte...
86cada22d4c0078b50172e07d9c76f992d778d56
ramsayleung/leetcode
/100/binary_search_tree_iterator.py
3,046
4.21875
4
""" source: https://leetcode.com/problems/binary-search-tree-iterator/ author: Ramsay Leung date: 2020-03-22 Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Example: https://assets.l...
ede9bac2f14b14510b72306e3620977f09d4e3e5
RobertEne1989/python-hackerrank-submissions
/itertools_product_hackerrank.py
772
4.0625
4
''' Task You are given a two lists A and B. Your task is to compute their cartesian product AxB. Example A = [1, 2] B = [3, 4] AxB = [(1, 3), (1, 4), (2, 3), (2, 4)] Note: A and B are sorted lists, and the cartesian product's tuples should be output in sorted order. Input Format The first line cont...
350ff920efd20882b4b138110612d4a6ad08b378
RobertEne1989/python-hackerrank-submissions
/nested_lists_hackerrank.py
1,312
4.40625
4
''' Given the names and grades for each student in a class of N students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. Note: If there are multiple students with the second lowest grade, order their names alphabetically and print each name on a new line. Ex...
af639784c1e2313e2734245d00dfd78163ca501b
RobertEne1989/python-hackerrank-submissions
/itertools_combinations_with_replacement_hackerrank.py
647
3.984375
4
''' Task You are given a string S. Your task is to print all possible size k replacement combinations of the string in lexicographic sorted order. Input Format A single line containing the string S and integer value k separated by a space. Constraints 0 < k <= len(S) The string contains only UPPERCASE...
a0ad6f15852766135cfce42c45d4070f1105e6fe
RobertEne1989/python-hackerrank-submissions
/repeated_string_hackerrank.py
1,559
3.984375
4
''' There is a string, s, of lowercase English letters that is repeated infinitely many times. Given an integer, n, find and print the number of letter a's in the first n letters of the infinite string. Example s = 'abcac' n = 10 The substring we consider is abcacabcac, the first 10 characters of the infinite...
d01ce91ed81058213738aed04fb39716f3184ef2
RobertEne1989/python-hackerrank-submissions
/plus_minus_hackerrank.py
1,785
4.03125
4
''' Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with 6 places after the decimal. Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers wi...
a89e546c4a3f3cd6027c3a46e362b23549eee2d0
RobertEne1989/python-hackerrank-submissions
/validating_phone_numbers_hackerrank.py
1,136
4.4375
4
''' Let's dive into the interesting topic of regular expressions! You are given some input, and you are required to check whether they are valid mobile numbers. A valid mobile number is a ten digit number starting with a 7, 8 or 9. Concept A valid mobile number is a ten digit number starting with a 7, 8 or 9...
8d3e58e5049ef80e24a22ea00340999334358eb2
RobertEne1989/python-hackerrank-submissions
/viral_advertising_hackerrank.py
1,709
4.1875
4
''' HackerLand Enterprise is adopting a new viral advertising strategy. When they launch a new product, they advertise it to exactly 5 people on social media. On the first day, half of those 5 people (i.e.,floor(5/2)=2) like the advertisement and each shares it with 3 of their friends. At the beginning of the sec...