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
cec0de331d63b5bfc03d99d8ca0b843471d40a54
Halal-Appnotrix/Problem-Solving
/hackerrank/Problem-Solving/Algorithm/Warmup/Mini_Max_Sum.py
299
3.796875
4
''' Problem Link:-https://www.hackerrank.com/challenges/mini-max-sum/problem ''' def miniMaxSum(arr): Suming_arr = [ sum(arr) - i for i in arr ] print(min(Suming_arr), max(Suming_arr)) if __name__ == '__main__': arr = list(map(int, input().rstrip().split())) miniMaxSum(arr)
85b7cadb2452063b7c9330a36558ee4dcc9f8888
Halal-Appnotrix/Problem-Solving
/hackerrank/Problem-Solving/Algorithm/Warmup/BirthdayCake.py
303
3.59375
4
''' Problem Link:-https://www.hackerrank.com/challenges/birthday-cake-candles/problem ''' def birthdayCakeCandles(ar): maximum_num = max(ar) return ar.count(maximum_num) if __name__ == "__name__": ar = list(map(int, input().split(())) res = birthdayCakeCandles(ar) print(res)s
b57b87613722928d3011f9bba5325e962765a403
matsalyshenkopavel/codewars_solutions
/Stop_gninnipS_My_sdroW!.py
833
4.125
4
"""Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (like the name of this kata). Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.""" def spin_words(sent...
91dbac050284be497951bff95906a76d754c1e21
faizygithub/-Database-Appplication-Demo-using-tkinter
/Database Application/account/acc.py
1,227
3.640625
4
class Account: def __init__(self,filepath): self.filepath=filepath with open (filepath,'r') as file: self.balance=int(file.read()) def withdraw(self,amount): self.balance=self.balance-amount def deposit(self,amount): self.balance=self.balance+amount ...
224b04df8a951e6e19d9dda07f32588882ddd9d7
Mature2010/generador-de-contrasenas
/contrasena.py
585
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import random listaSignos = ["!", "#", "$", "%", "&", "(", ")", "=", "?", "¿", "¡", "+", "-", "*"] i = 0 f = open ('listado-general.txt','r') lista = f.read().split() while i < 5: parteUno = "" parte1 = lista[random.randrange(80383)] for letra in parte1: azar = r...
46fe3fcb79ff76e0214215fff0bc6a2af4b5d514
atw1020/AmongUsScraper
/src/Models/Text_Recognition/YOLO/box_geometry.py
2,078
4
4
""" Author: Arthur Wesley """ def box_area(box): """ finds the area of the box :param box: box to find the area of :return: area of the box """ # decompress tuple x, y, w, h = box return w * h def overlap_distance(x1, w1, x2, w2): """ finds the distance of overlap of t...
c81c3b35d20221d90593bec531469b94e9258304
ngocson2vn/learnpython
/itv/selection_sort.py
435
3.8125
4
#!/usr/bin/python class SelectionSort(object): """ i j-> [10, 9, 20, 5, 8, 16, 7] i j-> [5, 9, 20, 10, 8, 16, 7] """ def sort(self, arr): n = len(arr) for i in xrange(n): min_index = i for j in xrange(i + 1, n): if arr[j] < arr[min_index]: min_index = j a[i], a[min_index] = a[...
16cd37791ec10dfabfe673d39e14ffb2cf9d2430
ngocson2vn/learnpython
/itv/decimal_fraction_to_binary.py
706
3.953125
4
#!/usr/bin/python MAX_BITS = 32 def decimal_fraction_to_binary(num): if num is None or num >= 1 or num <= 0: return 'ERROR' result = ['0', '.'] while True: num = num * 2 if num >= 1: result.append('1') num = num - 1 else: result.append('0...
35e922b8acad4943fa4e104a1d6f1febb0bf840c
ngocson2vn/learnpython
/iterator.py
408
3.75
4
#!/usr/bin/python class PowerTwo: """ A custom iterator """ def __init__(self, max = 0): self.max = max def __iter__(self): self.n = 0 return self def next(self): if self.n <= self.max: result = 2 ** self.n self.n += 1 return result else: raise StopIteration obj = PowerTwo(4) pt = it...
c03a857775c1100a3d62a2f26687ad169bc4059d
ngocson2vn/learnpython
/oop/person.py
231
3.609375
4
class Person: def __init__(self, name, job=None, pay=0): self.name = name self.job = job self.pay = pay bob = Person('Bob Smith') sue = Person('Sue Jones', job='dev', pay=100000) print(bob.name, bob.pay) print(sue.name, sue.pay)
6aeb2caf58e1bcbdfa61d16d937c995b68289169
ngocson2vn/learnpython
/itv/hash_table.py
1,511
3.796875
4
#!/usr/bin/python class Item: def __init__(self, key, value): self.key = key self.value = value def __str__(self): return str((str(self.key), str(self.value))) def __repr__(self): return str((str(self.key), str(self.value))) class HashTable: def __init__(self, siz...
dae97300abc10ddd8fc63e2b1c913862349251e2
tatsuya4559/ClassicComputerScienceProblemsInPython
/chap9/knapsack.py
1,679
3.984375
4
from collections import namedtuple from pprint import pprint Item = namedtuple("Item", "name weight value") def knapsack(items, max_capacity): table = [[0.0 for _ in range(max_capacity + 1)] for _ in range(len(items) + 1)] for i, item in enumerate(items): for capacity in range(1, max_capacity + 1): ...
8254a29e96e61abbe3410cc8dca4b0c958c6b7a5
tatsuya4559/ClassicComputerScienceProblemsInPython
/chap1/fib.py
605
3.90625
4
import functools # 再帰は性能問題があるからメモ化する memo = {0: 0, 1: 1} def fib2(x): if x not in memo: memo[x] = fib2(x - 1) + fib2(x - 2) return memo[x] # lru_cacheでメモ化を自動で行ってくれる @functools.lru_cache(maxsize=None) def fib3(x): if x < 2: return x else: return fib3(x - 1) + fib3(x - 2) #...
6b40604f01216dae28dbe1c657aa66f231395ba9
wdembski/mini-projects
/Red door numbers.py
3,081
3.921875
4
""" This code is an absolute mess because I did this and had it working, but then I wanted the output to be a lot cleaner, so I just built on top of a crappy foundation. Basically the first 3 variables can be changed. times_printed is the desired number of outputs. target_number is self explanatory. number...
e4dca3262a3e1b6d045ca5c0f77f59d3004a261f
biwot/AndelaProjects
/fibo.py
102
3.796875
4
def fibo(num): if num==1: return 1 if num==2: return 2 else: return fibo(num-1)+ fibo(num-2)
8c067cbaf4f623cf7e15b9c993737dc40594c2fd
sgoutam/LISP-Interpreter
/parser.py
819
3.703125
4
from lispeval import * def tokenize(chars): "Creates a list of tokens" return chars.replace('(',' ( ').replace(')',' ) ').split() def parse(program): "Begin parsing from here" return read_from_tokens(tokenize(program)) def read_from_tokens(tokens): "Validate the list of tokens generated" if len(tokens) == 0: ...
ec032c38241a21a69ea74a412cc065b941fde566
eduardoorm/pythonExercises
/parte2/e10.py
407
4.125
4
# Escriba una función es_bisiesto() que determine si un año determinado es un año # bisiesto.Un año bisiesto es divisible por 4, pero no por 100. También es divisible por 400 def es_bisiesto(anio): if(anio%4==0 and anio%100!=0): return True return False anio = int(input("Por favor ingrese un año")) is...
347e47162c2f136756037e841f2d4d86b1fcede7
eduardoorm/pythonExercises
/parte2/e3.py
375
3.96875
4
# Escribir una función filtrar_palabras() que tome una lista de palabras y un entero n, # y devuelva las palabras que tengan mas de n caracteres. def filtrar_palabras(list,n): newArray=[] for i in list: if(len(i)>n): newArray.append(i) return newArray palabras=filtrar_pa...
493d5899bf31118f5140ad0e6bedc5dc348377e7
eduardoorm/pythonExercises
/listas/e2.py
514
4
4
# Ejercicio 2 # Escribe una función llamada "elimina" que tome una lista y elimine el primer y último elemento de la lista y cree una nueva lista # con los elementos que no fueron eliminados. # Luego escribe una función que se llame "media" que tome una lista y devuelva una nueva lista que contenga todos # los elemen...
6e0c32081d6d30354701870cc67be06814ebfea1
eduardoorm/pythonExercises
/clasesyobjetos/e1.py
211
3.71875
4
# Escribir una clase en python que convierta un número entero a número romano class convertToRoman(): def __init__(self,number): print("voy a convertir",number) entero = convertToRoman("30")
a5d35dd64bab650b97874c8149ed4dceda135a02
eduardoorm/pythonExercises
/parte2/e1.py
518
4.09375
4
#La función max() del ejercicio 1 (primera parte) y la función max_de_tres() del ejercicio 2 (primera parte), #solo van a funcionar para 2 o 3 números. Supongamos que tenemos mas de 3 números o no sabemos cuantos números son. # Escribir una función max_in_list() que tome una lista de números y devuelva el mas grande....
be36f7e9e72065ebde19d7194cfb652491fef463
himanshi18037/Booth_Algortihm
/mul.py
3,614
3.734375
4
def mul(a, b): # Main driver function # Error Handling if not (isinstance(a, int) or isinstance(b, int)): return 'Error: Enter a integer' if a==0 or b==0: # print(0) #if either of the number is 0 return 'Product is 0' nega=True if(a<0...
fbab96e14501b03538a8b3cf0245630df85802f4
LucasLaibly/Hangman
/app/hangman.py
2,913
3.984375
4
import sys BODY = ["head", "body", "left arm", "right arm", "left leg", "right leg"] STATE = [] COUNTER = 0 WORD = "" usedLetters = [] NEWGUESS = "" class Game: number = 0 word = "" # constructor def __init__(self, number): self.number = number # array of words that the user can get ass...
f8bb93b2b07703d44e56c12dee53f928a02cf114
Luis-Filho/Uri-codes
/1168 - LED.py
176
3.6875
4
A = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6] n = int(input()) while n: total = 0 n -= 1 for i in input(): total += (A[int(i)]) print("{} leds".format(total))
61189d7e85f2b2ae2680b1b510ccc6a42eda673a
Luis-Filho/Uri-codes
/2760 - Entrada e Saída de String.py
278
3.671875
4
a = input() b = input() c = input() A = [a, b, c] print("{}{}{}".format(a, b, c)) print("{}{}{}".format(b, c, a)) print("{}{}{}".format(c, a, b)) for i in A: if len(i) > 10: print("{}".format(i[:10]),end="") else: print("{}".format(i),end="") print("")
209bc940e6b2fa6144f175cbe8b2e7dba3ee7eec
kamalakshancg/Library-management-
/Library.py
2,295
3.984375
4
class Library: def __init__(self,booklist,name): self.Booklist = booklist self.name = name self.lendbook={} def BookAdd(self , newbook): self.Booklist.append(newbook) def lendingBook(self,book , user): if book in self.Booklist: if book not in self.len...
7f7e7f9701ce968d97c5c3cf7f0217a66a47b1d2
sathishkumarusk/py4e
/assigment 9.4.py
1,110
3.8125
4
#9.4 Write a program to read through the mbox-short.txt and figure out who has the sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a cou...
9962ea729a3c49205adfab3cdac1e0acd1bcf322
sathishkumarusk/py4e
/tryEx.py
203
3.640625
4
age=input('Hey enter your age:') try : con=int(age) except : con = -1 print('your age is', con) angs=input('Hey enter one more ') try: asdf=int(angs) except: asdf=0 print('age is ', asdf)
03f03c6389eac74c4cae6798e7646f2b80bdcc11
R-54/UNAM-MyP
/ArrayHash.py
1,590
3.9375
4
import fileinput class ArrayHash(): """ Makes a hash code from a given input """ def challenge_input(self): """ Example: 1 1 ZZZZZZZZZZ """ user_input = list() for line in fileinput.input(): user_input.append(line[:...
3c785b1a42f9e2bced1c7aaa36e0dc83397e756f
R-54/UNAM-MyP
/Jaida.py
2,152
3.703125
4
import fileinput class Jaida(): """ Programming challenge number 1697. From https://www.urionlinejudge.com.br/judge/es/ """ def challenge_in(self): """ Input for this challenge. Returns a list with all the lines the user enter. """ user_in = list() ...
bf8e3e5d7a71244fc7698bf3738b556b33e4efc7
gladguy/PyKids
/GameDevelopment/IFthenElse.py
434
4.03125
4
x = 10 #Intial x = input("Enter X value ") print("Value entered by the user " + str(x)) if(x.isnumeric()): #Explain this We are string to number x = int(x) if (x > 85): print("First Class") elif (x < 85 and x >= 60): print("Second Class") elif (x < 60 and x >= 35): print("Thi...
53d0df3943eab5a6df4a504527262f4ea20f9e44
gladguy/PyKids
/GotoTurtle.py
173
3.5625
4
import turtle from random import randint t1 = turtle.Turtle() t1.shape('turtle') t1.penup() for i in range(5): t1.goto(randint(-100,0),randint(0,100)) turtle.done()
72ca893a64d68df62007a37b70a597fa7f11112f
gladguy/PyKids
/project.py
2,313
4.21875
4
print("Hi i am a turtle and I can draw many shapes") import turtle def circle(radius,bob): bob.pendown() bob.circle(radius) bob.penup() def star(bob): bob.pendown() for i in range(5): bob.forward(100) bob.right(144) bob.penup() def square(bob): bob.pendown() for i i...
c8ba22783ac90fe69a8c3b86dab3a3fc8d905980
gladguy/PyKids
/Aamirah Fathima/Input_file.py
231
4.15625
4
print("My name is Aamirah what is your name?") name = input("Enter your name!") print(name) print("My age is 10 ?") age = input("Enter your age!") print(age) a = 6 if int(age) < a: print("You are too young to drive!")
65dfb742e13fc215eeebd9dcfcde7eddb4e80e4b
gladguy/PyKids
/MultipleCircle.py
361
3.75
4
import turtle pet = turtle.Turtle() screen=turtle.Screen() screen.setup(500,500) # Size of the Screen pet.pencolor('green') pet.pensize(1) pet.shape('turtle') n=0 while n < 7: #loop for 7 circles n=n+1 pet.penup() pet.setpos(0,-n*20) pet.pendown() pet.circle(20*n) pet.pensi...
3e944bebaee201a4be8680c37231eb331c5e945f
Jennlee0314/python-challenge
/PyPoll/PyPoll.py
1,654
3.640625
4
import os import csv csvpath = os.path.join('Resources', 'election_data.csv') #read in csv file with open(csvpath, newline='') as data: poll_data = csv.reader(data) print(poll_data) Poll_header = next(poll_data) print(f'csv_header: {Poll_header}') #create lists to be used to store variable values at each ro...
4c44551d7650fc8cbcb0fa70805c4d5f7d63e517
olabrudecka/modelowanie
/python-course/lab3.py
3,339
4.125
4
from cs50 import get_float from math import * from enum import * #1 Write a function countField which calculates the field of a given figure. It takes the following input parameters: # - type: circle/rectangle/triangle/rhombus # - x & optional y. # For circle we get only x which stands for radius. For Rectangle x&y are...
e9183dc00682ac9e38bc8f01fd49f4b5f3c9fa37
Isha09/mit-intro-to-cs-python
/edx/week1/prob1.py
552
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 6 14:52:43 2017 @author: esha Prog: Assume s is a string of lower case characters. Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghak...
c93ba831278aac442c7fb78ca41ecffd22b12460
didriksi/fys-stk3155_project1
/python/plots_test.py
2,785
3.71875
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from matplotlib.animation import FuncAnimation plt.style.use('ggplot') def side_by_side(*plots, title="plot", filename="plot", animation=False, init_azim=240): """Plots two plots...
098013d9e0a8d126becdc3d59102daf762f69072
ssalenik/nothomework
/aiproject/gif_test.py
393
3.5625
4
import Image import numpy as np im = Image.open("fish_02_02.png") # To iterate through the entire gif print im pix = im.convert("LA") width, height = pix.size for x in range(width): for y in range(height): if pix.getpixel((x,y))[0] < 210: #print pix.getpixel((x,y))[0] pix.putpixel((x,y), (0, 255)) else : ...
70e73b4e92c4431fe57873d7050d7b1bf9f08cfb
mason-landry/cats-dogs
/sort.py
2,015
3.625
4
from glob import glob # Needed to get folder and file names from pathlib import Path # Needed to create and verify sorting folders import os # Needed to move images to sorted folder (rename function) ## Set main directory. I have a folder called 'data', which contains both 'test' and 'train' folders. we wan...
2671dfaa74d450b758ff130bd889023265d05b0b
afrazsalim/Python
/SortingAlgorithms/selectionSort.py
490
3.796875
4
class SelectionSort: def sort(self,list): for i in range (len(list)-1): tempValue = i for j in range (i+1,(len(list))): if list[j] < list[tempValue]: tempValue = j self.swap(list,i,tempValue) return list def swap(self,li...
8783190cb89403ae124e528f66769e209aa21068
skuldyami/praxis
/testing/Python/finding_data2.py
1,491
3.640625
4
import sqlite3 # db= sqlite3.connect("surfersDB.sdb") # db.row_factory= sqlite3.Row # cursor= db.cursor() # cursor.execute("select * from surfers") # rows= cursor.fetchall() # for row in rows: # if row['id'] == 104: # print("ID is " + str(row['id'])) # print("Name is " + row['name']) # print("Board type...
98862effac8821c1c550ae59b4e31ffff76c35eb
skuldyami/praxis
/HackerRank/apples_and_oranges.py
627
3.859375
4
def countApplesAndOranges(s, t, a, b, apples, oranges): #code num_apples=0 num_oranges=0 for a_dist in apples: if a+a_dist>=s and a+a_dist<=t: num_apples+=1 for b_dist in oranges: if b+b_dist>=s and b+b_dist<=t: num_oranges+=1 print(num_apples) print(num_oranges) if __n...
92cd0ce4429adc9ce8d515e5ff94972faf39ad38
skuldyami/praxis
/testing/Python/guessing_game.py
277
3.890625
4
from random import randint print("Welcome!") secret=randint(1,10) guess=secret+1 while guess != secret: g= input("Guess a number: ") guess= int(g) if guess==secret: print("You win!") elif guess<secret: print("Too low!") else: print("Too high!") print("Game over!")
b89d2545fe2cfbe58393fffa82e18d7da00b620e
skuldyami/praxis
/testing/Python/reverse.py
182
4.25
4
def reverse(text): st=list(text) for i in range(len(text)//2): st[i]=text[-i-1] st[-i-1]=text[i] return "".join(st) if __name__=="__main__": print(reverse("string"))
42b61e82620560a37fb108aa4787651536318339
hamie96/CS-4720-Internet-Programming
/In Class Code/in_class_190115/comprehensions.py
264
3.546875
4
b = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] bsq = [x*x for x in b] print("bsq", bsq) bsq_even = [x*x for x in b if x % 2 == 0] print("bsq_even", bsq_even) prods = [x*y for x in b for y in b] print("prods", prods) print("length of prods", len(prods))
a464467afcc8d4a2f80d2202f35b92483b24b850
mumudata/python_logging_config
/logger_example_file.py
1,041
3.59375
4
import logging from logger import setup_logger setup_logger() logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler()) logger.setLevel(logging.DEBUG) # sets the logging level for this script def add_two_strings(string_one, string_two): """ Concatenates two strings :param string_one ...
b8ea3850a969fd3677c59d1b58d19cdd72c8261c
samiksha5/recruiting-exercises
/trackingcode-data-processor/src/samiksha_submission.py
1,345
3.5625
4
order = { 'apple': 5, 'banana': 5, 'orange': 5 }; inv = [ { 'name': 'owd', 'inventory': { 'apple': 5, 'orange': 10 }}, { 'name': 'dm', 'inventory': { 'banana': 5, 'orange': 10 } } ] result=[] fount = [] for key, value in order.items(): #print(key, value) req = value flag = 0 # to go throught all the inventor...
90fd58a60095a888058eb7788255886b6870056a
david778/python
/Point.py
1,233
4.4375
4
import math class Point(object): """Represents a point in two-dimensional geometric coordinates""" def __init__(self, x=0.0, y=0.0): """Initialize the position of a new point. The x and y coordinates can be specified. If they are not, the point defaults to the origin.""" self.move(x, ...
debd5b7b18dd47bfa7f38fbba0716410d4859d56
Lupaxx/LuizaCostaPacheco_P1
/Q1.py
713
3.8125
4
#Questão 1 import math def Q1(): print("Para a equação ax^2 + bx + c, insira os valores de a, b e c, respectivamente.") a = int(input()) b = int(input()) c = int(input()) Delta = ((b**2) - 4*a*c) x1 = 0 x2 = 0 if(Delta > 0): x1 = ((b*(-1)) + math.sqrt(Delta))/(2*a) x2 = ((b*(-1)) - math.sqrt(Delta))/(2*a)...
414cffd4732ce588e49e90e89d51f77d55aa49ff
lmdpadm/Python
/desafio10.py
280
3.875
4
n = float(input('Quanto dinheiro você tem na carteira? R$')) #d = n / 3.27 print('Convertendo os seus R${:.2f} para dólar, hoje você tem US${:.2f} dólares.'.format(n, n/5.69)) print('Convertendo os seus R${:.2f} para euro, hoje você tem Є{:.2f} euros.'.format(n, n/6.78))
c1d5ddbe0c85eeebfe996c688073e95b939a44fd
lmdpadm/Python
/desafio33.py
415
3.953125
4
n1 = int(input('Escolha um número: ')) n2 = int(input('Escolha outro: ')) n3 = int(input('O último: ')) #Encontrando o menor menor = n1 if n2 < n1 and n2 < n3: menor = n2 if n3 < n2 and n3 < n1: menor = n3 #Encontrando o maior maior = n1 if n2 > n1 and n2 > n3: maior = n2 if n3 > n2 and n3 ...
7763828c14c608f625995c5febb54cd39787c109
lmdpadm/Python
/desafio12.py
133
3.53125
4
n = float(input('O preço do produto é R$')) p = n * 0.95 print('O preço do produto com 5% de desconto é R${:.2f}!'.format(p))
a9e79479dcadec2605532aa8d03545363f58d926
lmdpadm/Python
/desafio37.py
643
4.0625
4
número = int(input('Escolha um número inteiro qualquer: ')) opção = int(input('Escolha uma das bases para conversão:\n[ 1 ] Converter para BINÁRIO\n[ 2 ] Converter para OCTAL\n[ 3 ] Converter para HEXADECIMAL\nSua escolha: ')) if opção == 1: print('{} convertido para BINÁRIO é igual a {}.'.format(número, bin(núm...
11a2091b82195d89c87acfa2ebe96c2045f2f7b7
lmdpadm/Python
/desafio06a.py
153
3.796875
4
n1 = int(input('O primeiro número é:')) n2 = int(input('O segundo número é:')) s = n1+n2 print('A soma entre {} e {} é {}'.format(n1, n2, s))
9b19438c601532af5ee6463a26e6c96b7dea044e
lmdpadm/Python
/desafio61.py
349
3.875
4
tempo = 1 print('Vamos estruturar uma progressão aritimética'.upper()) termo = int(input('Qual é o primeiro termo desta PA? ')) razao = int(input('Qual é a razão desta PA? ')) termo1 = termo print('Segue a progressão:') while tempo <= 10: print('{} ➟ '.format(termo1), end=' ') tempo += 1 termo1 += ...
9082c4057aa5ee53013e03a376979592d31c92f6
lmdpadm/Python
/aula14.py
735
3.78125
4
'''for c in range(1, 10): print(c) print('Fim') c = 1 while c < 10: print(c) c += 1 print('Fim') for c in range(1, 5): n = int(input('Digite um valor: ')) print('Fim') n = 1 while n != 0: #Condição de parada n = int(input('Digite um valor: ')) print('Fim') r = 'S' while r ==...
93d685175fcdbe0f54a993cb9d7789ca51c62dd7
lmdpadm/Python
/desafio74.py
319
3.640625
4
from random import randint tupla = randint(1, 100), randint(1, 100), randint(1, 100), randint(1, 100), randint(1, 100) print(f'OS VALORES SORTEADOS FORAM ', end='') for n in tupla: print(f'{n}', end=' ') print(f'\nO MAIOR NÚMERO DA TUPLA É {max(tupla)}') print(f'O MENOR NÚMERO DA TUPLA É {min(tupla)}')
65c8190f1d26ff02a9fd8c84d83946dd34eaebf9
lmdpadm/Python
/desafio52.py
445
3.625
4
lista = [] cont = 0 primo = int(input('Vamos descobrir se o número é primo: ')) for n in range(1, primo + 1): if primo % n == 0: cont += 1 lista += [n] if cont == 2: print('O número {} é primo, pois é divisível apenas por duas bases, que são {}.'.format(primo, lista)) else: print('...
db817deeef623c58e3448b49ddcb87e9c3af64f4
lmdpadm/Python
/desafio53.py
369
4.09375
4
frase = input('Vamos verificar se sua frase é um palíndromo. Digite a frase: ') frasefinal = frase.upper().replace(' ', '').strip() palindromo = frase[::-1].upper().replace(' ', '').strip() if frasefinal == palindromo: print('A frase {} é um palíndromo!'.format(frase.strip())) else: print('A frase {} não ...
47c580cf46d2c83ebf1ca05601c7f4c05ea4d913
nitred/nr-common
/examples/mproc_example/mproc_async.py
1,442
4.15625
4
"""Simple example to use an async multiprocessing function.""" from common_python.mproc import mproc_async, mproc_func # STEP - 1 # Define a function that is supposed to simulate a computationally intensive function. # Add the `mproc_func` decorator to it in order to make it mproc compatible. @mproc_func def get_squa...
9f02133d3bb242516ac198bffb1edf95c1e2ae66
sarah1985/IS210_final_project
/final_project.py
10,809
3.875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Final Project...here we go!""" import os import os.path import pickle class RecipeManagement(object): """This class will create a file to house recipes. It will also allow a user to add new recipes via a dictionary key, value pair. Users can recall rec...
343a06272b6ccd76ce871b4bd880c687d4bcf47e
IndependentDeveloper1/PyCourse
/Week2/Exact degree of two.py
164
3.828125
4
n = int(input()) edt = 1 degree = 0 while edt <= n: if edt == n: print("YES") exit() else: edt *= 2 degree += 1 print("NO")
1b6a149dbe018625c80507ebc196544afc022973
Sergiomerce/Primeros_intentos
/COMER_HELADO.py
495
4.0625
4
helado=input("Quieres un Helado? (Si/No)").upper() if helado=="SI": helado=True elif helado=="NO": helado=False else: print("El valor introducido no corresponde asi que lo considero como que no") dinero=input("Tienes dinero? (Si/No)").upper() if dinero=="SI": dinero=True elif dinero=="NO": dinero=Fa...
3e414c4e1510d5228c9800adfe9567dc2aa22593
SunderRaman/MachineLearningProjects
/CarPricing/CarPricing.py
12,213
3.71875
4
#!/usr/bin/env python # coding: utf-8 # # Car Price Prediction # ## Data Understanding # In[1]: # Imports import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from sklearn import linear_model from sklearn.linear_model import LinearRegression import os # In[2]: # Set the ...
170959454f66a543183c32fd07bf2a2279fff035
EllenHoffmann/BasicTrack3
/Week_2/Assignments_2.14.py
329
3.53125
4
a = 'All' b = 'work' c = 'and' d = 'no' e = 'play' f = 'makes' g = 'Jack' h = 'a' i = 'dull' j = 'boy' print(a,b,c,d,e,f,g,h,i,j) #I am writing a comment and nothing should happen# 6*(1-2) P = 'principle amount' \ n = "number of installments" \ t = "number of years" \ r = "annual nominal interest rate" A = P*(1+r/n)*...
bfc0bddf09b9e5451658cd34738f15fdd8f630df
Priyanka-Kothmire/MORE-EXERCISE
/quetion5.py
124
3.8125
4
i=int(input("enter the number :")) fac=1 sum=0 while i>0: fac=fac*i sum=sum+fac print(i) i=i-1 print(fac)
682b503f36c9dba27771cebab854c4815059dd71
PhatStraw/Sprint-Challenge--Data-Structures-Python
/names/names.py
570
3.65625
4
import time from bst import BinarySearchTree #time complexity of O(n^2) start_time = time.time() f = open('names_1.txt', 'r') names_1 = f.read().split("\n") # List containing 10000 names f.close() f = open('names_2.txt', 'r') names_2 = f.read().split("\n") # List containing 10000 names f.close() duplicates = [...
1c35bf62f9cd82a0792f4d68bac27ccfaff757e2
Zeeshanahmad4/My-Path-to-Python
/pandas.py
484
3.671875
4
#reading and setting index on column 1 df = pd.read_csv('College_Data',index_col=0) #Building datafram using variables df_jobsearch = pd.DataFrame(columns=['location', 'time', 'applicants','jobfunction','industry']) df_jobsearchappend = pd.DataFrame() df_jobsearch = pd.DataFrame(dict_jobsearch,columns=['location',...
27f57494c8a3b6efb1b88799e261da4441cb690d
saiftg/Python-Stuff
/lists.py
585
4.03125
4
students = ["Huey", "Dewey", "Stewie", "Launchpad"] print students print students[0] print students[-1] atlanta_teams = ["Falcons", "Thrashers", "Hawks", "Braves"] print atlanta_teams #atlanta_teams.pop() #print atlanta_teams atlanta_teams.append("Atl Utd") print atlanta_teams atlanta_teams_length = len(atlan...
39cb8e44ec4ce04131e40af18635154b78083947
saiftg/Python-Stuff
/Algorithm1.py
335
3.5
4
threesList = [] fivesList = [] fifteensList = [] i = 1 for i in range(1,1000): if (i%3 == 0): threesList.append(i) for i in range(1,1000): if (i%5 == 0): fivesList.append(i) for i in range(1,1000): if (i%15 == 0): fifteensList.append(i) sumList = (sum(threesList) + sum(fivesList)) - sum(fifteensList) ...
242f9e737ddba4579e45bd9a2c1c1abde237001d
saiftg/Python-Stuff
/tuples_dictionary.py
568
4.03125
4
a_tuple = (1,2,3) #tuples are unchangeable and in parentheses # Dictionaries are just like lists but they have english indices zombie = {} zombie["weapon"] = "Axe" zombie["health"] = "100" print zombie for key, value in zombie.items(): print"Zombie has %s with %s" % (key, value) print"ZOmbie %s with %s" % (k...
c77d7f32acb84b777c1847e4413c5a0919f0b50a
Melisawijaya/UG9_B_71210714
/2_B_71210714.py
192
3.546875
4
#input r = int(input("Masukkan jari-jari alas tabung: ")) t = int(input("Masukkan tinggi tabung: ")) phi = 3.14 #process v = phi * r**2 * t #output print("Volume tabung adalah ", v)
195ad188db568f1bfcf91b7ac468289127486c7a
belgort-clark/ctec-121-module-10-dictionaries-problems
/03_date_time_sample_3.py
791
4.09375
4
# CTEC 121 # 03_date_time_sample_3.py # import datetime library and timedelta library from datetime import datetime, timedelta # import the calendar library import calendar # current date time of this computer now = datetime.now() testDate = now + timedelta(days=2) # 2 days from now print(testDate) # 3 Weeks ago ...
aa5b9bd616a57948655d4eae097b81d00461c764
kannanhacker123/password_Genaretor
/passwd_genaretor.py
512
3.828125
4
import random lower = "abcdefghijklmnopqrstuvwxyz" upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" number = "0123456789" signs = "~`|•√π÷×¶∆£¢€¥^°={}\%©®™✓[]@#$_&-+()/*':;!?" all = lower+upper+number+signs print("Enter the length of your password.") print("Short password is better to break.") print("So make strong password") pri...
68f316683fac3a07413e3e2f5024593c0005fb1d
DanielStrohfeldt/PythagoreanCupcake
/Labs/Lab2/room.py
621
3.640625
4
class Room: def __init__(self, name, square): self._name = name self._squares = [square] self._area = square.area @property def area(self): return self._area @property def squares(self): return self._squares @property def name(self): retur...
3038291734342bb78cf899bc5b8f469e50cc8cc5
krmirandas/criptografia
/Practica1/xor_cipher.py
568
3.71875
4
def cipher(message): """ Cifra el mensaje recibido como parámetro con el algoritmo de cifrado XOR. Parámetro: message -- el mensaje a cifrar. """ cipher = "" for ch in message: cipher += chr(ord(ch) ^ 1) return cipher def decipher(criptotext): """ Descifra el mens...
d6fb8c780bc46b577df3beb95265bf6addd4d2e1
ronBP95/insertion_sort
/app.py
690
4.21875
4
def insertion_sort(arr): operations = 0 for i in range(len(arr)): num_we_are_on = arr[i] j = i - 1 # do a check to see that we don't go out of range while j >= 0 and arr[j] > num_we_are_on: operations += 1 # this check will be good, because we won'...
49392e65d61afc5bb61340e437b7dd113759f4b9
pbartlett/animated-wight
/mobs.py
450
3.90625
4
# classes for mobs class Mob(object): """ Base class, which all others will be derived from """ def __init__(self, name, level = 1): self.name = name self.level = level def __str__(self): rep = "\nName: " rep += self.name rep += "\nLevel: " rep += str...
7314f15c59cd41a095c2d6c9e12e824ff23f9dad
davidalanb/PA_home
/Py/dicts.py
1,188
4.4375
4
# make an empty dict # use curly braces to distinguish from standard list words = {} # add an item to words words[ 'python' ] = "A scary snake" # print the whole thing print( words ) # print one item by key print( words[ 'python' ] ) # define another dict words2 = { 'dictionary': 'a heavy book', \ 'cl...
28815203747dff42a5bc0ee798cd3d939e946d4a
davidalanb/PA_home
/Py/ps2/turtlename (2).py
1,674
3.984375
4
# These functions are the library!!! def print_D( joe, color, width ): joe.color( color ) joe.width( width ) joe.pd() # D joe.circle(50,180) joe.left(90) joe.forward(100) # next joe.left(90) joe.penup() joe.forward(50) def print_A( joe, color, width ): joe.color( c...
3516a235bcf825be23b9f5b552930aeb54ce3d2b
davidalanb/PA_home
/Py/eBook/ch20.py
853
3.640625
4
def get_occurrences( s ): letters = {} for l in s.lower(): if l.isalpha(): if l in letters.keys(): letters[l] += 1 else: letters[l] = 1 return letters def print_table( d ): for key,value in sorted(d.items()): print( key, '\t'...
7ee36b667134ec7becf78744c548cf68b94beaf0
davidalanb/PA_home
/Py/__laptop___cp1/ebook/pythonch2.py
678
3.53125
4
#! /cygdrive/c/Python33/python ''' Python Chapter 2 ''' # 1. String concat x = "Hello " y = "to " z = "you " print( x + y + z ) # 2. math print( 6 * 1 - 2 ) print( 6*(1 - 2) ) # 3. Commented code doesn't execute # 4. fixing NameError bruce = 6 print( bruce + 4 ) # 5. Principal P = 10000 n = 12 r = .08 t = in...
803a4d82b69b00138a1f7bcd7eb5709de2dbdefe
davidalanb/PA_home
/Py/pygame/cards.py
4,135
3.609375
4
import random class Card(): def __init__(self, s, r): self.suit = s self.rank = r def __str__(self): rank_map = {1:'A',11:'J',12:'Q',13:'K'} r = self.rank if r in rank_map: r = rank_map[r] suit_map = {0:'C',1:'S',2:'H',3:'D'} s = self.su...
aa5a664ccba0cd7dee9df189804cbcce0fd3e6d0
davidalanb/PA_home
/Py/ps4/lists.py
1,492
4.125
4
''' Lists are mutable ''' print( '----------- identical to string methods ---------------' ) # type-casting: make a list out of a string s = "Benedetto" ls = list(s) # basics print( ls ) print( len( ls ) ) print( ls[0], ls[-1] ) # one way to iterate for letter in ls: print( letter, end='.' ) print() # 2nd way...
c4a4d2e1d180060b646b3665106e572090e3301b
KrishnaGMohan/Projects-Udacity-AINano
/SudokuTrial/SudokuTrial/function.py
448
4
4
from utils import * def search(values): "Using depth-first search and propagation, create a search tree and solve the sudoku." # First, reduce the puzzle using the previous function # Choose one of the unfilled squares with the fewest possibilities # Now use recursion to solve each one of the...
af15d1b542a8bfb064dfd7f9b4c40b4e3eb14b64
KuldeepRaw/Duplicate-characters
/my-codes.py
926
4.0625
4
# Find the number of occurrences of a character using for loop in Python def count_repeat(s): ''' (str) -> int return the occurence of values in the word >>> count_repeat('dhgssjhjj') >>> 2 ''' repeat = 0 for i in range(len(s) - 1): if s[i] == s[i + 1]: ...
b0d01444d7d1f603b350ceddc18f279f8afd1dab
ju7stritesh/Artificial-Intelligence
/AI-2/Tetris/tetris.py
11,684
4.15625
4
# Simple tetris program! v0.2 # D. Crandall, Sept 2016 from AnimatedTetris import * from SimpleTetris import * # from kbinput import * import time, sys import copy class HumanPlayer: def get_moves(self, tetris): print "Type a sequence of moves using: \n b for move left \n m for move right \n n for rota...
2eb7105d0a2dcb3869c56e8a253cf7cd0aeddc35
lylinsh/introduction-to-python
/code/tuple1.py
353
3.78125
4
#coding=utf-8 if __name__ == "__main__": tp1 = (1, 2, 3) tp2 = () tp3 = tuple([4, 5, 6]) print(tp1) print(tp3[0]) try: tp1[1] = 0 except TypeError: print("Tuple can not be modified!") tp4 = tp1 * 2 print(tp4) tp5 = tp1 + tp3 print(tp5) v1, v2, v3 = ...
1853735a33815b4ba779fe8ac365135d69cac745
lylinsh/introduction-to-python
/code/str1.py
901
3.609375
4
#coding=utf-8 if __name__ == "__main__": s1 = 'hello "world"!' s2 = "Convert a list to string: " s3 = """this is a string \rin mutiple lines""" s4 = "This is another string " + \ "in mutiple lines!" print(s1, s2, s3, s4, sep="\n") s7 = "hello world\n" s8 = r"hello wor...
0b4f05e843f0664e2faeb29ba42085c3abca9480
shaneweisz/TED-Talks-Text-Classification
/scripts/01_exploratory_data_analysis.py
2,731
3.5
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt from preprocessing import read_in_merged_data, extract_label # Use LaTEX font from matplotlib import rc rc('font', **{'family': 'serif', 'serif': ['Palatino']}) def print_summary_statistics(df_merged): print(f"Number of samples: {len(df_merge...
f014a23fc9bf98bd235aef74c285b3aafab89b00
Tao-Kim/study_algo
/group/g11_2_부품찾기_p197.py
935
3.53125
4
n = int(input()) storeList = tuple(map(int, input().split())) m = int(input()) requestList = tuple(map(int, input().split())) for item in requestList: if item in storeList: print("yes", end=' ') else: print("no", end=' ') ''' 0.99초 list에서 in 탐색 n = int(input()) storeList = tuple(map(int,...
5f273f1a02735894636f6a5039b8595fcb5897ce
Tao-Kim/study_algo
/programmers/p6_42583_다리를지나는트럭_kit_스택큐_3.py
1,298
3.828125
4
def solution(bridge_length, weight, truck_weights): trucks_on_bridge = [] current_time = 1 current_weight = 0 for truck_weight in truck_weights: while current_weight + truck_weight > weight: pop_time, pop_weight = trucks_on_bridge.pop(0) current_time = pop_time + bri...
48ade6e2b39a05ea234b3db01abb04364250e0bd
Tao-Kim/study_algo
/codility/c1_BinaryGap.py
624
3.546875
4
def solution(N): # write your code in Python 3.6 search_list = list(bin(N))[3:] count = 0 gaps = [0] for num in search_list: if num == '0': count += 1 elif num == '1': gaps.append(count) count = 0 return max(gaps) """ 문제주소 : https://app.cod...
ec81c329a816595b15e9e38ca0d926bacb638fd8
JasonBao-BB/BMI-500-HM3
/mods/data_process.py
1,046
3.703125
4
import pandas as pd # # loads the data set by pandas def init(path): # loads the data set by pandas dataset = pd.read_csv(path, sep='\s+', header=None) # add column name to every column dataset.columns = ["area", "perimeter", "compactnes", "length of kernel", "width of kernel", ...
b77181dfab96c3d0d048f3035428066c516059c3
bscharfstein/bscharfstein
/bscharfstein/location.py
596
3.765625
4
#Find the nearest Pizza Place from googlemaps import GoogleMaps def FindPizza(): print "Enter in an address to find Pizza places near it" address = raw_input() gmaps = GoogleMaps("AIzaSyA5R4PnzAcoe2vpVRKyWWby-d6RrMmIwtQ") lat, lng = gmaps.address_to_latlng(address) destination = gmaps.latlng_to_address(lat, lng) ...
27beb6249c8a9654a8ee53a7bd4b16db66b0c71e
sigmeh/tools
/tools/queue.py
1,047
4.09375
4
#!/usr/bin/env python ''' Standard Queue (FIFO) implemented as python object, using a dictionary/hash to track element order. Instantiation takes name as only argument. New data is added to self.data dictionary through 'push' function. Items are removed through 'pull' function; hash is automatically updated. ''' cla...
fd628f72aadb4419c5e23da686566abc54d1bf2a
kirisi2008/leetcode_best_worst_me
/src/utils/generate_linked_list.py
627
3.859375
4
import json class ListNode(object): def __init__(self, x): self.val = x self.next = None def stringToListNode(input): # Generate list from the input numbers = json.loads(input) # Now convert that list into linked list dummyRoot = ListNode(0) ptr = dummyRoot for number in n...
1a8b37d0c46ee9fa8bf4f633732877d95f89aa0e
golfz/practical-ai
/Lab/day10/lab9-problem1-1.py
1,141
3.671875
4
import matplotlib.pyplot as plt import numpy as np from scipy.io import loadmat def findClosestCentroids(X, centroids): """ Returns the closest centroids in indices for a dataset X, where each row is a single example. :param X: :param centroids: :return: """ number_of_centroids = cen...