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 |
|---|---|---|---|---|---|---|
ac2174ef82ce36315658619340bd211bc2767e34 | Sabsterrexx/PixelRacer | /AiCar.py | 1,631 | 3.59375 | 4 | import pygame
import constants
from PlayerCar import PlayerCar
import random
class AiCar(PlayerCar):
# Function to generate random car:
def generate_random_car(self, min_x, max_x):
car_choice = random.randint(0,10)
self.image = pygame.image.load("Car_Images/" + constants.car_images[car_choi... |
f44cef95514bf81a331161cf7289bfd453a3876d | orbengigi/matala2 | /test.py | 974 | 3.671875 | 4 | #!/usr/bin/python
import sqlite3
def create_db():
conn = sqlite3.connect('test.db')
c=conn.cursor()
c.execute(""""drop table if exists nmea""")
conn.commit()
c.execute('drop table if exists nmea')
conn.execute('CREATE TABLE nmea'
' (ID INT PRIMARY KEY NOT NULL,\n'... |
2e285677fdb99b49fed410d231a0bbf46a7c5d66 | ragavan98/Numpy-study | /Lec6-NumpyArrayReshaping.py | 3,514 | 4.8125 | 5 | ###################### Reshaping Arrays #################################
# Reshaping means changing the shape of an array.
# The shape of an array is the number of elements in each dimension.
# By reshaping we can add or remove dimensions or change number of elements in each dimension.
###################### Res... |
568d4df911360221711652935b98bcee1871fca0 | ragavan98/Numpy-study | /Lec9-NumPyArraySplit.py | 3,106 | 4.6875 | 5 | ###################### NumPy Splitting Array #################################
# Splitting is reverse operation of Joining.
# Joining merges multiple arrays into one and Splitting breaks one array into multiple.
# We use array_split() for splitting arrays, we pass it the array we want to split and the number of spli... |
49e3cfd28915531e4499675d748f2484e0073683 | kofort9/everything | /fifth.py | 753 | 4 | 4 | import random
question =raw_input("Please ask the 8 ball a question: ")
array = question.split(" ")
#print array
last_word= len(array)-1
#print array[last_word]
responses = ['It is certain','It is decidedly so','Without a doubt',
'Yes definitely','You may rely on it','As I see it, yes',
'Most likely','Outl... |
aafb755ab521de866ad1e7364e1b811071e1498e | kofort9/everything | /python2lesson.py | 181 | 3.75 | 4 | groceries =['eggs','milk','butter', 'onion', 'apples']
#print groceries[1:3]
#print groceries[1:4]
#print groceries[:4]
#print groceries[::2]
for i in groceries:
print i
|
4b74bc27c227f32b70f684bde85dff4c2ebd14b7 | djs1193/-w3r-esource | /exe14.py | 712 | 4.03125 | 4 |
# calculating difference in days
#approximating a month has 30 days
#assuming all years 365 days
s1 = input("enter the first date: ")
s2 = input("enter the second date: ")
list_1 = (s1.split())
list_2 = (s2.split())
if (list_1 == list_2):
print ('the two days are same')
elif((list_1[2] == list_2[2]) and (list_... |
b1fc4c3182a0acf5efd849936af09c4243eeae01 | ViniciusRomano/oficina-python | /ex5.py | 266 | 3.75 | 4 | p1 = int(input("Me de um número ae meu chapa\n"))
p2 = int(input("Me de outro número ae meu chapa\n"))
media = (p1 + p2) / 2
if(media >= 6):
print("Aprovado")
elif(media < 6 and media >= 4):
print("Quebra de Pré Requisito")
else:
print("Reprovado")
|
9624683d927428fbdaea8d30d1079ab31127c99e | ViniciusRomano/oficina-python | /ex10.py | 175 | 4.0625 | 4 | nomes = []
for x in range(3):
nomes.append(input("Me de um nome ae meu chapa\n"))
if("Klebinho" in nomes):
print("Tem Klebinho")
else:
print("Nao tem Klebinho")
|
0b3d37a30679489a3a48b532a0980d4838fc7168 | Prabithapallat01/pythondjangoluminar | /flow_controls/decision_making/assment.py | 381 | 3.8125 | 4 | a=int(input("Enter the numbers:"))
b=int(input("Enter the num2:"))
c=int(input("enter num3:"))
#if(a+b==100|a==100|b==100):
# print("true")
#else:
#print("false")
if(a>b )&( a>c):
print(a,"is grater number:")
elif(b>a)&( b>c):
print(b,"is grater number:")
elif(c>a )&( c>b):
print(c,"is grater number:... |
f09ae3093afd4078f4e91148da3c50d596e21aac | Prabithapallat01/pythondjangoluminar | /regular_expression/rule.py | 301 | 3.703125 | 4 | # a,k first character must be an alphabet b/w a,k
# second must be a digit divisible by 3
# folloewd by any no.of character
from re import *
var_name=input("enter name:")
rule="[a-k][369][a-zA-Z0-9] "
matcher=fullmatch(rule,var_name)
if matcher==None:
print("invalid:")
else:
print("valid") |
cbed4ebcf5937258462597295e1f3cb7d05a1533 | Prabithapallat01/pythondjangoluminar | /flow_controls/looping/awv.py | 67 | 3.796875 | 4 | num=input("Enter the value:")
data=0
i=1
while(i<=int(num)):
re |
cd6e57a9a7e20c6ce68b46983223049116966874 | Prabithapallat01/pythondjangoluminar | /exam_questions/set/q3.py | 145 | 3.515625 | 4 | #How to convert a list into a string?
weekdays=["mon","tue","wed","thur","fri","sat","son"]
listAsString=' '.join(weekdays)
print(listAsString) |
e6b876f2390696a35d8c1954e560e531bbb45c10 | Prabithapallat01/pythondjangoluminar | /flow_controls/looping/reversestring.py | 134 | 4.09375 | 4 |
name=input("Enter the name:")
length=len(name)-1
reverse=" "
while(length>0):
reverse+=name[length]
length-=1
print(reverse)
|
ef5ef06f3928de1c3ae4d007d96f5200e3747a97 | Prabithapallat01/pythondjangoluminar | /exam_questions/while_loop/counting.py | 154 | 4.09375 | 4 | # Given a number count the total number of digits in a number
n=int(input("enter the number:"))
count=0
while n!=0:
n//=10
count+=1
print(count) |
d877adbe8004e4cca3b0d60261b35c715fb79d64 | Prabithapallat01/pythondjangoluminar | /pythoncollections/list/example2.py | 185 | 3.796875 | 4 | lst=[1,2,3,5]
num=int(input("Enter number is find pairs"))
for i in range(0,len(lst)):
for j in range(i+1,len(lst)):
if(lst[i]+lst[j]==num):
print(lst[i],lst[j]) |
50249cbfbfd0eb2e6a64cb97c00743ad91541cdf | Prabithapallat01/pythondjangoluminar | /flow_controls/looping/samlefor.py | 343 | 4.125 | 4 | #for i in range(start,stop):
#loop body
#for i in range(1,10):
#print(i)
#for i in range (10,0,-1):
# print(i)
# to print total of first 50 numbers
#total=0
#for i in range(1,51):
# total=total+i
#print(total)
# to print given number is prime or not
#to print allprime numbers btwn 5 to 50
#low=5
#upperl... |
25d13dfe05c7bb509972363cae78cad749598a4b | Prabithapallat01/pythondjangoluminar | /oops/multiple_inheri.py | 233 | 3.609375 | 4 | class Parent:
def m1(self):
print("inside parent ")
class Child:
def m1(self):
print("inside child")
class Sub_child(Parent,Child):
def m3(self):
print("inside")
obj=Sub_child()
obj.m3()
obj.m1()
|
e7fb1c6617b215ea73e9ef836273bafddc44b075 | Prabithapallat01/pythondjangoluminar | /oops/sample.py | 518 | 3.640625 | 4 | class Stud:
def __init__(self,name,rol,course,total):
self.name=name
self.rol=rol
self.course=course
self.total=total
def __str__(self):
return self.name
obj=Stud("pranhha",12,"bca",199)
obj1=Stud("maya",13,"mca",898)
obj2=Stud("Neha",14,"django",111)
obj3=Stud("Neena",1... |
3df88691b5ff4b6fa5ab652784f1dc9f1f5f54ba | Prabithapallat01/pythondjangoluminar | /oops/person.py | 300 | 3.859375 | 4 | class Person:
def setPerson(self,name,age):
self.name=name
self.age=age
def printPerson(self):
print("name=",self.name)
print("age=",self.age)
obj=Person()
obj.setPerson("annie",29)
obj.printPerson()
obj1=Person()
obj1.setPerson("maya",34)
obj1.printPerson() |
37e0577e9f4a559617395b9dca04aa8330a86d25 | Prabithapallat01/pythondjangoluminar | /pythoncollections/dictionary/employees.py | 398 | 4.03125 | 4 | employees={"id":12,"ename":"latha","exp":2,"salary":30000}
if("salary" in employees):
print("salary")
#name
if("ename"in employees):
print("ename")
#add gender
if("gender" in employees):
print("exist")
else:
employees["gender"]="female"
print(employees)
#if any employees salary is <35000 and add500
... |
4b69dff9b8537a50bf6fb1ff00710db94876790c | Prabithapallat01/pythondjangoluminar | /pythoncollections/sets/work1.py | 272 | 3.84375 | 4 | students_names={"alan","aleena","ram","leena","jins","jimmy","jhon","Neena","Mega"}
failed_stud={"Mega","leena","ram"}
diff=students_names.difference(failed_stud)
print("passed students:",diff)
inter=students_names.intersection(failed_stud)
print("failed students:",inter) |
8a2d6131d4a634940bc2aec894db2a3111fe21b4 | NikIshmametev/hhhomework | /core/classes.py | 1,778 | 4.0625 | 4 | class Car:
# Реализовать класс машины Car, у которого есть поля: марка и модель автомобиля
# Поля должны задаваться через конструктор
def __init__(self, brand, model):
self.brand = str(brand)
self.model = str(model)
def __repr__(self):
return ' '.join([self.brand, self.model])
... |
df0b133005720436dba21f6f580ea928e5f4d08f | mledall/Web_scraping | /test_webscraping.py | 3,189 | 3.921875 | 4 | # We will follow the tutorial at https://blog.miguelgrinberg.com/post/easy-web-scraping-with-python
# use the 'requests package' http://docs.python-requests.org/en/master/user/quickstart/
import requests
import bs4
#use beautiful soup: https://www.crummy.com/software/BeautifulSoup/
from bs4 import BeautifulSoup
impor... |
59793bcf0f03f686239659306a7df2e18d72335a | chefmohima/python | /stack_list_implement.py | 938 | 4.125 | 4 | class Stack:
#list-based stack implementation
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
def size(self):
return len(self.items)
def push(self,item):
self.items.append(item)
def p... |
992c0d176e93761e662b33ef1d51c773679e2e22 | brunopontes90/Cursos | /Python/Mundo 1/desafios/desafio17.py | 499 | 3.96875 | 4 | from math import hypot
print('===== desafio 17 ====='.upper())
#SOLICITA O CATETO OPOSTO E CATETO ADJACENTE
cat_oposto = float(input('Digite o cateto oposto: '))
cat_adjacente = float(input('Digite o cateto adjacente: '))
#CALCULA A HIPOTENUSA RECEBENDO OS CATETOS ADJACENTE E OPOSTO
hipotenusa = hypot(cat_... |
d9ab7f24a37b1d344805c8a475d83593fa9e873b | brunopontes90/Cursos | /Python/Mundo 3/desafios/desafio76.py | 472 | 3.765625 | 4 | print('===== desafio 76 ====='.upper())
produtos = ('Lapis', 1.75,
'Borracha', 2,
'Caderno', 5.90,
'Estojo', 10.50,
'Mochila', 125.50,
'Livro', 27.50)
print('-' * 40)
print(f'{"LISTAGEM DE PREÇOS":^40}')
print('-' * 40)
for pos in range(0, len(p... |
29b422ca96aeeb141045cdef3934bbf59bce62ed | brunopontes90/Cursos | /Python/Mundo 1/desafios/desafio12.py | 142 | 3.78125 | 4 | print('===== desafio 12 ====='.upper())
produto = float(input('Digite o valor: '))
desconto = produto - (produto * 5 / 100)
print(desconto) |
3da50aafcf498a755f3d5e68812e88640824d9ea | brunopontes90/Cursos | /Python/Mundo 2/desafios/desafio43.py | 655 | 3.90625 | 4 | print('===== desafio 44 ====='.upper())
peso = float(input('Digite seu peso: '))
altura = float(input('Digite sua altura: '))
imc = peso / (altura * altura)
if imc < 18.5:
print('Abaixo do Peso!')
elif imc >= 18.5 and imc < 25:
print('Indice de Massa Corporea: {:.1f}'.format(imc))
print('Peso ... |
c08af567bd7a1625fe1adb31bdd8c4498dc7bac8 | brunopontes90/Cursos | /Python/Mundo 1/desafios/desafio05.py | 211 | 3.84375 | 4 | print('==== desafio 05 ===='.upper())
num = int(input('Digite um valor inteiro: '))
ant = num - 1
suc = num + 1
print('O valor digitado {}, \n seu antecessor {} e \n seu sucessor {}'.format(num, ant, suc))
|
394d9846c61dc5cde3f11dabbcdbefd80b924bc9 | brunopontes90/Cursos | /Python/Mundo 2/desafios/desafio55.py | 445 | 3.859375 | 4 | print('===== desafio 55 ====='.upper())
maior = 0
menor = 0
for i in range(1,6):
peso = float(input('{}º paciente, digite seu peso: '.format(i)))
if i == 1:
maior = peso
menor = peso
else:
if peso > maior:
maior = peso
if peso < menor:
... |
d0a3ed68f6596face6e5bf01fb7d1e47d43049a1 | brunopontes90/Cursos | /Python/Mundo 1/desafios/desafio10.py | 198 | 3.9375 | 4 | print('===== desafio 10 ====='.upper())
reais = float(input('Digite o valor em reais: '))
dolar = reais / 3.27
print('Com: R${} reais\n Você pode comprar US${:.2f} dolares'.format(reais, dolar)) |
07fc92071eed813c456ef68294bd1b2096a12167 | brunopontes90/Cursos | /Python/Mundo 2/desafios/desafio42.py | 557 | 4.03125 | 4 | print('===== desafio 42 ====='.upper())
r1 = float(input('1º segmento: '))
r2 = float(input('2º segmento: '))
r3 = float(input('3º segmento: '))
if (r1 < r2 + r3) and (r2 < r1 + r3) and (r3 < r1 + r2):
print('Os seguimentos acima podem formar um triangulo ', end="")
if (r1 == r2) and (r2 == r3): #OUTRA ... |
6b8e33d1ee47e1c410916c22031e5bbff8cc0c2b | brunopontes90/Cursos | /Python/Mundo 2/desafios/desafio70.py | 1,018 | 3.890625 | 4 | print('===== desafio 70 ====='.upper())
total = totmil = menor = cont = 0
barato = ''
while True:
# SOLICITA PRODUTO E VALOR E SOMA TODOS
produto = str(input('Nome do produto: ')).strip().capitalize()
preco = float(input('Valor do produto: R$'))
cont += 1
# VERIFICA QUANTOS PRUDOTOS SÃO M... |
fdf06a9b7b2d642b328d44c527c5e289a1b86d23 | shapudl/coursera | /stopwatch_game.py | 3,735 | 3.5625 | 4 | ####
## stopwatch game for two players
## keyboard input for player 1 is "a"
## keyboard input for player 2 is left arrow
import simplegui
# Global variables
interval = 100
count_try_1 = 0
count_win_1 = 0
count_try_2 = 0
count_win_2 = 0
score1 = 0
score2 = 0
count = 0
minutes = "00"
sec = "00"
mili = "0"
name1 = "... |
6f1235b0f275cfa53e81335401189ea29fe9cc7c | gbanfi3/python_automation | /02/a223 oop.py | 471 | 3.828125 | 4 | class Student:
def __init__(self, name, gr):
self.name = name
self.grades = gr
def average(self):
return sum(self.grades) / len(self.grades)
student = Student('alfréd', (12,34,55,66,55))
print(student.name)
print(student.grades)
print(student.average())
print(Student.average(student))
... |
503db886de43a62ee6d29ab0880c3de8bd61bcac | gbanfi3/python_automation | /02/a225 factory.py | 733 | 3.84375 | 4 | class Book:
TYPES = ("hardcover", "paperback")
def __init__(self, name, booktype, weight):
self.name = name
self.booktype = booktype
self.weight = weight
def __repr__(self):
return f"<Book {self.name}, {self.booktype}, {self.weight}g>"
@classmethod
def hardcover(cl... |
fb167dcdd270d019402443230887932aecdd3ed4 | cs-fullstack-2019-fall/codeassessment2-LilPrice-Code | /q3.py | 708 | 4.40625 | 4 | # ### Problem 3
# Given 2 lists of claim numbers, write the code to merge the 2 lists provided to produce a new list by alternating values between the 2 lists. Once the merge has been completed, print the new list of claim numbers (DO NOT just print the array variable!)
# ```
# # Start with these lists
# list_of_claim_... |
ea269b29ff32d322db41f697168cca7febee5aea | Scrat-the-Agent/mdp-visualizer | /mdp_visualizer/logic/gameObject.py | 8,103 | 3.765625 | 4 | """
Game Object module
=================
This module contains backend implementations of game objects like Scrat, Hippo and Watermelon.
"""
from random import randint, random
from .actions_objects_list import Actions
class GameObject:
"""A class that implements backend logic of game objects like Scrat, Hippo a... |
ec0bad1eb5a49f5a128e313b8b0a70e51f6f107b | yuufujikata2/Jisakucode | /MycompPY/Dot/dot.py | 1,708 | 3.546875 | 4 | import numpy as np
import sys
def main():
n=input('Please input dimension: ').split()
if len(n)==0:
print('error:no dimension')
sys.exit()
elif len(n)==1:
n1=1
n2=int(n[0])
A=np.zeros(n2)
elif len(n)==2:
n1=int(n[0])
n2=int(n[1])
A=np.zeros((n1,n2))
elif len(n)>=3:
print('... |
29e7eb490b503b8ce6f4c6ff9f582ef9e2163913 | AmelishkoIra/it-academy-summer-2021 | /task1_hw4.py | 1,423 | 4.5 | 4 | """Функции из Homework4 для тестирования"""
def compare_lists(list_one, list_two):
"""
Функция считает, сколько различных чисел содержится одновременно как в
первом списке, так и во втором.
"""
compare = list_one & list_two
return len(compare)
def compare_lists_difference(list_... |
c41b8c0c8eaac075b7d009d5e288dfb11615f2dd | ramyanaga/Misc.- | /projecteuler14.py | 823 | 3.53125 | 4 | #project euler 14?
#pseudeocode:
maxLength = 0
for i in range(1,50):
#startNumb = i
chainNumb = i
chainValues = [] #the actual chain
allChains = [] #list with lists of all chains
chainLengths = [] #holds lengths of chains
#maxLengthIndex = 0
while (chainNumb > 1):
#for i in range(1,10):
if chainNumb % 2 =... |
4fa92a8205b818d0f9f37d98042a832c50782aa7 | ramyanaga/Misc.- | /primes.py | 1,462 | 3.5625 | 4 | import time
def calculate_primes_old(limit):
primes = []
for i in xrange(2, limit):
count = 0
for j in xrange(2, i):
if i % j == 0:
count += 1
if count == 1:
primes.append(primes)
return primes
def calculate_primes(limit):
primes = []
... |
b19e2044c16582d09b1fe0807abcbb78e8039e3f | ivan570/code | /python/Validating Email Addresses With a Filter.py | 893 | 3.59375 | 4 | def fun(s):
try:
s, extension = s.split(".")
if len(extension) > 3 or len(extension) == 0:
return False
username, websitename = s.split("@")
if len(username) == 0 or len(websitename) == 0:
return False
for i in websitename:
if i.isalpha() o... |
ecde267a5323758f7868987c1626627b1cfda5e0 | ivan570/code | /python/Calendar Module.py | 130 | 3.75 | 4 | import calendar
m, d, y = map(int, input().split(" "))
cal = calendar.weekday(y,m,d)
print(list(calendar.day_name)[cal].upper()) |
81de8c821869822087f7becf6930962638e7fc3d | ivan570/code | /python/Loop.py | 163 | 3.859375 | 4 | x=int(input("enter x"))
y=int(input("enter y"))
while x>0:
print(x)
x-=1
for i in range(y,-1,-1):
print(i)
list=[*range(y,-1,-1)]
print(list)
|
0b220b5cc0e1958a10ec68d2fb5d3336f3242591 | ivan570/code | /python/tempCodeRunnerFile.py | 116 | 3.546875 | 4 |
test = int(input())
while test > 0:
string = input()
print(sherlockAndAnagrams(string))
test -= 1
|
3777bca6ec45e27a381c9c0951dd5105ada03d62 | ivan570/code | /python/gfg/gfg-Multiply two strings.py | 198 | 3.78125 | 4 |
def multiply(a, b):
return int(a) * int(b)
if __name__ == "__main__":
t = int(input())
for i in range(t):
a, b = input().split()
print(multiply(a.strip(), b.strip()))
|
6ec6483e455f3f023219b3b12c2f1f8e9820bb0c | ivan570/code | /python/TwoCharacters.py | 1,151 | 3.5 | 4 | def countChar(string):
d = [0] * 26
a = ord('a')
for i in string:
int_i = ord(i)
d[int_i - a] += 1
return d
def findMax(char_array):
m = 0
ans = -1
for i in range(len(char_array)):
if char_array[i] > m:
m = char_array[i]
ans = i
return an... |
415b9a8b68c8ba36c53765cc0f5b0a25ea2d5c63 | ivan570/code | /python/Find the Running Median.py | 538 | 3.515625 | 4 | import bisect
item = []
for _ in range(int(input())):
value = int(input())
if len(item) == 0:
item.append(value)
elif len(item) == 1:
if item[0] > value:
item = [value, item[0]]
else:
item.append(value)
else:
bisect.insort(item, value)
# print... |
5430eb3399861f7725712ba501d215a4560a871d | polyeuct/eden | /Stepik/Strings_02.py | 204 | 3.640625 | 4 | DNA = input()
test = DNA[0]
out = ''
s = 0
for p in DNA:
if p != test:
out += test + str(s)
s = 1
test = p
else:
s += 1
test = p
print(out + test + str(s))
|
0823b50cb05cc30897ccfec263c5567f880ce19f | polyeuct/eden | /Stepik/RW exercise.py | 269 | 3.546875 | 4 | words_lst = []
words_dst = {}
while True:
inp = input()
if inp == ' ':
break
words_lst += inp.split()
for word in words_lst:
txt_count = words_lst.count(word)
words_dst[word] = txt_count
for key in words_dst:
print(key, words_dst[key])
|
462c756db5826b1b0586f32e6bc0687f85128719 | Leg3nd3/Project_97 | /guessNumber.py | 426 | 4.25 | 4 | import random
number = random.randint(1, 5)
guess = int(input("Enter a number from 1 to 5: "))
while number != "guess":
print
if guess < number:
print("Guess is low")
guess = int(input("Enter a number from 1 to 5: "))
elif guess > number:
print("Guess is high")
gues... |
6184fe53341c9eb095ec008871ae31ecf8f5219e | nadiamarra/learning_python | /triangle.py | 776 | 4.28125 | 4 | def area(base,height):
"""(number,number)-> number
Return the area of a triangle with dimensions base and height.
>>>area(10,5)
25.0
>>>area(2.5,3)
3.75
"""
return base*height/2
def perimeter(side1,side2,side3):
"""(number,number,number) -> number
Return the perimeter of a t... |
4a9aed915df06acdefb8e06a5f8e2f9585a6f526 | nadiamarra/learning_python | /dict_increment_values.py | 264 | 3.703125 | 4 | def increment_values(d):
'''(dict with number values)-> NoneType
Increase each value in d by 1.
'''
for k in d:
d[k]=d[k]+1
#we pass the KEY to get the VALUE
#ex.
#>>>d={'a':4,'b':8,'c':12}
#>>>d['b']
#>>>8
|
698816b1931d4493e6e2db4370654af61f364f16 | nadiamarra/learning_python | /stop_copying_me_while_loop.py | 224 | 4.0625 | 4 | #ask for input
#user enters a response
#we get the same response printed
msg=input("Enter a sentence: ")
while msg!=("Stop copying me"):
print(msg)
msg=input("Enter a sentence: ")
print("Ugh fine you win")
|
a8112029c21f504bcfdfd671309b91f9a12edef8 | nadiamarra/learning_python | /password.py | 148 | 3.625 | 4 | msg=input("Enter you PIN: ")
while msg!="0000":
print("Wrong PIN. Please try again")
msg=input("Enter your PIN: ")
print("Correct" )
|
e4d0c47ce89a6f38f2372a9ca81f6805d23cb26c | nadiamarra/learning_python | /REGEX_parse_date.py | 895 | 4.03125 | 4 | import re
def parse_date(string):
date_regex=re.compile(r'^(?P<day>[0-3]{1}[0-9]{1})(\/|\.|\,)(?P<month>[0-1]{1}[0-9]{1})(\/|\.|\,)(?P<year>(19|20)[0-9]{2})$')
match=date_regex.search(string)
if match:
day=match.group('day')
month=match.group('month')
year=match.group('year')
return {'d':day,'m':month,'y':y... |
8a68d28e002f59a91c15da4bf2a283958fbf7857 | nadiamarra/learning_python | /rock_paper_scissors_against_computer.py | 1,696 | 4.15625 | 4 | import random
player_wins=0
computer_wins=0
while player_wins<2 and computer_wins<2:
print("rock...\npaper...\nscissors...")
print(f"Player Score:{player_wins} Computer Score:{computer_wins}")
player=input("Player, make your move: ")
rand_num=random.randint(0,2)
if rand... |
39148beb2114fccdf719e143a4da66607eee1b22 | nadiamarra/learning_python | /invert_dict.py | 962 | 4.21875 | 4 | fruit_to_colour={
'banana':'yellow',
'cherry':'red',
'orange':'orange',
'pear':'green',
'peach':'orange',
'plum':'purple',
'pomegranate':'red',
'strawberry':'red'
}
#inverting fruit_to_colour
colour_to_fruit={} #accumulator set as the new dict name
... |
b8deed4ba71dace3cab84c78dd0f42af92839a7c | wgh19950620/python_test | /venv/com.src.wgh/conditionExpression/traverse.py | 1,023 | 3.890625 | 4 | """
break 语句可以跳出 for 和 while 的循环体。
如果从 for 或 while 循环中终止,任何对应的循环 else 块将不执行
continue 语句被用来告诉Python跳过当前循环块中的剩余语句,然后继续进行下一轮循环
"""
# import sys
sites = ['Google', 'Baidu', 'Runoob', 'Taobao', 'QQ']
print("sites: ", sites)
print("使用range遍历:")
for i in range(len(sites)):
print(i, sites[i])
print("使用iter遍历:")
it = ite... |
4744ad31ee30f7428017da886d2f8c1b3271f3e6 | wgh19950620/python_test | /venv/com.src.wgh/variable/tuple_variable.py | 1,533 | 4.84375 | 5 | """
元组(tuple)与列表类似,不同之处在于元组的元素不能修改。元组写在小括号 () 里,元素之间用逗号隔开。
元组中的元素类型也可以不相同
元组与字符串类似,可以被索引且下标索引从0开始,-1 为从末尾开始的位置。也可以进行截取
元组元素不可被修改
虽然tuple的元素不可改变,但其可以包含可变对象,如list列表
"""
tuple_test = ('hello', 786, 2.23, 'python', 70.2)
tiny_tuple = (123, 'python')
print("tuple_test: ")
print(tuple_test) # 输出完整元组
print(tuple_test[0]) ... |
0be508dbc49ef3dbe1e2588895df7618391956a6 | manuelenrq9/PythonCurriculum | /DayByDayLessons/Day1/day1_projects.py | 1,589 | 3.734375 | 4 | # Part 3 - Project: Letter to the Future
career = "Software Engineer"
goal1 = "climb mount everest"
goal2 = "become a great chef"
goal3 = "learn scuba diving"
accomplishment1 = "won first place in a marathon"
accomplishment2 = "traveled to 30 different countries"
print("Dear future me,")
print("")
print("I hope that wh... |
632be2c07f3cf077e29f543a6962539bf6abb58a | vijaypatha/tkinter_intro | /main.py | 909 | 4.09375 | 4 | from tkinter import *
window = Tk()
window.title("My first GUI")
window.minsize(width=500, height=500)
window.config(padx=20,pady=20)
def button_clicked():
print("I got clicked")
# label.config(text="button got clicked")
label.config(text=input.get())
# TODO: Label Widget
label = Label(text="Im a labe... |
a6e2b2149391cbfccb1c808acfcd62a80450edd9 | r-fujiyama/Python | /fibonacci/main.py | 281 | 3.53125 | 4 | import time
from fibonacci import fibonacci
print("フィボナッチ数列を生成します。")
val = int(input("値を入力してください:"))
start = time.time()
fibo = fibonacci(val)
process_time = time.time() - start
print(fibo)
print("要した時間:", process_time)
|
10079a7d13b60d4f53a90f1b347ab30d11f13b69 | Omega-Dejavi77/ATM | /src/presentation/__init__.py | 961 | 3.6875 | 4 | #from sys import exit
from src.domain.CaixaBank import CaixaBank
#from src.Client import Client
if __name__ == '__main__':
str_bank = 'Caixa Bank-0.2-100000'
obj_bank = CaixaBank.create_by_string(str_bank)
print(obj_bank)
while True:
try:
"""First we are gonna ask to the client wh... |
7ee4d809598e05f704b2628c564b391b008ac03a | dingkunpeng/Design-of-Computer-Programs-Udacity | /lesson6/scrabble/scrabble.py | 10,897 | 3.796875 | 4 | # *** SCRABBLE GAME ***
def prefixes(word):
"A list of the prefixes of a word, excluding the entire word."
return [word[:i] for i in xrange(len(word))]
def readwordlist(filename):
'''Read the words from a file and return a set of
the words and a set of the prefixes.'''
wordset = set(file(filenam... |
ab3834dcdf36883083ee735c5dc7b734c1513c5c | dingkunpeng/Design-of-Computer-Programs-Udacity | /lesson3/compiler.py | 2,408 | 3.75 | 4 | # *** BUILDING A COMPILER TO MATCH PATTERNS IN TEXT ***
def search(pattern, text):
"Match pattern anywhere in text; return longest earliest match or None"
for i in xrange(len(text)):
m = match(pattern, text[i:])
if m is not None:
return m
def match(pattern, text):
"Match pat... |
e1c9c1eaa85d9245125af0a5a7e2b9b3f07e340e | Chanukacnm/project | /util/books.py | 2,735 | 3.609375 | 4 | import urllib.request
import json
# 324991-stuy-YAU093CG
def get_key(key_type):
'''Gets the api key from keys.JSON base on the key_type'''
with open('keys.JSON', 'r') as f:
keys = json.load(f)
# print(keys)
return keys.get(key_type)
def google_books_data(query):
'''Returns the search ... |
f38b0579a0d52a2a4354c25a3d453a76082fbf82 | stoner2497/Algorithms-HacktoberFest | /Python/nQueenProblem.py | 981 | 3.796875 | 4 | def put_queen(self,positions,target_row):
if target_row == self.size:
self.show_full_board(positions)
self.solutions += 1
else:
for column in range(self.size):
if self.check_place(positions,target_row,column):
positions[target_row] = column
sel... |
45caa5f705099ac1d259b63e768dce3627efdce5 | tonycnchang/machine-learning | /code2_apple.py | 779 | 3.671875 | 4 | import os
def main():
print("Hello World!")
print("这是Tony\'的问候")
print("这是Bob\'的问候")
foo(5,10)
print("==========")
print("这将直接执行" + os.getcwd())
counter = 0
counter += 1
food = ["苹果","杏","李子","梨"]
for i in food:
print("俺就爱整只:" + i)
print("数到十"... |
0509c0238fc33547e5b2ab3a3e79742d439cd248 | rocharayani/chatroom | /Client.py | 1,380 | 3.5625 | 4 | import socket
import sys
import time
s = socket.socket()
cliente = input(str("Digite seu nome: "))
host = input(str("Por favor, inclua o hostname do servidor: ")) #Pede o nome do host, para realizar a conexão do servidor, tbm poderia pedir o Ip, tanto faz.
port = 8080 #especifica a porta que ja consta no servidor par... |
3eff129c86eaa9651a8f97a2c2c85928988cf340 | abderrahmanesaad/python-climb-learning-tutorial | /python-tips-and-tricks/enumeration/main.py | 267 | 4.125 | 4 | mynames = ['john', 'mike', 'anna', 'bob', 'sara']
counter = 0
for name in mynames:
print(f'{counter}: {name}')
counter += 1
for index, name in enumerate(mynames):
print(f'{index}: {name}')
print(list(enumerate(mynames)))
print(dict(enumerate(mynames))) |
52f5d74ffa0ecdafa27946e44c6bee7850d63e11 | abderrahmanesaad/python-climb-learning-tutorial | /data-science/pie-charts-with-matplotlib/main.py | 374 | 3.53125 | 4 | import matplotlib.pyplot as plt
nationalities = ['American', 'German', 'French', 'Other']
students = [60, 23, 21, 34]
pairs = zip(students, nationalities)
pairs = sorted(list(pairs))
students, nationalities = zip(*pairs)
plt.pie(students, labels=nationalities, autopct='%.2f%%', shadow=True, counterclock=False, star... |
9a18b6acad525ca30d0202b6ad0af3d3f128812b | abderrahmanesaad/python-climb-learning-tutorial | /python-tips-and-tricks/Merging-Dictionaries/main.py | 192 | 3.71875 | 4 | dict1 = {'a': 1, 'b': 7}
dict2 = {'b': 4, 'c': 8}
# update
dict2.update(dict1)
print(dict2)
dict3 = {**dict1, **dict2}
print(dict3)
dict3 = dict(dict1.items() | dict2.items())
print(dict3) |
ba861b3428044b9d4181fd3ad07d1d210d0dc753 | abderrahmanesaad/python-climb-learning-tutorial | /python-tips-and-tricks/Binary Search/main1.py | 1,011 | 3.78125 | 4 | numbers = [257, 281, 308, 494, 344, 12, 163, 72, 231, 332, 8, 235, 441, 436, 438, 375, 71, 308, 334, 364, 224, 461, 152, 57, 261, 241, 66, 412, 495, 482, 207, 316, 259,
77, 270, 497, 98, 27, 488, 264, 132, 29, 170, 441, 151, 204, 319, 435, 243, 409, 313, 153, 182, 22, 368, 160, 200, 45, 483, 381, 140, 158, 7, 485, 411... |
6dfb40b3b1915ac69a1151e4532232a3f03a3bd5 | abderrahmanesaad/python-climb-learning-tutorial | /python-tips-and-tricks/Ternary-Operator/tricks1.py | 157 | 4.25 | 4 | age = 12
adult = True if age >= 18 else False
print("you are an adult!")
if adult:
print("you are an adult!")
else:
print("you are not an adult!")
|
6c0d8520d90572005083ef75fe94c71790565847 | abderrahmanesaad/python-climb-learning-tutorial | /python-tips-and-tricks/map-function/tricks1.py | 120 | 3.609375 | 4 | numbers = [14, 23, 8, 12, 2, 5, 90]
def square(x):
return x * x
new_list = map(str, numbers)
print(list(new_list)) |
0938a59935f9b693a6f19974a07b03b152ea8628 | jenniferquiroz-lpsr/class-samples | /Jennifer/4-2WrittingFiles/homeworkProgram.py | 585 | 3.953125 | 4 | print("Welcome to the Haiku generator!")
print("Provide the first line of your haiku:")
firstLine = raw_input()
print("Provide the second line of your haiku:")
secondLine = raw_input()
print("Provide the third line of your haiku:")
thirdLine = raw_input()
print("What file would you like to write your haiku to?")
... |
022f606a8af5d8e8976dd0b71d1dae2a7d7b5e94 | jenniferquiroz-lpsr/class-samples | /Jennifer/drawShape.py | 350 | 3.515625 | 4 | import turtle
def drawSide(myTurtle):
count = 0
while count < 4:
drawVee(myTurtle)
myTurtle.left(180)
count = count + 1
def drawVee(myTurtle):
myTurtle.forward(10)
myTurtle.right(90)
myTurtle.forward(10)
myTurtle.right(90)
shawn = turtle.Turtle()
count = 0
while count < 4:
drawSide(shawn)
shawn... |
624c187cbd5f5e50f50665461371056307bc7144 | branislavblazek/projects | /ciphers/monoalphabetic/caesar.py | 2,718 | 3.6875 | 4 | class Caesar:
def __init__(self, alphabet=None):
self.alphabet = [chr(i + 65) for i in range(26)] if alphabet is None else alphabet.upper()
self.alpha_len = len(self.alphabet)
def encode(self, input_text, offset):
sign = -1 if offset < 0 else 1
offset = abs(offset) % self... |
91416775e0bf8e91aee175bb1e914ede550678ad | tmdgusya/PythonAlgorithmInterview | /src/drink/solution.py | 1,880 | 3.6875 | 4 | import unittest
from collections import deque
# 음료수 얼려먹기 dfs
def solution_dfs(m, n, graph):
def dfs(x,y):
if x <= -1 or x >= m or y <= -1 or y >= n:
return False
if graph[x][y] == 0:
# visited => True
graph[x][y] = 1
dfs(x+1, y)
... |
a8e4a9720717f5226f147990dcb355831ea4437e | tmdgusya/PythonAlgorithmInterview | /src/delete_if_duplicate/case_one.py | 473 | 3.75 | 4 | import unittest
def solution(s):
if len(s) % 2 == 1:
return 0
stack = []
for i in s:
if len(stack) > 0 and i == stack[-1]:
stack.pop()
else:
stack.append(i)
if len(stack) == 0:
return 1
return 0
class TestClass(unittest.TestCase):
... |
dd9bd1cf19b585fec71689849cabcfcab1cd6030 | tmdgusya/PythonAlgorithmInterview | /src/validPalindrom/case_two.py | 581 | 3.734375 | 4 | import unittest
import collections
from typing import Deque
def deq_valid_palindrom(wording: str):
strs: Deque = collections.deque()
for char in wording:
if char.isalnum():
strs.append(char.lower())
while len(strs) > 1:
if strs.popleft() != strs.pop():
return Fal... |
d9b542af929bb4c1e9e92960921da0b596b62e89 | tmdgusya/PythonAlgorithmInterview | /src/validPalindrom/case_one.py | 491 | 3.734375 | 4 | import unittest
def valid_palindrom(wording : str):
strs = []
for char in wording:
if char.isalnum():
strs.append(char.lower())
while len(strs) > 1:
if strs.pop(0) != strs.pop():
return False
return True
class CaseOne(unittest.TestCase):
def test_case_o... |
a2ca3709a42a4465ccdec20b302141f8a53e1491 | MGRD-K/Myfirtst | /loop_tst.py | 318 | 3.828125 | 4 | from typing import List
colors = {'Red': ['Apple', 'Pomegranate'], 'Yellow': ['Banana', 'Lemon'], 'Green': ['Grapes', 'Mangoes']}
print(colors.keys())
print(colors.values())
# item() method
print(len(colors))
for k, v in colors.items():
# for i in range (len(colors)):
print(k,v)
for d in colors:
print(d)
|
7ac48ef4081bd66bf90b968283425da02040fa87 | ZhitingChia/Mini-projects | /typingGame.py | 1,292 | 4.09375 | 4 | #Simple Typing Speed test
# Author: Chia Zhi Ting
# Created on 20/3/2018
#The game selects a word from a list and the user has to type in the word.
#If the spelling is right, the number of passed rounds increases.
#Else the number of failed round will be incremented by one.
import random
import time
word... |
6100ae9257fec365b62541c9dfb16a5b1312121b | alibizhan/instaBot | /notFollowing.py | 1,299 | 3.53125 | 4 | #run this file after getting followers and following.
from userInfo import theirUsername
userFollowing = []
userFollowers = []
list_difference = []
followingFile = theirUsername+"Following.txt"
followerFile = theirUsername+"Followers.txt"
notFollwers = theirUsername+"_fans.txt"
notFollowing = theirUsername+"... |
fc416eac9e468b582974225de2c8d4fe1f43470b | arpitgupta275/MyCaptain-Python | /task1.py | 401 | 4.46875 | 4 | import math
# accepts radius of circle and computes area
radius = float(input('Input the radius of the circle : '))
area = math.pi * radius * radius
print(f'The radius of the circle with radius {radius} is: {area}')
# accepts a filename and prints its extension
filename = input('Input the Filename: ')
f_extns = f... |
9c74e624bc98d09f566c30ced49b4c623fc175d9 | hahoetal/python_homework | /homework_4.py | 274 | 3.609375 | 4 | price = input('가격을 입력해주세요: ')
discount_rate = input('할인율을 입력해주세요: ')
price = int(price)
discount_rate = int(discount_rate)
discount_price = price * (100 - discount_rate) /100
print('할인된 가격은',discount_price, '입니다.')
|
2b7c6279ffa5df08d3b2e3892c9ba141deff1d5d | romeroarmando173/Simple-Product-Project | /Store and Product Class OPTIONAL/StoreClass.py | 1,744 | 4.0625 | 4 | from productClass import * #importing productClass into this class
class Store:
def __init__ (self, name): #here you a
self.name = name #you can also crate as many stores as you want
self.productList = []
def add_product(self, new_product):
self.productList.appen... |
d9cedafc27230129be83944106b8b66bcb4758cc | bestyoucanbe/joypyli0827kennelrevisited | /kennel.py | 1,287 | 3.734375 | 4 | animals_in_kennel = [
{
"id": 1,
"breed": "German Shepherd",
"age": 3,
"name": "Jack"
},
{
"id": 2,
"breed": "Siamese",
"age": 9,
"name": "Shy"
},
{
"id": 3,
"breed": "Labradoodle",
"age": 5,
"name": "Ave... |
045b49e748cd065e98519237c8d0f3fdc31e235c | Anas-Abuhatab/game_of_greed | /game_of_greed/banker.py | 627 | 4.03125 | 4 | class Banker:
"""
this class for storing the player point :
it will take two values:
balance=0
shelved=0
- store unbanked point in the shelf method
- reset the shelved point to 0
- stored the point in the method bank
"""
def __init__(self):
self.balance=0
... |
89cb949b36512c412fa3346044df0d5a869d8d3e | F74086250/DataScience_2021_Spring | /hw0_polynomial_product/hw0_p2.py | 8,841 | 3.6875 | 4 | """
這個副程式是用來計算演員的revenue平均值的
"""
def calcu_average(act_lis):
sum=0
if len(act_lis)==0:
return 0.0
else:
for i in range(len(act_lis)):
sum+=act_lis[i]
return sum/len(act_lis)
f=open("IMDB-Movie-Data.csv","r")
print("========================================")
#listmyfile=f.readlines()
list1=[]
for line in ... |
1e8d464fbc02a54d47f110306e7c81b6794a21e8 | vijaykanth1729/python_material | /multi-threading/thread.py | 341 | 3.796875 | 4 | import threading
class X(threading.Thread):
def run(self):
for p in range(1,101):
print(p)
class Y(threading.Thread):
def run(self):
for p in range(101,201):
print(p)
x1 = X()
y1 = Y()
#x1.run() #to excute the method as a thread we need to call start method on it
x... |
86a322c092bb3a8513791ab03227e9a19a5d1f7b | vijaykanth1729/python_material | /socket_programming/server2.py | 4,354 | 3.796875 | 4 | # Handling multiple connections using Multi threading...
import socket
import sys
import threading
import time
from queue import Queue
NUMBER_OF_THREADS = 2
# job-1: Listen and accept connections from thread1
# job-2: Send commands to the already connected client ..
JOB_NUMBER = [1,2]
queue = Queue()
all_connection... |
d84115d315532808c709e1a7cd3b0b84f7090ca8 | vijaykanth1729/python_material | /decorators/decorator2.py | 347 | 3.6875 | 4 | def smart_divide(func):
def inner(a,b):
print("I am going to divide", a,"by",b)
if b==0:
print("OOPS!!, can not divide, change the denominator value..")
return
return func(a,b)
return inner
@smart_divide
def divide(a,b):
return a/b
p = divide(10,5)
print(p)
... |
e46e7c50fc7865eeb95a36b4664111f6c64e9b0a | vijaykanth1729/python_material | /file_handling/myfile4.py | 256 | 3.734375 | 4 | x = open('file1.txt')
lines = x.readlines() # readlines will read all the data , and stores in a list
#print(lines)
#print(type(lines))
for data in lines:
# print(data, end="") # removes the spaces between lines....
print(data)
x.close()
|
0cd177b0f508ba272e1cca5ec047800dc4753cba | AaronDonaldson74/code-challenges | /python/biggest_smallest.py | 591 | 4.15625 | 4 | ### biggest / smallest function
def biggest_smallest(selection, list_of_numbers):
# list_of_numbers = [43, 53, 27, 40, 100, 201]
list_of_numbers.sort()
smallest_num = (list_of_numbers[0])
biggest_num = (list_of_numbers[-1])
# selection = ("small")
if selection == ("small"):
print("sm... |
092c64fb38b2fa9190c62f47d53bfa2f1cb693f3 | AaronDonaldson74/code-challenges | /python/birthday.py | 508 | 4.78125 | 5 | # Create a variable called name and assign it a string with your name. Create a variable called current_year and assign it an int. Create a variable called birth_year and assign it an int. Using the following variables print the following result. Please print it using the f"" way.
# Example result: "Hello, my name is D... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.