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
4c7f6e74dad352ec6d2627ee502384a7dd361c8f
kenshimota/Learning-Python
/Learning Basic/if_elif_else.py
167
4.09375
4
num1 = 8 num2 = 6 if num1 < num2: print("num1 es menor que num2...\n") elif num1 == num2: print("Son identicos....\n") else: print("num1 es mayor que num2...\n")
1c321283b31a0d7822c27bc3042dce99f1891527
Keerthana8897/Bridgelabz
/Algorithms/monthlypayment.py
181
3.703125
4
import math def monthlypay(P,Y,R): n=12*Y r=R/(12*100) k=P*r h=1-(1+r)**(-n) pay=float(k)/float(h) print pay P=input() Y=input() R=input() monthlypay(P,Y,R)
30b829b57ba2d58fc07c15c00aa7edeba79b1a4f
Keerthana8897/Bridgelabz
/Algorithms/mergesort.py
525
3.734375
4
def merge_sort(a): l = len(a) if l == 1: return a a1 = merge_sort(a[:l//2]) a2 = merge_sort(a[l//2:]) a_sort = [] idx1, idx2 = 0, 0 while idx1 < len(a1) and idx2 < len(a2): if a1[idx1] >= a2[idx2]: a_sort.append(a2[idx2]) idx2 += 1 else: ...
df9db9f0378177ce3dc0daadc266f5b3eb5730a5
vivek-x-jha/TIL
/leet_code/algorithm_problems/twosum.py
361
3.671875
4
def twoSum(nums, target): complements = {} for i, num in enumerate(nums): comp = target - num if comp not in complements: complements[num] = i else: assert target == nums[complements[comp]] + nums[i] return [complements[comp], i] nums = [2, 7, 11, 15...
85207e81ace52bfdcb2be5813bb5d42a5f7842f0
mootils/mootils
/mootils/visualization/__init__.py
974
3.65625
4
from matplotlib import pyplot as plt class Plot: def __init__(self, title: str = '', subtitle: str = '', font: str = 'serif', fontsize: int = 16, default_color: str = '#236FA4', **kwargs): """ :p...
1a21136bd05b232ac4e636e3ddf71e5ec5f44738
ClaudiaSofia222/homework2
/02 - String/04 - Sherlock and Valid String.py
779
3.859375
4
#!/bin/python import sys def isValid(s): ele = {} for e in "abcdefghijklmnopqrstuvwxyz": times = s.count(e) if times > 0: if times in ele: ele[times].append(e) else: ele[times] = [e] if len(ele) == 2: keys ...
0fb3bf481431a680512dbcb404e1409059705123
felipegarciab9601/Ejercicios.py
/Ejercicios.py/Condicional8.py
369
3.9375
4
user = str(input("Please introduce your name: ")) age_user = int(input("Please introduce your age: ")) if age_user <0: print("Invalid age please try again") elif age_user <4: print("Your entrance is free") elif age_user <=18: print("Your entrance will be $5") elif age_user >18: print("Your entrance will be $1...
7181067911603e216f432c9cacfbd7294170499a
felipegarciab9601/Ejercicios.py
/Ejercicios.py/Condicional2.py
134
3.796875
4
edad = int(input("Please introduce your age: ")) if edad < 18: print("No eres mayor de edad") else: print("Eres mayor de edad")
e7f99a79fe4d6eea70f633d16a0343dc7fe704f1
felipegarciab9601/Ejercicios.py
/Ejercicios.py/Condicional7.py
415
3.84375
4
inaceptable = 0.0 aceptable = 0.4 dinero = 2400 score = float(input("Please insert the score of the user: ")) if score == 0.0: print("Insuficient, Your bonus would be : " + str(dinero*0.0)) elif score == 0.4: print("Aceptable, Your bonus would be: " + str(dinero*0.4)) elif score >= 0.6: print("Wonderful, Y...
756259025fb02d1c167a17d85e9069ca9dd2cb8c
avkour13/Avinash_C0804437_Assignment3
/Student.py
1,044
3.734375
4
import unittest import logging class Student(unittest.TestCase): logger = logging.getLogger() logger.setLevel(logging.DEBUG) def total_marks(self, subject1, subject2, subject3): try: assert subject1 > 0 assert subject2 > 0 assert subject3 > 0 self....
281ba6307be6d9dc6ae528eda2f25e7e95d2fd7e
PaulWang1905/tint
/stage1/expression.py
116
3.953125
4
length = 5 breadth = 2 area = length * breadth print('Area is',area) print('Perimeter is' , 2*(length + breadth))
ce80bd1bbe2f8034a45c68e4c3ddb9ca2248d5ed
PaulWang1905/tint
/stage2/assignment11.py
233
3.53125
4
import re name = input('Enter File Name:') handle = open(name) total = 0 for line in handle: x = line y = re.findall('[0-9]+',x) for number in y: number = int(number) total += number print(total)
c35759cf6ddf382cd6ec14e90bd013707af13fd6
learninfo/pythonAnswers
/Task 5 - boolean.py
236
4.375
4
import turtle sides = int(input("number of sides")) while (sides < 3) or (sides > 8) or (sides == 7): sides = input("number of sides") for count in range(1, sides+1): turtle.forward(100) turtle.right(360/sides)
81849f77995e755e9e592c926feb7cee8535cc32
NicholasMaisel/Algorithms
/Stack.py
1,093
4.0625
4
from LinkedList import Node from LinkedList import LinkedList class Stack(LinkedList): #this inherits the Node class def __init__(self): self.top = None #The isEmpty function is used to make sure, before the linkedlist is edited #that the edit will cause no errors. def isEmpty(self): i...
b394361baed2d048d3c658525763171df3ae95e0
NicholasMaisel/Algorithms
/knapsack.py
1,959
3.78125
4
def read(): items = {} capacities =[] for line in open('spice.txt','r'): line = line.rstrip().split(';') line = [x.strip() for x in line] if 'spice name' in line[0]: items[line[0].split('=')[1].strip()] = [float(line[1].split('=')[1].strip()), ...
b76a2b62821a3c9b3e1394fab64b78f8abe6e711
sauravgupta2800/Bikeshare-Project-Python
/bikeshare_2.py
10,192
4.3125
4
import time import pandas as pd import numpy as np CITY="'washington'" CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } MONTH_LIST = ['january', 'february', 'march', 'april', 'may', 'june','all'] DOW_LIST = ['sunday','monday','tue...
227dbfbd5ae0bea2281533033a010b996c27fef7
martintvarog/python
/domecek.py
361
3.5
4
from turtle import forward, left, right, penup, pendown, exitonclick from math import sqrt for _ in range (4): forward (100) left (90) left (45) for _ in range (2): forward (100 * sqrt(2)) left (135) forward (100) left (135) right (135) for _ in range (2): left (45) forward ((100 * ...
d99396e79e06fe7ef172ff5f1613e43d32a27a75
alexandnpu/pythonLearning
/test_corountine.py
1,263
3.515625
4
import time def coroutine(func): def start(*args, **kwargs): cr = func(*args, **kwargs) next(cr) return cr return start def follow(thefile, target): thefile.seek(0, 2) while True: line = thefile.readline() if not line: time.sleep(0.1) ...
7cfc168f42e036a36e9886891ff683d5f1d2d9c8
rajdeep2804/OpenCV
/canny_edge_detection_in_opencv.py
720
3.65625
4
#the canny edge detection is an edge detection operator that uses a multi-stage algorithm to detect #a wide range of edges in images. it was developed by john f canny in 1986 #the canny edge detection algorithm is composed of 5 steps: # 1.) noise reduction # 2.) gradient calculation # 3.) non-maximum suppression ...
a7bef5820765e1ab474de3769ed461300ba9385a
ameliacgraham/udemy_courses
/python_for_data_structures/linked_list_cycle_check.py
971
3.96875
4
class Node(object): def __init__(self, data, next=None): self.data = data self.next = next def is_cycle(self): """Checks if a singly linked list contains a cycle given a head node. >>> a = Node("a") >>> b = Node("b") >>> c = Node("c") >>> a.next = b ...
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 ...