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 |
|---|---|---|---|---|---|---|
8323d427d833cc9faaedecc8598c782e090b4dba | DanLivassan/clean_code_book | /chapter3/employee_clean_code.py | 1,457 | 3.640625 | 4 | from abc import ABC, abstractmethod
MANAGER_EMPLOYEE = 1
SELLER_EMPLOYEE = 2
"""
Switch statements should be avoid or buried in one class
(Ps.: Python have no switch statement but its like a if sequence)
"""
class Employee(ABC):
def __init__(self, name: str, employee_type: int, hour: float):
self.name ... |
a8a5edf3c6cf3f5a6470016eb6c5802e18df4338 | bharath-acchu/python | /calci.py | 899 | 4.1875 | 4 | def add(a,b): #function to add
return (a+b)
def sub(a,b):
return (a-b)
def mul(a,b):
return (a*b)
def divide(a,b):
if(b==0):
print("divide by zero is not allowed")
return 0
else:
return (a/b)
print('\n\t\t\t SIMPLE... |
b12f5b4ab877f09ba7ffbe98ed5ce569c8c475f8 | qzwj/learnPython | /learn/基础部分/序列化.py | 2,477 | 3.53125 | 4 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
# 我们把变量从内存中变成可存储或传输的过程称之为序列化,在Python中叫pickling,在其他语言中也被称之为serialization,marshalling,flattening等等,都是一个意思。
# 序列化之后,就可以把序列化后的内容写入磁盘,或者通过网络传输到别的机器上。
# 反过来,把变量内容从序列化的对象重新读到内存里称之为反序列化,即unpickling。
# d = dict(name = 'Bob', age = 20, score = 88)
d = dict(name='Bob', age=20, scor... |
da13a5588d74bedac440978ed66363fcc1d7fc24 | qzwj/learnPython | /learn/基础部分/类和对象.py | 4,325 | 3.9375 | 4 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
print('--------------类和对象-------------')
class Student(object): #object 继承object
pass
bart = Student()
bart.name = 'lwj' #感觉有点类似js的对象
bart.age = 25
print('name =', bart.name, ',age =', bart.age)
#ming = Student()
#print('name =', ming.name) #上面对象的变量不影响下面的, 下面的对象仍然没有这个n... |
c8166981f11f593d2dcee65efc6839a7796159a9 | Terminator163/tfkdr0dodu | /venv/nemazice.py | 256 | 3.765625 | 4 |
гшшыагщрку
date = input().split()
x = before_the_concert(date[0], date
8ehsioerhgihgiohoiesghoieshigheosgergihgoihore
date = input().split()
x = before_the_concert(date[0], date
date = input().split()
x = before_the_concert(date[0], date
|
9020848d921ee28d2d3ce6455b0c69aeb1089fdc | alehatsman/pylearn | /py/lists/find_nth_from_the_end_test.py | 392 | 3.5 | 4 | import unittest
from lists.test_utils import simple_list
from lists.find_nth_from_the_end import find_nth_from_the_end
class TestFindNthFromTheEnd(unittest.TestCase):
def test_find_nth_from_the_end(self):
ll = simple_list(10)
for i in range(0, 10):
self.assertEqual(9 - i, find_nth_fro... |
18aaa52439a63cf8158f67fe1578cd229e91f352 | alehatsman/pylearn | /py/lists/test_utils.py | 837 | 4.09375 | 4 | """
LinkedList test utils. Functions for generating lists.
"""
import random
from lists.linked_list import LinkedList
def simple_list(n):
"""
Generates simple linked lists with numbers from 0 to n.
Time complexity: O(n)
Space complexity: O(n)
"""
ll = LinkedList()
for i in range(n - 1, -... |
cdfec446b032f3161d3049c9c67da71dbd9680b1 | alehatsman/pylearn | /py/lists/linked_list.py | 2,403 | 3.84375 | 4 | """
LinkedList ADT implementation.
"""
class Node:
"""
Node represents Node ADT in LinkedList.
Usage:
Node(value)
"""
def __init__(self, value):
self.value = value
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def insert(self, valu... |
314a0e022ad79a3c9271b34e9a4dca94daeff484 | LostHeir/Coffee-Machine-oop | /main.py | 867 | 3.546875 | 4 | from menu import Menu, MenuItem
from coffee_maker import CoffeeMaker
from money_machine import MoneyMachine
coffee_menu = Menu()
espresso = MenuItem("espresso", 75, 0, 7, 1.2)
cappuccino = MenuItem("cappuccino", 125, 30, 10, 1.9)
latte = MenuItem("latte", 200, 100, 15, 2)
coffee_maker = CoffeeMaker()
money_machine = M... |
a1629771647bbf9b0ae5087e3bdf73734b905c85 | ovasylev/dev-sprint2 | /chap6.py | 330 | 3.921875 | 4 | # Enter your answrs for chapter 6 here
# Name: Olha Vasylevska
# Ex. 6.6
def is_palindrome(word):
length = len(word)
for i in range (length/2):
if word[i]!=word[length-1-i]:
return False
return True
print is_palindrome("noon")
# Ex 6.8
def gcd(a, b):
if b==0:
return a
else:
r = a % b
return gcd(b, r... |
b0c9d4b7b8644a9a25a671919869253fc9d86ad8 | piperpi/python_book_code | /Python编程锦囊/Code(实例源码及使用说明)/08/09/dataframe_drop_duplicates.py | 652 | 3.703125 | 4 | import pandas as pd
aa =r'../data/1月销售数据.xls'
df = pd.DataFrame(pd.read_excel(aa))
#判断每一行数据是否重复(全部相同),False表示不重复,返回值为True表示重复
print(df.duplicated())
#去除全部的重复数据
print(df.drop_duplicates())
#去除指定列的重复数据
print(df.drop_duplicates(['买家会员名']))
#保留重复行中的最后一行
print(df.drop_duplicates(['买家会员名'],keep='last'))
#inplace=True表示直接在原来... |
158a744489b862223cdc88890e5da7c535de81ff | piperpi/python_book_code | /Python编程锦囊/Code(实例源码及使用说明)/01/12/1.字符串去重的5种方法:/demo02.py | 415 | 3.703125 | 4 | # *_* coding : UTF-8 *_*
# 开发团队 :明日科技
# 开发人员 :Administrator
# 开发时间 :2019/7/1 16:23
# 文件名称 :demo02.py
# 开发工具 :PyCharm
name='王李张李陈王杨张吴周王刘赵黄吴杨'
newname=''
i = len(name)-1
while True:
if i >=0:
if name[i] not in newname:
newname+=(name[i])
i-=1
else:
break
print (newn... |
d2646ffd9542f0231615afebcf29893cf503cfcf | piperpi/python_book_code | /Python编程锦囊/Code(实例源码及使用说明)/03/01/createfile.py | 907 | 3.703125 | 4 | # !/usr/bin/env python3
# -*- coding: utf-8 -*-
# 开发团队 :明日科技
# 开发人员 :小科
# 开发时间 :2019/4/9 9:31
# 文件名称 :createfile.PY
# 开发工具 :PyCharm
'''
以当前日期时间创建文件
'''
import os
import datetime
import time
while True:
path=input('请输入文件保存地址:') # 记录文件保存地址
num=int(input('请输入创建文件的数量:')) # 记录文件创建数量
# 循环创建文件
fo... |
00b09af8de5cafd536f08b46fdbb8e917b0a6af6 | piperpi/python_book_code | /Python编程锦囊/Code(实例源码及使用说明)/02/02/方法1:利用zfill()函数实现数字编号/demo02.py | 1,158 | 3.578125 | 4 | # *_* coding : UTF-8 *_*
# 开发团队 :明日科技
# 开发人员 :Administrator
# 开发时间 :2019/7/2 13:49
# 文件名称 :demo02.py
# 开发工具 :PyCharm
import random # 导入随机模块
char=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'] # 随机数据
shop='100000056303' # 固定编号
prize=[] # 保存抽奖号码的列表
inside='' ... |
be5d95d9cbbd2c44a43149038aa15b55e2a22799 | piperpi/python_book_code | /Python高级编程(第二版)/chapter13/threads_one_per_item.py | 1,002 | 3.734375 | 4 | """
"An example of a threaded application" section example
showing how to use `threading` module in simplest
one-thread-per-item fashion.
"""
import time
from threading import Thread
from gmaps import Geocoding
api = Geocoding()
PLACES = (
'Reykjavik', 'Vien', 'Zadar', 'Venice',
'Wrocław', 'Bolognia', 'Ber... |
abdd6c39ce1f703848351413b7564d55bfa5d9c1 | hnagib/Parametric-Curves | /parametric_curve_functions.py | 7,389 | 3.515625 | 4 | import matplotlib.pyplot as plt
import numpy as np
from scipy.misc import *
import seaborn as sns
# Functions for constructing and plotting Bezier Curves
# ------------------------------------------------------------------------
def bezier_poly_interact(ctrl_points, pt, t=0.5, P1x=-1, P1y=2, P2x=3, P2y=2):
'''
... |
4510765c18aea20419106e1ec9c1cd22e84a8d84 | mayurigujja/PythonTest1 | /StringDemo.py | 143 | 3.578125 | 4 | Str = "Mayuri Gujja"
print(Str[0])
print(Str[2:5])
mun = Str.split(" ")
print(mun[0])
Str1 = " Mayuri "
print(Str1 in Str)
print(Str1. strip())
|
97f5dae4bd5a790d2628007409f09f7d4d02ecbe | bladedpenguin/meow | /main.py | 1,269 | 3.5 | 4 | """a little game about various things"""
import pygame as pg
# import menu
from main_menu import MainMenu
# from lore import Lore
from event import SCREEN_TRANSITION
class Game:
"""run the whole game"""
def __init__(self):
self.display = pg.display.set_mode([640, 480])
self.next_screen = None
... |
609322d1fb5216022d5cdaeba6c812ed9d6a4bf9 | haxsgvnbdus/UPGMA-clustering | /matrixTest.py | 312 | 3.90625 | 4 | '''
Created on Mar 15, 2017
@author: Hannie
'''
def matrixToList(table):
matrix = []
for i in range(0, len(A[0])):
row = []
for j in range(0, len(A[0])):
if i>j:
row.append(A[i][j])
matrix.append(row)
# print(pos)
print(matrix)
|
7cf42fdcdb3e23f2988006ce8cd2ac4773cf1dca | neiljdo/problem-solving-practice | /UVa/solved/12709.py | 645 | 3.640625 | 4 | import sys
import math
import bisect
def main():
while True:
n = int(sys.stdin.readline().strip())
if n == 0: break
# max h gives the largest downward acceleration
max_h = -math.inf
max_volume = -math.inf
for ant in range(n):
l, w, h = list(map(int,... |
873cb8a71f6bceb866c4cd88a442fd15edf52edc | neiljdo/problem-solving-practice | /EPIP/10_1.py | 1,307 | 4 | 4 | import sys
import math
import heapq
from functools import partial
from collections import namedtuple
"""
Test if a binary tree is height-balanced
i.e. abs(height(left subtree) - heigh (right subtree)) = 1 for each node of the tree
"""
# For trees, function call stack is part of the space complexity
class BinaryTree... |
047239ca05aa7e55383767f781c5f5f6b026389f | neiljdo/problem-solving-practice | /EPIP/8_1.py | 1,405 | 4 | 4 | import sys
import math
from functools import partial
from collections import namedtuple
"""
Create a stack with a `max` API.
"""
class Stack():
"""
O(1) space
straightforward approach is to compute the max every push
when popping:
* if element popped is < max, no issue
* if element popped is... |
212917d8632ff3d9d03628bcebd888fe356b6df4 | Indrasena8/Python-Programs | /GeometricProgression.py | 232 | 3.9375 | 4 | def printGP(a, r, n):
for i in range(0, n):
curr_term = a * pow(r, i)
print(curr_term, end =" ")
a = 2 # starting number
r = 3 # Common ratio
n = 5 # N th term to be find
printGP(a, r, n) |
04bd26afcd5d8f627206e8f311d27d7c9c0967dd | WahajAyub/RandomPythonProjects | /bounce.py | 2,000 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 29 13:47:34 2019
@author: wahaj
5"""
import math
class Box:
def __init__(self, mass, width, velocity, x):
self.m = mass
self.w = width
self.v = velocity
self.x = x
def checkCollision (self, other):
if (... |
541d24e31724f0e3b3180b9dfe3df381d05e510c | mateusfh/Concepcao | /MIPS/ADDAC/GoldenModel/somador.py | 230 | 3.640625 | 4 | def somador(a, b, carryIn):
y = a + b + carryIn
#print("Soma: ", y, a, b, carryIn)
cout = 0
if y > 1:
cout = 1
if y == 2:
y = 0
elif y == 3:
y = 1
return y, cout |
85be56b1f4f0ae5e51463b8ef7005fcef33fa357 | parasmaharjan/Python_DeepLearning | /ICP4/ClassObject.py | 1,226 | 4.125 | 4 | # Python Object-Oriented Programming
# attribute - data
# method - function associated with class
# Employee class
class Employee:
# special init method - as initialize or constructor
# self == instances
def __init__(self, first, last, pay, department):
self.first = first
self.last = last... |
502f19b51e091cbe13dd7c94e6eb3556dcbf6b8c | parasmaharjan/Python_DeepLearning | /ICP2/Problem2.py | 138 | 3.78125 | 4 | file = open("Text.txt", 'r')
line = file.readline()
while line != "":
length = len(line)
print(length)
line = file.readline()
|
3107e5dd759abedf9efcd6e894fda9aefd350c61 | parasmaharjan/Python_DeepLearning | /ICP5/Problem1.py | 688 | 3.53125 | 4 | import numpy as np
import matplotlib.pyplot as plt
data = np.array([[0, 1], [1, 3], [2, 2], [3, 5], [4, 7], [5, 8], [6, 8], [7, 9], [8, 10], [9, 12]])
x = np.array([0, 1, 2, 3, 4, 5, 6, 7 , 8, 9])
y = np.array([1, 3, 2, 5, 7, 8, 8, 9, 10, 12])
x_mean = np.mean(x)
print(x_mean)
y_mean = np.mean(y)
print(y_mean)
xx = x ... |
ed0a242d34f528c283284beb7857763bd60b75c3 | Adam-smh/ErrorHandling | /main.py | 1,723 | 3.5625 | 4 | from tkinter import *
from tkinter import messagebox
root = Tk()
root.title("Authentication")
root.config(bg="#e76f51")
root.geometry("500x600")
class Authentication:
def __init__(self, window):
self.username = Label(window, text="Enter Username:", font="25")
self.username.config(bg="#e76f51", f... |
38a9a38575095feae8c1ed3b8509d61abade119a | dannyleandro/TDDKataSimple-G12 | /test_estadistica.py | 873 | 3.59375 | 4 | from unittest import TestCase
from KataSimple import Estadistica
class TestEstadistica(TestCase):
def test_getArregloVacio(self):
self.assertEqual(Estadistica().getArreglo(""), [0], "cadena vacia")
def test_getArregloUnNumero(self):
self.assertEqual(Estadistica().getArreglo("1"), [1], "Un... |
88ea08642ab265bb8905d656916cae5922929d81 | Andrusha2999/pervaja | /pervaja.py | 586 | 3.875 | 4 | from module1 import *
while True:
print("funksioind".center(50,"+"))
print("arithmetic- A,\nis_year_leap-Y,\nseason- D ,\nyears- V")
v=input("arithmetic- A")
if v.upper()=="A":
a=float(input("esimene arv"))
b=float(input("teine arv"))
sym=input("Tehe:")
result=arithmetic(... |
49629b071964130f6fb9034e96480f7b5a179e51 | aakhriModak/assignment-1-aakhriModak | /01_is_triangle.py | 2,117 | 4.59375 | 5 | """
Given three sides of a triangle, return True if it a triangle can be formed
else return False.
Example 1
Input
side_1 = 1, side_2 = 2, side_3 = 3
Output
False
Example 2
Input
side_1 = 3, side_2 = 4, side_3 = 5
Output
True
Hint - Accordingly to Triangle inequality theorem, the sum of any two sides of
a triangl... |
cd9c9418168891a2255b5053d74b6db8cabafa82 | nevil-patel7/Astar-RigidRobots | /Project 3 Phase 3/Phase3.py | 11,657 | 3.515625 | 4 | import numpy as np
import matplotlib.pyplot as plt
import copy
import math
import time
#Variables
CurrentNode = []
UnvisitedNodes = []
VisitedNodes = []
CurrentIndex = 0
Rpm1 = 0
Rpm2 = 0
#Function to get Clearance,RPM
def GetParameters():
# global Rpm1,Rpm2
Clearance = int(input("Enter the C... |
34b54ec83214420e2b61b73a3c9f595cc9ca309d | xbash/Progra-0769 | /CLASES/holaPython18_1.py | 519 | 3.5625 | 4 | def validaNumero(promptText):
try:
x = int(float(raw_input(promptText)))
return x
except ValueError:
return None
def leerNumero(promptText):
x = validaNumero(promptText)
while(x == None):
x = validaNumero(promptText)
return x
try:
num = leerNumero('Ingrese num... |
95ae4edda6635d1e4ee9d27c3ce435d344695974 | xbash/Progra-0769 | /CLASES/holaPython12.py | 1,373 | 3.59375 | 4 | #Diccionarios
Guatemala = {'Capital':'Guatemala','Habitantes':15.08e6,'Extension':108889}
Eslovenia = {'Capital':'Liublijana','Habitantes':2.047e6,'Extension':20253}
Italia = {'Capital':'Roma','Habitantes':59.4e6,'Extension':301338}
Cuba = {'Capital':'La Habana','Habitantes':11.24e6,'Extension':110860}
print Guatemal... |
bfc62e67d675d594f83ddcd562fb5c44ed69a296 | xbash/Progra-0769 | /CLASES/holaPython11.py | 1,138 | 3.765625 | 4 | import random
#Mas sobre ciclos while
#Numero magico
def generaAleatorio(rango):
x = random.randrange(rango[0], rango[1], 1)
#print x #Imprimir el numero secreto: SOLO PARA DEPURACION
return x
def verifica(x, n):
"""
x: Ingresado por el usuario
n : Generado aleatoriamente al inicio del juego
... |
28ef97ef53a13df5260eb59cb610a624f2cad690 | dieuwkehupkes/POStagging | /HMMgenerator.py | 17,864 | 3.515625 | 4 | """
Functions to generate HMMs.
Add scaled smoothing lexicon dict (based on how often a word occured)
"""
from HMM2 import HMM2
import string
import numpy
import copy
from collections import Counter
import csv # do something with this
import sys
import itertools
class HMM2_generator:
"""
HMM2_generator i... |
ff99acfff83d155f961d08ebf9301d8cb706d8ae | gandreadis/danger-zone | /danger_zone/agents/car.py | 12,743 | 3.6875 | 4 | from danger_zone.map.map import MAP_SIZE
from danger_zone.map.tile_types import TILE_DIRECTIONS, Tile, NEUTRAL_ZONES
CAR_LENGTH = 3
CAR_WIDTH = 2
class Car:
"""Class representing a car agent."""
def __init__(self, position, is_horizontal, map_state):
"""
Constructs an instance of this class.... |
cec0813ca0fd3e4c623541014b9508b4f7af267b | prabyM/PassMan | /PassMan/db_handler.py | 448 | 3.59375 | 4 | import sqlite3
import os
file_present = os.path.isfile("credentials.db")
if file_present is False:
try:
open('credentials.db', 'w').close()
except Error as e:
print(e)
def create_connection(db_file):
""" create a database connection to a SQLite database """
try:
conn = sqlite... |
b39ee328950234e3ca4654f86a32cd0f4e41b849 | Bryan-20/t07_santamaria_baldera | /santamaria/codificadores_04.py | 233 | 3.5 | 4 | # iteracion decoficador 04
import os
msg=str(os.sys.argv[1])
for letra in msg:
if(letra == "P"):
print("Profesor")
if (letra == "F"):
print("Feliz")
if (letra == "N"):
print("Navidad")
#Fin_For
|
c66c83e5d5b08aa2a65fb8cccd93a35326f23c27 | Bryan-20/t07_santamaria_baldera | /santamaria/mientras03.py | 328 | 3.921875 | 4 | # Ejercicio nro 03
# Ingrese a1 y luego pedir a2, mientras a2 sea menor a a1
# Donde a1 es un numero para entero positivo
a1=1
numero_ivalido=((a1%2)!=0)
a2=0
while(numero_ivalido):
a1=int(input("Ingrese a1:"))
numero_ivalido=((a1%2)!=0)
while(a2<a1):
a2=int(input("Ingrese a2:"))
#Fi_While
print("A1=",a1,"A... |
ecd5aed47e007a597dd3ca6d1d755c3a4fb2099c | spontaneously5201314/Algorithms | /src/main/match/equal/Number.py | 449 | 3.71875 | 4 | def search(exp, nums):
if '_' not in exp or nums is None:
exps = exp.split('=')
if eval(exps[0]) == float(exps[1]):
print exps[0]+'='+exps[1]
return
else:
for num in nums:
e = exp.replace('_', num, 1)
ns = nums[:]
ns.remove(num)
... |
5097aa5c089e31d239b06bbd76e99942694cbdd7 | CBehan121/Todo-list | /Python_imperative/todo.py | 2,572 | 4.1875 | 4 | Input = "start"
wordString = "" #intializing my list
while(Input != "end"): # Start a while loop that ends when a certain inout is given
Input = input("\nChoose between [add], [delete], [show list], [end] or [show top]\n\n")
if Input == "add": # Check if the user wishes to add a new event/task to the list
check... |
813e9e90d06cb05c93b27a825ac14e5e96abcc9b | bparker12/code_wars_practice | /squre_every_digit.py | 520 | 4.3125 | 4 | # Welcome. In this kata, you are asked to square every digit of a number.
# For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1.
# Note: The function accepts an integer and returns an integer
def square_digits(num):
dig = [int(x) **2 for x in str(num)]
dig... |
312b662283a4f358cfaeec5bfd0e7793bf03816d | unisociesc/Projeto-Programar | /Operadores/Exercícios Aritméticos.py | 994 | 4.21875 | 4 | #Exercícios Operadores Aritméticos
# 1- Faça um Programa que peça dois números e imprima a soma.
print('Soma de valores...\n')
num1 = float(input('Digite um número: '))
num2 = float(input('Digite outro número: '))
soma = num1 + num2
#%s = string
#%d = inteiros
#%f = floats
#%g = genéricos
print('O resultado da... |
95f6426db6745fd9196069fd507dd155259bf220 | unisociesc/Projeto-Programar | /Operadores/Logicos.py | 222 | 3.90625 | 4 | #Operadores Lógicos
num1 = int(10)
num2 = int(20)
num3 = int(30)
print(num1<num2 and num2<num3) #Operador and (e)
print(num1>num3 or num3>num2) #Operador or (ou)
print(not(num1<num2 and num2<num3)) #Operador not (não)
|
577a3f912959c0d5ef4e9cf02e0f70af5ac04496 | yusinzxc/python-basics | /OOP-INHERIT/test.py | 102 | 3.71875 | 4 |
test = []
for i in range(3):
p = i
test.append(p)
for i in test:
print(i)
print(test)
|
eeea25c958866630ec58fc4764cc91e122cfd865 | yusinzxc/python-basics | /OOP-INHERIT/OOP-inherit.py | 925 | 3.828125 | 4 | class Species:
def __init__(self,called,name,gender):
self.called = called
self.name = name
self.gender = gender
print("Those are " + self.called)
def introduce(self):
if self.called == "Human" or self.called == "human":
if self.gender == "Male" or self.gende... |
083bbb6fd84769a0911f5441713907ef95c3e4e4 | BrianArne/Schedule | /Schedule.py | 5,275 | 3.625 | 4 | import random
from enum import Enum
from random import randint
'''
MACROS
'''
# Total CPU quantums
C_TIME = 0
#Used to generate task IDs
CURR_ID = 0
# Total GPU quantums
G_TIME = 0
# Total time when GPU and CPU were running calculations
SAVED_TIME = 0
# Size that a process can be <= to be passed to CPU
SMALL_ENOUGH =... |
28fe55b8782822236607c1c4fbce3524272b06b3 | ayellis/cerealrobot | /src/order2.py | 3,541 | 3.5625 | 4 | class Order:
def __init__(self, waiter):
self.waiter = waiter
self.items = {} #map MenuItem -> quantity
self.picked_up = {} #map MenuItem -> quantity
self.served_up = {} #map MenuItem -> quantity
def addItem(self, menuItem, quantity):
if (self.items.has_... |
f9b9cc936f7d1596a666d0b0586e05972e94cefa | jamiekiim/ICS4U1c-2018-19 | /Working/practice_point.py | 831 | 4.375 | 4 | class Point():
def __init__(self, px, py):
"""
Create an instance of a Point
:param px: x coordinate value
:param py: y coordinate value
"""
self.x = px
self.y = py
def get_distance(self, other_point):
"""
Compute the distance between the... |
2274eb9acc9808d5e0be1a7afe09666d9e4be977 | G-development/Python | /Python exercises/programmareInPython/seiUnaVocale.py | 179 | 3.875 | 4 | def seiUnaVocale():
vocali = "aeiou"
x = input("Inserisci un carattere:")
if x in vocali:
print(x + " è una vocale")
else:
print(x + " non lo è") |
174bed02a88e9ab467a20c27aab7eb0d75a5550d | G-development/Python | /Python exercises/programmareInPython/maggioreFraTutti.py | 209 | 3.734375 | 4 | def maggioreFraTutti(lista):
maggiore = 0
for numero in lista:
if numero > maggiore: maggiore = numero
print("Il maggiore è: " + str(maggiore))
#print("Il maggiore è: " + max(lista)) |
833b7f1186fa4bd1e46ef2035cadf235012f994a | G-development/Python | /Python exercises/Py ONE/GuessTheNumber.py | 385 | 3.984375 | 4 | import random
num = random.randint(0,20)
user = int(input("\nGuess the number between 0-20: "))
moves = 0
while user != num:
if user<num:
print("The number is bigger!")
user = int(input("Retry: "))
moves += 1
else:
print("The number is smaller!")
user = int(input("Retr... |
e882c2b5a90168e73b14c24941cd50e8076ce947 | shalinichaturvedi20/decsonary | /question7.py | 818 | 3.609375 | 4 | # dic=[{"first":"1"}, {"second": "2"}, {"third": "1"}, {"four": "5"}, {"five":"5"}, {"six":"9"},{"seven":"7"}]
# c={}
# for i in dic:
# c.update(i)
# a=[]
# for i in c.values():
# if i not in a:
# a.append(i)
# print(a)
# def a(name):
# i=1
# num=""
# while i<=len(name):
# ... |
838dd102460259673e75338915bc80ed5f3dac59 | shalinichaturvedi20/decsonary | /question8.py | 257 | 3.625 | 4 | i=1
student=[]
marks=[]
while i<=10:
user=input("enter the student name")
student.append(user)
mark=int(input("enter the student marks"))
marks.append(mark)
i+=1
d=dict()
n=marks[0]
for i in student:
d[i]=n
n+=1
print(d)
|
4d6fbe8ee7aa616ebefb83152fc7aa1b2881b32f | Gregog/leetcode | /Python/0002.Add_two_numbers.py | 658 | 3.765625 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
res = ListNode(0)
result_tail = res
buf = 0
while l1 or l2... |
b68d03bff0977ea545db470ae975249fee1483dd | mwyciszczak/Laby- | /Lista_Zadań_Zaliczeniowa_Semestr_Zimowy/lz_zad3.py | 1,560 | 3.6875 | 4 | pytania = ["Czy python to język programowania?",
"Czy każdy komputer posiada zasilacz?",
"Czy 64 GB ramu w komputerze do dużo dla przeciętnego użytkownika?",
"Czy pierwszym językiem programowania był Polski język LECH?",
"Czy umiesz obsłużyć przeglądarkę internetową?(tak jest... |
7512f2edb142237b941cc1290326052abf0dbce9 | mwyciszczak/Laby- | /Lab_2/lab2_zad8.py | 379 | 3.6875 | 4 | a = int(input("Podaj pierwszą przyprostokątną: "))
b = int(input("Podaj drugą przyprostokątną: "))
c = int(input("Podaj przeciwprostokątną: "))
a = a**2
b = b**2
wynik = a + b
if wynik == c**2:
print("Z podanych długości boków można utworzyć trójkąt prostokątny")
else:
print("Z podanych długości boków nie mo... |
49c4b437462f6df2c325d898a9bd27c0c7ad1a6e | mwyciszczak/Laby- | /Lab_8/lab8_zad4.py | 415 | 3.578125 | 4 | dict = {}
ile = int(input("Podaj ile maili chcesz dopisać do słownika"))
plik = open("adresy.txt", "wt")
for x in range(ile):
imie = input("Podaj imię użytkownika: ")
mail = input("Podaj mail użytkownika: ")
dict[imie] = mail
dopliku = str(dict)
plik.write(dopliku)
#w ten sposób możemy przetrzymywać adr... |
95c9f96ee8fc963e301a828d5ca0143465c7dd46 | mwyciszczak/Laby- | /Lab_10/lab10_zad1.py | 1,607 | 3.859375 | 4 | a = '''Magia jest w opinii niektórych ucieleśnieniem Chaosu. Jest kluczem zdolnym otworzyć zakazane drzwi. Drzwi,
za którymi czai się koszmar, zgroza i niewyobrażalna okropność, za którymi czyhają wrogie, destrukcyjne
siły, moce czystego zła, mogące unicestwić nie tylko tego, kto drzwi te uchyli, ale i cały ś... |
104c27ce9540454e75d58a52050a6d9043eacd44 | mwyciszczak/Laby- | /Lab_7/lab7_zad1.py | 162 | 4.03125 | 4 | tuple = (1, 2, 3, "a", "b", "c")
print(len(tuple))
print(id(tuple))
tuple = tuple + (2, "d")
print(tuple)
print(id(tuple))
tuple = list(tuple)
print(id(tuple))
|
c31bc4734ab732f235977dd33ef836dc9354da80 | mwyciszczak/Laby- | /Lab_4/lab4_zad10.py | 205 | 3.578125 | 4 | ostatnia = 0
sum = 0
while True:
podana = float(input("Podaj liczbę: "))
sum = sum + podana
if podana == ostatnia:
break
ostatnia = podana
print("Koniec, suma to {}".format(sum)) |
2ecd6d99e8d58bfbe5fc038e6b2d06f6827c0bd1 | mwyciszczak/Laby- | /Lab_6/lab6_zad6.py | 364 | 3.625 | 4 | import random
n = int(input("Podaj długość ciągu: "))
y = int(input("Podaj dolną granicę ciągu: "))
z = int(input("Podaj górną granicę ciągu: "))
tab = []
unikalne = []
for x in range(n):
tab.append(random.randint(y, z))
tab = list(dict.fromkeys(tab))
print("Unikalne elementy listy to {}, a jej długość to {}".... |
1cfefffa5f42d2b0cef526ee8e7b577507fd639f | mwyciszczak/Laby- | /Lab_2/lab2_zad5.py | 235 | 3.796875 | 4 | promile = float(input("Podaj ilość promili: "))
if promile >= 0.2 and promile <= 0.5:
print('Stan „wskazujący na spożycie alkoholu”.')
elif promile > 0.5:
print("Stan nietrzeźwości.")
else:
print("Trzeźwość.") |
46ad1ff1c606120fd5f869bda71d1896f229d7f3 | mwyciszczak/Laby- | /Lab_2/lab2_zad4.py | 237 | 3.796875 | 4 | l = float(input("Podaj liczbę: "))
if l == 0:
print("Liczba to 0.")
elif l > 0:
print("Liczba jest dodatnia.")
elif l < 0:
print("Liczba jest ujemna.")
if l % 2 != 0:
print("Liczba jest podzielna przez dwa z resztą.") |
b2efdc0cb8568a3a29b3d1ed5874f55e165dc201 | rakieu/python | /multa para excesso de peso.py | 280 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Sep 11 16:09:02 2020
@author: raque
"""
a = int(input('a: '))
b = int(input('b: '))
c = int(input('c: '))
if a >= b and a >= c:
print (f'Maior: {a}')
elif b >= c:
print (f'Maior: {b}')
else:
print (f'Maior: {c: }')
input () |
13cfdb9005da7b58f23d631ee8617b37ef71aedc | rakieu/python | /imprimir de 1 ate um numero lido_2.py | 84 | 3.890625 | 4 | x = 1
fim = int(input('Fim: '))
while x <= fim:
print (x)
x = x + 2
input () |
9ed4b89fd12fd80ec4674639d9da1aff771b5f26 | rakieu/python | /mac_while_cont_potencia_2.py | 533 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
# ------
# este programa recebe um inteiro nao negativo n e calcula o fatorial de n
#definição de fatorial de n, denotado por n!
#0! = 1
# n! = n * (n-1)! = n (n-1) * (n-2) * ... * 2 * 1,
# ------
def main ():
n = int(input("Digit um ... |
318a80ce77b542abc821fa8ff2983b0760da2838 | aaronstaclara/testcodes | /palindrome checker.py | 538 | 4.25 | 4 | #this code will check if the input code is a palindrome
print('This is a palindrome checker!')
print('')
txt=input('Input word to check: ')
def palindrome_check(txt):
i=0
j=len(txt)-1
counter=0
n=int(len(txt)/2)
for iter in range(1,n+1):
if txt[i]==txt[j]:
counte... |
f0754dfa5777cd2e69afa26e2b73b216d0ff5313 | sb1994/python_basics | /vanilla_python/lists.py | 346 | 4.375 | 4 | #creating lists
#string list
friends = ["John","Paul","Mick","Dylan","Jim","Sara"]
print(friends)
#accessing the index
print(friends[2])
#will take the selected element and everyhing after that
print(friends[2:])
#can select a range for the index
print(friends[2:4])
#can change the value at specified index
friends[... |
4439d7172aa52d5be811fa29a2f621ea92ac1f8d | Vincetroid/learning-python | /rest_apis_with_flask_and_python/advanced-set-operations.py | 392 | 3.984375 | 4 | #difference
friends = {"Bob", "Anne", "Rolf"}
abroad = {"Bob", "Anne"}
local_friends = friends.difference(abroad)
print(local_friends)
#union
two_fruits = {"Orange", "Tangerine"}
one_fruit = {"Apple"}
shake = two_fruits.union(one_fruit)
print(shake)
#intersection
art = {"Bob", "Jen", "Rolf", "Charlie"}
science = {"B... |
d3c9b4e1093dcd93ee0bd9fb147d4bf97d8f1e95 | fernandosvicente/cursoemvideo-python | /PycharmProjects/CursoemVideo/aula06a.py | 773 | 3.953125 | 4 | n1 = int(input('digite um valor :'))
n2 = int(input('digite outro :'))
s = n1 + n2
# print('a soma entre', n1, ' e ',n2, ' vale ', s)
print('a soma entre {} e {} vale {}'.format(n1, n2, s))
n3 = float(input('digite um valor :'))
print(n3)
print(type(n3))
n4 = bool(input('digite um valor : '))
print(n4)
n5 = input('... |
3a4de5aeaec57f0e58c8a8726b66289827c98da2 | fernandosvicente/cursoemvideo-python | /PycharmProjects/CursoemVideo/ex10.py | 3,980 | 3.765625 | 4 | #from time import sleep
#for cont in range(10, -1, -1):
# print(cont)
# sleep(0.5)
#for par in range(1, 51):
# # outra forma de escreve: print(par)
# if par % 2 == 0:
# print(' {} '.format(par), end='')
# sleep(0.2)
#print('acabou')
#for n in range(2, 51, 2):
# # outra forma de escreve: pri... |
cf88677d861926a33f12434740118993107dfbed | fernandosvicente/cursoemvideo-python | /PycharmProjects/CursoemVideo/ex07a.py | 2,054 | 4.0625 | 4 | n = int(input('digite um numero: '))
a = n - 1
s = n + 1
d = n*2
t = n*3
r = n**(1/2)
q = n**2
c = n**3
print('analisando o valor {}, seu antecessor é {} e o sucessor é {}'.format(n,a,s))
print('o dobro de {} é : {}, o triplo de {} é : {} \n a raiz quadrada de {} é : {:.2f}'.format(n,d,n,t,n,r), end="")
print('o quadra... |
730e51e2fcb0b354cadf6b529593ef07d03c19d1 | vaziridev/euler | /009.py | 577 | 3.75 | 4 | #ProjectEuler: Problem 9
#Find the Pythagorean triplet for which a + b + c = 1000. Return product abc.
import time
def main():
start = time.time()
result = findProduct()
elapsed = time.time() - start
print("Product %s found in %s seconds" % (result, elapsed))
def findProduct():
a = 1
b = 2
... |
e32b25c89cbbf63ecad715edf196de0daa994e3b | mullerpeter/authorstyle | /authorstyle/preprocessing/util.py | 1,300 | 3.71875 | 4 | from nltk.corpus import stopwords as nltk_stopwords
from nltk.tokenize import RegexpTokenizer
from nltk.stem import PorterStemmer
def make_tokens_alphabetic(text):
"""
Remove all non alphabetic tokens
:type text: str
:param text: The text
:rtype List of str
:returns List of alphabetic tokens
... |
c1a9da5613f1e80447c73dbf34cbb2f3d9d7cd9c | manavsinghcs18/The-perfect-guess-Game | /The Purfect Guess.py | 690 | 3.90625 | 4 | import random
randNumber=random.randint(1,100)
userGuess=None
guesses=0
while (userGuess != randNumber):
userGuess=int(input("Enter your guess: "))
guesses+=1
if userGuess==randNumber:
print("You guessed it Right!")
else:
if(userGuess>randNumber):
print("You guesse... |
6b71f866ea703c3ab8779cd1aa9032a704e63284 | AlexDharmaratne/CSC-part-2 | /main.py | 6,457 | 3.53125 | 4 |
from tkinter import *
import random
global questions_answers
names_list = []
asked =[]
score =0
question_answers = {
1: ["What must you do when you see blue and red flashing light behind you?",'Speed up to get out the way','Slow down and drive carefully','Slow down and stop','Drive on as usual','Slow down and ... |
e3be05086d5147f13ea59b9751ffdabca26dc715 | Tikrong/sudoku | /board.py | 3,317 | 3.78125 | 4 | """
high level support for doing this and that.
"""
import pygame
from sudoku import *
pygame.init()
# colors
WHITE = (255,255,255)
BLACK = (0,0,0)
GREEN = (0,255,0)
RED = (255,0,0)
#fonts
numbers_font = pygame.font.SysFont('verdana', 24)
#screen size
screen_height = 600
screen_width = 450
... |
1b601202676058620ac2074468c4130d2260c80d | nato4ka1987/lesson2 | /4.py | 540 | 4.03125 | 4 | '''
Пользователь вводит строку из нескольких слов, разделённых
пробелами. Вывести каждое слово с новой строки.
Строки необходимо пронумеровать. Если в слово длинное,
выводить только первые 10 букв в слове.
'''
my_str = input("Enter string: ")
a = my_str.split(' ')
for i, el in enumerate(a, 1):
if len(el) >... |
9161708731404df8a8d2e943b97efefb3d4a72db | benjaminwilson/word2vec-norm-experiments | /modify_corpus_word_freq_experiment.py | 1,141 | 3.5 | 4 | """
Modifies an input text for the word frequency experiment according to the
parameters defined in parameters.py
Reads from stdin, writes to stdout.
Requires sufficient diskspace to write out the modified text at intermediate
steps.
"""
import os
import sys
from parameters import *
from functions import *
wf_experime... |
e4e58672f121baae0fbe3f9ba7fac94d072073cc | ObukhovVladislav/python-adv | /homeworks/210125/tast_1_example_4.py | 1,042 | 4.0625 | 4 | # def is_palindrome(num):
# if num // 10 == 0:
# return False
# temp = num
# reversed_num = 0
#
# while temp != 0:
# reversed_num = reversed_num * 10 + temp % 10
# temp = temp // 10
#
# if num == reversed_num:
# return True
# else:
# return False
# def i... |
95413238babbc337a678c4ec2267e7f23e7547ba | jaiswalIT02/pythonprograms | /Chapter-3 Loop/untitled0.py | 261 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 3 14:21:13 2020
1,-2,3,-4....
7@author: Tarun Jaiswal
"""
n=int(input("Enter the no="))
x=range(11,1,-1)
print(x)
for item in x:
if item % 2==0:
print(n*item)
else:
print(item*n)
|
7bb24992e011787e8ab538ed3cd9a133367fa1a6 | jaiswalIT02/pythonprograms | /GUI Applications/calculator2.py | 875 | 3.515625 | 4 | from tkinter import *
root=Tk()
root.geometry("500x500")
root.resizable(0,0)
x=IntVar()
y=IntVar()
z=IntVar()
e1=Entry(root,font=("Arial",25),textvariable=x)
e1.pack()
e2=Entry(root,font=("Arial",25),textvariable=y)
e2.pack()
# Sum of two integer
def show(op):
a=x.get()
b=y.get()
if(op==1):
c=a+b... |
8213167d8b5da70eea22723295f51802b2bb85e5 | jaiswalIT02/pythonprograms | /Preparation/leftrotate.py | 482 | 3.921875 | 4 | def leftrotate(str):
l=list(str)
n=len(l)
t=l[n-1]
for i in range(n-1,0,-1):
l[i]=l[i-1]
l[0]=t
result="".join(l)
return result
str="TIGER"
str=leftrotate(str)
print(str)
# left rotate
def leftrotate(str):
l=list(str)
n=len(l)
t=l[n-1]
for i in range(n-1,0,-1):
... |
e2dbfd38a74c82a59c3600939f61ecd1f7bd683e | jaiswalIT02/pythonprograms | /Chapter-3 Loop/Series_Pattern/fibbonacy no.py | 164 | 3.765625 | 4 | n=int(input("N="))
a=0
b=1
sum=0
count=1
print("Fibbonaci series=",end=" ")
while (count<=n):
print(sum,end=" ")
count+=1
a=b
b=sum
sum=a+b
|
aaff1f7f2e02e1fba60af4e0f426762f07ad211b | jaiswalIT02/pythonprograms | /Chapter-5 Functions/c_to_f function.py | 125 | 3.6875 | 4 | def c_to_f(c):
Farhenheite=(c*9/5)+32
return Farhenheite
n=int(input("Celcius="))
f=c_to_f(n)
print(f,"'F")
|
3e0b50298a6ec8476a4a6999431ad630d91cb9a0 | jaiswalIT02/pythonprograms | /Chapter-3 Loop/oddno.py | 67 | 3.84375 | 4 |
x=range(1,10,2)
print (x)
for item in x:
print(item,end=",")
|
bd9bfbad1ab769c34652f888c40cf20b672db239 | jaiswalIT02/pythonprograms | /Preparation/+_-_n.py | 206 | 3.546875 | 4 | l=[-9,-86,56,-9,88]
positive=[]
negative=[]
for i in l:
if i >= 0:
positive=positive+[i]
if i <= 0:
negative=negative+[i]
print("positive list=",positive,"\nNegative List=",negative) |
570e15d6d3b0868329b5bf43f91b1ae898fe30fb | jaiswalIT02/pythonprograms | /Chapter-3 Loop/prime.py | 212 | 3.96875 | 4 | a=int(input("A= "))
limit=a**.5
limit=int(limit)
isprime=True
for i in range(2,limit+1):
if a % i==0:
isprime=False
break
if isprime:
print("Prime")
else:
print("NotPrime")
|
f4cb92fdc77320fe94f6aa51e466ef65d328ac93 | jaiswalIT02/pythonprograms | /Preparation/noduplicate.py | 168 | 3.53125 | 4 | l=[1,3,4,4,1,5,5,6,7]
l.sort()
print(l)
n=len(l)
nonduplicatelist=[]
prev=l[0]
for i in range(1,n):
curr=l[i]
if curr==prev:
print(curr)
|
68ce7ccdaa5bd03c6b9b7df2734337d61d8f243a | jaiswalIT02/pythonprograms | /Preparation/Basic_Python Program/split.py | 185 | 3.734375 | 4 |
word="boy"
print(word)
reverse=[]
l=list(word)
for i in l:
reverse=[i]+reverse
reverse="".join(reverse)
print(reverse)
l=[1,2,3,4]
print(l)
r=[]
for i in l:
r=[i]+r
print(r) |
a2c5a0d70841b6f946b7a9c2ef5d0a2fb79292de | jaiswalIT02/pythonprograms | /Chapter-2 Conditional/Result.py | 468 | 3.71875 | 4 |
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 2 17:09:46 2020
@author: Tarun Jaiswal
"""
p=int(input("Physics="))
c=int(input("Chemistry="))
m=int(input("Mathematics="))
if p<40 or c<40 or m<40:
print("Result=Fail")
else:
print("Result=Pass")
Total= p+c+m
print("Total={0}".format(Total))
per=... |
9999ffcec508d80c632832af3106ac14e50ca149 | jaiswalIT02/pythonprograms | /Preparation/positive_list.py | 177 | 3.671875 | 4 | #find the positive no from list
l1= [10, -21, -4, -45, -66, 93]
positive=[]
for item in l1:
if item >= 0:
positive=positive+[item]
print("positive list=",positive)
|
b7d668fbb96eb76401def55fdfcece6c435a6569 | jaiswalIT02/pythonprograms | /Chapter-3 Loop/nestedpyramidloop.py | 377 | 3.5625 | 4 | '''
n=0
r=4
for m in range(1,r+1):
for gap in range(1,(r-m)+1):
print(end=" ")
while n!=(2*m-1):
print("0",end=" ")
n=n+1
n=0
print()
'''
n=int(input("Enter the n="))
k=(2*n)-2
for i in range(1,n):
for j in range(1,k):
print(end=" ")
k=k-1
for n in range(1,i+... |
09ceb85b032927f8481fae86450d4995f6501ce2 | jaiswalIT02/pythonprograms | /Chapter-9 Regression/market.py | 615 | 3.5 | 4 |
import pandas as pd
#from sklearn import linear_model
#from sklearn import tree
from sklearn.tree import DecisionTreeClassifier
#import pandas as pd
def readexcel(excel):
df=pd.read_excel(excel)
return df
df = readexcel("F:\\Excel2\\Market.xlsx")
#print(df)
x = df[['phy','chem' ]]
y = df['division']
pri... |
234ccf83fdd88ba514fd6290c3d2f3b4894f2eec | jaiswalIT02/pythonprograms | /Chapter-3 Loop/Triangle_Pattern/reverseabcpattern.py | 156 | 3.5625 | 4 |
n=5
x=1
for i in range(1,n+1,1):
for j in range(i,0,-1):
ch=chr(ord('A')+j-1)
print(ch,end="")
x=x+1
print()
|
422097e0e6295618159d1ed54dcb6575a1975647 | jaiswalIT02/pythonprograms | /Chapter-3 Loop/Forloop.py | 334 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 3 10:06:06 2020
@author: Tarun Jaiswal
"""
x1=range(10)
print(x1)
x2=range(2,10)
print(x2)
x3=range(2,10,3)
print(x3)
print("X1=",end="")
for item in x1:
print(item,end=",")
print("X2=")
for item in x2:
print(item,end=",")
print("X3=",end="")
for item in x3:
... |
f5d819cc1ab5956c324329169dace5be9525f826 | jaiswalIT02/pythonprograms | /Chapter-2 Conditional/Many Min.py | 354 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 2 12:29:09 2020
@author: Tarun Jaiswal
"""
a=int(input("A= "))
b=int(input("B= "))
c=int(input("C= "))
d=int(input("D= "))
min=a
variablename="b= "
if b<min:
variablename="b= "
min=b
if c<min:
variablename="c= "
min=c
if d<min:
variablename="d=... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.