blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
587fd3ce9e5acfe319289c6bee661309e317a652
colinwangdesign/SFPCDetroit2019-makingSense
/Class Code Commented/MakingSense_Comments_1_LED.py
523
3.640625
4
from gpiozero import LED # Imports the LED functions from the GPIO library from time import sleep # Imports the sleep functions from the time library led = LED(21) # Initializes pin 21 as an LED and defines variable name "led" while True: # Run the indented code forever led.on() # Turn...
87eb5814944799353ecace73b50eb19540ff9990
massey-high-school/2020-91896-7-assessment-zzthomaszzz
/06_num_check_01.py
1,246
4
4
# not_blank_01 def not_blank(subject, error, num): loop = True while loop: fail = False response = input(subject) if response == "": print(error) continue else: if not num: for letter in response: if letter.i...
1b19e6ac2b13249abd72926deaf32acb9fa784eb
RoryWinterborn/first_repository
/cppb_2020/playing_card.py
761
3.796875
4
class PlayingCard(object): def __init__(self,rank,suit,colour): ranks = ["Joker","Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"] suits = ["null","Diamonds", "Hearts", "Spades", "Clubs"] colours = ["Red", "Black"] self.rank = ranks[rank] self.su...
380a224f5dcfeb19e038d9cbf8f54d54df2af61e
edelgrace/last.fm_data_story
/src/getLyrics.py
1,313
3.5
4
import lyricsgenius as genius import argparse import json def getSongInfo(song): data = json.loads(song) title = data["Song_Title"] artist = data["Artist"] return title, artist def getLyrics(filename, token): song_list = [] # initialize api api = genius.Genius(token) # open the file file = open(...
0ac693d26b84884912e4c4ad5abc8dfce8f83ac9
sstrohkorb/spotit
/trunk/branches_12_4/.svn/text-base/window.py.svn-base
2,806
3.796875
4
import pygame import scoreboard from table import * class Window(object): def __init__(self, size=[1440,820]): self.size = size def constructWindow(self): """ This function sets up the screen; it creates options and table objects. This is where everything happens. """ #### SARAH AND JEFF!! #### d...
cb1ed6c2fc33015795d424f9ddd8af78889520e2
sstrohkorb/spotit
/trunk/branches_12_4/card.py
3,176
3.6875
4
import pygame import os import random from image import * class Card(object): def __init__(self, screen, diameter, image_file_path): self.screen = screen self.diameter = diameter self.image_file_path = image_file_path self.photo_list = self.create_photo_list() # Where does this get used? --KOH #~ ...
4516837a2ae0b80f65c5ee533fd0a7a061df96e3
natibaggi/faculdade-python
/funcoes/exemplo.py
815
3.765625
4
# def quociente(a,b): # soma = cont = 0 # while soma < (a - 1) and a > b: # soma = soma + b # cont = cont + 1 # print(cont) # a = 5 # b = 10 # quociente(a,b) # def misterio(a, b, c): # d = False # e = 0 # f = 0 # g = c-1 # while (f<=g) and (not d): # h = ...
1e6bb0f610d6939867dcf20c51305453f67416c4
natibaggi/faculdade-python
/Exec-lacos2/exec3.py
246
4.09375
4
letra = input("Digite uma letra: "); quantidade = 1; while True: letraAnterior = letra letra = input("Digite uma letra: "); if letra >= letraAnterior: quantidade = quantidade + 1; else: break print(quantidade)
ee70849e22ed3cca68146e2d508891165888f4d6
natibaggi/faculdade-python
/Exec-lacos2/exec2.py
167
4.03125
4
numero = int(input("Digite um número: ")); sequencia = 0; for contador in range(1, numero + 1): sequencia = sequencia + contador; print(sequencia, end= " ");
913b3c44bd0b2734e7f30eaaff64001f93341bd3
natibaggi/faculdade-python
/prova.py
684
3.671875
4
# a = int(input('a: ')) # b = int(input('b: ')) # m = 0; # while b > 0: # m = m + a # b = b - 1 # print("a * b =", m) # n = int(input('n: ')) # d = n % 10 # while True: # n = n // 10 # if n <= 9: # break # if d == n: # print("Iguais") # else: # print("Diferentes") # n =...
57d8c614cf15038a488e05eac80c16f12c76be9d
stjordanis/tddsession
/tests/test_payment_calculator.py
1,274
3.53125
4
import unittest class PaymentCalculator(object): def __init__(self, hour_rate, free_time): self.hour_rate = hour_rate self.free_time = free_time def calculate_payment(self, start_time, end_time): duration = (end_time - start_time) if duration <= self.free_time * 60: ...
bcf6981c9443800567c921612d010541ddf584f9
matiasvc/pl2-oving6
/sensors/sensor.py
341
3.703125
4
from abc import abstractmethod class Sensor(object): '''Base class for sensors. The main methods are update and get_value''' def __init__(self): pass @abstractmethod def update(self): pass @abstractmethod def get_value(self): pass @abstractmethod def rese...
c8f5d16b1d8dd45de436f7c484c06a5c9fee96a6
romulovieira777/Programacao_em_Python_Essencial
/Seção 05 - Estruturas Lógicas e Condicionais em Python/Exercícios da Seção/Exercício_01.py
447
4
4
""" 1) Faça um programa que receba dois números e mostre qual deles é o maior. """ number_1 = int(input('Enter the first number: ')) number_2 = int(input('Enter the second number: ')) if number_1 > number_2: print(f'The number one {number_1} greater than the number two {number_2}') elif number_2 > number_1: pr...
b43cef7a6cca8179fdae2ea4f4e7cc189527bb54
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_21.py
343
3.703125
4
""" 21) Leia um valor de massa em libras e apresente-o convertido em quilogramas. A fórmula de conversão é: K = L * 0.45, sendo K a massa em quilogramas e L a massa em libras. """ pounds = float(input('Enter the amount in pounds: ')) kilograms = round(pounds * 0.45, 2) print(f'The value of pounds {pounds} for kilogram...
404c13f732db19368f22afaa84d7506531d2dda0
romulovieira777/Programacao_em_Python_Essencial
/Seção 07 - Coleções Python/Exercícios da Seção/Exercício_08.py
284
4.1875
4
""" 8) Crie um programa que lê 6 valores inteiros pares e, em seguida, mostre na tela os valores lidos na ordem inversa """ lista = [] for i in range(6): lista.append(int(input("Enter the value: "))) print("\nValues in reverse order: ", end='') print(* lista[::-1], sep=', ')
640b3e84c873b313bc16427073f61d7d5162e97c
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_27.py
365
4.09375
4
""" 27) Leia um valor de área em hectares e apresente-o convertido em metros quadrados m². A fórmula de conversão é: M = H * 10000, sendo M a área em metros quadrados e H a área em hectares. """ acre = float(input('Enter the value in acre: ')) square_meters = round(acre * 10000, 2) print(f'The value of {acre} acre fo...
a8cb8d9055c6e7ab1fd6954f83ebab13426e053b
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_26.py
383
4.0625
4
""" 26) Leia um valor de área em metros quadrados m² e apresente-o convertido em hectares. A fórmula de conversão é: H = M * 0.0001, sendo M a área em metros quadrados e H a área em hectares """ square_meters = float(input('Enter the value in square meters: ')) acre = round(square_meters * 0.0001, 2) print(f'The value...
07df0293501747917a3e7a502a2e02acbd291ba1
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_09.py
345
3.875
4
""" 9) Leia uma temperatura em graus Celsius e apresente-a convertida em graus Kelvin. A fórmula de conversão é: K = C + 273.15, sendo C a temperatura em Celsius e K a temperatura em Kelvin. """ celsius = float(input('Enter the temperature in celsius: ')) kelvin = round(celsius + 273.15, 2) print(f'The temperatre in C...
078437ea7ccf4eaf26ec6b4308cd1d516bd5432a
romulovieira777/Programacao_em_Python_Essencial
/Seção 08 - Funções em Python/Exercícios da Seção/Exercício_03.py
643
4.3125
4
""" 3) Faça uma função para verificar se um número é positivo ou negativo. Sendo que o valor de retorno será 1 se positivo, -1 se negativo e 0 se for igual a 0 """ def positivo_ou_negativo(number): """ Função que retorna o valor 1 caso o número recebido seja positivo, -1 se negativo e se for igual a 0 ...
82a009441721d236c96ebcdd3382b185ce9d6914
romulovieira777/Programacao_em_Python_Essencial
/Seção 06 - Estruturas de Repetição em Python/Exercícios da Seção/Exercício_27.py
468
3.828125
4
""" 27) Em Matemática, o número harmônico designado por H(n) define-se como sendo a soma da série harmônica: H(n) = 1 + 1/2 + 1/3 + 1/4 + ... + 1/n Faça um programa que leia um valor n inteiro e positivo e apresente o valor de H(n). """ number = int(input("Enter an integer and positive value: ")) h = 1 if number...
a374728c0261ed0d4703c3d87a775e9698df03c8
romulovieira777/Programacao_em_Python_Essencial
/Seção 05 - Estruturas Lógicas e Condicionais em Python/Exercícios da Seção/Exercício_26.py
716
4.25
4
""" 26) Leia a distância em km e a quantidade de litros de gasolina consumidos por um carro em um percurso, calcule o consumo em km/l e escreva uma mensagem de acordo com a tabela abaixo: CONSUMO | (Km/l) | MENSAGEM menor que | 8 | Venda o carro! entre | 8 e 12 | Econômico! ma...
b74defd7d6f5e852184f99b1fb0618334cb1f401
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_47.py
387
3.53125
4
""" 47) Leia um número inteiro de 4 dígitos (de 1000 a 9999) e imprima """ number = int(input('Enter the number: ')) number_1 = str(number)[0] number_2 = str(number)[1] number_3 = str(number)[2] number_4 = str(number)[3] print('Number one {}'.format(number_1)) print('Number two {}'.format(number_2)) print('Number thre...
85f3405cdf5a5c8642d84854aed154d08620156f
romulovieira777/Programacao_em_Python_Essencial
/Seção 05 - Estruturas Lógicas e Condicionais em Python/Exercícios da Seção/Exercício_21.py
1,219
4.46875
4
""" 21) Escreva o menu de opções abaixo. Leia a opção do usuário e execute a operação escolhida. Escreva uma mensagem de erro se a opção for inválida. Escolha a opção: 1 - Soma de 2 números. 2 - Diferença entre 2 número (maior pelo menor). 3 - Produto entre 2 números. 4 - Divisão entre 2 números (o ...
efa8a4253c351364bc3c4ac8894b71aa84f36d49
romulovieira777/Programacao_em_Python_Essencial
/Seção 06 - Estruturas de Repetição em Python/Exercícios da Seção/Exercício_26.py
284
4.125
4
""" 26) Faça um algoritmo que encontre o primeiro múltiplo de 11, 13 ou 17 após um número dado. """ number = int(input("Enter the number: ")) lista = [11, 13, 17] print() print(f"First multiple of 11, 13 or 17 of {number}:") for x, y in enumerate(lista): print(number * y)
cae2389a7e07fde3cce158c5e152dd232a8b64b4
romulovieira777/Programacao_em_Python_Essencial
/Seção 07 - Coleções Python/Exercícios da Seção/Exercício_55.py
2,420
4.15625
4
""" 55) Faça um programa para corrigir uma prova com 10 quetões de múltipla escolha (a, b, c, d ou e), em uma turma com 3 alunos.txt. Cada questão vale 1 ponto. Leia o gabarito, e para cada aluno leia sua matricula (número inteiro) e suas respostas. Calcule e escreva: Para cada aluno, escreva sua matrícula, suas respos...
17fa67eded5f5e88219dc0693b3fd584424ebeba
romulovieira777/Programacao_em_Python_Essencial
/Seção 06 - Estruturas de Repetição em Python/Exercícios da Seção/Exercício_04.py
249
3.765625
4
""" 4) Escreva um programa que declare um inteiro, incialize-o com 0, e incremente-o de 1000 em 1000, imprimindo seu valor na tela, até que seu valor seja 100000(cem mil). """ number = 0 while number < 100000: number += 1000 print(number)
7d4eac8e7d6e31bb652d5a19b426536dea149320
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_28.py
370
4.125
4
""" 28) Faça a leitura de três valores e apresente como resultado a soma dos quadrados dos três valores lidos. """ number_1 = int(input('Enter the value: ')) number_2 = int(input('Enter the value: ')) number_3 = int(input('Enter the value: ')) high = pow(number_1, 2) + pow(number_2, 2) + pow(number_3, 2) print(f'The v...
b176cb405e8b4e507874d3b5d2a0390acf8dc62a
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_24.py
410
4.03125
4
""" 24) Leia um valor de área em metros quadrados e m² e apresente-o convertido em acres. A fórmula de conversão é: A = M * 0,000247, sendo M a área em metros quadrados e A área em acres. """ sqaure_meters_area = float(input('Enter the area value in square meters: ')) acres = round(sqaure_meters_area * 0.000247, 2) pr...
3f50bd729a67bfb55af0e0fbac29705102494ce5
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_18.py
352
4.15625
4
""" 18) Leia um valor de um volume em metros cúbicos m³ e apresente-o convertido em litros. A fórmula de conversão é: L = 1000 * M, sendo L o volume em litros e M o volume em metros cúbicos """ meters = float(input('Enter the value in cubic meters: ')) liters = round(1000 * meters, 2) print(f'The meter value {meters} ...
db8d77328591aac0b5af3f36b138dc5c8d7b7833
romulovieira777/Programacao_em_Python_Essencial
/Seção 05 - Estruturas Lógicas e Condicionais em Python/Exercícios da Seção/Exercício_05.py
247
4.28125
4
""" 5) Faça um programa que receba um número inteiro e verifique se este número é par ou ímpar. """ number = int(input('Enter a number: ')) if number % 2 == 0: print(f'Number {number} is even') else: print(f'Number {number }is odd')
8c95c5651b9324be471ae63f13c4197ad2db9b60
romulovieira777/Programacao_em_Python_Essencial
/Seção 06 - Estruturas de Repetição em Python/Exercícios da Seção/Exercício_10.py
282
3.96875
4
""" 10) Faça um programa que calcule e mostre a soma dos 50 primeiros números pares. """ number = 50 count = 0 even_sum = 0 for n in range(1, 1000): if n % 2 == 0: print(n) even_sum += 1 count += 1 if count == 50: break print(even_sum)
93e309760e9ee23a8d59b3fa58315df11a7a72bb
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_52.py
760
3.796875
4
""" 52) Três amigos jogaram na loteria. Caso eles ganhem, o prêmio deve ser repartido porporcionalmente ao valor que cada deu para a realização da aposta. Faça um programa que leia quanto cada apostador investiu, o valor do prêmio, e imprima quanto cada um ganharia do prêmio com base no valor investido. """ friend_1 =...
f6cbeb5e0b5b2b3b9c620a7518efec8e5f722f34
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_07.py
377
4.03125
4
""" 7) Leia uma temperatura em graus Fahrenheit e apresente-a convertida em graus Celsius. A fórmula de conversão é: C = (F-32.0)*5.0/9.0, sendo C a temperatura em Celsius e F a temperatura em Fahrenheit. """ fahrenheit = float(input('Enter the temperature in Fahrenheit: ')) celsius = round((fahrenheit - 32) * 5 / 9, ...
f7a651d5ca87f820efd3ec230c9b63da8213244a
arifromadhan19/Codility
/time_complexity/perm_missing_elem.py
311
3.59375
4
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(A): # write your code in Python 3.6 n = len(A) total = (n + 1) * (n + 2) / 2 sum_of_A = sum(A) miss = total - sum_of_A return int(miss) pass A = [2, 3, 1, 5] print(solution(A))
6b307c9b4c894c6542fee60773f9d0d371997fc7
SaraSchim/Pokemon-project
/service.py
5,639
3.625
4
from connection import connection # add a new pokemon to the pokemon table def add_pokemon(id, name, height, weight, types): try: with connection.cursor() as cursor: cursor.execute("insert into pokemon(id, name, height, weight) values({}, '{}', {}, {})".format(id,name,height,weight)) ...
126c4a2b9b734724e242fa73ccc85167f9d0251e
ZhenguPanda/comp110-21f-workspace
/exercises/ex03/happy_trees.py
347
3.546875
4
"""Drawing forests in a loop.""" __author__ = "730401590" # The string constant for the pine tree emoji TREE: str = '\U0001F332' n: int = int(input("Depth: ")) s: str = "" a = n if n > 0: while n > 0: if a == n: s = TREE + s else: s = TREE + " " + s n = n - 1 ...
3597824ddcb30d744bbd6ecfe98145e38d6ff508
mahmedraza/6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python
/source/Problemset5/search.py
712
3.8125
4
def search(L, e): for i in range(len(L)): if L[i] == e: return True if L[i] > e: return False return False def newsearch(L, e): size = len(L) for i in range(size): if L[size-i-1] == e: return True if L[i] < e: return False...
b7fba01180f9216144994871abdc88fd72d71567
mahmedraza/6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python
/source/ProblemSet6/parser.py
596
3.890625
4
import string def parser1(text): count = 0 word = '' z = [] words = text.split(" ") for word in words: for i in word: if i in string.punctuation or i == ' ' or i.isdigit(): z.append(word.replace(i, "")) return z # else: # ...
77f43b765896bc00b393eaca04214df1865d6316
mahmedraza/6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python
/source/gcdIter.py
465
4.03125
4
def gcdIter(a, b): ''' a, b: positive integers returns: a positive integer, the greatest common divisor of a & b. ''' # Your code here if (a < b): g = a else: g = b while (g != 0): if ((a % g == 0) and (b % g == 0)): return g else: ...
efa038b12f21297dadf98575ad33e0948c5c8b20
KenjiIlao/ASSIGNMENT4
/Assign4.2.py
541
4.125
4
print("the price of apple is 20") apple = 20 print("the price of orange is 25") orange = 25 def getUserInput(): apples = int(input("the total of apples that i want to buy: ")) oranges = int(input("the total of oranges that i want to buy: ")) amount = apples * apple + orange * oranges return apples, ora...
47b9d95cf669fca8fd49c099f0615156a04a9f50
thedrgman/Python-Unit-1
/guessing_game.py
3,125
4.28125
4
""" Python Web Development Techdegree Project 1 - Number Guessing Game -------------------------------- """ import random # Set minimum and maximum values that will be used for the range MAX = 10 MIN = 1 def start_game(): play = "y" highscore = 0 while play == "y" or play == "yes": # This helps keep the...
81a0618fa9a868af920db70cc9bbd2248e516bed
gowthamnvg/gowtham
/bin.py
99
3.75
4
inp1=input() S=set(inp1) L={'0','1'} if S==L or S=='0' or L=='1': print("yes") else: print("no")
4a8af630d2091294762cd972a95fa3c238104fcc
gowthamnvg/gowtham
/fib.py
124
3.703125
4
inp=int(input()) first=0 second=1 for i in range(inp): print(second,end=" ") temp=first first=second second=temp+second
ccab889a74830383f258885948147189ed4207ed
gowthamnvg/gowtham
/pow.py
122
3.609375
4
var=int(input()) n=var c=0 while (n!=1): n=n//2 c=c+1 temp=2**c if (var==temp): print("yes") else:print("no")
724720472d158829cfb3fa434e92cafd56ff29b1
jeong-hyejin/Algorithm
/TIL/SWEA/D2/swea_5174.py
595
3.609375
4
def preorder(node): global cnt if node: cnt += 1 preorder(tree[node][0]) preorder(tree[node][1]) T = int(input()) for tc in range(1, T+1): E, N = map(int, input().split()) temp = list(map(int, input().split())) tree = [[0] * 3 for _ in range(E+2)] cnt = 0 for i in ra...
07a1dd702ecf636401b961a31c3e886b64804541
JoelPatricio/Analizador-Lexico
/pruebas.py
181
3.53125
4
import re str1="a" str2='\d' aux=bool(re.search(r'\d', str1)) if(aux==True): print(aux) else: print("False") linea = "6=>=:10" linea = linea.split("=>") print(linea)
00cef02c3bcf8bb173a55027c27cd91775dc38ea
SoulAttacker/knowledge_base
/algorithms/data_structure/stack/stack.py
547
3.765625
4
class Stack: def __init__(self): self.stack = list() def __bool__(self): return bool(self.stack) def __str__(self): return str(self.stack) def push(self, data): self.stack.append(data) def pop(self): return self.stack.pop() def peek(self): if ...
25efa650027f208016479bdbf41aeee5987022ea
comRamona/Learn-Python-The-Hard-Way
/ex7.py
130
3.65625
4
x=10 print ("Print this %d times "%x) *x e1="B" e2="i" e3="g" e4="M" e5="a" e6="c" print e1+e2+e3, print e4+e5+e6 print "test"*2
b6aa4b198c276d9f940557e0554b3a1a2c2713af
JaDogg/__py_playground
/reference/parson/eg_json.py
2,058
3.671875
4
""" Example: parse JSON. """ from parson import Grammar literals = dict(true=True, false=False, null=None) mk_literal = literals.get mk_object = lambda *pairs: dict(pairs) escape = lambda s: s.decode('unicode-escape') mk_number = float # Following http://www.json.org/ json_pars...
edf2c1770fb2888d175dc949fb277cc877c290f7
harrywestt/Snake
/main.py
9,728
3.953125
4
""" Project: Snake with pygame Version: 1.1 Author: Harry West Date: 09/2019 """ from tkinter import Tk from tkinter import messagebox import pygame import random import sys class fruit: def __init__(self, width, height): # Initialise a fruit with a random position and colour self.position = [ra...
9535ae66f72b181e74236016d945a067ca92a8fa
jkerw/Math-Adventures-
/rotTriangle.pyde
744
3.890625
4
def setup(): size(600,600) rectMode(CENTER) colorMode(HSB) t = 0 def draw(): background(255) global t translate(width/2,height/2) for i in range(90): rotate(radians(360/90)) pushMatrix() #saves the orientation #goes to circumference of circle translate(2...
dc981d65efd1875f5f2656924d97685f6b4a5d67
martinpbarber/python-workout
/src/chapter_03/exercise_11.py
241
3.6875
4
""" exercise_11 """ import operator def alphabetize_names(people): """ Sort an array of dictionaries by 'first' and 'last' name """ sorted_people = sorted(people, key=operator.itemgetter("last", "first")) return sorted_people
1a59a91bf74bf9b9d5fef5cc407e5d45c0c27461
martinpbarber/python-workout
/src/chapter_01/exercise_04.py
400
4.15625
4
""" exercise_03 """ PROMPT = "Enter a hex number to convert: " def hex_output(): """ Convert hexadecimal number to decimal """ hex_number = input(PROMPT) decimal_number = 0 for (place, value) in enumerate(reversed(hex_number)): print(f"value: {value}") print(f"place: {place}") ...
0255c053d28e22970556e6a2ff0f3ee1edab6c56
mirzalorena/Fundamentals-Of-Programming
/Connect4/Board.py
4,736
3.96875
4
''' Created on Dec 20, 2018 @author: Lorena ''' class Board: def __init__(self,width,height): self.board=[[" "]*width for i in range(height)] self.width=width self.height=height def clear_board(self): """ clears the board """ self...
5347f5324b30c8dc4558f7c73180a1386e5401da
vigneshsrao/python_exercism
/hamming/hamming.py
664
3.765625
4
strand1 = raw_input("Enter the first strand ") strand2 = raw_input("Enter the second strand ") strand1= strand1.replace(' ', '') strand2= strand2.replace(' ', '') strand1 = list(strand1) strand2 = list(strand2) table = ['G','C','A','T'] t=1 for i in strand1: if i not in table: t=0 for i in stra...
6493e02a24bc64485864e4b99311b93e74f01fab
monkey3199/tensorflow_example
/MNIST_single_keras/mnist_cnn.py
1,834
3.96875
4
# Lab 11 MNIST and Convolutional Neural Network import tensorflow as tf import random # import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data tf.set_random_seed(777) # reproducibility mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) # Check out https://www.tensorfl...
c4300906fdfd59a0b188dabf53cebf5d1ece1292
Sanchr-sys/Letsupgrade_python7
/day 6-ass2.py
580
4.125
4
##############SHAPES############ import math class Cone: def __init__(self,Radius,Height): self.Radius = Radius self.Height = Height #self.Volume = Volume #self.Surface = Surface def Volume(self): Vol = (1/3) * math.pi * self.Radius*self.Radius*self.Height ...
eea6b813227be48e0a1be4f66be5ee21320aede1
MantieReid/100-days-of-code-round-2
/Day 98/844. Backspace String compare.py
462
3.65625
4
class Solution: def backspaceCompare(self, S: str, T: str) -> bool: def build(S): ans = [] # create a stack for c in S: # loop through s if c != '#': # if c does not equal # ans.append(c) # append it to the list elif ans: ans.pop() # remove from the stack retu...
d4650d5a77b85ee4d0efbe44abcf56ff3e312982
MantieReid/100-days-of-code-round-2
/Day 6/846. Hand of Straights.py
577
3.765625
4
def isNStraightHand( hand: List[int], W: int) -> bool: hand.sort() # sort the hand list while hand: # start iterating through the hand try: base = hand[0] # base will equal the first element in hand for i in range(W): # make numbers from 1 to w. hand.remove(base + i) # remove ...
73a7778e7409b462d4dcb53f6c07ea577342058d
MantieReid/100-days-of-code-round-2
/Day 33/876. Middle of the Linked List.py
441
3.828125
4
class Solution: def middleNode(self, head: ListNode) -> ListNode: # basically using two pointers to go through the list. # slow will move by one step to the next node. # Fast will move by two steps to the next node slow = fast = head while fast and fast.next: slow = slow.next # slow will go ...
ef6a1bdaabfa5e760116fdc7ca7dcaf82d3d7484
MantieReid/100-days-of-code-round-2
/Day 40/20. Valid Parentheses.py
764
4.0625
4
class Solution: def isValid(self, s: str) -> bool: stack = [0] mapping = {0: None, '(': ')', '[': ']', '{': '}'} # create a dictionary that holds both sides of the brackets. Zero to help check if the stack is empty for c in s: # iterate through string. if c in mapping: # check to see if the string c...
eff7c40f63debbf6c1a6d0dd35fd4a599089d53f
MantieReid/100-days-of-code-round-2
/Day 97/1051. Height Checker.py
411
3.859375
4
from typing import List from self import self class Solution: def heightChecker(self, heights: List[int]) -> int: s = sorted(heights) # sorts the list ans = 0 # ans is equal to zero for h, hs in zip(heights, s): if h != hs: # if h is not equal to hs ans += 1 # increment ans by one ret...
c8540465e4b1031a3ff46370dc4ca1dda3646c95
MantieReid/100-days-of-code-round-2
/Day 99/442. Find all duplicates in an array.py
611
3.875
4
import collections from collections import Counter from typing import List from self import self class Solution: def findDuplicates(self, nums: List[int]) -> List[int]: counthem = collections.Counter(nums) # counter to get the number of times each element appears in the list. duplicates = [x for x in counthem...
5a67da9dc2a3714907a9ca4f860fc17d40e6dee9
MantieReid/100-days-of-code-round-2
/Day 8/Merge two sorted lists final.py
1,406
4.3125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: dummyroot = ListNode(0) # create a new linkedlist called dummyroot mergedlist = [] # create a ...
19d7f35bcad13bc8bb98b0a70351d407733048de
ashmita18-dxc/python-assignments
/config/scratches/scope.py
2,020
4.28125
4
#global and local variables data = "Hello.. I am a global variable to the function" #global variable def demo(): print(data) demo() def local(): data1="Hello.. I am a local variable to the function" #local variables deleted once function is executed print(data1) local() #2 data4="Hello You" def oute...
9c2c16213e73506b16c3ae5970c9ac8ab6151184
ashmita18-dxc/python-assignments
/config/scratches/function.py
931
3.65625
4
#unparameterised def greetings(): print("Hi All") greetings() greetings() #parameterised def sayhello(name1,name2): print("Hi "+name1+" "+name2) sayhello("Ashmita","Sarkar") #positional arguments #return type function def helloagain(name1,name2): return(name1+" "+name2) data=helloagain("Ashmita","S...
a22d83d8a3dad81d40763c1bfefb0df5cda64393
ashmita18-dxc/python-assignments
/config/scratches/day4.py
2,918
4.625
5
#1 def outer(a): #print("This is out!") def inner(): print("This is in!") print(type(a)) a() print("Done!!") return inner def hello(): print("Hello World") demo=outer(hello) #demo contains inner function->inner function contains hello->so a() implies to hello() dem...
3665d13359dd2c6a5f241472fc802704ab3efeed
ashmita18-dxc/python-assignments
/config/scratches/nonsq.py
742
4.03125
4
#SET s={False,None,"Hello",1,"Sachin"} #1 and true are considered duplicate of each other print(type(s)) print(s) s1={1,2,3,4} s2={3,4,5,6} s3={1,2} print(s1|s2) #union print(s1&s2) #intersection print(s1-s2) #difference print(s2-s1) #difference print(s3<s2) #subset print(s3<s1) #subset #in python,...
62b4b34f8824935be78264c5a50680b778742302
ashmita18-dxc/python-assignments
/config/scratches/datefn.py
420
3.84375
4
days={ "1":"Friday", "2":"Saturday", "3":"Sunday", "4":"Monday", "5":"Tuesday", "6":"Wednesday", "0":"Thursday" } date=int(input("Enter: ")) mod=date%7 print(days[str(mod)]) #factors list number=int(input("Enter number: ")) factors=[] for i in range(1,number+1): if(number%i==0): ...
b06a80ba93c639e07ad951fba9d82a5086e62c83
zwarshavsky/Sprint-Challenge--Computer-Architecture
/cpu_2.py
7,857
3.859375
4
"""CPU functionality.""" import sys class CPU: """Main CPU class.""" def __init__(self): """Construct a new CPU.""" self.ram = [0] * 256 # Must share space with 1) stack (holds the register's addresses), 2) reserved memory spaces, and 3) instructions to be loaded ...
0cd5789c80e675cbffa93c4e54f9fdc99a6efad8
vishal-kr-yadav/backup
/General/PawnJump.py
1,140
4.375
4
#pawnJump is function that will take Array as a input def pawnJump(Array): #calculating the length of the Array array_length = len(Array) #initializing array_Index and toBeReturned array_Index = 0 to_Be_Returned = 0 #looping till the array_index is less then the size of the Array and arrayInde...
7369d29ecf1aacf6682c6ba96bcc310e553c25af
Zulbukharov/ml_practice_theory
/diana.py
1,721
3.90625
4
#собственно калькулятор, хехе print('\ ░░░░█▐▄▒▒▒▌▌▒▒▌░▌▒▐▐▐▒▒▐▒▒▌▒▀▄▀▄░ \n\ ░░░█▐▒▒▀▀▌░▀▀▀░░▀▀▀░░▀▀▄▌▌▐▒▒▒▌▐░ \n\ ░░▐▒▒▀▀▄▐░▀▀▄▄░░░░░░░░░░░▐▒▌▒▒▐░▌ \n\ ░░▐▒▌▒▒▒▌░▄▄▄▄█▄░░░░░░░▄▄▄▐▐▄▄▀░░ \n\ ░░▌▐▒▒▒▐░░░░░░░░░░░░░▀█▄░░░░▌▌░░░ \n\ ▄▀▒▒▌▒▒▐░░░░░░░▄░░▄░░░░░▀▀░░▌▌░░░ \n\ ▄▄▀▒▐▒▒▐░░░░░░░▐▀▀▀▄▄▀░░░░░░▌▌░░░ \n\ ░░░░█▌▒▒▌░░░░░▐...
8b28601f0f6b303c851d5f60e2ad668099e05c8b
PHig/pongPython
/pong.py
4,810
3.921875
4
# Pong # This game can be played @ the following url # http://www.codeskulptor.org/#user13_SlpveYUHvQ_10.py import simplegui import random # initialize globals - pos and vel encode vertical info for paddles WIDTH = 600 HEIGHT = 400 BALL_RADIUS = 20 PAD_WIDTH = 8 PAD_HEIGHT = 80 HALF_PAD_WIDTH = PAD_WIDTH / 2 H...
a6e7228b91e1eadabefd06656583b20bd157caee
GuilhermeBizzani/Seguranca
/T1/T1/Transposicao.py
2,052
3.5
4
import math __author__ = 'Guilherme' print("Bem vindo ao criptografador de Transposicao!") ent = 1 while 0 != ent: print("Digite o nome do arquivo de entrada COM A EXTENSAO!") arq = input('->') file = open(arq, 'rb') leitura = file.read() file.close() print("Menu:\n1 - Criptografar frase\n2...
06f87f18379575f97afd8a16e140ae137b8514c3
JuankRodriguez/Recursion
/sumasyrestas_recur.py
446
4.1875
4
def operar(numero1, numero2): if(numero2 == 0): return numero1 elif(numero2 < 0): return operar(numero1-1, numero2+1) #recursividad else: return operar(numero1+1, numero2-1) #recursividad print("10+3=", operar(5, 2)) print("5-2=", operar(6, -2)) # este ...
18a77ed521edae39b45aa20616639c693cfaeb4b
build3r/Competitive-Coding-Daily
/extraLongFactorial.py
254
3.75
4
#https://www.hackerrank.com/challenges/extra-long-factorials/problem if __name__ == '__main__': n = int(input()) fact = 1 if n == 0: print(fact) else: for i in range(1,n+1): fact = fact * i print(fact)
5bb045372bd95e0d663455c8a945962630707b28
Jayesh97/programmming
/special/149_MaxPointsinaLine.py
748
3.5625
4
points = [[1,1],[2,2],[3,3],[1,1]] def maxpoints(points): if len(points)<3: return len(points) res = 0 for i in range(len(points)-1): cur = 0 overlap = 0 lines = {} for j in range(i+1,len(points)): #print(points[i],points[j]) dx = points[i][0] ...
1c9026b22d60bb38de26b521ae501ebb815208d2
Jayesh97/programmming
/special/139_WordBreak.py
511
3.59375
4
s = "leetcode" wordDict = ["leet", "code"] def recurse(s,seen,wordset,lengths): if s=="": return True if s in seen: return seen[s] for length in lengths: if s[:length] in wordset and recurse(s[length:],seen,wordset,lengths): #print(s[:length]) seen[s]=True ...
a3a95a05da8dc2541c8c57c8f11a2eaecf8ccd8f
Jayesh97/programmming
/dynamic_programming/string_interleaving.py
825
3.859375
4
''' Checking truth values with the substring ''' def matrix(x,y,s1,s2,s3): k = [[0 for i in range(x+1)] for j in range(y+1)] for y in range(y+1): for x in range(x+1): if x==0 and y==0: k[x][y] = 1 elif x==0: if k[x][y-1] == 1 and s3[y-1]==s1[y-1]: ...
3f6af88337e0c04dd6ec8ae65d110af977de25bd
Jayesh97/programmming
/numbers/38_CountAndSay.py
556
3.953125
4
n = 3 def countandsay(n): result = "1" for i in range(n-1): prev = result result = "" j = 0 while j<len(prev): current = prev[j] count = 1 j = j+1 #if the next character also repeats, we need to increase count #So this i...
4be2ec7bea34e69579ec5183039dc38c9d53c1c2
Jayesh97/programmming
/recursion/10_RegularExpressionMatching.py
1,452
3.546875
4
s = "aa" p = "a*" def matching(s,p): if not p: #print(s,p) return not s #like "aa" and ".*" if s!="" and p[0] in (s[0],'.'): firstmatch = True else: firstmatch = False #print(firstmatch) #for those with "aa" and "c*aa" #1st letter doesnt match but 2nd letter ...
8332d43eeeeb35ca4c759c0817535c92742a84f4
Jayesh97/programmming
/strings/159_LongestSubstringwithatmost2.py
454
3.71875
4
from collections import defaultdict s = "ccaabbb" def longestwith2(s): n = len(s) if n==0: return 0 max_len = 1 left,right = 0,0 d = defaultdict() while right<n: d[s[right]]=right right = right+1 if len(d.keys())==3: del_idx = min(d.values()) ...
676b4d39cdaf93001f51eaf5f7b489f695dc014a
Jayesh97/programmming
/recursion/nth-stair-msteps.py
509
3.703125
4
def ways(n,m): if n<=1: return n total = 0 i = 1 while i<=m and i<=n: total = total + ways(n-i,m) i=i+1 return total print(ways(3+1,3)) def countWaysUtil(n,m): total = [0 for x in range(n+1)] # Creates list res witth all elements 0 total[0],total[1] = 0,1 ...
d44ffefe026a0a85691d1a9627fbfbfb45d92d44
Jayesh97/programmming
/strings/70_ClimbingStairs.py
169
3.78125
4
n = 10 def climbing(n): if n==1: return 1 dp = [1,1,2] for i in range(3,n+1): dp.append(dp[i-1]+dp[i-2]) return dp[n] print(climbing(n))
5ef219fde0bb858b7071210a5c6cca65ceb9556d
Jayesh97/programmming
/special/315_CountofSmallernumbers_afterself.py
612
3.984375
4
nums = [9,2,6,1] def merge_sort(enums): half = int(len(enums)/2) print(half) if half>0: left,right = merge_sort(enums[:half]),merge_sort(enums[half:]) for i in range(len(enums))[::-1]: #print(i,left,right,enums) if not right or left and left[-1][1]>right[-1][1]: ...
70e76fd2b69609ae2cd462a6c4d749f1af4f1051
Jayesh97/programmming
/cicso/242_ValidAnagram.py
411
3.59375
4
#O(nlgn) s = "anagram" t = "nagaram" def anagram(s,t): s = sorted(s) t = sorted(t) if s==t: return True return False print(anagram(s,t)) #O(n) def anagram2(s,t): l = [0 for i in range(26)] for i in s: l[ord(i)-ord('a')] += 1 for i in t: l[ord(i)-ord('a')] -= 1 fo...
e2d9ad70b33efcc902b6604225ea0073ee3cef1e
Jayesh97/programmming
/cicso/344_StringRevere.py
239
3.875
4
a = ["h","e","l","l","o"] start = 0 end = len(a)-1 def reverse(a,start,end): while start<end: temp = a[start] a[start] = a[end] a[end]=temp start=start+1 end = end-1 reverse(a,start,end) print(a)
c8e092ec8a821ba3ea5f723f547035c89d2e0756
Jayesh97/programmming
/linked_lists/138_CopyListsWithRandomPointers.py
952
3.796875
4
class ListNode(): def __init__(self,value,next=None,random=None): self.value = value self.next = next self.random = random def print_ll(l1): print("start") while l1.next!=None: print(l1.value,"----",l1.random) l1= l1.next print(l1.value,"----",l1.random) prin...
8d2da501224feef53ca54eb2b506caf02e987ce6
Jayesh97/programmming
/special/56_mergeIntervals.py
205
3.578125
4
a = [[1,3],[8,10],[15,18],[2,6]] a.sort(key=lambda x: x[0]) merged = [] for i in a: if not merged or merged[-1][-1]<i[0]: merged.append(i) else: merged[-1][-1] = i[-1] print(merged)
6dde78243e66d5d65f7938822700cb06ee5e2e6c
Jayesh97/programmming
/arrays/169_MajorityElement.py
197
3.703125
4
nums=[3,2,3] def majorityelement(nums): d = {} for i in nums: d[i]=d.get(i,0)+1 for i in d.keys(): if d[i]>len(nums)/2: return i print(majorityelement(nums))
bdaabb1f24d78508642ff5dca15e805895e09f40
Jayesh97/programmming
/arrays/239_SlidingWindow.py
422
3.625
4
from collections import deque nums = [1,3,-1,-3,5,3,6,7] k = 3 def sliding(nums,k): res = [] bigger = deque() for i,j in enumerate(nums): while bigger and nums[bigger[-1]]<=j: bigger.pop() bigger.append(i) if i-bigger[0]>=k: bigger.popleft() if i+1>=k:...
88502bd6321b55185ed3f16746ae614c21a1f572
Jayesh97/programmming
/arrays/130_SurroundRegions.py
1,184
3.703125
4
board = [["X","X","X","X"], ["X","O","O","X"], ["X","X","O","X"], ["X","O","X","X"]] def surround(board): if not board: return m = len(board) n = len(board[0]) def expand(i,j): neighbors = [(1,0),(0,1),(-1,0),(0,-1)] ans = [] for (x,y) in neighbors: r = i+x ...
a9b376742241ef2895e9f52302e21b81f8de7c4d
Jayesh97/programmming
/cicso/20_ValidParenthesis.py
607
3.84375
4
stack = [] d = {')':'(','}':'{',']':'['} string = "{[]}[]}" def validation(string): for i in string: if i in d.values(): #openings go here stack.append(i) else: #closing or invalid go here if i in d.keys(): if stack==[]: return False ...
8e6e501f35a3e8c31af76c1a6747536a5b002eb3
jr31112/Start-Camp
/day4/d4.py
3,239
3.65625
4
""" Python dictionary 연습 문제 """ # 1. 평균을 구하시오. score = { '수학': 80, '국어': 90, '음악': 100 } # 아래에 코드를 작성해 주세요. print('==== Q1 ====') # 1-1. 기본풀이 result1 = 0 for subject in score.values(): # result = result + subject result1 += subject print('평균은 {}점입니다.'.format(result1/len(score))) # 1-2. s...
6b9c1ab240db62b1f9343dc58dbb45531fee873e
L-Nafaryus/leetcode-tasks
/python/maxProduct.py
694
3.859375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def maxProduct(words: [str]) -> int: val1, val2 = "", "" for word1 in words: for word2 in words: check = [ letter in word2 for letter in word1 ] if sum(check) == 0 and word1 != word2: #if len(val1) < len...
212ebbf8f4fd23a421fac79fe0cbc6e5128eefb3
wtripp/udacity-cs215-intro-algorithms
/final/final-9_top_two.py
2,191
4
4
# # write a function, `top_two` that takes in a graph and a starting # node and returns two paths, the first and second shortest paths, # for all the other nodes in the graph. You can assume that the # graph is connected. # import heapq def top_two(graph, start, n=2): # Create the heap and populate it with the s...
b7543c56b0ada1bdc81382541376aae7b0a00e39
ceruleanat/Basic-Python-Projects
/files_main.py
1,122
3.65625
4
from tkinter import filedialog from tkinter import * def browse_button(): # Allow user to select a directory and store it in global var # called folder_path global folder_path filename = filedialog.askdirectory() folder_path.set(filename) print(filename) root = Tk() folder_path = StringVar()...
3aaea0fa9a29e67c8df6688386a92f881bac46b6
xjie0403/cs263-c-animats
/grid.py
2,089
4.03125
4
import pygame # Define some colors BLACK = ( 0, 0, 0) WHITE = ( 255, 255, 255) GREEN = ( 0, 255, 0) RED = ( 255, 0, 0) #set the height and width of each cell width = 20 height = 20 #starting location of bull bull_x = 5 bull_y = 5 #set the margin between each cell margin = ...
9083ac958197371c850cc39206be951d80c6fb55
tkmru/machine-learning-playground
/neutral_network/activation_function/relu.py
257
3.53125
4
#!/usr/bin/env python3 # coding: UTF-8 import matplotlib.pyplot as plt import numpy as np def relu(x): return np.maximum(0, x) x = np.arange(-5.0, 5.0, 0.1) y = relu(x) plt.plot(x, y, label='relu') plt.xlabel('x') plt.ylabel('relu(x)') plt.show()
589f38aa09be52a39e89c783e79bcc771fe2b4e9
Hiteshc29/Todo
/encrypt.py
562
3.59375
4
import hashlib def encryption(x): salt = ['hiw', 'fgb', '012', 'abz', '9fe', 'yx3', 'v57', 'jkl'] no_of_char = int(len(x) / 8) x = ' '.join(x[i:i + no_of_char] for i in range(0, len(x), no_of_char)).split() salted = [] i = 0 while i < 8: salted.append(salt[i]) salted.append(x[0]...