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 |
|---|---|---|---|---|---|---|
696ca3fa9cf624a24dcf7a00d48b854fba6a72f0 | ImmortalKirill/infa_2020_klimanov | /Lab21/Task14.py | 255 | 3.765625 | 4 | import turtle
turtle.shape('turtle')
turtle.left(180)
def star(n):
i = 0
while i < n:
turtle.forward(80)
turtle.left(180 - 180/n)
i += 1
star(5)
turtle.right(180)
turtle.penup()
turtle.forward(200)
turtle.right(180)
turtle.pendown()
star(11) |
e8e66fb5683b6fcaf9966a8d50b1099233b9af7a | eletro/practice | /practice_1/Trofimova_year.py | 271 | 4.0625 | 4 | def calend():
year = input("Enter year: ")
if type(year) != int:
print 'please, enter number'
else:
if year%400 == 0:
print 'Leap'
elif year%100 == 0:
print 'not leap'
elif year%4 == 0:
print 'Leap'
else:
print 'not leap' |
219ef9054fe28680046f86296fbae2ecea2d4db5 | BridgeFour4/python-examples | /index lesson.py | 227 | 3.859375 | 4 | import random
name=input("enter your name")
print(name[0])
length= len(name)
print(length)
position=random.randrange(0,length)
if position<=length:
char =name[position]
print(char)
else:
print("thats out of range")
|
813a5288fc26121aee0081f4b9ab131a2190e321 | aprabhu84/PythonBasics | /Methods and Functions/Level 1/03_Makes_Twenty.py | 473 | 4.15625 | 4 | #MAKES TWENTY:
# -- Given two integers,
# -- return True if the sum of the integers is 20
# -- or if one of the integers is 20.
# -- If not, return False
#makes_twenty(20,10) --> True
#makes_twenty(12,8) --> True
#makes_twenty(2,3) --> False
def makes_twenty(number1, number2):
int_num1 = int(number1)
... |
f751e02345f05a8f287ff20671542153c6e88cac | aprabhu84/PythonBasics | /Methods and Functions/Level 2/02_Paper_Doll.py | 394 | 4.15625 | 4 | # PAPER DOLL: Given a string, return a string where for every character in the original there are three characters
# paper_doll('Hello') --> 'HHHeeellllllooo'
# paper_doll('Mississippi') --> 'MMMiiissssssiiippppppiii'
def paper_doll(someString):
resultString = ""
for pos in range(0,len(someString)):
... |
4bb645c2831bb073979233c99e028cb59ff39c39 | oratusxd/Python-Curso_em_Video | /Mundo_1/Aula7/desafio8.py | 354 | 4.125 | 4 | '''
Escreva um programa que leia valor em metros e exiba convetido em centímetros
e em milímetros
'''
metro = float (input('Coloque o valor em metros: '))
km = metro/1000
hm = metro/100
dam = metro/10
dm = metro*10
cm = metro*100
mm = metro*1000
print(f'{metro} metros medirá:\n{km}km, {hm} hm , {dam} dam\n{d... |
da69d4ff1ff431972add359c44e17f94fec4f885 | oratusxd/Python-Curso_em_Video | /Mundo_1/Aula6/desafio3.py | 177 | 3.875 | 4 | n1 = int (input('Coloque o primeiro número da soma: '))
n2 = int( input('Coloque o segundo número da soma: '))
s = n1 + n2
print(f'A soma entre {n1} e {n2} é igual a {s}') |
34b57231386b745e7e152c72cf6c979e5eaae437 | oratusxd/Python-Curso_em_Video | /Mundo_1/Aula9/desafio25.py | 253 | 3.796875 | 4 | '''
Exercício Python 25: Crie um programa que leia o nome de uma
pessoa e diga se ela tem “SILVA” no nome.
'''
nome = input('Qual é o seu nome completo? ').strip()
nome_min = nome.lower()
print('O seu nome tem Silva? ', 'silva' in nome_min) |
a5c6cd947ca2f16b0c08b3ead1da2af3cef26b4a | oratusxd/Python-Curso_em_Video | /Mundo_1/Aula7/desafio11.py | 463 | 3.90625 | 4 | '''
Crie um programa que leia a largura e a altura de uma parede em metros,
calcule a sua área e a quantidade de tinta necessária para pinta-la.
Sabendo que para cada 1l de tinta, pinta uma área de 2m²
'''
largura = float(input('Qual é a largura da parede? '))
altura = float(input('Qual é a altura da parede? '))... |
ea7cd1ce5318bfc2d68387a1b324ae884adb4118 | Aleksandraboy/basics | /homework/homework03_21.py | 4,898 | 4.09375 | 4 | #h/w 03/21/21
print('*** swap 2 variable values ****')
'''
how to swap 2 variable values. a=45 b=78 >> a=78 b=45
'''
a = 45
b = 78
print(f'a = {a} and b = {b}')
temp = a
a = b
b = temp
print(f'swaped a = {a} and swaped b = {b}')
print('\n'"*** count the vowels (гласные звуки) in any phrase/sentance/word ***")
# Count ... |
69676448ce157f72da1056f78387110759662054 | Aleksandraboy/basics | /if_condition.py | 3,233 | 4.4375 | 4 | #if statement
# if expression:
# code here when expression is true
# else:
# code here when expression is false
num1 = 2
num2 = 3
# if num1 < num2 :
# print("expression is true")
# else:
# print("expression is false")
# print("***********")
# if num1 == num2 : # comparing 2 values using ==
# print... |
2c7da9584cee536a955a7fe6bff827b9c6d3c172 | Aleksandraboy/basics | /homework/home work.py | 10,301 | 4.3125 | 4 | # Whitespace to strings with Tabs and Newline
print('Python')
print('\tPython') # add TAB to your text
print('Languages:\nPython\nC\nJavaScript') # add a NEWLINE
print('Languages:\n\tPython\n\tC\n\tJavaScript') # combine TAB & NEWLINE
#Striping Whitespases
# Exercise 2-3
print('\n'+'#Exercise 2-3')
msg = "Hello Eric,... |
46be0a96d81cb8c48dc94ab9a2883c6ffdbaddd8 | Aleksandraboy/basics | /nesting.py | 2,894 | 4.5 | 4 | # 03/20/21
# 1. A List of Lists
# 2. A List of Dictionary
# 3. A List in a Dictionary
# 4. A Dictionary in a Dictionary
print('*** 1. A List of Lists***')
countries = ['usa', 'russia', 'spain', 'france']
cities = ['new york', 'moscow', 'barcelona', 'paris']
companies = ['level up', 'abc company', 'ola company']
custo... |
8bbd2be57607834d402db0a75e6ed2dc1cf67a2f | mryoungci/projects | /py_learn/inherit.py | 980 | 3.9375 | 4 | class ShoolMember:
def __init__(self,name,age,sex):
self.name = name
self.age = age
self.sex = sex
print("Initializing ShoolMember:",self.name)
def tell(self):
print("Name:%s,Age:%s,Sex:%s" %(self.name,self.age,self.sex))
class Teacher(ShoolMember):
def __init__(s... |
7fab101d70672109dbcefb92396b0dbad5cd65af | mryoungci/projects | /py_learn/class_obj.py | 996 | 3.984375 | 4 | class person:
number = 0
list = []
def __init__(self,name):
self.name = name
person.number += 1
print("initializing")
person.list.append(self.name)
def __del__(self):
person.number -= 1
if person.number ==1:
print("I am the only person!")
... |
9021f1c36f27a46c2191e862950b818e817222b4 | jhl0204/Udacity-Programming-for-Data-Science-Nanodegree | /2_Python/Final_Project/bikeshare_2/Finished Functions/user_stats.py | 1,835 | 3.78125 | 4 | def user_stats(df):
"""Displays statistics on bikeshare users."""
print('\nCalculating User Stats...\n')
start_time = time.time()
# Display counts of user types
user_type_count = df["User Type"].value_counts()
print(user_type_count)
# Display counts of gender
# tried to use try / exc... |
7307907a81111a1a85e7e4c3b7405392be4539a2 | Rohanadityakumar/programming-with-python | /multiplication.py | 121 | 3.703125 | 4 | #printing the result of substraction
a=120
b=200
c=1500
result=a*b*c
print("multiplication of",a,b, "and",r,"is",result ) |
f6770fe45cf0b92b47143ef2a360bea15523c309 | Rohanadityakumar/programming-with-python | /program24.py | 428 | 3.78125 | 4 | import matplotlib.pyplot as grph
#values of x-coordinates towards left side
x=[1,2,3,4,5]
#values of y-coordinates toward up
y=[43,52,25,36,20]
#names for bars
name=['mon','tue','wed','thur','fri']
#plotting bar graph
grph.bar(x,y,tick_label=name,width=0.8,color=['red','blue','green','yellow','orange'])
#naming x-axis
... |
b6e3174095a418874504a288a361b5795b3aafbe | klim-goryaev/lesson2 | /z2back.py | 614 | 3.796875 | 4 | #словарь вопросов ответов
qa = [
{'question':"Как дела", 'answer': "Хорошо!"},
{'question':"Куда пойдешь?", 'answer':"На курсы"},
{'question':"Что делаешь?", 'answer':"Программирую"},
]
for quest in qa:
a=(quest["question"])
b=(quest["answer"])
while True:
user_say = input()
if user_s... |
2dcbbeeedcabbfd79f8be82585e8330e34e7826c | junteak/sbjectA_BMI | /subjectA-1.py | 1,066 | 3.703125 | 4 | '''
subject A
'''
# A-1
users = ["Bob", "Tom", "Ken"]
print(users)
# A-2
int_numbers = [1, 2, 3, 4, 5, ]
print(int_numbers)
# A-3
kazuma_info = ['kazuma', 'takashi', 35]
print(kazuma_info)
# A-4 範囲指定はコロン
members = ["Kazuma", "Makoto", "Ohira"]
print(members[0:2])
# A-5
kazuma_info = ["Kazuma", "Takahashi", 35]
p... |
0f0d4aca3a404655fe2e0e226e831b65d8d18307 | XDA-7/boids | /src/vector.py | 1,912 | 4.25 | 4 | """Vector module"""
from math import sqrt, sin, cos
class Vector:
"""2D Vector with operations useful to the program"""
def __init__(self, x: float, y: float):
self.x_val = x
self.y_val = y
def __add__(self, other: 'Vector'):
return Vector(self.x_val + other.x_val, self.y_val + oth... |
55abb2bb5efbba294e3821fed4d8690bad270a41 | pradeepprakhar/python-for-devops | /apps/todo-cli/cli0.py | 5,462 | 3.546875 | 4 | import os
FILE_LOC = "data.txt"
# color related code for better view on terminal
colors = {
'DANGER': '\033[91m',
'WARNING': '\033[33m',
'MILD': '\033[94m',
'OK': '\033[92m',
'RESET': '\033[0m',
'BLUE': '\033[94m',
'CYAN': '\033[96m',
}
format = {0: 5, 1:25, 2:10, 3:25, 4:5... |
20127e1855c3307e7b25812eccb46818d7db4609 | JoseVteEsteve/Lists | /LI_03.py | 289 | 4.1875 | 4 | #given a list of numbers, find and print all the elements that are greater than the previous element.
list = [1,3,7,9,2,4,11,10,8,5,14,16]
n = len(list)
max = 0
for i in range(n):
if list[i] > list[i - 1]:
print(str(list[i]) + " is greater than " + str(list[i - 1]))
|
430f842df39886fa2f0044bc3d2108e897ea4b8e | lauralebu/wit-Project | /laura/sorting.py | 1,359 | 4 | 4 | def sort_list(list):
def sort_list(entered_list):
evens=[]
odds=[]
chars=[]
dictionary_of_list = dict()
list_length = len(list)
list_length = len(entered_list)
i=0
while i<list_length:
if i%2 ==0:
evens.append(i)
elif i%2 == 1:
odds.ap... |
d4fecfd9aa79660a4008880962653fe15ab72fa9 | ben-nathanson/miscellaneous | /pacer.py | 746 | 3.90625 | 4 | from time import sleep
def format(d) -> str:
return str(int(d)).zfill(2)
time_in_minutes = int(input("How many minutes long is your exam?\n"))
number_of_questions = int(input("How many questions are on the exam?"))
if number_of_questions <= 0:
exit()
if time_in_minutes <= 0:
exit()
pace = time_in_minute... |
4bd1142c424c0dbe8f7866f596d1dcb5aef8efc6 | douglas-hetfield/CURSOS | /Programacao III/Programas/2019_2/CCT0696_1/PESSOA/EXEMPLO7_DICT_1/MODELO.py | 1,250 | 3.859375 | 4 | class Pessoa(object):
_nomePessoa_ = None
_idadePessoa_ = None
_salarioPessoa_ = None
_codCargo_ = None
def __init__(self,nome,idade,salario,codcargo) -> None:
super().__init__()
self._nomePessoa_ = nome
self._idadePessoa_ = idade
self._salar... |
791fcaa7a1be6258e07cc277661bab022488dfda | MadhuV99/shubham_tk_sql3 | /sql3_intro/sql3_funcs.py | 1,561 | 3.96875 | 4 | # sql3_intro using https://sqlitebrowser.org/
import sqlite3
conn = sqlite3.connect('mycompany.db')
curr = conn.cursor()
qry_stmt = "CREATE TABLE IF NOT EXISTS employees(id INTEGER PRIMARY KEY, name TEXT, salary REAL, department TEXT, position TEXT)"
print(qry_stmt)
curr.execute(qry_stmt)
conn.commit()
def sql_fetch... |
2e5ddf1d821073c90510829391a670c83ae08079 | HananeKheirandish/Assignment2 | /Second-to-Time.py | 233 | 3.90625 | 4 | import math
Second = int(input("please enter second: "))
hour = Second / 3600
minute = (Second % 3600) / 60
second = (Second % 3600) % 60
print(str(int(hour)).zfill(2),":",str(int(minute)).zfill(2),":",str(int(second)).zfill(2)) |
340ae067444d465b6f62d6e512544c76e494130a | sagardspeed2/PythonMiniprojects | /pattern/32123/pattern.py | 427 | 4.15625 | 4 | num = int(input("enter numbers of rows"))
# for i in range(1,num+1):
# for j in range (1,num-i+1):
# print(end=" ")
# for j in range (i,0,-1):
# print(j,end="")
# for j in range (2,i+1):
# print(j,end="")
# print()
for i in range(1, num+1):
for j in range(1, num-i+1):
pri... |
c067e4825f746f4a61dac2d838da027b4cdf2a77 | 3rduncle/LittlePythonTools | /struct/trie.py | 2,526 | 3.546875 | 4 | import sys
class Node(object):
def __init__(self, key, meta = None):
self.key = key
self.meta = meta
self.parent = None
self.children = {}
def add_child(self, node):
key = node.key
hold = self.children.get(key)
if hold is None:
hold = self.children.setdefault(key, node)
hold.parent = self
el... |
0c95d7d2d5775ff2d43cd8007b43ac7457f60762 | paolobejarano/desarrolllo-de-soluciones-UP | /Laboratorio2/lab2_ejercicio4.py | 960 | 3.578125 | 4 | import sqlite3
def obtener_resultado4():
"""Retorna el número de cliente"""
try:
db = sqlite3.connect("linioexp_parcial.db")
lista_resultado = None
cursor = db.cursor()
query = "SELECT producto.nombre, SUM(cantidad) FROM linea_pedido INNER JOIN producto ON linea_pedido.id_produc... |
4b7f4c2120a385d0387838a7aaf034044be7a790 | DUDA18/ProgISD20202-1 | /Maria_Eduarda/aula 3/aula3.py | 826 | 4.25 | 4 |
import math #Importando Math
print("Python")
#Declarando variaveis
varString="maria"
p,l=9,4
escolha=True
variavel=list()
#printando type e variavel na tela
print(varString)
print(type(variavel))
print(type(varString))
print(type(p))
print(str(p) + "top" + str(escolha))
#Captando informações e usando a biblioteca m... |
36aadb141f00e95170ec2c3a72c6f316f64b527f | DUDA18/ProgISD20202-1 | /Carolina/Aula 3/imc_exercicio2.py | 460 | 3.875 | 4 | import math
#valores do peso e altura
peso=float(input('Insira seu peso '))
altura=float(input('Insira sua altura '))
#IMC
imc= peso/math.pow(altura,2)
#Mostrando o valor de IMC
print(imc)
#Mostrando a analise do IMC
print ("Muito abaixo do peso",imc<17.0)
print ("Abaixo do peso",imc>=17.0 and imc<18.5)
print ("Peso... |
19868903677cb569ecb893a0329d401de2940d29 | DUDA18/ProgISD20202-1 | /Maria_Eduarda/aula8/aula8.py | 1,733 | 3.5625 | 4 | import csv
"""F=open('novo.txt','w') #CriarArquivo
print(F)
#Escrever
F.write("Lá vem esse tal Hello world novamente\\n \n")
F.write("Queria que o platfor.io me ajudasse\n")
F.write("Eu só queria que ele deixasse eu dá start no django\n")
F.close()#tudo que abre fecha
F=open('novo.txt','r')
#print(F.read())#Ler
print(F... |
1b6f7ff5a8a95a56c2c1490a5868e1cf932d7639 | DUDA18/ProgISD20202-1 | /Maria_Eduarda/aula 7/Code2A7.py | 690 | 4.0625 | 4 | import math #Importando a biblioteca math para uso de operações como pow
#Função que calcula o IMC
def FuncImc(peso,altura):
imc= round(peso/math.pow(altura,2),2)
if (imc<17.0):
print ("Imc:",imc,"Muito abaixo do peso")
elif (imc>=17.0 and imc<18.5):
print ("Imc:",imc,"Abaixo do peso")
... |
ef658927b0d5cf2a4db44064a36d4c185eb07ff0 | khanak077/Number-Guessing | /number guessing.py | 1,488 | 4.03125 | 4 | n = int(input("Enter no. from 1 to 10: "))
x = 8
for i in range(3):
if (n != x):
if (i == 1):
print("The no. entered is wrong. Two chance left")
n = int(input("Next chance: "))
elif (i == 2):
print("The no. entered is wrong. One chance left")
... |
e84c9552baee3c0fd7fc7f7de2edc18790b5499c | ai-coordinator/Python_turtle_graphics | /Python_turtle_graphics1.py | 371 | 3.671875 | 4 | import turtle
tur=turtle.Turtle()
scr=turtle.Screen()
scr.bgcolor('black')
tur.pencolor('white')
x=0
y=20
tur.speed(0)
tur.penup()
tur.pendown()
colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow']
while True:
tur.pencolor(colors[y%6])
tur.forward(x)
tur.right(y)
x +=3
y +=1
if y==... |
bab49aed7cf61572bc5c038a62801734bf9f1f05 | tieje/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/1-search_replace.py | 221 | 4.03125 | 4 | #!/usr/bin/python3
def search_replace(my_list, search, replace):
def replacethis(x):
if x == search:
x = replace
return x
new_list = list(map(replacethis, my_list))
return new_list
|
13138b77fa5fe0557b188da3345505699a204339 | tieje/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/9-multiply_by_2.py | 168 | 3.6875 | 4 | #!/usr/bin/python3
def multiply_by_2(a_dictionary):
def mult2(x): return (x[0], x[1] * 2)
new_dict = dict(map(mult2, a_dictionary.items()))
return new_dict
|
c31e3efad554b39ec12d2feb176f2283bd6cc101 | tieje/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/tests/test_models/test_square.py | 2,578 | 3.890625 | 4 | #!/usr/bin/python3
"""
Tests for Square class
"""
import unittest
from models.square import Square
class TestSquareMethods(unittest.TestCase):
"""
Square class tests
"""
def test_string_input(self):
'''String Input'''
with self.assertRaises(TypeError):
Square("word", 'up')... |
a9058750c8113f5f28dfb4517dce750b7c9e3a9c | tieje/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/models/base.py | 3,180 | 3.53125 | 4 | #!/usr/bin/python3
"""
Base class for almost a circle
"""
import json
import csv
class Base:
"""
Base class for almost a circle
"""
__nb_objects = 0
def __init__(self, id=None):
if id is not None:
self.id = id
else:
__class__.__nb_objects += 1
s... |
a3d204581bd24365e6ebb3ce7fb1d750e795237f | tieje/holbertonschool-higher_level_programming | /0x0B-python-input_output/0-read_file.py | 240 | 4.1875 | 4 | #!/usr/bin/python3
"""This module reads a text file"""
def read_file(filename=""):
"""This method reads a file."""
with open(filename, mode="r", encoding="utf_8") as file:
for line in file:
print(line, end='')
|
c3d7cbd6973b6fa1a7ca1933e966e39c9a4ad96a | LukasMaly/spot-it-generator | /spotit/cards.py | 1,805 | 4.03125 | 4 | from itertools import *
import math
def is_prime(n):
"""
Check if number is a prime.
:param n: number to be checked
"""
if n % 2 == 0 and n > 2:
return False
return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))
def create_cards(p):
"""
Creates the l... |
32040098ac2f626214124dab1cc919b8aebd8eb9 | GaryGonzenbach/python-exercises | /control_structures_examples.py | 1,991 | 4.3125 | 4 | print('Good Morning Ada!')
i_like_coffee = True # switch to False to test else
if i_like_coffee:
print('I like coffee!')
else:
print('Ok - lets have some tea')
# ---
pizza_reference = input('What kind of pizza do you like?')
if pizza_reference == 'pineapple and hot sauce':
print('Wow - what a coincidence!... |
542bc2de921ccde30b7cd39e1d712e66de532b07 | GaryGonzenbach/python-exercises | /4.7_numpy_exercises.py | 3,552 | 4.125 | 4 | import numpy as np
print(' 4.7 numpy exercises ')
# Exercise 1)
# How many negative numbers are there
a = np.array([4, 10, 12, 23, -2, -1, 0, 0, 0, -6, 3, -7])
less_than_zero = a < 0
n_true = less_than_zero.sum()
print('Exercise 1: There are ',n_true,' negative numbers in the array.')
# Exercise 2)
# How many posi... |
5112196d156033ae656e6bc974bbea1fa7a77cfa | LYTXJY/intermediate_python | /intermediate/debugging.py | 5,156 | 4.25 | 4 | """
python 进阶
"""
import time
# debugging
def debugging_test():
"""更多的操作,请看官方文档
"""
pass
def timmer(func):
def deco(*args, **kwargs):
print('\n函数:{_funcname_}开始运行:'.format(_funcname_=func.__name__))
start_time = time.time()
res = func(*args, **kwargs)
end_time = tim... |
c2e249e9cdc42daafe8192fea880550982ad0487 | LemonGuai/python_study | /ex16_0.py | 502 | 3.9375 | 4 | from sys import argv
script, file_name = argv
print(f"so you want to open the file of {file_name}")
print("if you don't want to open the file,hit CTRL-C")
print("if you want to continue,hit RETURN")
input("?")
txt = open(file_name,'w')
print("let's trunsate the file!")
txt.truncate()
print("now let's input 3 lines.... |
4eb47d48b74afbddaa83dae0a6575373d1e696dd | LemonGuai/python_study | /hw_3_2_1.py | 345 | 3.625 | 4 | with open('random.txt', 'r') as file:
text = file.readlines()
item_list = [num.strip() for num in text]
# print(item_list)
set_list = set(item_list)
count_list = []
for i in set_list:
count = item_list.count(i)
count_list.append(count)
max_count = max(count_list)
print(item_list)
print(set_list)
print(max_... |
ea60ef0d5cf6e90235b3911d4f2556517493267a | LemonGuai/python_study | /hw_2_1.py | 612 | 3.984375 | 4 | # 身体质量指数BMI
weight, height = eval(input('请输入您的体重(kg)与身高(m),以逗号分隔:'))
int_weight = int(weight)
int_height = float(height)
int_height_2 = pow(int_height,2)
bmi = int_weight / int_height_2
# bmi = bmi_0.format('%.2f')
if bmi < 18.5:
print(f"您的身体质量指数BMI为: {round(bmi,2)},too thin")
elif 18.5 <= bmi <= 23.9:
print... |
1ee45d2d280941d1f306e1a7732f1e6f5311e94d | Yair345/App-Schedualer | /Server/server.py | 1,935 | 3.546875 | 4 | import socket
import select
import files
import codecs
LISTEN_PORT = 34679
MAX_MSG_LENGTH = 1024
def server():
print("Setting up server...") # control
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # server socket
server_socket.bind(('0.0.0.0', LISTEN_PORT))
server_socket.listen(... |
3fc7b8f7b09a888a8e002d74e062a8dc86eb7cc1 | luitrach/Assignments | /Python Task5.py | 2,068 | 4.0625 | 4 | #Question 1: Write a program in Python to allow the error of syntax to be handled using exception handling.
x = int(input("Enter a number : "))
y = int(input("Enter another number : "))
try:
print(x/y)
except Exception:
print("Number is not divisible")
#Question 2: Write a program in Python to allow the user t... |
ef5ea698a78987ed3e3a4249e5737e12a38da831 | Gustavasa/PG_ENY | /personality_ENY.py | 842 | 3.53125 | 4 | import webbrowser
name = "Erik"
state="michigan"
city="quatemala"
tvshow="flash"
composer="hans zimmer"
book = "LOTR"
password= "erik"
url= "https://www.google.com/search?q=memes&rlz=1C1GCEA_enUS752US752&source=lnms&tbm=isch&sa=X&ved=0ahUKEwi_iaDwytfWAhUK2oMKHbq8BgUQ_AUICigB&biw=1034&bih=615"
print( name + "... |
223bfd35534d09e3aa61f551cf668210cc031f0e | Syed-Osama-Hassan/Data-Mining | /Multinomial Logistic Regression.py | 4,038 | 4.03125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[47]:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
def main():
# Reading data
data = pd.read_csv(r"C:\Users\Syed\Desktop\Studies\7th Semester\Data Mining\Assignments\data.csv", header= None)
# Reading output variable
Y = pd.read_csv... |
4aebdfbac29113ce42aad6100af647535a69f0f3 | ZachsFinalForm/Python | /timeClock.py | 1,653 | 3.59375 | 4 | #Author: Zach Page
#Date: 11/10/2020
#Filename: timeClock.py
#import utility class
import utilities as u
## Adding hours or minutes or seconds to datetime
from datetime import datetime, timedelta
## Original datetime
datetime_original = datetime(year=2020, month=11, day=10)
print("\nOriginal date: ", ... |
b5380a339184ce5a54a3703e0f7169209ae2d043 | dglass710/BinaryAdder | /adder.py | 2,518 | 3.6875 | 4 | def xor(a, b):
return (a or b) and (not (a and b))
def bit(a, b, c):
return int(xor(bool(a), xor(bool(b), bool(c)))), int(xor(bool(a), bool(b)) and bool(c) or (bool(a) and bool(b)))
def cushionZeros(strg, val):
while len(strg) < val:
strg = '0' + strg
return strg
def nBit(a, b, n):
'returns ... |
b27acfbc54aeae4b5741ed27fa849e09d9c8a46a | skyrydberg/LPTHW | /ex3/ex3.py | 1,251 | 4.25 | 4 | # Exercise 3: Numbers and Math
# I addressed Exercises 1 & 2 in the same post because they
# are trivial. This one gets its own post.
print "I will now count my chickens:"
# Note the order of operations holds here, a kind programmer
# would type this 25 + (30 / 6) for clarity, we divide 30 by 6
# and then add the res... |
ebb8c38815ff77757aadc8887155c04b6fa5ef8c | orbardugo/English_Exams_System | /src/Student.py | 5,516 | 3.78125 | 4 | import json
import os
import random
import time
class Student(object):
def __init__(self, name, ident):
self.name = name
self.ident = ident
self.correct_ans_counter = 0
def train(self):
""" train function will gives you all types of questions, when you answer you will receive ... |
dab994e9d45444d7976d1d0e97048a3832383d4a | papaniivanderpuye/Public-Projects | /Mario Game(Python)/bricks.py | 10,357 | 3.59375 | 4 | ################################################
# bricks.py
# This module contains the platforms, boundaries and coins for the Super Mario game
# Papa Nii Vanderpuye and Adolfo Pallares-Aceves
################################################
import pygame
BLACK = ( 0, 0, 0)
WHITE = ( 255, 255, 255)
BLUE ... |
f798f1d73e19b0726b81648adc63e914293d88b0 | andrediluca/fft_advlabprj | /software/lut_generator.py | 700 | 3.78125 | 4 | import numpy as np
#Conversion to hex
#Ref: https://stackoverflow.com/questions/7822956/how-to-convert-negative-integer-value-to-hex-in-python
def tohex(val, nbits):
return hex((val + (1 << nbits)) % (1 << nbits))
frequency = 1
npoints = 1024
nbits = 8
cos_name = "cos.mem"
sin_name = "sin.mem"
f = open(cos_name... |
dc04dba396316ac1216b1e1e14cf677a68e10925 | TJRobson/MITx6.00.2x | /quiz/quiz_code.py | 3,863 | 3.75 | 4 |
def song_playlist(songs, max_size):
"""
songs: list of tuples, ('song_name', song_len, song_size)
max_size: float, maximum size of total songs that you can fit
Start with the song first in the 'songs' list, then pick the next
song to be the one with the lowest file size not already picked, repeat... |
484f6d035f4c5e47f5e26ab5e876a3191bf1c95e | iaalharbi/python | /numbers.py | 97 | 3.609375 | 4 | print(10+int("20"))
print(20-21)
num1 = 11
num2 = 1.6
print(round(num1*num2))
print((num1*num2)) |
86cdc938a3394a0bd36f98b942f59bc40120f0b2 | AbChatt/Final-Project-C11-Part-1-Python | /cross_validation.py | 4,848 | 3.875 | 4 | """
CSCC11 - Introduction to Machine Learning, Winter 2020, Exam
E. Franco, B. Chan, D. Fleet
===========================================================
COMPLETE THIS TEXT BOX:
Student Name: Abhishek Chatterjee
Student number: 1004820615
UtorID: chatt114
I hereby certify that the work contained here is my own
... |
4343370f437195041ddd01452ccef77d340493c4 | gitsubas/gitsubas.github.io | /dictonaries.py | 189 | 3.5 | 4 | relation = {"Subas": "self", "Ashok": "eldest brother", "Krishna": "elder brother", "Anupam": "nephew"}
relation["Anubhav"] = "nephew"
print(relation["Anupam"])
print(relation["Anubhav"]) |
e6a677240c2017f26eda6293616963dc0b5ba100 | andreeaantohe/OSSS | /python/min_max.py | 925 | 3.8125 | 4 | #!/usr/bin/env python
import sys
def usage():
print >> sys.stderr, "Usage: python %s <filename>" % (sys.argv[0])
def main():
print "Program arguments are:", sys.argv
print "Number of arguments is:", len(sys.argv)
if len(sys.argv) != 2:
usage()
sys.exit(1)
try:
fp = open(... |
2862f0fad3f7130b73bcf08e912338d22c8de42a | zy19525/python_sudoku | /24-26.py | 6,023 | 3.5625 | 4 | from random import seed
from random import randint
import random
import numpy as np
import time
def place():
one=[]
for i in range(3):
seed()
block=[(i*3+1),(3*i+2),(3*i+3)]
random.shuffle(block)
one=one+block
return one
def rowcol():
row=place()
... |
035702c58117076aefc9164541944d0c7c575000 | hyoungsookim/data_structures | /data_structure.py | 2,220 | 3.921875 | 4 | """
Data structure implementation
"""
class Stack(object):
def __init__(self):
self.__data = []
@property
def is_empty(self):
return len(self.__data) == 0
@property
def size(self):
return len(self.__data)
def push(self, value):
self.__data.append(value)
d... |
e7a205d9c407330033e77825e266a1f98ea92738 | z-arnott/SYSC3010_zoe_arnott | /Lab-3/lab3-database-JSON.py | 1,617 | 3.84375 | 4 | import requests
import json
import sqlite3
from sqlite3 import DatabaseError
# The URL that is formatted: http://api.openweathermap.org/data/2.5/weather?APPID=a808bbf30202728efca23e099a4eecc7&units=imperial&q=ottawa
# As of October 2015, you need an API key.
# I have registered under my Carleton email.
apiKey = "a80... |
0e8e36a6fd272fd09ec298712db8337614936a95 | musabedin/Algorithms-and-Data-Structures-using-Python | /Chapter 3/33selfcheck.py | 247 | 4.03125 | 4 | # write two Python functions to find the minimum number in a list.
# The first function should compare each number to every other number on the list O(n^2)
# the second function should be linear O(n)
def find_min_slow:
def find_min_fast: |
2addc52e7a8decde57d26f8a9872c8d2b75d0eac | WenboTien/ML_school_assignments | /project1/tiny1_2/test_script.py | 3,305 | 3.578125 | 4 | # will ``sample_submission`` to your submission filename.
from sample_submission import regressor
import numpy as np
def rmse(a, b):
"""
This function produces a point-wise root mean squared error error between ``a`` and ``b``
Args:
a: first input ndarray
b: second input ndarray
Retu... |
bc41a28c09aeada6df75e0cbe5174d7e368f88b9 | DSarceno/CursoProgra2020 | /Miscelaneos/attendance.py | 1,361 | 3.515625 | 4 | # This script needs two arguments in terminal after the python command:
# - 0: attendande.py
# - 1: csv file with previous assistance
# - 2: txt file with assistance list
import sys
attendance_file = sys.argv[2]
dataBase = sys.argv[1]
data_base_file = open(dataBase, "r")
data_base = []
for line ... |
9930e0cbb12bd6e0ee819606807eba18560d0336 | EricSchles/web_scraping | /linkedlists.py | 392 | 3.5625 | 4 | class Node:
def __init__(self,data=None,next=None):
self.data = data
self.next = next
def __str__(self):
return repr(self.data)
if __name__ == '__main__':
head = Node()
cur = head
for i in xrange(1000):
node = Node(i)
cur.next = node
cur = cur.next
... |
c79ec0a054554378f82f132bb47ee02d3f15c556 | kazeichev/computer_science | /Data_Structures_1/Stack/postfix.py | 806 | 3.609375 | 4 | from stack import Stack
def postfix(string):
stack_1 = Stack()
stack_2 = Stack()
operands = ['+', '*', '=']
for i in reversed(string.split(" ")):
stack_1.push(i)
while stack_1.size() > 0:
st1_element = stack_1.pop()
if st1_element in operands:
if st1_element ... |
f4fb835a6da7ffdcddc29e653f67c8c8b75796c2 | kazeichev/computer_science | /Data_Structures_1/LinkedList/linked_list.py | 2,864 | 3.984375 | 4 | class Node:
def __init__(self, v):
self.value = v
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
def add_in_tail(self, item):
if self.head is None:
self.head = item
else:
self.tail.next = ite... |
56f0fdf2593493d1ef3dd85c38441eaa7b468da7 | kazeichev/computer_science | /Data_Structures_2/BinarySearchTreeAsArray/binary_search_tree_as_array.py | 2,154 | 3.6875 | 4 | class aBST:
def __init__(self, depth):
# правильно рассчитайте размер массива для дерева глубины depth:
tree_size = pow(2, depth + 1) - 1
self.Tree = [None] * tree_size # массив ключей
def FindKeyIndex(self, key):
"""
ищем в массиве индекс ключа
:param key:
... |
18d96632ae05bfecd1fca76913700e1e41e759fb | ryancbolton/piliaenlle-sheep-and-wolves | /SemanticNetsAgent.py | 4,670 | 3.65625 | 4 | class State:
def __init__(self, state_vars, num_moves=0, move=(0, 0), parent=None):
self.state_vars = state_vars
self.num_moves = num_moves
self.parent = parent
self.move = move
@classmethod
def initialState(cls, initialSheep, initialWolves):
return cls((ini... |
ee610a4257cd6556b089ea082a89fc3b30aaaf98 | chenguiyuan/Leetcode | /1twosum.py | 451 | 3.640625 | 4 | class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
map = {}
for i, num in enumerate(nums):
if target - num in map:
return([map[target - num], i])
els... |
290b92824f048fc849d805f67119df8353f3da9c | canyon289/LandingAI | /landingai/image.py | 4,941 | 3.609375 | 4 | """
All methods required to make the test and train images for the
classifier
"""
import shutil
from random import randint, sample, choice
from collections import namedtuple
import os
import string
from PIL import Image, ImageFont, ImageDraw
CHARACTERS = string.ascii_letters + "."
FONT_DIR = os.path.join(os.path.dirn... |
b1341ab4c376cd08ea589285db1f06313e24769d | Melinal23/Trees | /second_minimum_node.py | 1,301 | 3.65625 | 4 | from collections import deque
"""brute force solution"""
def findSecondMinimumValue(self, root):
path = []
self.helper(root, path)
if len(path) <= 1:
return -1
path = sorted(path)
return path[1]
def helper(self, root, path):
if not root:
return
if root.val not in pat... |
d6baad5f46041d84793c16203266d21f47bee4c7 | Melinal23/Trees | /insert_node_BST.py | 401 | 3.796875 | 4 | class TreeNode:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def insertIntoBST(root, val):
if root is None:
return TreeNode(val)
elif root.val > val: # insert left
root.left = insertIntoBST(root.left, val)
elif root.val < val: # ... |
a38bc51045b3c846595a1a9481fe2d43f342a508 | Melinal23/Trees | /double_tree.py | 877 | 3.90625 | 4 | """For each node in a binary tree, create
a new duplicate node, and insert the duplicate
as the left child of the original node."""
class TreeNode:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def doubleTree(root) :
if root is None:
return None... |
61b3eb028412ab169bfa3b130b8dc3d6d698f8ff | sean-donoghue/recommender | /streamlit_app.py | 2,204 | 3.796875 | 4 | import pandas as pd
import streamlit as st
# List of users
user_list = {
'---': -1,
'Melissa': 1,
'Hasan': 2,
'Megan': 3,
'Brian': 5,
}
# Show title and dropdown list of names
st.title('Movie Recommender')
name = st.selectbox(
'Choose a user to look at:',
[... |
9396ed1a28a89a69d92ce11f9eeac0bc2a5ba855 | Ramy34/Sistemas_Embebidos | /Practica 02 (Leds y botones)/semaforo2.py | 1,037 | 3.765625 | 4 | from gpiozero import LEDBoard,Button
from time import sleep
leds = LEDBoard(5,6,13,19,26,17)
boton = Button(2)
def semaforo(n):
while True:
sleep(5)
if boton.is_pressed:
if n == 0:
n = 1
else:
if n == 2:
n = 3
... |
0d194f7e07fd103fe14cb0e8d8cfdd1747fab2b3 | Simi16/Python_pratice | /first.py | 3,599 | 3.796875 | 4 | #In this program, only use if-elif-else a basic menu to complete this task and it is design for windows base os.
#Menu Run For Base Operating System:
import os
print("Hello This is the windows chatbox:")
while True:
print("Chat With Me with Your Requirement: ", end='')
p=input()
if (("open" in p) or ("run"... |
8ca8633302ecbd2f5162970a2bcb8bb8a15abe1e | NaNdalal-dev/Tree-DS | /bst.py | 1,864 | 3.953125 | 4 | class BinarySearchTree:
def __init__(self,key):
self.key = key
self.left = None
self.right = None
def insert(self,value):
if self.key is None:
self.key = value
return
if self.key == value:
return
if value < self.key:
if self.left:
self.left.insert(value)
else:
self.left = BinarySea... |
817d89ed6ff26adfe99d9481cdfb16ea21fca7e5 | amlan-dutta/Compititive-Programming | /python/Codechef/H1.py | 729 | 3.6875 | 4 | swaps=[(0,1),(0,3),(1,2),(1,4),(2,5),(3,4),(3,6),(4,5),(4,7),(5,8),(6,7),(7,8)]
primes=[3,5,7,11,13,17]
all=[(1,2,3,4,5,6,7,8,9)]
move={(1,2,3,4,5,6,7,8,9):0}
for board in all:
for j in swaps:
if board[j[0]]+board[j[1]] in primes:
newboard=list(board)
newboard[j[0]],newboard[j[1]]=n... |
55cf304e897f759727156f69cbc7240727e87fcb | amlan-dutta/Compititive-Programming | /python/GFG/tempCodeRunnerFile.py | 514 | 3.59375 | 4 | #User function Template for python3
class Solution:
def _sum(self,arr, n):
# code here
if n==0:
return 0
else:
return (arr[n-1]+self._sum(arr,n-1))
#{
# Driver Code Starts
#Initial Template for Python 3
# Driver code
if __name__ == "__main__":
tc=int(input())
while... |
5255ba483a0229f5fb038e48577933f01a95515d | git4lhe/lhe-algorithm | /Simulation/JadenCase문.py | 247 | 3.609375 | 4 | def solution(s):
s = s.lower()
answer = s[0].upper()
for idx in range(1, len(s)):
if s[idx-1].isspace() and s[idx].isalpha():
answer += s[idx].upper()
continue
answer += s[idx]
return answer |
99d6030e84497f13f3a459c98d1a761b21f2aa5e | git4lhe/lhe-algorithm | /programmers/level1/이상한_문자_만들기.py | 299 | 3.515625 | 4 | def solution(s):
split_s = s.split(" ")
for n, word in enumerate(split_s):
a = ""
for i, ss in enumerate(word):
if i % 2 == 0:
a += ss.upper()
else:
a += ss.lower()
split_s[n] = a
return " ".join(split_s) |
93b8af46f2920db8a2f45e8cf017532c3bcb2b9f | git4lhe/lhe-algorithm | /Greedy/카펫.py | 379 | 3.53125 | 4 | def solution(brown, yellow):
x,y= 3,3
while (1):
guess_br = x * y - (x-2) * (y-2)
guess_yellow = (x-2) * (y-2)
if guess_yellow < yellow:
y += 1
elif guess_br > brown:
x += 1
y = x
elif guess_br == brown and guess_yellow == yellow:
... |
74b5194f53c63a7d03dce54f0008d63149a07e2e | shangguanyunluo/ThePythonStandardLibrary | /calculation_method/quick_sort.py | 302 | 4.0625 | 4 | def quicksort(array):
if len(array) < 2:
return array
else:
pivot = array[0]
lower = [i for i in array[1:] if i <= pivot]
higher = [i for i in array[1:] if i > pivot]
return quicksort(lower) + [pivot] + quicksort(higher)
print quicksort([10, 5, 2, 3])
|
88b1968313d83d40876709efc88310f84a26e6fe | shangguanyunluo/ThePythonStandardLibrary | /calculation_method/quick_sort_demo001.py | 667 | 3.71875 | 4 | def sum(list):
if list == []:
return 0
else:
return list[0] + sum(list[1:])
print (sum([]))
print (sum([2, ]))
print (sum([2, 4, 6]))
print('-' * 20)
def count_list(list):
if list == []:
return 0
else:
return 1 + count_list(list[1:])
print (count_list([]))
print (c... |
dfc486730e6785d27835193516f39787da8ce3ce | hszymanski/projekt | /znaki.py | 99 | 3.609375 | 4 | #!/usr/bin/python
import string
S = string.ascii_letters
for x in S:
print x, "-", ord(x)
|
618535ad2c3d769521c1a60f73b2e37f26ee5cc3 | GaddamMS/PythonMoshYT | /own_program_weather_notify_0.py | 1,481 | 4.4375 | 4 | '''Feature: Intimate user with precautions based on weather when going outside
Problem Statement: We should identify the weather and tell the user of necessary precautions
Solution:
1. We will ask the user for temperature
2. Based on the given temperature, we will intimate user with self - defined precautions
'''
... |
51cbc77b07066c637b0cfc8da9a589bdadfaf6fc | rsx-utoronto/galaxy | /ground_station/RPi_Arduino_Communication/new_i2c.py | 1,037 | 3.671875 | 4 | import smbus, time
def read_int(address):
"""
Read 4 bytes (as a 32-bit int) from the i2c stream. The least significant bits are first.
Parameters:
address - address of the arduino
Returns:
an int from the stream
"""
result = 0
for i in range(4):
result += bus.read_byte(address) << i * ... |
ad23315a730c2a8f747a192f13fc05901d8fb75c | rsx-utoronto/galaxy | /rover/mcu/arduino.py | 3,010 | 3.78125 | 4 | # arduino.py
# Create a one-size-fits-all interface between Python (computer or Raspberry Pi) and Arduino.
import serial
from time import *
def connect_to_serial(): # def connect_to_serial(digital_outs):
"""
Establish a connection to the serial port and return it.
The name of the USB port i... |
d80d1698f476bac4ac1fb8226da14f8bd547ad8a | Accoustium/PyBites | /bite_30/directors.py | 2,106 | 3.671875 | 4 | import csv
from operator import attrgetter
from collections import defaultdict, namedtuple
import os
from urllib.request import urlretrieve
BASE_URL = 'http://projects.bobbelderbos.com/pcc/movies/'
TMP = 'tmp'
fname = 'movie_metadata.csv'
remote = os.path.join(BASE_URL, fname)
local = os.path.join(TMP, fname)
urlretr... |
2b0e96382fa359d678143d2bbd9ef7cc14d6cccb | Accoustium/PyBites | /bite_270/freq.py | 258 | 3.78125 | 4 | def freq_digit(num: int) -> int:
num_string = str(num)
highest = ' '
for val in num_string:
if num_string.count(val) > num_string.count(highest):
highest = val
return int(highest) if highest != '' else int(num_string[0])
|
31bb9b410c141f23967acdb65198638f975fcbe3 | DataAna1ytics/Programming_interview_questions | /Greenpeace_Prime_numbers/Prime_numbers_generator_in_Python.py | 519 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Aug 4 13:48:14 2017
@author: Gavrilov
"""
#Position: Senior business data analyst
#Task: Implement code to display prime numbers up to 100 in any programming language
#On-site interview
lower = 2
upper = 101
def prime(x,y):
result = []
for num in ran... |
454e7eaa709362b710359a1d9d8da4bfba1c1dac | covalenzuela/cvalenzuela_repoSoluciones | /Proyect1/maze.py | 5,874 | 3.84375 | 4 | # MAZE.PY
import turtle
class maze():
def __init__(self):
#register shapes
turtle.register_shape("star.gif")
turtle.register_shape("kirby.gif")
turtle.register_shape("wall3.gif")
#create Drawing
class Drawing(turtle.Turtle):
def __init__(self):
... |
7b28907cfd5737677e3d0380f631272847cfe936 | monsybr11/FirstCodingAttempts | /textrealiser.py | 535 | 4.21875 | 4 | abc = input("Type any text in.\n")
abc = str(abc) # converting the input to a string in case of text and digits being used.
if abc.islower() is True:
print("the text is lowercase!")
if abc.isupper() is True:
print("the text is Uppercase!")
if abc.isupper() is False and abc.islower() is False and ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.