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
38cebc4b8358782b77b27e9f46c0b76a17b24b17
JoseBalbuena181096/python_course
/lesson_10/adivina.py
1,699
4.125
4
from utilidades import logo from utilidades import limpiar_consola from random import randint from time import sleep VIDAS_FACIL = 10 VIDAS_DIFICIL = 5 def elegir_dificultad(): dificultad = input('¿Qué dificultad deseas?, F para fácil y D para difícil.\n').upper() if dificultad == 'F': return VIDAS_FA...
6953c29380f807348c85c844201d75f4a6236671
JoseBalbuena181096/python_course
/lesson_15/lesson15-6.py
550
3.609375
4
import turtle as t import random tortuga = t.Turtle() tortuga.speed('fastest') t.colormode(255) def color_random(): r = random.randint(0,255) g = random.randint(0,255) b = random.randint(0,255) color = (r,g,b) return color def dibujar_circulos(numero_circulos): incremento = int(360 / numero...
f3fe711abdee528436d5e0f4bfc782c2e72fb8d0
JoseBalbuena181096/python_course
/lesson_16/lesson_16-2.py
1,234
3.8125
4
import turtle as t import random ventana = t.Screen() ventana.setup(width=500, height=400) ventana.bgcolor('black') eleccion = ventana.textinput(title='Carrera de tortugas', prompt='¿Cuál tortuga ganará la carrera?, ingrese el color en ingles blue, green, red, purple') colores = ['blue','green','red','purple'] posici...
55905f2c0b115957b0057ef28186c41765867903
JoseBalbuena181096/python_course
/lesson_20/lesson_20-2/marcador_turtle.py
1,167
3.71875
4
from turtle import Turtle class Marcador(Turtle): def __init__(self): super().__init__() #nuevo -2 with open('/home/jose/Desktop/python_course/lesson_20/lesson_20-2/datos.txt', mode='r') as file: self.mayor_puntaje = int(file.read()) self.puntuacion = 0 self.co...
fb1b8211301edf24687c46265fbe9e7cf20aa98a
JoseBalbuena181096/python_course
/lesson_07/ cifrado_cesar.py
1,517
3.671875
4
#herramienta de cifrado césar from arte import logo from arte import limpiar_consola def case(ascii_,direccion,desplazamiento,char,n): index = ascii_ - ord(char) if direccion == 'encode': index_desplazado = (index + desplazamiento) % n elif direccion == 'decode': index_desplazado = (index...
5faf88b78791b9cc8f1e7501cd46a180eb1fb2ab
macjosh23/Learning_Python
/Book_ThePractice/Chapter_2/Exercise_20.py
141
3.96875
4
num = raw_input("Type an entry: "); while(not(num.isdigit())): num = raw_input("Type an integer: "); print num, " is an integer";
2ee2ff98d1f45fba069c1ebb3b2281c1b06322ee
macjosh23/Learning_Python
/Book_ThePractice/Chapter_2/Exercise_17.py
496
4.09375
4
# Verify if a number is a perfect squared: #Is a perfect squared? def IsSquared(num_in): square = True; i = 1; while(i < num_in): if(num_in == i*i): square = False; # Print out if it is a perfect squared print num_in, " is a perfect squared "; ...
36eae1f7c9c6c483a8c010a17509caccaa884b93
ropeke/cs224w-webbopekedo-finalproj
/RandomRegressor.py
901
3.53125
4
""" FILE: RandomRegressor.py ------------------ Author: James Webb (jmwebb@stanford.edu) Created: 11/15/2015 """ import random class RandomRegressor: """ Regressor that guesses psuedo-random float value between provided range. The predicted rating of business B by user A is selected randomly from a uniform distri...
1e636f2b15e3881a6dae993e1293788e3eb1d1e5
pako535/Design_Pattern
/observer.py
2,026
3.609375
4
from random import randint class Observer: def __init__(self, name, totolotek): self.name = name self.results = [0, 0, 0, 0, 0] self.totolotek = totolotek def __repr__(self): return "\nThe result of today's draw: {} is: {}".format(str(self.name), str(self.results)) def up...
684a461578aa7a89a5d314b87c8ae225787e79ce
o8oo8o/Py_Design_Patterns
/factory.py
896
4.21875
4
#!/usr/bin/env python """ 抽象工厂模式 """ class PetShop: def __init__(self, animal_factory=None): self.pet_factory = animal_factory def show_pet(self): pet = self.pet_factory.get_pet() print("动物类型:", str(pet)) print("动物叫声:", pet.speak()) print("吃的东西:", self.pet_factory.ge...
7e0053b320f3901d1300fda7fdc8dfd4d06acbb0
o8oo8o/Py_Design_Patterns
/visit.py
451
3.90625
4
#!/usr/bin/env python """ 访问者模式 """ class Book: def __init__(self, name): self.name = name class Student: def read(self, book): print(f"{book.name}这本书,学生看不懂") class Teacher: def read(self, book): print(f"{book.name}这本书,老师看不懂") if __name__ == "__main__": book = Book("金瓶...
cf15fd00cc6e6fea5460f6204cc728b6e8073da8
o8oo8o/Py_Design_Patterns
/responsibility.py
1,636
3.953125
4
#!/usr/bin/env python """ 职责(责任链)模式 """ class Handler: def set_next_handler(self, next_handler): self.next_handler = next_handler # 流程发起人 class Person(Handler): def __init__(self, name, off_day): self.name = name self.off_day = off_day def request(self): self.next_handl...
d0ad3afe3e2dd32c6e643d00fb3a984286f13cb4
fjmkfjmk/hangman
/hangman.py
1,010
3.90625
4
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> #第十章HANGMAN >>> def hangman (word): wrong=0 stages=["", "_______ ", "| ", "| | ", "| ...
9c33904e4f7aa5755bdc68499645da20d9c86902
MatiasToniolopy/condicionales_python
/profundizacion_2.py
1,990
4.1875
4
# Tipos de variables [Python] # Ejercicios de profundización # Autor: Inove Coding School # Version: 2.0 # NOTA: # Estos ejercicios son de mayor dificultad que los de clase y práctica. # Están pensados para aquellos con conocimientos previo o que dispongan # de mucho más tiempo para abordar estos temas por su cuenta...
4c3d57cc236c2f56e60dfcba9188975a451db08b
ian-yitzhak/python-arrays
/array2.py
243
3.53125
4
cars = ['mercedes', 'bmw' , 'toyota' , 'vitz' , 'prado'] cars.append('benz') print(cars) print(len(cars)) color = ['red', 'yellow' , 'green' , 'blue' , 'indigo' , 'violet', 'purple'] del color[1] color.pop(4) color.remove('blue') print(color)
3bf0e49ba5cc32c1fe0241b62ea41d88ae527dd5
ryanbrate/DS_thesis
/6_Evaluation/gold_standard/prediction_labels_by_pattern.py
4,945
3.546875
4
"""Return a list of [TN, TP, FP, FN,..] outcomes for each extract by pattern, wrt. each sentence in the gold standard. A positive match is deemed a positive outcome to the question "is the sentence a smell experience". The gold standard tags"d" and "o" represent the presence of a smell experience in text for which to j...
bee70d6fa16e25998f08830db5669e8b260e93d7
DriesDD/python-workshop
/Examples/guess.py
1,237
4.21875
4
""" This uses the random module: https://www.w3schools.com/python/module_random.asp Exercises: 1. Can you make it a number between one and 100? Give more hints depending on whether the player is close or not? And change the number of guesses that the player can make? 2. Can you make the game into a function called sta...
7c41adceb0541e708b20ded6d5f8925dca26a3ce
Mehdi-SIO/checkio
/median/median_tests.py
885
3.53125
4
import unittest import median class MedianTest(unittest.TestCase): def test_checkio_with_sorted_array_odd_length_returns_3(self): result = median.checkio([1, 2, 3, 4, 5]) self.assertEquals(3, result) def test_checkio_with_not_sorted_array_odd_length_returns_3(self): result = median.checkio([1, 2, 3, 4, 5]) ...
0b4fbea5cdde2487623436c77b19de208c55b81e
cgunkel/mycode
/moveplease01.py
403
3.625
4
#!/usr/bin/env python3 import shutil import os # Set the working directory os.chdir('/home/student/mycode/') # The following line will rename a file # Move the file or folder shutil.move('raynor.obj', 'ceph_storage/') # Prompt for input for new newname xname = input('What is the new name for kerrigan.obj? ') # Ren...
f501c770656ea62910fd3ab9fed143742e77d1f0
cgunkel/mycode
/advlist/animal-list.py
701
3.84375
4
#!/usr/bin/env python3 # Create a list of animals called animal_list1 animal_list1 = ["Fox", "Fly", "Ant", "Bee", "Cod", "Cat", "Dog", "Yak", "Cow", "Hen", "Koi", "Hog", "Jay", "Kit"] print(animal_list1) print(animal_list1.index("Ant")) print(animal_list1[7]) # List number and value for list until end of file #for ...
2ba56fd75addf4f5e66c0ba06d7a2397e2d3e992
rodrez/notime-scripts
/PongGame/first_gui.py
1,431
3.515625
4
from random import randint from kivy.app import App from kivy.properties import NumericProperty, ReferenceListProperty, Clock, ObjectProperty from kivy.uix.widget import Widget from kivy.vector import Vector class PongBall(Widget): # Velocity of the ball velocity_x = NumericProperty(0) velocity_y = Numer...
cf5edbd445d0da2c537d29f5d98b621db3eb080c
travisbonneau/MyNN
/src/cnn.py
46,888
3.9375
4
################################################################################ # # LOGISTICS # # Travis Bonneau # tmb170230 # # FILE # # cnn.py # # DESCRIPTION # # MNIST image classification with a CNN written and trained in Python # # INSTRUCTIONS # # 1. Go to Google Colaboratory: https://colab.resear...
f2ad30af95938402076bb3951212852641af1537
Ironmen007/00scanner
/00Scanner/test.py
224
3.546875
4
yuanzu_s = ("one", "two", "three", "four",); print(yuanzu_s[0]); print(len(yuanzu_s)); print(len(yuanzu_s[0])); # i = 0; for i in yuanzu_s: # print(i); print i print type(str(yuanzu_s)) print str(yuanzu_s)
3c32c99b08852663090f235b8b320d07a6a114ba
JSGrondin/CNN-modMNIST
/KNN.py
4,598
3.71875
4
from data_extraction import getdata import pandas as pd from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import confusion_matrix from sklearn.metrics import classification_report import numpy as np import matplotlib.pyplot as plt # Re...
928468498d49a62af4d8e252b63827fc499c3a9d
mhighmore/intro-python-code
/replace first check io.py
322
3.9375
4
def replace_first(items: list) -> Iterable: # your code here # create a new list with last item as first if len(items) <=1: return items first = items[0] new_list = items[1:] # add rest of original list apart from last item to the new list new_list.append(first) return new_li...
3a696f2dd9fbf7dde0b796b91ccda48e769f6999
dornheimer/roguelike-python3
/map_objects/dungeon_generation/tunnel.py
1,987
3.53125
4
from random import randint from map_objects.dungeon_components.rect import Rect from map_objects.dungeon_generation.dun_gen import DunGen from map_objects.dungeon_helper import Rectangular class Tunnel(DunGen, Rectangular): """ Create rectangular rooms of at random locations in the dungeon and connect th...
0206d054812ae1b506a0a9b5ed65cfbba0e2246f
aryashah603/project
/python pro1.py
1,150
4.03125
4
import random a=["stone","paper","scissor"] while True: x=input("do you want to play the game?\n(type Y to play and type N to not)\n") if x=='Y': b=input("Enter stone,paper or scissor") random.shuffle(a) c= a.pop() print("The system got",c) if b=="stone": ...
d801d329f094f2f7c99d92af6c2a7f8260a56f7a
macginitie/pyscripts
/fibofact.py
549
3.671875
4
#! /usr/bin/python def fibo( n ) : if (n < 1) : print('error: invalid argument to fibo()') return 0 if n < 3 : return 1 return fibo( n - 1 ) + fibo( n - 2 ) def facto( n ) : if (n < 1) : print('error: invalid argument to facto()') return 0 if (n == 1) : ...
a07523055fa9f16da846acbedc439de8ee85ab43
macginitie/pyscripts
/hoifihy.py
502
3.859375
4
import math """ How Old Is Fido In Human Years """ def new_formula(dog_age): return 16 * math.log(dog_age) + 31 def old_formula(dog_age): return 7 * dog_age if __name__ == '__main__': age = input('how old is Fido? ') dog_age = float(age) print('Fido is {0} in human years accord...
2d49d9cddf967800734827f7ec7252030cf59751
PrivateHL/Python
/BasicNotes/IO4Doc.py
2,391
3.515625
4
''' ļIO ȡд pythonC ļ ļʹPythonõopen()ļͱʾ һļ r ļ rb ָʽ encoding 벻淶UnicodeDecodeError Ӳ errors='ignore' ȡļread()һζȡļȫݣһstr󣨴洢ڴ棩 Сļ read(size) һζȡļڴռ ļ readlinereadline() жȡ ļ readlines() ɵlist رļclose()رļ 쳣ִУҪtry-catch-fina...
8f9686511fa41377d4a280edcafbbf12269d886f
lakshmanraob/MyPythonExp
/src/turtleapp/graphic_file.py
3,177
3.84375
4
import turtle import time import random def draw_rectangle(length, height): turtle.up() x = -150 y = 150 C = height*(7/13) D = length*(2/5) L = stripe_width = float(round(height/13,1)) ## Draw rectangle first. turtle.color(0,0,0) turtle.begin_fill() turtle.setpos(x,y) turtl...
ef4faf0a0cb683b9a6ddec9796901acd8d429162
lakshmanraob/MyPythonExp
/src/learnings/oop3.py
1,962
3.875
4
class AnimalActions: def quack(self): return self._doAction('quack') def bark(self): return self._doAction('bark') def fly(self): return self._doAction('fly') def bite(self): return self._doAction('bite') def _doAction(self, action): if action in self.strings: return self.a...
d899e66dccacca664ee18ef39c7b6bc65fa7db7b
lakshmanraob/MyPythonExp
/src/learnings/dict.py
419
3.796875
4
# Created by labattula on 29/12/15. def main(): print("this is dictionary file") d = dict( one=1,two=2,three=3,four=4,five='five' ) d['six'] = 6 for k in sorted(d.keys()): print(k,d[k]) print('--retrieving the value from dict--') va = 'seven' print(d.get(va,'other')) ...
7bd6f2b5acaaebfba549f7a489591306b0cdf7ce
lakshmanraob/MyPythonExp
/src/learnings/loopControl.py
685
3.875
4
# Created by labattula on 30/12/15. import os def main(): print("main function") s = 'this is a String' # break, continue and else for c in s: if c == ' ': continue # just continue to the next iteration with out executing the next statement print(c,end='') else: print(' el...
fd6c0413aebb09c21acc06c5a1fa3cb6c4a5ed50
carlosmontoyargz/Python-para-todos
/02_Colecciones/Diccionarios.py
262
4.03125
4
#!/usr/bin/env python # La clave de un diccionario puede ser cualquier valor inmutable movies = {"Love Actually": "Richard Curtis", "Kill Bill": "Tarantino", "Amelie": "Jean-Pierre Jeunet"} print(movies) movies["Kill Bill"] = "Quentin Tarantino" print(movies) print(movies["Amelie"])
1cb070edaf0dfb4d4e501ed315957e1d75537e7a
carlosmontoyargz/Python-para-todos
/05_OrientacionObjetos/Encapsulacion.py
877
3.65625
4
#!/usr/bin/python class Ejemplo: def publico(self): print('Publico') def __privado(self): print('Privado') class Fecha: def __init__(self): self.__dia = 1 def getDia(self): return self.__dia def setDia(self, dia): if dia > 0 and dia < 31: ...
00e04a643e74fc11ac01e9cecca5803df5b34e6e
Rockforge/python_training
/exercise11.py
134
3.65625
4
# exercise11.py heroes = ['Batman', 'Darna', 'Ironman', 'Kardo Dalisay'] heroes_upper = [x.upper() for x in heroes] print(heroes_upper)
554f0ccf1ca0bd3bd7da513e690f74fa1f170f4e
Rockforge/python_training
/exercise17.py
321
4.15625
4
# exercise17.py # Data type: tuple denominations = ('pesos', 'centavos') # denominations = ('pesos',) # this should be the syntax for one element tuples print(denominations) print(type(denominations)) print(denominations[1]) print('--- Entering loop ---') for denomination in denominations: print(denomination) ...
6068a17c422ba82a669159f068a7170cb50ea0d9
Rockforge/python_training
/exercise36.py
316
3.65625
4
# exercise36.py # Function is a datatype def getRank(element): return element[1] fruits = [ ('apple', 1), ('Banana',3), ('rambutan',2), ('GUAVA',4), ] # Sorted case sensitive # Pass the function as a variable # fruits.sort(key=getRank) fruits.sort(key=lambda element: element[1]) print(fruits)
9607e34b695a350f4e3001680b8e6c87ea1fb2f7
Rockforge/python_training
/exercise5.py
371
4.0625
4
# exercise5.py # strings are always case sensitive sentence = 'the quick brown FOX jumps over the lazy dog' print(sentence.upper()) print(sentence.lower()) print(sentence.swapcase()) print(sentence.title()) print(sentence.count('u')) print(sentence.replace('fox', 'cat')) print(sentence.replace('FOX', 'elephant')) pri...
08ea7501c2d6644d2755a27752ac6b522cb1730d
Rockforge/python_training
/exercise12.py
368
4.0625
4
# exercise12.py # List slicing fruits = [ 'Coconut', 'Avocado', 'Apple', 'Melon', 'Papaya', 'Banana', ] print(fruits[0:4]) # Exclusive print(fruits[3:len(fruits)]) print(fruits[0:6:2]) # The third value is the step in slicing print(fruits[3:]) print(fruits[:4]) print(fruits[::2]) print(frui...
541a571b7a208797e5ffe203a12babe2c91b2cff
jeremiahtenbrink/Sprint-Challenge--Data-Structures-Python
/names/names_stretch.py
904
3.625
4
import time start_time = time.time() f = open('names_1.txt', 'r') names_1 = f.read().split("\n") # List containing 10000 names f.close() names_1 = sorted(names_1) f = open('names_2.txt', 'r') names_2 = f.read().split("\n") # List containing 10000 names f.close() duplicates = [] def binary_search(name): global...
8ccaab48c3e7b7adb0581656033d63b4008abed1
dannyramasawmy/Data-Structures-and-Algorithms
/Sorting/bubbleSort.py
494
4.0625
4
def bubbleSort(items): """ Bubble sort O(n**2) - time O(1) - memory, in place """ # loop for each element for idx in range(len(items)): jdx = 0 stop = len(items) - idx while jdx < stop - 1: # swap if larger if items[jdx] > items[jdx + 1]: ...
6b1a7a90fbe51b5f68ff61c90de812fe4baae9a8
dannyramasawmy/Data-Structures-and-Algorithms
/DataStructures/LinkedList.py
4,004
4.3125
4
# =========================================================== # CLASSES FOR LINKED LIST # =========================================================== class Node(): """ Node : a node on the linked list. """ def __init__(self, value): self.value = value self.next = None def __rep...
b647ac2ba8bc6352308971d732533cbd19fee1eb
freemanbrandon/lpthw
/ex16.py
982
4.09375
4
# pull in argv from sys import argv # unpack argv script, filename = argv print "########################################" print "#Welcome to the simple file editor 9000#" print "########################################" print "This file %r, is marked to be cleaned" % filename # prompt user for input print "To contin...
2880d30d8ecfce9f9007b6c760ff12738ea363ac
freemanbrandon/lpthw
/extra1
258
3.703125
4
#!/usr/bin/env python import random rank = random.choice(('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')) suit = random.choice(('clubs', 'diamonds', 'hearts', 'spades')) x = () cards = x in rank != 0 + ' of ' + x in suit != 0 print cards
d83df860b8dbc4b14540f65d619f502dfa2feb5d
roeiburstein/LeetCodeProblems
/Valid_Parenthesis.py
642
3.953125
4
class Solution: def isValid(self, s: str) -> bool: stack = [] for bracket in s: if bracket is '(' or bracket is '{' or bracket is '[': stack.append(bracket) elif (bracket is ')' or bracket is '}' or bracket is ']') and stack != []: if bracket i...
42388ff11810d42f3d8fe4eff0f0d5b59c9961b6
Leownhart/My_Course_of_python
/Geek University/Seção 5/Exercicios/EX03.py
337
4.09375
4
''' 03 - Leia um número real. Se o número for positivo imprima a raiz quadrada. Do contrario, imprima o número quandrado. ''' from math import sqrt, pow number = float(input('Informe um número real: ')) if number > 0: raiz = sqrt(number) print(f'A raiz quadrada de {number} é {raiz}') else: print(f'{pow(nu...
6c6341cf4989c57c420cf661aa26836f35a2f4f4
Leownhart/My_Course_of_python
/Geek University/Seção 5/Exercicios/EX21.py
1,121
4.25
4
''' 21 - Escreva o menu de opções abaixo. Leia a opção do usuário e execute a operação escolhida. Escreva uma mesagem 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úmeros (maior pelo menor) 3 - Produto entre 2 números. 4 - Divisão ente 2 números (o denominador não pod...
de82fb55367e48c0794a67b94c72a6631441a722
Leownhart/My_Course_of_python
/Exercicios/ex020.py
306
3.796875
4
from random import shuffle Primeiro = str(input('Primeiro Aluno: ')) Segundo = str(input('Segundo Aluno: ')) Terceiro = str(input('Terceiro Aluno: ')) Quarto = str(input('Quarto Aluno: ')) list = [Primeiro, Segundo, Terceiro, Quarto] shuffle(list) print('A ordem de Apresentação será\n{}'.format(list))
5f608e8ee713e1b492020ab47627184ea7189107
Leownhart/My_Course_of_python
/Exercicios/ex017.py
308
3.9375
4
from math import hypot oposto = float(input('Comprimento do cateto oposto: ')) adjacente = float(input('Comprimento do cateto adjacente: ')) #hipot = sqrt(pow(oposto, 2) + pow(adjacente, 2)) # ou (oposto ** 2 + adjacente ** 2) ** (1/2) print('A hipotenusa vai medir {:.2f}'.format(hypot(oposto, adjacente)))
ec9b8fac5dd0be6f60102c2eaebe615fbfb9a430
Leownhart/My_Course_of_python
/Geek University/Seção 4/tipo_float.py
390
4.125
4
""" Tipo Float -> Váriaveis com ponto flutuante """ # Errado valor = 1, 44 print(valor) # Certo so ponto de viata float valor = 1.44 print(valor) print(type(valor)) # É possivel realizar dupla atribuição valor1, valor2 = 1, 44 print(valor1) print(valor2) print(type(valor1)) print(type(valor2)) # Podemos converter u...
6e2c2420c8ee8ba1d30bb53df82aa271f1d02617
Leownhart/My_Course_of_python
/Geek University/Seção 4/Exercicios/EX32.py
275
3.5
4
''' 32 - Leia um número inteiro e imprima a soma do sucessor de seu triplo com o antecessor de seu dobro. ''' s = 0 n = int(input('Informe um valor: ')) ant = (n-1) * 3 suc = (n+1) * 2 print(f'soma do sucessor de seu triplo com o antecessor de seu dobro é {ant + suc}')
6d6ccbd9f5c5b000d148cf49de230a4e54f679e9
Leownhart/My_Course_of_python
/Geek University/Seção 4/Exercicios/EX16.py
348
3.734375
4
''' 16 -Leia um valor de comprimento em polegadas e apresente-o convertido em centimetros. A fórmula de conversão é C = P * 2,54, sendo C o comprimento em centimetros e P o comprimento em polegdas. ''' p = int(input('Informe um valor de comprimento em polegadas: ')) c = (p * 2.54) print('o valor informado em centimetr...
5d696af45d3080d5ff872e72901943dff93ec84c
Leownhart/My_Course_of_python
/Exercicios/ex056.py
604
3.71875
4
totf = 0 maisv = 0 maior = 0 med = 0 for p in range(1, 5): print('----- {}ª PESSOA -----'.format(p)) nome = str(input('Nome: ')).title().strip() idade = int(input('Idade: ')) Sexo = str(input('Sexo [M/F]: ')).upper() med += idade if maior < idade and Sexo == 'M': maior = idade ma...
f1060d0d03dc96163645ed076c63489b9810b6a9
Leownhart/My_Course_of_python
/Geek University/Seção 5/Exercicios/EX07.py
400
4.03125
4
''' 07 - Faça um programa que receba dois números e mostre o maior. Se por acaso, os dois números forem iguais, imprima a mensagem número iguais. ''' n1 = int(input('Número Um: ')) n2 = int(input('Número Dois: ')) if n1 > n2: print(f'O número {n1} é maior que {n2}') elif n2 > n1: print(f'O número {n2} é maio...
43cc5f655b98dda161080e20fdc4d60bc8ba0d8a
Leownhart/My_Course_of_python
/Exercicios/ex029.py
348
3.9375
4
km = float(input('Qual é a velocidade atual do carro? ')) if km <= 80: print('Tenha um bom dia! Dirija com segurança') else: multa = (km - 80) * 7 print('MULTADO! Você execedeu o limite permitido que é 80km/h') print('Você deve pagar uma multa de R${:.2f}!'.format(multa)) print('Tenha um bom dia! Di...
ee652d63011824dafce28e3d6cbe428883c6354b
Leownhart/My_Course_of_python
/Exercicios/ex082.py
426
3.578125
4
a = [] b = [] c = [] while True: elemento = int(input(f'Informe um valor: ')) a.append(elemento) opcao = str(input(f'Deseja continuar? [S/N] ')) if opcao.upper() == 'N': break for n in range(0, len(a)): if a[n] % 2 == 0: b.append(a[n]) else: c.append(a[n]) print('-='*30) ...
9c5395129d0cb72c9de13b91dba5e13e0a14d240
Leownhart/My_Course_of_python
/Geek University/Seção 4/Exercicios/EX44.py
551
3.953125
4
''' 44 - Receba a altura do degrau de uma escada e a altura que o usuário deseja alcançar subindo a escada. Calcule e mostre quantos degraus o usuário deverá subir para atingir seu objetivo. ''' # RESPOSTA cont = 0 altd = degrau = float(input('Informe a altura do degrau: ')) altura = float(input('Informe a altura que...
e15553a5f649823fa57cae5b216aa003014b1bfd
Leownhart/My_Course_of_python
/Geek University/Seção 4/Exercicios/EX42.py
425
3.546875
4
''' 42 - Receba o salário-base de um funcionário. Calcule e imprima o salário a receber, sabendo-se que esse funcionario tem uma gratificação de 5% sobre o salário-base. Além disse, ele paga 7% de imposto sobre o salário-base. ''' # RESPOSTA sbase = float(input('Informe o sálario base de um funcionário: ')) grati = ...
00bac904482e2231c24325b7d8de4335b4fcf6e5
Leownhart/My_Course_of_python
/Exercicios/ex012.py
284
3.734375
4
Preco = float(input('Qual é o preco do produto R$: ')) Percent = 5.0 Descont = Preco * Percent / 100.00 NewPreco = Preco - Descont print('O produto que custava R${:.2f},' ' na promoção com desconto de ' '{:.0f}% vai custar R${:.2f}'.format(Preco, Percent, NewPreco)) #
1b9f42c358edc59909f87dbabee554afd6d3848e
Leownhart/My_Course_of_python
/Geek University/Seção 4/Exercicios/EX34.py
297
3.75
4
''' 34 - Leia o valor do raio de um circulo e calcule e imprima a área do circulo correspondente. A área do circulo é PI * RAIO², considere PI = 3.14592. ''' rai = float(input('Informe o valor do raio: ')) area = 3.14592 * pow(rai, 2) print(f'A área do circulo correspondente é {area:.2f}')
8ad662296e95222506e01a903b694aaddbde2b15
Leownhart/My_Course_of_python
/Geek University/Seção 6/entendendo_ranges.py
744
4.375
4
""" - Precisamos conhecer o loop for para utilizar o range. Ranges são utilizados para gerar sequências numéricas, não de forma aleatória, mas sim de maneira especifica. Formas gerais: # Forma 01 range(valor_de_parada) OBS: valor_de_parada não inclusive (inicio padrão 0, e passo de 1 em 1) # Forma 1 for num in ...
0018e7f3badd01e2d002370d68194f9b367a8f57
Leownhart/My_Course_of_python
/Geek University/Seção 4/Exercicios/EX02.py
166
3.96875
4
''' 2 - Faça um programa que leia um número real e o imprima. ''' # RESPOSTA number = float(input('Informe um valor: ')) print(f'O valor informado foi {number}')
90ea81bca22a45dec5afa70a1b5004e425836875
Alex-D-TC/neural-nets
/dnn/utils/stat_utils.py
622
3.875
4
import numpy as np def mean_normalization(data): """ Performs mean normalization on each column of the data matrix :param data: The data matrix :return: The mean-normalized data matrix """ means = np.zeros((1, data.shape[1])) stds = np.zeros((1, data.shape[1])) cpy_data = np.zeros(da...
8e5c4b8fbcf49eb02931a653bbbba9d49be94611
tazi337/smartninjacourse
/Class2_Python3/example_00630_secret_number_exercise_1.py
771
4.21875
4
# Modify the secret number game code below such # that it shows the number of attempts # after each failed attempt # Modify the secret number game code below such # that it shows the number of attempts # after each failed attempt secret = "1" counter = 5 while counter > 0: counter -= 1 guess = input("guess ...
2f056da07759ce4b904eeb8fb3410261289aa87a
tazi337/smartninjacourse
/Class1_Python3/example_00300_operations_strings.py
962
4.40625
4
greeting = "Hello World!" name = "Smartninja!" # ADDING STRINGS (CONCAT) print(greeting) print(greeting + " - AI ") # MULTIPLYING STRINGS - das Beispiel hier erzeugt einen String mit 20 Sternchen print("*" * 20) # PRINTING THEM BY INSERTING print("Greeting: {}, Name: {}".format(greeting, name)) # new in Python 3: pr...
7105a5492881af8f858279db26cc1102c9277863
StepanBarantsev/forcourses
/notepad/break_notepad/break_notepad.py
933
3.671875
4
# -*- coding: utf-8 -*- from notepad.break_notepad.generate_frequency_dict import generate_list_for_frequency_analyse, generate_frequency_dict from notepad.main import encrypt def break_notepad(text: str, d: dict = {}) -> str: lst = generate_list_for_frequency_analyse() lst_from_txt = generate_list_for_freque...
cc89e22276a5209f7ad737586d997a464b4e8f2b
Sameer19A/Python-Control_Structures
/Delete User Selected Characters from String.py
439
4.09375
4
#Task 17 #Compulsory Task 4 String = input("Please enter a string:\t") Remove = input("Which characters would you like to make dissappear:\t") for n in range(0,len(Remove)): # count the number of characters the user wants to remove String = String.replace(Remove[n],"") # loop through the string and rem...
0c0ac1ff95ca17027a412d55f380114f7427262d
Sameer19A/Python-Control_Structures
/Age Restriction check.py
169
4.09375
4
#Task 7 #Compulsory Task 1 age = int(input("Please enter the year in which you were born: ")) if (2018 - age) >= 18: print("Congrats you are old enough")
fe59be8b2ddf1483c74b10e74a783876f5dddf74
sarathradhakrishnan/Secret-Auction
/auction.py
696
3.890625
4
from art import logo import os print(logo) auction ={} ans ="true" def final_bid(auction_bid): highest_bid = '0' winner ="" for bid in auction_bid: bid_amount =auction_bid[bid] if bid_amount > highest_bid: highest_bid=bid_amount winner =bid print(f"The winner of t...
7e586ec3fe7b5ad3e4b7acb3f88d698c46abafb9
DennisPlaydon/RugbySort
/ResultTable.py
3,713
4.28125
4
""" This program will order the rugby teams and presents it in a neat format """ #Reading Text File def read_file(filename): with open(filename) as f: readlines = f.read().splitlines() file_out = [line.split(',') for line in readlines] for item in file_out: for index in range(1,le...
617ce64c1db2f0fc3f8be2cd7f2afbd66836d5f5
mjftw/design-patterns
/example-design-patterns/factory/factorrrr/animals.py
310
3.796875
4
import abc class IAnimal(metaclass=abc.ABCMeta): '''Animals can move and make a sound''' @abc.abstractmethod def make_sound(self): pass class Dog(IAnimal): def make_sound(self): print('Dog: Bark!') class Cat(IAnimal): def make_sound(self): print('Cat: Meow!')
dae58627d930502a1a950949637285e6a1275921
mjftw/design-patterns
/example-design-patterns/iterator/iterator_example.py
240
4.40625
4
'''Trivially simple iterator example - python makes this very easy!''' def main(): a = 'a' b = 'b' c = 'c' iterable = [a, b, c] for element in iterable: print(element) if __name__ == '__main__': main()
4fc3f7b392b4d11579b5c2119892a6b7d69d1bf2
houdak/battleship
/Battleship_v3.py
17,693
4.375
4
# This is a game of battleship, based off of Codecademy course (my first program!) # It currently supports a human playing against a computer # The computer is somwhat 'smart': # When picking randomly, it only guesses boxes which would fit in a checkerboard pattern # Once it hits a ship, it guesses all surroundin...
3295a12fbb2eb131d0595957dd9d76f1b9d1997f
krmaxwell/General
/fizzbuzz.py
159
3.5625
4
#!/bin/python i=1 while i <= 100: if i%15 == 0: print 'FizzBuzz' elif i%3 == 0: print 'Fizz' elif i%5 == 0: print 'Buzz' else: print i i = i + 1
af8478460bdcd0f84ea45527e275414dc3a32a85
agupta98/NLPAssignmnets
/a1/a1.py
8,617
3.625
4
def run_fsa(states, initial_state, accept_states, transition, input_symbols): """ Implement a deterministic finite-state automata. See test_baa_fsa. Params: states..........list of ints, one per state initial_state...int for the starting state accept_states...List of ints for the accep...
80d46a0a753c3ffc92220044e1d9132911ce3094
felipeescallon/lenguajes_programacion
/Programas/python/MITx/6.00.1x course/asset-v1_MITx+6.00.1x+2T2017+type@asset+block@Lecture12/search.py
514
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed May 18 20:26:49 2016 @author: ericgrimson """ def search(L, e): def bSearch(L, e, low, high): if high == low: return L[low] == e mid = low + int((high - low)/2) if L[mid] == e: return True if L[mid] > e: ...
45f5dea44847192261823f4fc57d613e143cc128
SinghAnimish/Income-Classification
/Assignment/Prime Number.py
235
3.609375
4
#Generate prime numbers between 100 to 300 for value in range(100,300): if (value > 1): for num in range(2, value): if (value % num) == 0: break else: print(value)
2936be21130ff5deaf86d903d134791acd1ccf4e
MutinE/python_hangman
/my_version.py
2,247
3.53125
4
import random def game(): # selects word word = ["impossible", "coordinate", "disgust", "mediocre", "apology", "civilization", "distinguish", "calculate", "horrendous", "dinosaur", "divisible", "anxiety", "millionaire", "vaccination", "possible", "keyboard", "coliseum", "decimate", "c...
343cbf483ac904a8b93e8da123f5a02a02bb1ec2
CC3688/studycode
/Python/lxf-paython/demo.1.py
136
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @ CC3688 # email:442677028@qq.com name=input("请输入你的名字:") print('Hello,',name)
a0f6ba8f4571e7eb2fa3db91f82fae617f8e7093
CC3688/studycode
/Python/lxf-paython/004pythonBasic.py
1,287
4.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @ CC3688 # email:442677028@qq.com #条件判断 #if age = 20 if age >= 18 : print('your age is',age) print('adult') #if else age = 10 if age >= 18 : print('your age is',age) print('adult') else: print('your age is',age) print('adult') #elif ---->else if py...
f7a6e23bef2ec753ba91f9eeb310d6eb6032b5a3
jkoppel/QuixBugs
/python_programs/topological_ordering.py
611
3.96875
4
def topological_ordering(nodes): ordered_nodes = [node for node in nodes if not node.incoming_nodes] for node in ordered_nodes: for nextnode in node.outgoing_nodes: if set(ordered_nodes).issuperset(nextnode.outgoing_nodes) and nextnode not in ordered_nodes: ordered_nodes.app...
cc573d4800f8a697e1eb6ce005b0a21dfb6853f1
jkoppel/QuixBugs
/correct_python_programs/quicksort.py
470
4.09375
4
def quicksort(arr): if not arr: return [] pivot = arr[0] lesser = quicksort([x for x in arr[1:] if x < pivot]) greater = quicksort([x for x in arr[1:] if x >= pivot]) return lesser + [pivot] + greater """ def quicksort(arr): if not arr: return [] pivot = arr[0] lesser...
e628a864e3a29c2ecadbec367f7041a2e31b4a44
jkoppel/QuixBugs
/python_programs/reverse_linked_list_test.py
1,241
4.0625
4
from .node import Node from .reverse_linked_list import reverse_linked_list """ Driver to test reverse linked list """ def main(): # Case 1: 5-node list input # Expected Output: 1 2 3 4 5 node1 = Node(1) node2 = Node(2, node1) node3 = Node(3, node2) node4 = Node(4, node3) node5 = Node(5, n...
d0a2a502929ec839607ab88eb4fa6eca97141342
jkoppel/QuixBugs
/python_programs/sqrt.py
420
4.3125
4
def sqrt(x, epsilon): approx = x / 2 while abs(x - approx) > epsilon: approx = 0.5 * (approx + x / approx) return approx """ Square Root Newton-Raphson method implementation. Input: x: A float epsilon: A float Precondition: x >= 1 and epsilon > 0 Output: A float in the interva...
14857cf1f6d3397403c422ebad8994bc33848216
jkoppel/QuixBugs
/correct_python_programs/mergesort.py
2,389
4.15625
4
def mergesort(arr): def merge(left, right): result = [] i = 0 j = 0 while i < len(left) and j < len(right): if left[i] <= right[j]: result.append(left[i]) i += 1 else: result.append(right[j]) j +...
9e3c4aab2c406afd868b015fc21eecc3364ef0d7
jkoppel/QuixBugs
/python_programs/next_permutation.py
684
3.8125
4
def next_permutation(perm): for i in range(len(perm) - 2, -1, -1): if perm[i] < perm[i + 1]: for j in range(len(perm) - 1, i, -1): if perm[j] < perm[i]: next_perm = list(perm) next_perm[i], next_perm[j] = perm[j], perm[i] ...
52af492e81ac2309a4462167c006027ddd148710
jkoppel/QuixBugs
/correct_python_programs/breadth_first_search.py
1,850
4
4
from collections import deque as Queue def breadth_first_search(startnode, goalnode): queue = Queue() queue.append(startnode) nodesseen = set() nodesseen.add(startnode) while queue: node = queue.popleft() if node is goalnode: return True else: que...
23bf4b2a12455334e5fb0ffa4fce75a11cdb2378
jkoppel/QuixBugs
/python_programs/hanoi.py
1,138
4.40625
4
def hanoi(height, start=1, end=3): steps = [] if height > 0: helper = ({1, 2, 3} - {start} - {end}).pop() steps.extend(hanoi(height - 1, start, helper)) steps.append((start, helper)) steps.extend(hanoi(height - 1, helper, end)) return steps """ Towers of Hanoi hanoi An a...
05ed53fa3790e8872b99ed23a1c052a41d971abc
lavish71/Forsk_2019
/Python/Solutions/age_cal.py
711
4
4
""" Code Challenge Name: Age Calculator Filename: age_cal.py Problem Statement: Lets assume your age is 21 today What would be your age after 5 years from today How old were you 10 years back Hint: You need to add to calculate future age You need to subtract to calculate your pa...
c7c69d1d1a4d0eafa1ca5c2109aaba5a950fc538
lavish71/Forsk_2019
/Project_1_Basic_Libraries/Libraries/Library_Pandas.py
2,598
3.890625
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 23 12:54:11 2019 @author: dell """ # We can analyze data in pandas with: # a. Series # b. DataFrames # a. Series: It is one dimensional(1-D) array defined in pandas # that can be used to store any data type. # 1. CREATING SERIES # Program to create se...
3cfa7e1014383d343aaee35da093db50063cf33e
lavish71/Forsk_2019
/Python/Solutions/crime.py
1,628
3.671875
4
""" Import Crime.csv File. Perform dimension reduction and group the cities using k-means based on Rape, Murder and assault predictors. file_name - "crime.py" """ # K-Means Clustering # Importing the libraries import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('crim...
6de84d5c2e16a36036639edd32101fe455eec807
lavish71/Forsk_2019
/Forsk_Training/Code Challenges/Day_09/Practice_Day_09.py
5,577
3.84375
4
# -*- coding: utf-8 -*- """ Created on Thu May 16 15:59:33 2019 @author: dell """ """ Code Challenge 1 Write a python code to insert records to a mongo/sqlite/MySQL database named db_University for 10 students with fields like Student_Name, Student_Age, Student_Roll_no, Student_Branch. """ import...
3016c005e0177bad96e4d214fc21a301ce9fb9a7
lavish71/Forsk_2019
/Python/05_Python_Exception_Handling.py
1,473
4.0625
4
""" Types Of Errors Syntax Error Compile Time Errors Runtime Errors """ """ Introduce the concept of Exception Handling Try to input a non integer number while input try and except block gets executed when failed Introduce the else block, it gets executed when it does not throws error """ try: ...
1bba367d932bbe095026558f0bd5556ddce692be
lavish71/Forsk_2019
/Project_1_Basic_Libraries/Libraries/Library_Matplot.py
576
3.9375
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 23 15:14:56 2019 @author: dell """ # importing matplotlib module import matplotlib.pyplot as plt # 1. BASIC PLOTS IN MATPLOTLIB # a. Line Plot # x-axis values x = [5, 2, 9, 4, 7] # Y-axis values y = [10, 5, 8, 4, 2] # Function to plot pl...
8a3a1cbef2422e649b0ad80b37242f940fe774ab
s-Akhil-krishna/Competitive-coding
/GeeksforGeeks/Check if string is rotated by two places.py
119
3.78125
4
class Solution: def isRotated(self,str1,str2): return str1[2:]+str1[:2] == str2 or str2[2:]+str2[:2]==str1
0c78d7a5479d6eaafaeef43ad81d82c464da3aa3
SodaCookie/amnesia-game
/engine/game/primitive/vector.py
2,713
4.03125
4
"""Vector class to represent a 2 dimensional vector""" import math class Vector(object): def __init__(self, x, y): self.x = x self.y = y def normalized(self): magnitude = self.get_magnitude() x = self.x / magnitude y = self.y / magnitude return Vector(x, y) ...
969dfd16e8799078ffbddd656a308282a49457f4
rookiy/PATBasic
/pb1020.py
964
3.5
4
#!/usr/bin/env python import sys class Cake(object): def __init__(self, amount, sale): self.amount = amount self.sale = sale # save the precision for case 4 self.price = sale/amount def main(): sys.stdin = open('./1.txt', 'r') N, D = map(int, raw_input().split()) ...
124d965717e9066c6f595c0440b126fde997ff44
rookiy/PATBasic
/pb1035.py
1,504
3.640625
4
#!/usr/bin/env python import sys def merge(l, start, mid, end): aux = l[:] i, j = start, mid+1 for k in range(start, end+1): if i > mid: l[k] = aux[j] j += 1 elif j > end: l[k] = aux[i] i += 1 elif aux[i] < aux[j]: l[k] = a...