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
4b34898fcb3957341a444633c0c6068d9b1bcfca
sidneyalex/Desafios-do-Curso
/Desafio004.py
393
3.640625
4
algo = input('Digite algo: ') print('O tipo primitivo deste valor é ', type(algo)) print('É um valor numerico?', algo.isnumeric()) print('Só tem espaços?', algo.isspace()) print('É alphanumerico?', algo.isalnum()) print('É alphabetico?', algo.isalpha()) print('É titulo?', algo.istitle()) print('É somente caixa alta?', ...
0afd492ae8246c953c088cf735ae1a525d2d49b9
sidneyalex/Desafios-do-Curso
/Desafio075.py
756
4.125
4
#Desenvolva um pgm que leia quatro valores pelo teclado e guarde-os em uma tupla. No final, mostre: #A)Quantas vezes apareceu o numero 9. #B)Em que posição foi digitado o primeiro 3. #C)Quais foram os numeros pares. print(f'O Programa coleta 4 numeros inteiros e os guarda em uma tupla.') num = (int(input('1º numero: ')...
c6fc804f87019de05e6af481690873e1325be114
sidneyalex/Desafios-do-Curso
/Desafio012.py
306
3.6875
4
#Faça um algoritmo que leia o preço de um produto e mostre seu novo preço, com 5% de desconto. preço = float(input('digite o preço do produto: R$')) desc = preço * 0.05 print('O pruduto está com 5% de desconto, portanto voce economiza R${:.2f} e paga somente R${:.2f}.'.format(desc, preço - desc))
3def1a98ef6897830617c40705c66d9991356e6b
sidneyalex/Desafios-do-Curso
/Desafio077.py
392
3.765625
4
#Crie um pgm q tenha uma tupla com varias palavras(não usar acentos). #Depois disso, você deve mostrar, para cada palavra, quais são as suas vogais. tupla = ('Palavras', 'Aleatorias', 'escolhidas', 'sem', 'nada', 'em', 'comum') for p in tupla: print(f'\nNa palavra {p} temos as seguintes vogais: ', end='') for v...
0daa0067eda4bb3f8ed3fce551217356beaa9f2f
sidneyalex/Desafios-do-Curso
/Desafio020.py
647
3.953125
4
#O mesmo professor do desafio 19 quer sortear a ordem de apresentação de trabalhos dos alunos. Faça um programa que leia o nome dos quatro alunos e mostre a ordem sorteada. '''from random import sample a1 = input('Digite o nome de um dos alunos: ') a2 = input('Mais um: ') a3 = input('Outro: ') a4 = input('O ultimo: ') ...
282a57dae05de18aa4a279fdf64e65e3b797355c
tmkinoue/AtCoder
/20190526/b.py
202
3.59375
4
# -*- coding: utf-8 -*- n = int(input()) sl = [] for i in range(n): sl.append(input().split()) # b = sorted(sorted(a, key = lambda x : x[0]), key = lambda x : x[1], reverse = True) print(sl)
2a0fbd1db6dc73d0157af3e8ee6425463e0bea22
Seymourm2063/backup
/conditionals.py
642
4.09375
4
#conditionals # prompt for age age = input("What is your age: ") age = int(age) if age > 17: print("You can see an R movie") else: # checks for 17 or less print("You can NOT see an R movie") print("Have a wonderful day") myNumber = 5 guess = int(input("Guess a number between 1 and 10")) if guess > ...
0a0dce4bbf1449c34f162926a1e1241dda84dab0
alexkrause88/GItTest
/final.py
3,413
4.15625
4
import sys #this is our dictionary that we will use for our map #this it shows each node and then an inner key that shows all of the connecting nodes # I learned this code from https://docs.python.org/2/tutorial/datastructures.html g = {'Elevator': {'3050':10,'3020':10}, '3050': {'3070':10,'Elevator':10,'...
13f8baa56bc9d120f99b40d21101fa708e60cf52
ejclarke/04-20-python4
/test.py
2,342
4.03125
4
#treat file as list file = open('sonnet_xviii.txt') #relative path for line in file: print(line) #count lines file = open('words_small.txt') count = 0 for line in file: count = count + 1 print(count, "lines") #count words file = open('sonnet_xviii.txt') count = 0 for line in file: words = line.spl...
43ab1f0f21dff9b998bd34771c39024e8069404a
AboutShanhai/Python3
/IterAndYield/IterAndYield.py
1,249
3.984375
4
#!usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/6/7 14:49 # @Author : shanhai # @File : IterAndYield.py # @Software: PyCharm import sys def iterFunction(num=10): number_list = list(range(1, num + 1)) print(number_list) print("iter实现列表元素输出:") it = iter(number_list) for index in it: ...
518ae7d9c5877febbcd5bcdd4d776392bace6bee
ayush7gupta/NLP-using-TensorFlow
/week1/week1-1.py
1,348
3.703125
4
import tensorflow as tf from tensorflow import keras from tensorflow.keras.preprocessing.text import Tokenizer from tensorflow.keras.preprocessing.sequence import pad_sequences sentences= [ 'I love my cats.', 'I love my dogs.', 'People say that my dog is the best.'] test_sentence = [...
b85c5e3c76b68ef65d459f13d195d2e1562d87aa
xxweell/cursoPython
/aula13.py
591
3.921875
4
#for c in range(0, 5): # print('Oi') #for c in range(6, 0, -1): # contar decrescendo # print(c) #for c in range(0, 7, 2): # contar de 2 em 2 # print(c) #num = int(input('Digite um número: ')) #for c in range(0, num+1): # print(c) #print('FIM!') #ini = int(input('Digite o inicio: ')) #fim = int(input('Di...
702ff7042c44aa89786ddf7b5de75ec062a39cea
gbhmh/Python_Lab1
/python code and datasets/5.py
3,049
3.5625
4
from sklearn.datasets import load_diabetes from sklearn.preprocessing import LabelEncoder le=LabelEncoder() import pandas as pd import numpy as np df = pd.read_csv('Loan payments data.csv') print(df.info()) #converting non-numeric features to numeric features using label encoder df['loan_status']=le.fit_transform(df[...
b5c195587ef2ebf320119445f00c377d068d1002
mxl1994/python_test
/test3.py
837
3.609375
4
# -*-coding:utf-8 -*- def list_file(): file_open = open(config["file_read"], "r", encoding="utf-8") file_write = open(config["file_write"], "a+") lists = file_open.readlines() print(lists) list_strs = [] for ele in lists: list_str = ele.strip("\n").split("\t") for str in list_str...
c2e6494c58541f97de07f63cc39eeec14dbf6f09
ChristopherMaselli/Primative-Web-Scraper-prototype
/bundlescraper.py
2,395
3.65625
4
import requests # Allows us to easily make HTTP Get requests of URL's from bs4 import BeautifulSoup url = "https://www.humblebundle.com/books/cloud-computing-books" r = requests.get(url) soup = BeautifulSoup(r.text, 'html.parser') # print(r.status_code) = shows if successful (200) # print(r.text) = shows all of the...
51e30d266e446fd9b2607c1aa2932f6a885f4289
jessep13/Rimstar
/Scripts/Brawl.py
1,720
3.703125
4
def brawl(p, e, w): import os clear = lambda: os.system("cls") clear() ed, pd = False, False print("You Are Brawling A", e.name) while True: print("Enemy:", e.name) p.show_stats() print("1: Attack") print("2: Quit") i = input("> ") if i is "1": ...
82c4291a70fec2cec577fc99394f223502dc60a7
ecastan960/AirBnB_clone
/tests/test_models/test_place.py
1,200
3.59375
4
#!/usr/bin/python3 """User tests""" import unittest from models.place import Place class TestUser(unittest.TestCase): """Checks if user is working""" def test_simpleinstantiation(self): """Checks if a user is created ok""" self.assertEqual(type(Place.name), str) self.assertEqual(typ...
5d2947d2d95cd7999e4f40936997dd945fd19637
Muthulekshmi-99/guvi
/code/hours_minutes.py
61
3.578125
4
m=int(input()) hours=m//60 minutes=m%60 print(hours,minutes)
dcc354de5bac5131f98794f55fa6a1ebafd31fda
Muthulekshmi-99/guvi
/code/factorial_no.py
60
3.5
4
m=int(input()) n=1 for i in range (1,m+1): n=n*i print(n)
2122beb8f83cb24f1c617d9fb388abdf42becd63
Laurentlsb/Leetcode
/leetcode/editor/en/[101]Symmetric Tree.py
2,992
4.375
4
#Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). # # For example, this binary tree [1,2,2,3,4,4,3] is symmetric: # # # 1 # / \ # 2 2 # / \ / \ #3 4 4 3 # # # # # But the following [1,2,2,null,3,null,3] is not: # # # 1 # / \ # 2 2 # \ \ # 3 ...
f83bdbef32373b1a2f9059f906b7b7f278e7d9f6
Laurentlsb/Leetcode
/leetcode/editor/en/[40]Combination Sum II.py
2,160
3.59375
4
#Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. # # Each number in candidates may only be used once in the combination. # # Note: # # # All numbers (including target) will be positive integers....
cac4653bd05e927064bc9a60f7b1f08613c37be8
peterliuu/crm
/crm/crm_pro/补充知识点/3、函数传参.py
354
3.859375
4
# -*- coding:utf-8 -*- # @Author : 'LZ' # @Time : 2019/12/10 19:51 """ print(func(1, True, 2, 4, a=1))--以这样的形式传参不可以 TypeError: func() got multiple values for argument 'a' """ def func(a, flag=True, *args, **kwargs): return a, flag, args, kwargs print(func(1, True, 2, 4, **{'A': 1})) # 可以以这样的形式
d9fe542059b0a2a8e1ec063aef9e7be7217f698b
pythoningLearning/python_start
/test_02.py
2,674
3.890625
4
# one comment print 'Hello world!' def foo(): "this is a doc string" return True print -2 * 4 + 3 ** 2 counter = 0 miles = 1000.0 name = "Bob" counter = counter + 1 kilometers = 1.609 * miles print "%f miles is te same as %f km" % (miles, kilometers) pystr = "python" iscool = "is cool !" print "pystr[0]:...
bf2321f044b3c88c26e67e8da4b6d84fa42ab5f4
eduardoquerido/pythonstuffs
/sortingalgorithms/quicksort.py
1,618
4.09375
4
""" Python heapsort algorithms This function takes last element as pivot, places the pivot element at its correct position in sorted array, and places all smaller (smaller than pivot) to left of pivot and all greater elements to right of pivot """ def partition(array, low, high): i = low - 1 # index of smaller ...
523793eae89af27d15d6e88c1bf2b5d4cecb14c8
njenga5/python-problems-and-solutions
/Solutions/problem79.py
272
3.890625
4
''' Question 79: Please write a program to randomly generate a list with 5 even numbers between 100 and 200 inclusive. Hints: Use random.sample() to generate a list of random values. ''' import random print(random.sample([x for x in range(100, 201) if x % 2 == 0], 5))
2b67533ea6b47d8666f0f3cd72dd7fd7a6b09d89
njenga5/python-problems-and-solutions
/Solutions/problem97.py
640
4.09375
4
''' Question 97: Please write a program which accepts a string from console and print it in reverse order. Example: If the following string is given as input to the program: rise to vote sir Then, the output of the program should be: ris etov ot esir Hints: Use list[::-1] to iterate a list in a reverse order. '''...
b27939b3a840c30900ec11f6c41372108c8a78d0
njenga5/python-problems-and-solutions
/Solutions/problem62.py
224
4.46875
4
''' Question 62: Write a program to read an ASCII string and to convert it to a unicode string encoded by utf-8. Hints: Use unicode() function to convert. ''' word = 'Hello world' word2 = unicode(word, 'utf-8') # print(word2)
b8b8639b7244a36bce240fd61986e799027c1c4e
njenga5/python-problems-and-solutions
/Solutions/problem47.py
396
4.15625
4
''' Question 47: Write a program which can map() and filter() to make a list whose elements are square of even number in [1,2,3,4,5,6,7,8,9,10]. Hints: Use map() to generate a list. Use filter() to filter elements of a list. Use lambda to define anonymous functions. ''' nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] nums3 =...
cd526869d4d51b2b674b9335c89ad71efddde994
njenga5/python-problems-and-solutions
/Solutions/problem59.py
621
4.34375
4
''' Question 59: Assuming that we have some email addresses in the "username@companyname.com" format, please write program to print the company name of a given email address. Both user names and company names are composed of letters only. Example: If the following email address is given as input to the program: john...
513d7bafcc4de1b6ca81b514e381918f9c0c9052
njenga5/python-problems-and-solutions
/Solutions/problem82.py
337
4.0625
4
''' Question 82: Please write a program to compress and decompress the string "hello world!hello world!hello world!hello world!". Hints: Use zlib.compress() and zlib.decompress() to compress and decompress a string. ''' import zlib s = 'hello world!hello world!hello world!hello world!' compressed = zlib.compress(s) p...
4eac214e15a3d21aef858726865d0e633c8e799d
njenga5/python-problems-and-solutions
/Solutions/problem49.py
293
4.15625
4
''' Question 49: Write a program which can map() to make a list whose elements are square of numbers between 1 and 20 (both included). Hints: Use map() to generate a list. Use lambda to define anonymous functions. ''' nums = [i for i in range(1, 21)] print(list(map(lambda x: x**2, nums)))
878e52902b63ed79cd80fd9ceefe909528bc7abd
njenga5/python-problems-and-solutions
/Solutions/problem28.py
210
4.1875
4
''' Question 28: Define a function that can convert a integer into a string and print it in console. Hints: Use str() to convert a number to string. ''' def convert(n): return str(n) print(convert(5))
69cabf96a705d1be9b44ddcd948c7b561fa37378
njenga5/python-problems-and-solutions
/Solutions/problem25.py
438
3.765625
4
''' Question 25 Level 1 Question: Define a class, which have a class parameter and have a same instance parameter. Hints: Define a instance parameter, need add it in __init__ method You can init a object with construct parameter or set the value later ''' class Test: parameter = 'Process' def _...
b0f6a31dc59b6f65bb7426639d8f9b7b8ed81021
shiawaseniikiyo/practices
/jump7.py
131
3.53125
4
a=1 for a in range (100): a+=1 if a%7==0: continue elif (a-7)%10==0 or a//10==7: continue print(a)
a9a9464a2fb5bf6699f2af78e360bae345408688
krishnaallani/pythonpractice
/src/findMinimumheight.py
990
3.9375
4
#!/usr/bin/env python class node: def __init__(self,val): self.value = val self.left = None self.right = None def insert(self,data): if self.value == data: return False elif self.value > data: if self.left: return self.left.insert(data) else: self.left = node(data) return True ...
419e07b12c6b06d1b51dec1d9d91f7e09f34d863
krishnaallani/pythonpractice
/src/countNeg.py
271
3.515625
4
#!/usr/bin/env python def countNeg(M,n,m): count = 0 i = 0 j = m-1 while j >=0 and i < n: if M[i][j] <0: count +=(j+1) i += 1 else: j -=1 return count M = [ [-3, -2, -1,-1, 1], [-2, -2, 3, 4], [-4, 5, 7, 8] ] print countNeg(M,3,4)
92bd5e4dc8ebf45c50f3969a3e9583cada451906
krishnaallani/pythonpractice
/src/lca.py
669
3.671875
4
#!/usr/bin/env python class node: def __init__(self,val): self.value = val self.left = None self.right = None def findPath(root,path,k): if root == None: return False path.append(root.value) if root.value == k: return True if root.left != None and findPath(root.left,path,k) or root.right != ...
c99abd60310c50929cec57781101bfa3f29d23ec
krishnaallani/pythonpractice
/src/sum_of_tree.py
588
3.875
4
#!/usr/bin/env python class Node: def __init__(self,val): self.value = val self.left = None self.right = None def inorder(self): if self: if self.left: self.left.inorder() print self.value if self.right: self.right.inorder() def findSum(root): if root == None: return 0 ...
84c639d15de0b7af4d3bcc57c6363de03c15d018
narendragnv/test
/2_datatypes.py
937
4.25
4
# list == array # tuple # dict ## LIST a = ["somestring", 2, 4.0] print(a) b = [2.3, a] b = [2.3, ["somestring", 2, 4.0]] # same as above line print(b) print(2 in a) print(3 not in a) print("somestring" in a) print("string" in a) a = ["somestring", 2, 4.0] print(a) print(a[1]) a[1] = 32 # list is mutable print(a) ...
ddc997dd58ad77667da5d030be0c62a0d5809bde
ademaas/python-ex
/round5/telemarketer.py
963
3.78125
4
def calculate_profit(list_orders): sum= 0 print('Payments of each day:\n') for x in list_orders: if x > LIMIT: profit = LIMIT*NORMAL_PAYMENT + (x-LIMIT)*HIGHER_PAYMENT else: profit = x* NORMAL_PAYMENT print_profit(profit) sum = sum + profit print('...
24252d812a834e02949a49c50e73e6e513862c44
ademaas/python-ex
/round5/costcalculator.py
889
4.03125
4
def calculate_average(group_list): ind_pay = [] sum =0 for i in range(group_list): x = float(input('Enter the sum (eur) paid by participant no {:d}.\n'.format(i+1))) ind_pay.append(x) sum=sum+x print('Total costs are {:.2f} eur.'.format(sum)) average = sum/group_list ...
603ed1468ffe0e7b5feaa5a34d9a334cfdcc3e67
ademaas/python-ex
/round5/time_calculator.py
1,278
4
4
def read_time(): time = [] h = int(input('Input the hours.\n')) while(h<0 or h> 23): h = int(input('Input the hours.\n')) time.append(h) m= int(input('Input the minutes.\n')) while(m<0 or m>59): m= int(input('Input the minutes.\n')) time.append(m) ret...
11e544465387266754d5d06a88c3d0bbe48942fa
ademaas/python-ex
/round9/bank.py
1,962
3.875
4
import bank_account def read_account(): ok = False while not ok: try: amount = float(input('Enter the amount to be deposited into the second account.\n')) ok = True except ValueError: print("ERROR: You did not enter a valid integer!") print("Try a...
35125342848100e7860cd9834d007353b70525ff
yassersaidi/Python-ZTM
/regExpres/password.py
179
3.59375
4
import re string = "Hello world yasser" print("hello" in string) pattern = re.compile(r"(^[a-zA-Z0-9#$%&@]*{8,})") password = "hgdsahdg54545" print(re.match(password))
8fca8aa8b2ab78ccac5853868ad4aa39f33b3810
yassersaidi/Python-ZTM
/conditionsANDLoops.py
2,364
3.75
4
# #shorthand # is_online = False # message_for_u = "Amine is Online" if is_online else "Amine isn't Online" # print(message_for_u) # dict = { # 'name': 'Yasser', # 'age': 22, # 'gender': 'Male' # } # for key,value in dict.items(): # print(f"{key}\t{value}") # s = 0 # my_list =...
f6443dc936c0d32efd76f939070b09993fb75656
deathpit123/python-1
/old/review/hi
139
3.765625
4
#!/usr/bin/env python3 import colors as c print(c.clear + c.red + "what is your name?" +c.reset) name = input(" > ") print("hi " + name)
498f674e9f39e456d130dac73ae2bb6ff8bbcd73
deathpit123/python-1
/old/nyan
90
3.609375
4
#!/usr/bin/env python3 import colors as c while True: print(c.blue+'meow',end=' ' )
f319a740770489ab4970f6b38bc705029ebf5003
darchoco/python-challenge
/pybank/main.py
3,510
4.0625
4
#import needed modules import os import csv #establish variables that will be called in csv loop rowcount = 0 nettotal = 0 average_change_list = [] largestincrease = 0 greatestdecrease = 0 previoustotal = 0 #set to the initial total in the CSV file... stupid hard coding currenttotal = 0 largestincreas...
512d5764466b7687ed62b222f82b03dce5ea9ee3
karinahu/Test2
/homework1-master/01_list_search/test.py
1,716
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # load our search functions from the other files from linear_search import linear_search from binary_search import binary_search # load our timing module import timeit # load random module for creating a random list import random '''def random_list(list_length=1): ...
67d0489a0350947afe266bf0588dbb7417210765
WangYue1998/Algorithms-and-Data-Structures
/project2/p2.py
3,106
4.125
4
""" PROJECT 2 - Recursion Name: Yue Wang PID: A54267282 """ from Project2.LinkedNode import LinkedNode def insert(value, node=None): """Insert the given value into the linked list that has head node The value should be inserted such that the list remains in ascending order Return the starting node of the ...
62ed099d5b99fafc9fa44d21f696402333524451
romitheguru/ProjectEuler
/4.py
821
4.125
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. """ def num_reverse(n): reverse = 0 while n: r = n % 10 n = n // 10 revers...
5948d07b0eb6ab8ada30ac9812cecfe36ba7d2eb
KaitoSorimachi/programing
/sihei.py
1,457
3.75
4
""" 金額を入力するとその金額を出来るだけ少ない枚数の貨幣を使って支払えるように貨幣の枚数を数えるプログラムを書いて下さい。貨幣は、{1万円札、五千円札、千円札、五百円玉、百円玉、五十円玉、十円玉、五円玉、一円玉}とする(余り使わないので2千円札は除く)。 実行結果 金額(円)> 48767 金額: 48767 円 一万円札= 4 枚 五千円札= 1 枚 千円札 = 3 枚 五百円玉= 1 枚 百円玉 = 2 枚 五十円玉= 1 枚 十円玉 = 1 枚 五円玉 = 1 枚 一円玉 = 2 枚 """ suuji = 11 while suuji == 11: try: money = int(input("...
230f3b9c7735deadb877274b1dfc9c6203f407c7
umahato/pythonDemos
/4_MethodAndFunctions/7_argsAndKwargs.py
1,279
4.1875
4
''' def myfunc(a,b): #Return 5% of the sum of a and b return sum((a,b)) * 0.05 print(myfunc(40,60)) def myfunc(*args): return sum(args) * 0.05 print(myfunc(34,53,53)) def myfunc (**kwargs): print(kwargs) if 'fruit' in kwargs: print('My fruit of choise is {}'.format(kwargs['fruit'])) ...
cf4bf78e08205d21f77080dc552247a94a3283e4
umahato/pythonDemos
/3_PythonStatements/3_whileLoops.py
909
4.375
4
# While loops will continue to execute a block of code while some condition remain true. # For example , while my pool is not full , keep filling my pool with water. # Or While my dogs are still hungry, keep feeding my dogs. ''' x = 0 while x < 5: print(f'The current value of x is {x}') #x = x +1 x += 1 el...
b7f0c53ae0215250ecf91d5f59489c8fd1f8793c
SilviaVazSua/Python
/Basics/coding_life.py
376
4.15625
4
# a program about something in real life :D number_of_stairs_1_2 = int(input("Tell me how many stairs from floor 1 to floor 2, please: ")) floor = int(input("In which floor you live? ")) total_stairs = number_of_stairs_1_2 * floor print("Then, if the elevator doesn\'t work, you will have ", total_stairs, "until you...
247b7c1a9aba17644415a90f117b4d327e3f332d
SilviaVazSua/Python
/Basics/leap_years.py
719
4.25
4
# This program asks for a starting year and an ending year and then puts all the leap years between them (and including them, if they are also leap years). Leap years are years divisible by 4 (like 1984 and 2004). However, years divisible by 100 are not leap years (such as 1800 and 1900) unless they are also divisible ...
fe52aa39d159e96c4773fd3072f779dcca74bcdd
SilviaVazSua/Python
/Advance/number_to_letters.py
82
3.515625
4
for i in range(65, 116): if i < 90 or i > 96: print(i, " stands for ", chr(i))
b507b8ff2ee5fbe4d3432b55e2ad8bce2e8a7c14
madgang/Study
/python_ruby/Modul/3.py
150
3.546875
4
import auth login_id = input('아이디를 입력해주세요') if auth.login(login_id): print('Hello '+login_id) else: print('Who are you?')
151e20cbd40596e0db53538edca4ad0e5b2d7f6d
madgang/Study
/python_ruby/Class_Member/3.py
1,383
3.75
4
class Calc(object): _history = [] def __init__(self,value1,value2): if isinstance(value1, int): self.value1 = value1 if isinstance(value2, int): self.value2 = value2 def add(self): result = self.value1 + self.value2 Calc._history.append("add : %d + %d ...
634776faba579fed3b8b1566f99125668f541975
rozanhilmi/Big_Data_CISCO
/Python project 1/bangunruang.py
2,410
3.8125
4
hitung = 'kubus','balok','bola' for x in hitung : hitung = str(input('mau menghitung apa ? (kubus/balok/bola) ')) if hitung == 'kubus': sisi = int(input('sisinya berapa ? ')) print() print('-------- KUBUS ---------') luas = 6*sisi*sisi keliling = 12*sisi volume = sisi*sisi*sisi prin...
e8f1bb445845fc25a0382b1178ff6d8fc972e148
1609cteam/1609C_repository
/interface_test_pro/run.py
807
3.5625
4
import unittest class MyTest(unittest.TestCase): # 继承unittest.TestCase def tearDown(self): # 每个测试用例执行之后做操作 print('111') def setUp(self): # 每个测试用例执行之前做操作 print('22222') @classmethod def tearDownClass(self): # 必须使用 @ classmethod装饰器, 所有test运行完后运行一次 print...
0ca234eadb72d02b9c4d9c0bf4d3a08c5c2a43a1
cvannelli/Data-Structures
/Python/queue.py
365
4
4
# A simple Queue implementation class Queue(): def __init__(self): self.queue = [] def enqueue(self, value): self.queue.insert(0, value) def dequeue(self, value): try: return self.queue.pop() except IndexError: print("Cannot dequeue an empty queue") def size(self): return len(self.queue) def ...
e444e84df5f79233d2b375795df6495ddd0ac89e
manasm11/DSA
/Array/Sorting/selectionSort.py
352
3.921875
4
def selection_sort(list_of_numbers): length = len(list_of_numbers) for i in range(length): max_index = i for j in range(i, length): max_index = j if list_of_numbers[j] > list_of_numbers[max_index] else max_index list_of_numbers[i], list_of_numbers[max_index] = list_of_numbers...
43c40e8eb46f891023aea282aa8fff1e081581fc
razvanalex30/Exercitiul3
/test_input_old.py
1,138
4.21875
4
print("Hi! Please choose 1 of these 3 inputs") print("1 - Random joke, 2 - 10 Random jokes, 3 - Random jokes by type") while True: try: inputus = int(input("Enter your choice: ")) if inputus == 1: print("You have chosen a random joke!") break elif inputus == 2: print("You have chos...
c4c32ee34cdfec3dfd5b59a64beba823a0cf43a3
annisakaraca/School-projects
/6-degrees-BFS/graph_toolz.py
9,361
4.125
4
import os from collections import deque class Graph(object): # Initializing empty graph def __init__(self): self.adj_list = dict() # Initial adjacency list is empty dictionary self.vertices = set() # Vertices are stored in a set self.degrees = dict() # Degrees stored as diction...
a70be84406ab8fdf4944f6030533fbda0297b11e
ashishp0894/CS50
/Test folder/Classes.py
910
4.125
4
"""class point(): #Create a new class of type point def __init__(self,x_coord,y_coord): #initialize values of class self.x = x_coord self.y = y_coord p = point(10,20) q = point (30,22) print(f"{p.x},{p.y} ") """ class flight(): def __init__(self,capacity): self.capacity = capacity ...
eec8d6944bf8b9bf6eeaa515fd1ca7a8e0896328
ashishp0894/CS50
/Test folder/Conditions.py
213
4.125
4
Number_to_test = int(input("Number")) if Number_to_test>0: print(f"{Number_to_test} is Positive") elif Number_to_test<0: print (f"{Number_to_test} is Negative") else: print(f"{Number_to_test} is Zero")
23f6a8643e06ed18a73c9bf1519b9719e0a3283c
christophe12/RaspberryPython
/codeSamples/fileManipulation/functions.py
933
4.25
4
#----handy functions---- #The os() function #os.chdir('directory_name') -> changes your present working directory to directory_name #os.getcwd() -> provides the present working directory's absolute directory reference #os.listdir('directory_name') -> provides the files and subdirectories located in directory_name. if...
3641eb15f558397f57cb89f8fb8c350224d63eed
christophe12/RaspberryPython
/pygame/games/Smarter/level one/chapter 6/animation.py
4,051
3.625
4
import pygame, sys from pygame.locals import * from smarter import Smarter class Animation(Smarter): """ This class will handle all the animations in the game. """ main_surf = None # this will hold the surface on which to perform the animation text_x = 0 #holds the x value for the text being animated hold_size = ...
7e0e91a60964cc1e93fb91adb6d3ea5f1ff43442
christophe12/RaspberryPython
/codeSamples/while-loop.py
85
4
4
# Looping: how we repeat things b = 0 while b < 5: print("Hello World!") b = b + 1
61938b5ebbbace0b3747025301f8df4ad98de8af
marcinbogdanski/rl-agent
/rl_agent/envs/swap_actions.py
2,156
3.65625
4
import gym class SwapActions: """Test envirnoment corresponds to Sutton and Barto 13.1 Nov 2017 draft. This is 3-state environment with middle state having left-right actions swapped. All states look the same to the agent. States are as follows: - 0 - left most state, start state, action le...
7da29195b143a2b7e6a78de02768428ce5d4ed49
reneelightner/explore-movies
/admin/Makejson.py
3,084
3.859375
4
#!/usr/bin/env python """Makejson.py: Output a json file from the data in movie_titles_metadata.txt. This json will be used in data viz prototype""" __author__ = "Renee Lightner" import json import pprint import ast # open the text file file = open('movie_titles_metadata.txt') # create an empty list where each lin...
41dbb5fe10b7ae1fd15074ba8bfe35eb7aa18896
SuryakantKumar/Data-Structures-Algorithms
/Recursion/Remove-Duplicates.py
748
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jan 5 18:17:33 2020 @author: suryakantkumar """ ''' Problem : Given a string S, remove consecutive duplicates from it recursively. Input Format : String S Output Format : Output string Constraints : 1 <= Length of String S <= 10^3 Sample Input : aab...
39c945c90a4e5048a293220dd00972e3b65171f9
SuryakantKumar/Data-Structures-Algorithms
/Conditions & Loops/Binary_To_Decimal.py
856
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Dec 26 07:13:51 2019 @author: suryakantkumar """ ''' Problem : Given a binary number as an integer N, convert it into decimal and print. Input format : An integer N Output format : Corresponding Decimal number (as integer) Sample Input 1 : 1100 Samp...
0ea9bf052665153ce2981af0079f0e4697567863
SuryakantKumar/Data-Structures-Algorithms
/Searching & Sorting/Sum-Of-Two-Arrays.py
2,221
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 2 02:43:34 2020 @author: suryakantkumar """ ''' Problem : Two random integer arrays are given A1 and A2, in which numbers from 0 to 9 are present at every index (i.e. single digit integer is present at every index of both given arrays). You need t...
ff0e7cbbf0cff9dd00e60a14d1382e52aac4331f
SuryakantKumar/Data-Structures-Algorithms
/Functions/Check_Prime.py
554
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 24 05:36:47 2019 @author: suryakantkumar """ ''' Problem : Write a function to check whether the number N is prime or not. Sample Input 1 : 5 Sample output 1 : prime Sample input 2 : 4 Sample output 2: Not Prime ''' def IsPrime(n): if n...
5d074b64d2c60946f117c4f6e851f125ce46e6cd
SuryakantKumar/Data-Structures-Algorithms
/Miscellaneous Problems/Modulo-Operator.py
521
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 16 15:44:48 2020 @author: suryakantkumar """ def modulous(m, n): if n == 0: return -1 elif m == n: return 0 elif m < n: return m else: sum = n original = sum while s...
1c4ccd633778efae1e6d402385ff2eb10a509c91
SuryakantKumar/Data-Structures-Algorithms
/Exception Handling/Else-And-Finally-Block.py
1,101
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Mar 7 14:42:20 2020 @author: suryakantkumar """ while True: try: numerator = int(input('Enter numerator : ')) denominator = int(input('Enter denominator : ')) division = numerator / denominator except Valu...
649b45e5fb2fe8b50542cbab310a8cc2d22b511d
SuryakantKumar/Data-Structures-Algorithms
/Miscellaneous Problems/Chessboard-Game.py
629
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 22 13:32:07 2020 @author: suryakantkumar """ from functools import lru_cache @lru_cache def chessboardGame(x, y): print(x, y) if x <= 2 or y <= 2: return 'Second' if chessboardGame(x - 2, y + 1) == True or chessboardGame(x ...
b895e3cd708cd102baaf7f4126f4d1a13c32e889
SuryakantKumar/Data-Structures-Algorithms
/Object Oriented Programming/Class-Method.py
1,374
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 6 06:20:20 2020 @author: suryakantkumar """ from datetime import date class Student: def __init__(self, name, age, percentage = 80): # Init method self.name = name self.age = age self.percentage = percentage ...
173bc92d9f2a8f8bcba0f789f774ad057cc9a3a4
SuryakantKumar/Data-Structures-Algorithms
/Arrays & Lists/Find-Duplicate-Element.py
1,352
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 31 14:10:56 2019 @author: suryakantkumar """ ''' Problem : Given an array of integers of size n which contains numbers from 0 to n - 2. Each number is present at least once. That is, if n = 5, numbers from 0 to 3 is present in the given array at le...
eda1cb04fd10eb376b807213cfc11f3b6544e586
SuryakantKumar/Data-Structures-Algorithms
/Miscellaneous Problems/Neighbours.py
1,126
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 30 14:23:26 2020 @author: suryakantkumar """ ''' Given a matrix, area which is a village in which every element is a home. Some homes have value 1 and some are having 0. 1 means occupied home and 0 means home is vacant. We need to find number of n...
0beb688b4af8803550204cf01f8879b8f327050e
SuryakantKumar/Data-Structures-Algorithms
/Functions/Fahrenheit_To_Celcius.py
878
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 24 07:44:35 2019 @author: suryakantkumar """ ''' Problem : Given three values - Start Fahrenheit Value (S), End Fahrenheit value (E) and Step Size (W), you need to convert all Fahrenheit values from Start to End at the gap of W, into their correspo...
7a39a095fd92388418ffc239731f88dd8f52e807
SuryakantKumar/Data-Structures-Algorithms
/Object Oriented Programming/Class-Attribute-And-Instance-Attribute.py
808
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 6 05:36:23 2020 @author: suryakantkumar """ class Student(): passingPercentage = 60 s1 = Student() # Creation of object / instance s2 = Student() print(Student.passingPercentage) # Accessing class Attirbute s1.na...
2450c7cccafa7d66157ef16b35ced3b903ee0b60
SuryakantKumar/Data-Structures-Algorithms
/Searching & Sorting/Insertion-Sort.py
1,120
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 1 08:42:58 2020 @author: suryakantkumar """ ''' Problem : Given a random integer array. Sort this array using insertion sort. Change in the input array itself. You don't need to return or print elements. Input format : Line 1 : Integer N, Array S...
740fa073a7d31e7171f97c811b2d50fcc28a6f51
SuryakantKumar/Data-Structures-Algorithms
/Recursion/Sum-Of-Natural-Numbers.py
457
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jan 5 10:04:44 2020 @author: suryakantkumar """ ''' Problem : Find sum of n natural numbers using recursion. Input format : One integer n Output Format: ∑n (i.e, Sum of n natural numbers) Sample Input 1 : 5 Sample Output 1 : 15 ''' def Sum(n): ...
574b565c7bc5fecb11693ef0b7e7687437ae429d
SuryakantKumar/Data-Structures-Algorithms
/Miscellaneous Problems/Bishop-Move.py
1,112
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 27 11:57:07 2020 @author: suryakantkumar """ ''' Find out number of positions on chess where bishop can attack. Bishop position is given as (x, y) coordinates and chess dimension is n * n. ''' def bishopMove(chess, position): count = 0 x, ...
6b2f818944fa2bf1c4ceb82056ec47e7e9bcca22
SuryakantKumar/Data-Structures-Algorithms
/Recursion/Remove-X.py
692
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jan 5 18:11:40 2020 @author: suryakantkumar """ ''' Problem : Given a string, compute recursively a new string where all 'x' chars have been removed. Sample Input 1 : xaxb Sample Output 1: ab Sample Input 2 : abc Sample Output 2: abc Sample Input...
89a774833698f87a01144154d703484becd9c60a
SuryakantKumar/Data-Structures-Algorithms
/Patterns/Arrow-Pattern.py
571
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Sep 19 01:34:26 2019 @author: suryakantkumar """ ''' Problem : Print Arrow Pattern for n = 7 as : * * * * * * * * * * * * * * * * ''' p = int(input()) q = (p+1)//2 for i in range(1, q+1): for spaces in range(i-1): print(' ...
d8289da60853d02ec138ee58dfcafbdacbd31798
SuryakantKumar/Data-Structures-Algorithms
/Arrays & Lists/Triplet-Sum.py
1,691
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 31 14:37:41 2019 @author: suryakantkumar """ ''' Problem : Given a random integer array and a number x. Find and print the triplets of elements in the array which sum to x. While printing a triplet, print the smallest element first. That is, if a v...
770ba84b7c571d65fa91b6cd8b904d04f34aa849
pablorodriper/multi-camera-tracking
/evaluation/bbox_iou.py
2,078
3.5
4
def bbox_iou(bboxA, bboxB): # compute the intersection over union of two bboxes # Format of the bboxes is [tly, tlx, bry, brx, ...], where tl and br # indicate top-left and bottom-right corners of the bbox respectively. # determine the coordinates of the intersection rectangle xA = max(bboxA[1], b...
77e742ad3aafc00c3beb4e727a12726195ca8dac
kndo/leetcode-python
/0001-two-sum.py
2,561
4.0625
4
#!/usr/bin/env python def two_sum1(nums, target): """Find indexes i and j of an array whose values add up to the target. Can assume that each input has exactly one solution. Time: O(n^2) -- nested loops to find all combinations of sums Space: O(1) -- loop through the array in place; each sum is O(1) ...
837239e92ebec4db6c07b9e56f7df03e7b0fd62e
de-Pret-Mikael/Escape-the-Dungeon
/libs/item/item.py
414
3.546875
4
class Item: def __init__(self, x, y, name, photo): """ PRE : x et y doivent être des integers, name et photo doivent être un str POST : Donne x à x, y à y, donne name à itemName et photo à pType """ self.x = x self.y = y self.itemName = name self.pType...
4d6ee89da9735ae8d7d0645bd2ad17cc4ea593cd
mpeamma/advent-of-code-2015
/day5/main1.py
439
3.6875
4
import re f = open("input", "r") contents = f.readlines() good_strings = 0 for line in contents: line = line.strip() vowels = len(re.findall("[aeiou]", line)) has_double = bool(re.search(r'(.)\1', line)) bad_strings = "ab" in line or "cd" in line or "pq" in line or "xy" in line if(has_double): ...
107b5eb33976e532814d92abcdf8c79381b11bf0
2016rshah/book-search
/wordSearch.py
2,124
3.734375
4
#------------------------------------------------------------------------------- # Name: word-finder # Purpose: Make english class easier # # Author: Rushi Shah # # Created: 09/11/2014 # Copyright: (c) Rushi Shah 2014 # Licence: <your licence> #-------------------------------------------------...
f0bb5bf89674632a249d665e4c54356c9cd24104
Eden998/SudokuSolver
/suduku.py
1,635
3.75
4
board = [ [0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0], [0,0,2,0,0,0,5,0,0], [0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0], [0,0,0,0,0,1,0,0,0], [0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0], [0,0,0,0,0,7,0,0,0] ] def print_board(board): for line in board: print(line...
45bdd6bd59231e63b4b0fe2f135e38048f50e4f9
rahulkatlaparthi/my-library
/models.py
498
3.65625
4
import sqlite3 as sql def insertUser(idcard_number, email, password): con = sql.connect("mylibrary.sqlite") cur = con.cursor() cur.execute("INSERT INTO user (idcard_number,email,password) VALUES (?,?,?)", (idcard_number, email, password)) con.commit() con.close() def retrieveUsers(): con = s...
2eb91a43f2eff80d60759815817ad882bcee0b49
kareemalsawah/Flappy_bird_circuit
/game.py
4,628
3.71875
4
import pygame import random pygame.init() pygame.mixer.init() WIDTH = 600 HEIGHT = 400 FPS = 60 #Global game variables gravity = 0.8 jumpImpulse = -12 # Represents the impulse applied when a bird jumps barrelSpeed = 6 # Speed by which the barrel is moving to the left barrelWidth = 125 # Width of the opening in the ...
38b786973fb3e48cd0ab851023f6421582eff86a
gavendanoc/misCursos
/Complete-Python-3-Bootcamp-master/Mis cosas/dataStructures/BinarySearchTree.py
3,058
3.765625
4
# cute from TreeNode import TreeNode from Stack import Stack from Queue import Queue class MyBST: def __init__(self): self.size = 0 self.root = None @staticmethod def heightNode(node): return 0 if node is None else 1 + max(MyBST.heightNode(node.left), MyBST.heightNode(node.right)) def height(self): retur...
c13a05399e686afbfd22cfd357c5bd7f92b49fca
gavendanoc/misCursos
/Complete-Python-3-Bootcamp-master/Mis cosas/queue.py
741
4.03125
4
class Node: def __init__(self, value, next=None, prev=None): self.value = value self.next = next self.prev = prev class Queue: size = 0 start = None end = None def __init__(self): self.start = Node(0) self.end = Node(0) self.start.next = self.end self.end.prev = self.start def inqueue (self, n): ...