blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
1cb206f0735dae7b5843518af5b6c99f7645f693
ricardofelixmont/Udacity-Fundamentos-IA-ML
/projeto1/testando_lista_max_min.py
544
3.59375
4
lista = [1,2,-1,3,4,40,5,6,7,8,9,10,20,10,11] maior = menor = lista[0] for numero in lista: if numero > maior: maior = numero elif numero < menor: menor = numero print(f'Maior:{maior}, Menor:{menor}') lista.sort() tamanho_da_lista = len(lista) print(tamanho_da_lista) if tamanho_da_lista % 2 ==...
005cf84096b707d1c3fa2d5244875382489cdca1
ricardofelixmont/Udacity-Fundamentos-IA-ML
/start-content/funcao.py
406
3.734375
4
def area(lado_a, lado_b = 10): area = lado_a * lado_b print(lado_a, lado_b) return area print(area(2, 3)) # Passagem de argumento por posição print(area(lado_b = 3, lado_a = 2)) # Passagem de argumento por nome(posso inverter as posições mas tenho que escrever o nome das variaveis de argumento) print(area...
d72d1950d63d25c229918f49761f614ac1ede6a7
drewkiimon/paxos
/pal.py
2,024
3.5625
4
''' Proposer, Acceptor, and Learner classes This document is created in conjunction with Brett Albano and Chen-Yu Leong to practice and demonstrate basic knowledge of the consensus algorithm Paxos. Written by Andrew Pagan ''' # A client makes a Node a Proposer # Proposer has a PID and a value it wants to...
4cb726601b5dda4443b8fe3b388cbd6f598013a8
varnagysz/Automate-the-Boring-Stuff-with-Python
/Chapter_05-Dictionaries_and_Structuring_Data/list_to_dictionary_function_for_fantasy_game_inventory.py
1,640
4.21875
4
'''Imagine that a vanquished dragon’s loot is represented as a list of strings like this: dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby'] Write a function named addToInventory(inventory, addedItems), where the inventory parameter is a dictionary representing the player’s inventory (like in...
71db3ebdbd3bbcac09c385947f6b327f9d7c3d73
harshit-sh/python_games
/matq.py
743
4.25
4
# matq.py # Multiplication Quiz program # Created by : Harshit Sharma from random import randint print "Welcome to Maths Multiplication Quiz!" print "--------------------------------" ques = int(raw_input("How many questions do you wish to answer? ")) print "--------------------------------" limit = int(raw_input("Ti...
1e48e1d29c33e272b6b0c79b8c27bb3d82c75596
joshasgard/AfricanDevelopment_web_app
/wrangling_scripts/wrangle_data.py
8,164
3.765625
4
import pandas as pd import plotly.graph_objs as go import plotly.express as px # Use this file to read in your data and prepare the plotly visualizations. The path to the data files are in # `data/file_name.csv` def clean_data(dataset,indicators_to_plot, keepcolumns = ['country_name_attr','1990', '2000','2010']): ...
443774e5a9e18194d8de9c7b95da3149864a803a
dmontigny/pyth
/udemy/beyond_basics/password_check.py
246
3.890625
4
correct_password = "python123" name = input("Enter name: ") password = input("Enter password: ") while correct_password != password: password = input("Wrong password. Please re-enter: ") print("Hi, %s. You are now logged in!" % name)
3d3366dc5c6ede9fcbc7a8034383053833144e14
Vasilis421/Rock_Paper_Scissors
/src/winning_score.py
465
3.96875
4
def winning_score(): while True: try: winning_score = int(input("\nHow many points should " "declare the winner? ")) except ValueError: print("\nInvalid input type. Enter a positive number.") continue else: if winnin...
107353b36c848eddc17681c1179373772149e7a5
lazyxu/pythonvm
/tests/op_overload5.py
461
3.515625
4
keys = [] values = [] class B(object): def __setattr__(self, k, v): if k in keys: index = keys.index(k) values[index] = v else: keys.append(k) values.append(v) def __getattr__(self, k): if k in keys: index = keys.index(k) ...
110fa9481c95c44a273d9a91cad598f30599c3e5
lazyxu/pythonvm
/hello.py
72
3.515625
4
i = 0 while i < 5: i = i + 1 if i > 3: break print(i)
428022538935fc013539264d3b913b523ec968a6
lazyxu/pythonvm
/tests/test_iter_fib.py
605
3.59375
4
class Fib(object): def __init__(self, n): self.n = n def __iter__(self): return FibIterator(self.n) class FibIterator(object): def __init__(self, n): self.n = n self.a = 1 self.b = 1 self.cnt = 0 def next(self): if (self.cnt > self.n): ...
9e6c78c17e9b9cb3bd4e359208aec3ffc9fbdeba
YulanJS/Software_Project
/mlr_scikit_learn.py
10,065
3.578125
4
# Multiple Linear Regression HW: Yulan Jin import pandas as pd import statsmodels.api as sm from sklearn.linear_model import LinearRegression from sklearn.feature_selection import RFE import matplotlib.pyplot as plt import seaborn as sns from pandas.plotting import scatter_matrix from pandas import set_option from pand...
05c461070ef9f5a7cee7b53541d22be836b65450
crisjsg/Programacion-Estructurada
/Ejercicio10 version 2.py
1,169
4.125
4
#10. Modifica el programa anterior para que en vez de mostrar un mensaje genérico en el caso #de que alguno o los dos números sean negativos, escriba una salida diferenciada para cada #una de las situaciones que se puedan producir, utilizando los siguientes mensajes: #a. No se calcula la suma porque el primer número es...
23d212bf281d72a4d0bbc32ba01539f6ed765c2b
crisjsg/Programacion-Estructurada
/Ejercicio13.py
586
3.671875
4
precioCompra = int(input("Introduce la cantidad de tu compra (solo el número): ")) if precioCompra <= 20: print ("Tu compra no llega al precio mínimo para conseguir descuento. El valor se queda igual:", precioCompra, "€") elif precioCompra <= 100: precioCompra = precioCompra - precioCompra * 0.05 print ("Tu compra h...
dc7761a6601b2d29f7ef50966814a7a4201f579f
josecaromuentes2019/CursoPython
/manehoExcepciones2.py
429
4.1875
4
import math print('estre programa calcula la Raiz cuadrada de un numero') def raiz(num): if num<0: raise ValueError('No es posible calcular Raices negativas') else: return math.sqrt(num) while True: try: numero = int(input('Digita un numero: ')) print(raiz(numero)) exc...
3539c45548c360fe498f1f3c44b67d618a573725
josecaromuentes2019/CursoPython
/practica_string.py
195
3.9375
4
email = input('Digita un correo: ') s ='yo' print(email.index('@')) if email.count('@') == 1 and email.index('@') != 0 and email[-1] != '@': print('correcto') else: print('incorrecto')
6f329ed3273f335a45978fd08a789ef08d1c3b97
josecaromuentes2019/CursoPython
/poo/info_permanente.py
1,438
3.546875
4
import pickle class Personas(): def __init__(self,nombre,genero,edad): self.nombre = nombre self.genero = genero self.edad = edad print('Se ha creado un apersona llamada ',self.nombre) def __str__(self): return '{} {} {} Años'.format(self.nombre,self.gener...
cec228f9fd7630f55ae4f25453179d8a98e0f9b2
josecaromuentes2019/CursoPython
/graficos/calculadora.py
4,194
3.53125
4
from tkinter import * import math class Calculadora(): numfilas=1 numcolum=1 bandera = False def pintaCalculadora(self): self.root = Tk() self.root.title('Calculadora') self.frame = Frame(self.root,bd=10) self.frame.config(bg='#333333') self.frame.pack...
bb03b94b27ebbf5bc6943c63406f7e7187c5d3dd
uyjang/python_basic
/Start/Section02-1.py
1,032
3.546875
4
# Section02-1 # 파이썬 기초 코딩 # print 구문의 이해 # 기본출력 print('Hello Python!') print("Hello Python!") print("""Hello Python!""") print('''Hello Python!''') print() # Sepatator 옵션 사용 print('T', 'E', 'S', 'T', sep='') print('2019', '02', '19', sep='-') print('niceman', 'google.com', sep='@') # end 옵션 사용 print('Welcome to', ...
c2dcdcd7b6de73b0ad3e09bd057000f8adaab072
josefutbult-school/D7032E-Exam
/src/BoggleGame/BoardTypes/SingleBoardBoggle.py
747
3.5625
4
from abc import ABC from BoggleGame.BoggleBase.BoggleBase import BoggleBase # This is an abstract class meant to be one of two implemented by a game mode. It lets the # lets the different players share a single board, making their moves impact each other. class SingleBoardBoggle(BoggleBase, ABC): def __init__(se...
e6de6ca21e63077157ee27640013434e17da7640
HubWorx/Python_Course
/Chap9_1.py
960
3.84375
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 coun...
4da2e65e7826242557e60225d8660b0293b4dd00
python-practice-b02-006/Sea-battle-2
/renderer.py
7,959
3.625
4
import pygame from pygame.draw import * from globaldata import (Colors, pixels_per_cell, left_indent, top_indent) c = Colors() class Renderer(): ''' Visualizes everything. ''' def __init__(self, screen): pygame.init() screen.fill(c.BLACK) background_image = pygame.image.load("...
a4273e4572bb07192be403816bf1ce34099952cf
ml-makaut/pybrain-neural-network
/neural.py
2,097
3.875
4
import numpy as np import random def sigmoid(x): """ Returns the sigmoid of the data """ return (1 / (1 + np.exp(-x))) def sigmoidprime(x): return sigmoid(x) * (1 - sigmoid(x)) class OneNeuronNeuralNetwork: """ A no-layer neural network with a single neuron/perceptron -----------------...
df495952d751fcbc82e0afdddbd267b41c762fc4
lpxxn/lppythondemo
/base/print-demo.py
1,462
4
4
print("你好") print("你好", end="") print("abc") import keyword print("list all keyword list:") print(keyword.kwlist) import sys print('========Python import mode========') print('命令行参数:') for i in sys.argv: print(i) print('\n python path:', sys.path) ## type 数据类型 a = 1 print(type(a), a) a = 'b' print(type(a), ...
d751cebd9f48dc06abda1d2fdba92b484879dc24
lpxxn/lppythondemo
/demo1/c1.py
1,024
4.09375
4
#! /usr/local/bin/python3 class myClass1: """第一个类""" i = 123 __b = "bbb" def f(self): print(self.i) print(self.__b) print(self) print(self.__class__) return "Hello World" def __init__(self, a="none", b="none"): self.a = a self.__b = b x = ...
004b7e2b9615e4e20513869977cc3a14a9ddfd34
kiranvswami/Python_Practice
/while_loop.py
68
3.609375
4
i=1 while i<=10: print("*"*i) i=i+1 print("Completed!!")
9a3a31dac5b5e11198ae8f50763b2a0d76a0e888
kiranvswami/Python_Practice
/tempearture_convertor.py
227
4.03125
4
temp=int(input("Enter Tempearature: ")) unit=input ("C or F: ") if unit.upper() == 'C': convert=temp*1.8+32 print(f"Tempearature in Fahreniet is: {convert} F") else: convert=(temp-32)/1.8 print(convert)
fa8dc2eaf913e5853721a32983d71428b4d2897e
midhmanohar/cs50x-2018
/test/editdistance.py
1,748
3.859375
4
from enum import Enum class Operation(Enum): """Operations""" DELETED = 1 INSERTED = 2 SUBSTITUTED = 3 def __str__(self): return str(self.name.lower()) a="cat" b="ate" row=len(b)+1 column=len(a)+1 matrix = [[(0, None) for x in range(len(b) + 1)] for y in range(len(a) + 1)] for i in r...
a37f3eaa18720bf1724b327f58011a3adf0266d4
rsirving/DojoAssignments
/Python/python_fundamentals/coin_toss.py
434
3.8125
4
import random def coin_toss(): heads = 0 tails = 0 result = "" for i in range(5000): coin = round(random.random()) print coin if coin == 0: heads+=1 result = "head" else: tails+=1 result = "tail" print "Attempt #{}:...
9d0757c21f8857c14edc65ed9f2f844e016e875a
rsirving/DojoAssignments
/Python/python_OOP/call_center.py
1,220
3.78125
4
class Call(object): def __init__(self, id, name, number, time, reason): self.id = id self.name = name self.number = number self.time = time self.reason = reason self.logged = True def display(self): print "ID: {} \nName: {} \nNumber {} \nTime: {} \nReason...
d9dd8cd49d9461920d8d41c2483d2995f3021825
rsirving/DojoAssignments
/Python/python_OOP/animals.py
1,162
3.796875
4
class Animal(object): def __init__(self, name, health): self.name = name self.health = health self.logged = False def walk(self): self.health -= 1 return self def run(self): self.health -= 5 return self def display_health(self): p...
1b60f7e6aa54f77cce11d1a7658d22d21281a9a3
rsirving/DojoAssignments
/Python/python_fundamentals/dict_basics.py
357
3.796875
4
info = {"name": "Stephen", "age": "23", "nation": "United States of America", "favlang": "Python"} def print_info(data): print "My name is {}.".format(data["name"]) print "My age is {}.".format(data["age"]) print "My country of birth is {}.".format(data["nation"]) print "My favorite language is {}.".for...
968fe1e9fbccfd4e84260210e08cce33eadcbfaa
rsirving/DojoAssignments
/Python/python_fundamentals/foo_bar.py
457
3.5625
4
def foobar(): for i in range(100, 100001): prime = True square = False for y in range(2, i): if y * y == i: square = True prime = False break if i % y == 0: prime = False print i, if prime...
d77e923463a855ad604ff8414f7fe0f2b7403693
kaitaklearn/CP3-Panupong-Saejong
/Exersice11_Panupong_S.py
115
3.84375
4
numberInput = int(input("Number")) for x in range(numberInput): print(" " * (numberInput-x), "*" * ((x+1)*2-1))
ca378fab0a285852df43ca5af29af8670e85ffd8
cshp635921/my-python-study
/helloword.py
354
3.609375
4
def findstr(str1,str2): len_str1= len(str1) ; len_str2= len(str2); N=0; for i in range(len_str1-len_str2): if str1[i:i+len_str2] ==str2: N+=1; else: continue; return(N) str1 = input('first one:') str2 = input('second one:') N = findstr(str1,str2) print('The nu...
526fabba249543131565a905e80020291152cc2c
kavprooijen/Pythonstudie
/drawing.py
266
3.5
4
def boom(teken, grootte): blad = "" for i in range(grootte): if len(blad) < grootte: blad += teken print(blad) for i in range(grootte): if len(blad) > 0: blad = blad[:-1] print(blad) boom('*', 8)
11cc990cb56343813192f324c8e1a3aae5e6e10d
Broken-Admin/Bot-Fighting
/Src/Raw Text/Bot_Fighting_100_Health.txt
489
3.65625
4
# Must import import random from random import randint # End of imports bot1HP = 100 bot2HP = 100 while(1==1): bot1Attack = randint(1,50) bot2Attack = randint(1,50) if(bot1Attack>bot2Attack): ran = randint(1,20) bot2HP -= ran print("Bot 1 does", ran, "damage!") else: ran = randint(1,20) bot1HP -= ran...
d9dde4b517227c4ca077a8d8d0e91d7e86925c73
DavidMachacek/machineLearning
/test.py
1,549
3.8125
4
def test(): return "ahoj" def rozlouceni(): return "mej se" text = test() text2 = rozlouceni() print(text) print(text2) class MojeTrida: def __init__(self, jmeno): self.krestni = jmeno self.prijmeni = jmeno + "Prijmeni" def predstavse(self): return (self.krestni + " " + self.prijmeni) def __repr__(sel...
2291cbdb54c91d6cccf9d535ed12a71683d04f03
liaochihung/LearnPython
/1.basic/first.py
1,473
3.875
4
''' while True: try: number = int(input("Wat's your age?\n")) print(100/number) break except ValueError: print("Not a number") except ZeroDivisionError: print("Don't pick zero") except: print("Unknown error") break; finally: print("Loop...
f0cdf4b5c2ab4a09add164d2c40aecd144287077
sreekanthreddybalne/pyranker
/pyranker/main.py
2,412
3.703125
4
import string from typing import List, Union def get_next_rank(rank: str, letters: Union[str, List] =string.ascii_lowercase, is_sorted=False): """ returns the next possible string """ if type(letters) is not list and not is_sorted: letters = sorted(set(letters)) if not rank: return ...
51f93d31ed7ca79c669358f23255fde334f5d1db
neerajkumarTTN/filehandling
/Q9.py
490
3.671875
4
import os import os.path from posix import listdir def list_file(dir_path,nested=True): path='/home/neeraj/Bootcamp_training/file_csv/'+f'{dir_path}' if nested==True: for root,dir,file in os.walk(path): for f in file: if f.endswith(".txt"): print(f) el...
47cc50f3181a184559944a016db95bb399bf55de
aVegetable/Snake
/Main.py
4,044
4
4
""" A game made using pygame to play snake. """ import pygame from random import randint from Character import SnakeBody from Food import FoodBlock #sets colours as variables BLACK = (0, 0, 0) WHITE = (255, 255, 255) #game window SCREENWIDTH = 800 SCREENHEIGHT = 800 size = (SCREENWIDTH, SCREENHEIGHT) ...
e8f2e543ced547d1230afec451b48aded04a208f
cdlight62/python-stuff
/Palindrome.py
142
4.15625
4
check = input("enter a string: ") if check[::-1] == check: print("that is a palindrome") else: print("that is not a palindrome")
14186b4cbaab543ca8bcd015ddf0023a501bdad9
cdlight62/python-stuff
/ListLessThanTen.py
118
3.859375
4
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] num = int(input("enter a number: ")) print([i for i in a if i < num])
99c01321b011f471394a7c00cd33092cd3bb84b3
quaxoc/FAA
/final/EstrategiaParticionado.py
2,990
3.5
4
from abc import ABCMeta,abstractmethod import random class Particion(): # Esta clase mantiene la lista de indices de Train y Test para cada particion del conjunto de particiones def __init__(self): self.indicesTrain=[] self.indicesTest=[] ###################################################...
47ede48eb3b773dd77fff9c4d14382d9d394e8c8
quaxoc/FAA
/plantillas/EstrategiaParticionado.py
2,029
3.5625
4
from abc import ABCMeta,abstractmethod import random class Particion(): # Esta clase mantiene la lista de ndices de Train y Test para cada particin del conjunto de particiones def __init__(self): self.indicesTrain=[] self.indicesTest=[] #################################################################...
6398cb70d63be5b679564c044892dad214ef4a7e
jchooker/py-users-bank-accounts
/users-bank-accounts.py
4,067
3.875
4
class User: def __init__(self, name, email, startBal=0): self.name = name self.email = email self.account = BankAccount(0.01, startBal) def make_deposit(self, amount): self.account += amount return self def make_withdrawal(self, amount): self.account -= amou...
d92518654667b02c221f04929d152ca9ba9164cb
mmengspv/Lab_Python
/เปลี่ยนตัวเลขเป็นค่า (lab13).py
1,634
3.5
4
inn1 = input() if len(inn1) <= 3 and inn1.isdigit() and int(inn1) >= 0: inn1 = inn1.lstrip("0") if inn1 == "" : inn1 = "0" x = ["one","two","three","four","five","six","seven","eight","nine"] ls1 = ["10","ten","11","eleven","12","twelve","13","thirteen","14","fourteen","15","fifteen","16","sixte...
bc706b3b1df3ac6d55c545b68bd4bd4954984517
mmengspv/Lab_Python
/Lab-Menu/menu.py
2,326
3.953125
4
print("---<< Main Menu >>---") print("%17s"%"<B>urger Meal") print("%18s"%"<C>hicken Meal") print("%16s"%"<P>asta Meal") main = input("Enter your choice: ") if main == "B" or main == "b" : print("---<< Burger Sub Menu >>---") print("%20s"%"<R>egular Burger") print("%19s"%"<C>heese Burger") print("%26s"%...
a625b26326d39d7f7323938cdd75c268dbbf3bfd
mmengspv/Lab_Python
/วันที่1ของทุกเดือน.py
868
4.09375
4
day = input() x = int(input()) if (day == "Monday" or day == "Tuesday" or day == "Wednesday" or day == "Thursday" or day == "Friday" or day == "Saturday" or day == "Sunday" ) and (x>0 and x <=31 ) : if day == "Monday" : y = (x-1)%7 elif day == "Tuesday" : y = x%7 elif day == "Wednesday" : ...
72ec4088af274f0f49766a6cf865fcabb8781ceb
mmengspv/Lab_Python
/หรม ครน.py
368
3.984375
4
first = int(input("Enter the first number: ")) second = int(input("Enter the second number: ")) a = first b = second print(" >> gcd(%d, %d) ="%(first,second),end="") while True : if second < 1 : break x = first%second first = second second = x print("%7d"%first) lcm = (a*b)/first print(" >> lc...
4db942169900edd043952aaf20739f7c3284684f
thrama/coding-test
/python/CountApplesAndOranges.py
918
3.953125
4
#!/bin/python3 import math import os import random import re import sys """ Link: https://www.hackerrank.com/challenges/apple-and-orange/problem """ def countApplesAndOranges(s, t, a, b, apples, oranges): # count the apples on the house applesInRange = 0 for i in apples: if (a + i >= s) and (a +...
b4b12d0163af3316b3d4af6df1d2f8e6a2717151
thrama/coding-test
/python/PwdGenerator.py
994
3.671875
4
from random import randint def pwd_generator(t): """ Scrivi una funzione generatrice di password. La funzione deve generare una stringa alfanumerica di 8 caratteri qualora l'utente voglia una password semplice, o di 20 caratteri ascii qualora desideri una password più complicata. """ co...
ced3c79f508e73a8dc0d09bf7f7d240508efa538
thrama/coding-test
/python/kangaroo.py
1,435
4.09375
4
#!/bin/python3 import math import os import random import re import sys """ You are choreographing a circus show with various animals. For one act, you are given two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity). - The first kangaroo starts at location x1 and mo...
dad57c37d4ffbd2e998d4bf9e0ee0c0fda8c5ada
henryleemr/tensorflow-projects-osqp
/fibb.py
1,586
4.03125
4
""" Tensorflow describes the computation using a static graph. You first have to define the graph and then execute it. The graph execution start from the node you put into the sess.run([var1,var2, ..., vaN]) call: the order of the variables is meaningless. Tensorflow graph evaluation starts from a random node and follo...
55893c96e900b7d6edcb2e7cbbf0a393b3834b30
khanfahad/learning
/primenumber.py
255
4.09375
4
num = input("Prime Checker: ") def is_prime(num): prime = 0 for i in range(2,int(num),1): if int(num) % i == 0: prime = 1 return prime x = is_prime(num) if x == 1: print("Not a Prime") elif x == 0: print("Prime")
eb9bb6d98d1846f9295f0c0a51253ff3c605c940
AntLrm/secretsanta
/secretsanta/secretdraw.py
5,153
3.625
4
import pdb import sys import random class secretdraw(): """ Secret draw define an object to roll the secret santa. Storing people, constrains, and constructing gift tree. - people : people dict containing names and emails. - constrain : constrain dict containing for each name, the list of forbi...
4efc7d7cc3d3170d0bae806f244f8fd92ba2342c
kobe24167/Study
/LeetCode/23.合并k个排序链表.py
1,070
3.859375
4
# # @lc app=leetcode.cn id=23 lang=python3 # # [23] 合并K个排序链表 # # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None from typing import List class Solution: def mergeKLists(self, lists: List[ListNode]) -> ListNode: interval = 1 ...
20808883eb963cd62610e0d65a04e739f06e0d0c
kobe24167/Study
/LeetCode/37.解数独.py
1,936
3.609375
4
# # @lc app=leetcode.cn id=37 lang=python3 # # [37] 解数独 # from collections import defaultdict class Solution: def solveSudoku(self, board: List[List[str]]) -> None: def could_place(d, row, col): return not (d in rows[row] or d in columns[col] or d in boxs[box_index(row, col)]) d...
45cd5282b92a36c9b1ee2da43f5170d1b90387ca
pe-gomez/cautious-octo-goggles
/GOMEZ_PEDRO_DSC510/Week8-hw1-pgomez-Gettysburg.py
3,279
4.46875
4
# File: Week8-hw1-pgomez-lists.py # Name: Pedro E Gomez # Date: 12-oct-2019 # Course: DSC510-T303 Introduction to Programming (2201-1) # Desc: Open the file and process each line. # # Usage: Open the file and process each line. # Either add each word to the dictionary with a frequency of 1 or update the word’s ...
beed60ec1c072856cc6b58b613492032ef4ee27d
joepalermo/game-playing
/tic_tac_toe.py
1,735
3.84375
4
from tic_tac_toe_utilities import * # play tic tac toe def play(): # player initializations ---------------------------------------------------------- player_symbols = {'player_1': 'x', 'player_2': 'o'} player_type = {'player_1': 'human', 'player_2': 'human'} human_playing = is_human_playing(player_ty...
94e7e5a150ceef7607f1aa596d53dd13abf36e75
gabriels3t/PythonParaCienciaDeDados-Modulo1-
/exercicios/ Listcomprehensions.py
178
3.703125
4
quadrado = [] for i in range(10): quadrado.append(i ** 2) print(quadrado) # mostrando que os dois metodos funcionam quadrado2 = [i ** 2 for i in range(10)] print(quadrado2)
a4030a3fadea745d7028a3dce21911492845937c
Rapt007/Frameworks
/Tkinter/TK_7.PY
192
3.734375
4
from tkinter import * root=Tk() def aman(event): print("hello my name is aman") button=Button(root, text="log in",bg="blue") button.bind("<Button-1>",aman) button.pack() root.mainloop()
c4c44e2b406cf19b5e6c5389cdde91beaebbdb18
SimonPavlin68/python
/sympy/sym_plot.py
346
3.859375
4
import sympy as sym x, y = sym.symbols('x y') # Make two plots with different colors. p1 = sym.plot(x**2, (x, -1, 1), show=False, line_color='b') p2 = sym.plot(x**3, (x, -1, 1), show=False, line_color='r') # Make the second one a part of the first one. p1.extend(p2) # Display the modified plot object. p1.show() f = -...
03df7ce57a32f5ac8a6f7f0213ec4cb9b1b0b802
SimonPavlin68/python
/sympy/sym_taylor.py
1,109
3.640625
4
import sympy as sy import numpy as np from sympy.functions import sin,cos import matplotlib.pyplot as plt x = sy.Symbol('x') f = sin(x) def factorial(n): if n <= 0: return 1 else: return n*factorial(n-1) def taylor(function, x0, n): i = 0 p = 0 while i <= n: p = p + (func...
5b73df54434ffa861541a1cdd2ab1986e9e8bee6
SimonPavlin68/python
/basic/basic_except.py
325
3.625
4
cifre = [1, 2, 3, 0, 4] try: for i in cifre: print(1/i) except ZeroDivisionError as e: print('nea gre:', str(e)) except: print('except') try: for i in cifre: print(i) if(i == 3): raise Exception('Vržena izjema') except Exception as e: print('Ujeta izjema: ', str...
06fd29de1f04ff47a3a9b0a1d66278b37d1c1fcd
danhdoan/project-euler
/solutions/eulerlib.py
1,895
3.75
4
""" Euler Library ============= Support library for solving ProjectEuler problems """ # ============================================================================== def numToList(x): """Convert an integer to list in reversed order""" if x == 0: return [0] lst = [] while x > 0: lst.append(...
756ceea84ddc36caccb7afa3559fef09a49ef5a6
RakshaPawar108/Machine-Learning-Course
/Part6_Reinforcement_Learning/Upper_Confidence_Bound/Random_Selection.py
821
3.921875
4
# Random Selection...selects random ads to show to the users and get results # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Imprting the dataset dataset = pd.read_csv('Ads_CTR_Optimisation.csv') # Implementing Random Selection import random N = 10000 d = 10 ads_...
146e491dd87764b45e848ea36d259836c60e4a65
Kabiirk/advent-of-code-2020-entries
/Day13/Day13.py
1,331
3.953125
4
day13 = open("day13.txt", "r") #Put data in a list input_list = [] for line in day13: input_list.append(line.strip()) day13.close() # Separating data for easier usage, can be omitted to save space # but list indexing would need to be used , which makes code # tougher to read departure_timestamp = int(input_list[...
3a05cf82b86b4a31e5aa30feb2eb8a18d959f3a7
ahmed2929/HNG-Script
/scripts/Micah-Elijah.py
379
3.5
4
#!/usr/bin/python3 def main(): def printDetails(): name = "Micah Elijah" hng_id = "HNG-04316" language = "Python" email = "melijah200@gmail.com" text = ("Hello World, this is {} with HNGi7 ID {} and email {} using {} for stage 2 task").format(name, hng_id,email, language) ...
762296a29470d1c1e446b8999b3a73606fa1146f
zhenchengit/pynet_test
/day1/list.py
111
3.5
4
list = [0,1,2,3,4] print list list.append(5) list.append(6) print list list.pop(0) print list print len(list)
a3d5cd324a622e85bbf676e62a5d1f1b9af19ca4
scottku/Python
/basic_tuple.py
2,101
3.5
4
def define_tuple(): """ 튜플 정의 연습 """ tp = tuple() print(tp, type(tp)) # 캐스팅 : 다른 순차자료형을 기반으로 튜플 생성 tp = tuple(); print(tp, type(tp)) tp = () #공튜플 tp2 = (1,) # 요소의 개수가 1개 일때는 마지막에 콤마 추가 tp3 = (1, 2, 3) print(tp, tp2, tp3) def tuple_oper(): """ 튜플의 연산 대부분 리스트와 비슷...
3704e5e0d5a558016f225d83c89abeba90d0b1e8
ellisonzeng/PythonPractice
/15/obcopy.py
1,407
4.09375
4
# coding:utf-8 # 第15课 Python对象比较、拷贝 import copy if __name__ == "__main__": a = 2 b = 2 print(a == b) print(a is b) print("id(a) = {}".format(id(a))) print("id(b) = {}".format(id(b))) # 以上只对-5至256的值有效 a = 10000000 b = 10000000 print(a == b) print(a is b) print("id(a) = {}".format(id(a))) print("id(b) = {...
fbe5711386876445e479e0a07c038afb0f163f28
ellisonzeng/PythonPractice
/13/utils/class_utils.py
194
3.765625
4
# coding:utf-8 # 第13课 Python模块化 class Encoder(object): def encode(self, s): return s[::-1] class Decoder(object): def decode(self, s): return ' '.join(reversed(list(s)))
cdaa647a527a20cf851f65ce4df554a3185b920a
annkon22/ex_book-chapter3
/linked_list_queue(ex20).py
1,835
4.1875
4
# Implement a stack using a linked list class Node: def __init__(self, init_data): self.data = init_data self.next = None def get_data(self): return self.data def get_next(self): return self.next def set_data(self, new_data): self.data = new_data...
32662139be2cd03f427faaa5a1255fb8fd24b1cd
annkon22/ex_book-chapter3
/queue_reverse(ex5).py
457
4.25
4
#Implement the Queue ADT, using a list such that the rear of the queue #is at he end of the list class Queue(): def __init__(self): self.items = [] def enqueue(self, item): self.items.append(item) def dequeue(self): return self.items.pop(0) my_q = Queu...
4ede4d0137652134ffd9586162792a9171b28700
anichucai/75.41-Algoritmos-y-Programacion-II
/TPs/TP3/FlyCombi.py
1,889
3.859375
4
#!/usr/bin/env python3 from Algueiza import * import sys def main(): if not parametros_correctos(): return vuelos=Grafo() ciudades,aeropuertos = leer_aeropuertos(vuelos,sys.argv[1]) leer_vuelos(vuelos,sys.argv[2]) consola(vuelos,ciudades,aeropuertos) def parametros_correctos(): if(len(sys.argv)!=3): ...
e80799ebc18f5df9c99a29297a62f12618495d8e
jkwok979/python-challenge1
/pypoll/main1.py
1,848
3.640625
4
import pandas as pd file = "election_data.csv" election_data = pd.read_csv(file) election_data.head() votertotal = len(election_data["Voter ID"].unique()) total_votes = election_data['Candidate'].value_counts() df = pd.DataFrame(total_votes) df.head() votes_percent = total_votes/votertotal totalvotes = total_votes.copy...
061acf150e2bea1ec8acbc7ce8d2a4550c408e0e
ChristianDzul/ChristianDzul
/Exam_Evaluation/Question_06.py
506
4.15625
4
##Start## print ("Welcome to the area calculator") ##Variables## length = 0 width = 0 area_square = 0 area_rectangle = 0 ##Getting the values## length = int( input("Insert a value for the lenght \n")) width = int( input("Insert a value for the width \n")) ##Process## if (length == width): area_square = length * wi...
251b5ac87ea626ee07ec431f86013f9c018ad11f
gustavotorrezan1/programacao_de_aplicativos
/SA2_recu/exercicio2.py
372
3.609375
4
valores = [] for y in range(1, 5): valores.append(int(input(f'Digite um valor de 0 a 10= {y}:'))) soma = 0 for i in valores: soma += i soma_valores = soma media_valores = soma_valores / 4 print(f'A média é: {media_valores}') if media_valores >=7: print('Se a média é acima de 7 = Aprovado') else: ...
f3d827d3a0c003f382e43b70351d0db7bc6beb65
Matonice/funaab-AI-assignment
/passowrd_gen.py
2,646
4.0625
4
from random import sample from random import shuffle def password_generator(): capital_letters = [chr(x) for x in range(65,91)] small_letters =[chr(x) for x in range(97,123)] capital_letters.extend(small_letters) numbers = [str(x) for x in range(0,10)] symbols = ["+", "-", "?" , "$", "!", "%", "*"]...
b06462b54c50fb07f2eea262f5ab6dec9ba42e83
Cz-zC/python-study
/day1/1.py
133
3.8125
4
temp = input("inpute a number:") guess = int (temp) if guess == 8: print("yes") else: print ("no") print("game over")
e9faa4ba9581e1037cb31ddf19cdd6d49b690806
SlvrWl/way_pythons
/Задания на списки/Task2. Больше предыдущего.py
837
3.9375
4
#Программа находит в списке число, которое больше предыдудещго и заносит его в отдельный список flag = 0 while flag == 0: number = list(input('Введите числа и я выведу Вам все числа,\nкоторые больше предыдущего\n')) number_plus = [] len_list = len(number) for i in range(0, len_list - 1): ...
7a20aca997f5ba8f3e5c1cb4b59a2ae1abdfd4c6
SlvrWl/way_pythons
/Задания на множества/example.py
163
3.640625
4
var_1 = [1,2,3] var_2 = [0,1,4] def func(a): var_1 = [] for i in a: var_1.append(i**2) return var_1 print(func(var_2)) print(var_1)
b455c2d1d32b5868b3cadea08bb31134fa54c085
MalikaSajjad/SP
/Assignments/BCSF13A552_SP_Assignment-02/p3.py
816
3.9375
4
####python script that finds 2 by 2 matrix from 8 by 8 matrix import sys def findMatrix(lst,m): lst = [int(i) for i in lst] # converting lst of str to int r = 0 l_c = 0 while(r != 7): c = 0 while(c != 7): if lst[l_c] is m[r][c] and lst[l_c + 1] is m[r][c+1] and lst[l_c + 2] is m[r+1][c] and lst[l_c + 3] ...
5aa2d245d628c79a70360f2c114a4cef537a65e4
dharm0us/prob_pro
/iterate_like_a_native.py
577
4.40625
4
#iterate like a native # https://www.youtube.com/watch?v=EnSu9hHGq5o myList = ["The", "earth", "revolves", "around", "sun"] for v in myList: #Look ma, no integers print(v) #iterator is reponsible for producing the stream #for string it's chars for c in 'Hello': print(c) d = {'a' : 1, 'b' : 2} fo...
00f1a488e63b2ec41b1ddb9f86a80ad401512937
majusk/Nauka-phyton
/rzut_kośćmi.py
353
3.515625
4
# program rzut kośćmi # demonstruje generowanie liczb losowych import random # generuj liczby losowe z zakresu 1-6 die1 = random.randint(1,6) die2 = random.randrange(6) + 1 total = die1 + die2 print ("Wyrzuciłeś", die1, "oraz", die2, "i uzyskałeś sumę", total) input("\n\nAby zakończyć program, klikni...
1da739ac1b4342c1576edcea1b2264458c62ad51
majusk/Nauka-phyton
/zwariowany_lancuch.py
297
4
4
# Program "Zwariowany lancuch" # Demonstruje użycie pętli for z łańcuchem znaków word = input("Wprowadz wybrane przez Ciebie słowo:") print("\nOto poszczególne litery Twojego słowa:") for letter in word: print(letter) input("\n\nAby zakończyć program kliknij Enter.")
3f81b1c5d7311bceda12b623aa01f4f8365c2464
majusk/Nauka-phyton
/licznik.py
343
3.875
4
# Program Licznik # Demonstruje funkcje range() print("liczenie:") for i in range(10): print(i, end=" ") print("\n\nLiczenie co pięć:") for i in range(0, 50, 5): print(i, end=" ") print("\n\nLiczenie do tyłu:") for i in range(10, 0, -1): print(i, end=" ") input("\n\nAby zakończyc program ...
364fdcae9d1e9731396effbd02c0fcc8e7762a7b
noamatkovic/PZW
/vjezba-02.py
186
3.5625
4
ime = input("Unesi svoje ime:") poruka1 = "Dobar dan! " print(poruka1 + ime) broj1 = int(input("Unesi broj a: ")) broj2 = int(input("Unesi broj b: ")) print(broj1 + broj2)
bec8641b0880446ff783cdd502ca350a6742e5fa
nikolaimozharenko/bank
/bank.py
601
3.921875
4
while True: a = int(input("Число: ")) p = float(input("Процент в десятичной дроби: ")) d = input("Сложные или простые проценты(+ для простых, - для сложных): ") n = int(input("Сколько раз выполнять операцию: ")) result = int if d == "+": c1 = n * p c2 = 1 + c1 c3...
2aa097a9f1a23af0917c655406b3ccea83792ca2
otatari/salary_prediction
/salary_prediction.py
17,735
3.71875
4
#!/usr/bin/env python # coding: utf-8 # # Salary Prediction based on Job Descriptions # # The goal of this project is to predict salaries based on job descriptions. We will look at different factors and build a machine learning algorithm to predict the salary. # # The model will help companies during hiring process ...
a1be71668cca2f889d7a51c8ff71520be9db3d20
DevVietRaKhoi/kata
/week0002/hienhpss/python/week0002.py
919
3.796875
4
def spi_round(n=4, m=4, x=0): '''Looping through the spiral path to return the next cell''' if (x >= (n+1) / 2) or (x >= (m+1) / 2): return for i in range(x, m - x -1): yield (x, i) for i in range(x, n - x - 1): yield(i, m - x - 1) for i in range(m - x - 1, x, -1): yield(n - x - 1, i) for i in range(n - ...
59890f09a10730dc76f570bd8d186c3cb9364f93
konovalovatanya26/prog_Konovalova
/turtle_new/упр 10.py
337
4.25
4
import turtle t = turtle.Turtle() t.shape('turtle') Number = 100 Step = 5 def circle(Number, Step): for step in range(Number): t.forward(Step) t.left(360/Number) for step in range(Number): t.forward(Step) t.right(360/Number) for _ in range(3): circle(Number, Step...
f182fa4da059cdb9f6872edcb352625e9f56251e
konovalovatanya26/prog_Konovalova
/turtle/упр 9.py
379
4.0625
4
import turtle turtle.shape('turtle') def proper_polygon(N,L): for step in range(N): turtle.forward(L) turtle.left(360/N) N= 3 L= 10 for x in range (10): proper_polygon(N,L) turtle.penup() turtle.right(360/N+180*(N-2)/(2*N)) turtle.forward(10) turtle.left(360/(N+1)+180*(N-2)/(2...
1885406d231c932ab19f2ee60fbf1e1c35d8881e
konovalovatanya26/prog_Konovalova
/turtle/упр 14(1).py
154
3.6875
4
import turtle turtle.shape('turtle') L=200 def line(L): turtle.forward(L) turtle.right(144) for x in range (5): line(L)
f3946edb08e69965cf47ff2f9082fd16bc72daca
kawoukaka/multiThread-CSV-writer
/csvWriter.py
1,180
3.5625
4
import io import csv from Queue import Queue import threading from threading import Thread import time #----------- #def listToCSV(data.args,fileName,header): # csv = csvWriter(data,50) # data1Exist = csv.createThreading(args,fileName,header) # print('CSV is created') #----------- class csvWriter: def __init__(s...
80880a9f96572d8a3db7fb66e2baa1ae19b91350
mathphysmx/teaching-ml
/evaluation/Exercises/francisco_clustering_silhouette.py
207
3.6875
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt x = pd.DataFrame({'x': [1,1,2,3,4,5], 'y':[4,6,6,8,3,2]}) i = 0 x.iloc[i, ] np.sqrt(3) def dist(x1,x2): return((x1.x - x2.x)^2)
6f60f93ee732339543cd40c4b63e9af19394f29b
cukejianya/leetcode
/notion/285_inorder_successor_in_bst.py
748
3.890625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def inorderSuccessor(self, root: 'TreeNode', p: 'TreeNode') -> 'Optional[TreeNode]': stack = [root] seen = set() ...
d25c6eb8bd4aa3fa0112147b442ca9466bdb56c9
cukejianya/leetcode
/notion/212_word_search_ii.py
908
3.828125
4
class Node: def __init__: self.next_letters = {} self.end_of_word = False class Solution: def findWords(self, board: List[List[str]], words: List[str]) -> List[str]: self.trie = Node() self.board = board self.words_found = [] for word in words: self.a...