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
c6c6aaca90af510e04ca35604f18f3c9f4995b96
zh-hang/algorithms
/problems/kth_small.py
1,088
3.5
4
import copy def get_data_from_file(filename): with open(filename, 'r')as f: return list(map(int, f.readline()[:-1].split(' '))) def get_min(L): if len(L) == 0: return (10000, 10000) min_num = L[0] for i in range(1, len(L)): if min_num[1] > L[i][1]: min_num = L[i] ...
134624f07a8d1feb895a847653742055eb8728d7
ValeWasTaken/DailyProgrammer_Solutions
/Python_Solutions/[Easy]_Challenge_004.py
501
3.90625
4
from random import randint def main(): numOfPasswords = input("How many passwords would you like to generate? ") passLength = input("How long would you like your password(s) to be? ") selection = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" result = '' for a in range(numOfPassw...
ee6358f8ac5638f5843f4922bac287f2eed4a578
nmagerko/ka-infection
/users/academy.py
4,613
3.953125
4
class UserAcademy(object): def __init__(self, users): """ Initializes a new UserAcademy args: users: a list of users to add to the academy. NOTE that although Users are mutable, they should not be modified after being added to the academy; modification may result in skewed infections """ self._class...
1461c3af8b230b58b1c2f539333925de442293ef
FAREWELLblue/AID1912_personal
/day10/thread_server.py
787
3.671875
4
''' 基于thread的多进程并发 重点代码 步骤: 创建监听套接字 等待接收客户端请求 客户端连接创建新的线程处理客户端请求 原进程继续等待其他客户端连接 如果客户端退出,则对应分支线程退出 ''' from socket import socket from threading import Thread ADDR=('0.0.0.0',8888) s=socket() s.bind(ADDR) s.listen(5) def handle(c): while True: data=c.recv(1024).decode() if not data: br...
c6704983d1c0bb83785922c7612af956ccf412a8
ShubhangiDabral13/Bobble-AI
/Ques4.py
1,194
3.640625
4
def area_rect(coord): l, m, n, o = coord #Return the area. return (n-l)*(o-m) def cover_area_rect(rects): return (min(r[0] for r in rects), min(r[1] for r in rects), max(r[2] for r in rects), max(r[3] for r in rects)) def remove_rect(bb, rects): if not rects:...
2cd4ac5d23fd72bac1de28bf82c8a66b425157ac
sonali09/PythonPractice
/bubblePractice.py
413
3.53125
4
def bubbleSrtPrac(arr): n=len(arr) for i in range(0, n-1): flag=0 for j in range(0, n-1-i): if(arr[j]>arr[j+1]): temp = arr[j] arr[j] = arr[j+1] arr[j+1]= temp flag =1 if(flag==0): break r...
81296e6db0426517c1b1369d0a2db71f9b6ddba6
Danishmahajan/Pairs_Matching_Memory_Game
/Final.py
5,400
3.734375
4
#Library from tkinter import * import random from tkinter import messagebox #Screen Showing using tkinter screen = Tk() screen.title("Matching Pairs Game......") screen.iconbitmap('brain.ico') # Logo screen.maxsize(height="400",width="400") #SIZE OF A DISPLA...
b4e78d4651de0829be797e99dd77c73a8391e3ac
MillerNerd/Google-Challenges
/bomb-baby/solution.py
779
3.765625
4
import math def solution(x, y): x = int(x) y = int(y) if x < 0 > y: return "impossible" count = 0 if x == 1 == y: return count print(x, y, count) while x > 1 or y > 1: if x == y: return "impossible" if (x % 2) == 0 == (y % 2): return ...
ec5ddf22b4d1b591ea9167e3a1b97a8b9c9b7958
vineettiwari456/Resume
/src/get_phone_number.py
3,385
3.703125
4
# -*- coding:utf-8 -*- import re # df = pd.read_csv("country_code.csv") input_text = "My number is 9451042288" def getPhone(inputString, debug=False): ''' Given an input string, returns possible matches for phone numbers. Uses regular expression based matching. Needs an input string, a dictionary where v...
6ee3be23b152b8d1c0aae008f489b9a81cad0637
TharkiCoder/Inventory-Management
/Inventory Management/main.py
3,984
3.65625
4
#importig json package import json #Function to Create Line def line(): print("===========================================================================") #Function to create heading def heading(str): print(" "+str) line() heading("INVENTARY MANAGEMENT") line() whil...
11ec9310cd6fd21fe96c1ebfbb16a3340b713d8b
GuoJia563/KMM
/k_multiple_means.py
11,187
3.625
4
""" Created on Sat May 2 09:20:19 2020 K-Multiple-Means方法,处理多原型的聚类问题 论文题目:K-Multiple-Means: A Multiple-Means Clustering Method with Specified K Clusters 出自 KDD论文集 2019 2020/5/23 20:54 能够实现一个双月形状的连线二部图了呢 """ import numpy as np import matplotlib.pyplot as plt import random import time import math def dbmoon(N, d, r, ...
1f731efc7309f42cede92f2ef20ed866a741eb0f
ayushgarg-ag/MIT-IntroCompSci
/Problem_Set_1/part_C.py
1,206
4.0625
4
#Part C: Finding the right amount to save away an_salary = float(input("Enter your starting annual salary: ")) total_cost = 1000000 portion_down_payment = .25 months = 36 bi_search_num = 0 low = 0.0 portion_saved = 0.5 high = 1.0 semi_annual_raise = .07 r = 0.04 def calculated_savings(por_saved): semi_annual_raise...
e63dffe4ca8ec3a3b5039556f6c4df9c40b0b0a0
martinambrueso/SGBD
/PRACTICA 1/ejercicio_2-1.py
1,325
3.53125
4
import re SIGNOS_DE_PUNTUACION_COMPILER = re.compile(r'[,.;:!¿?]') SALTO_DE_LINEA_COMPILER = re.compile(r'\n') ESPACIO_COMPILER = re.compile(r' ') def procesar_linea(texto, diccionarioDePalabras): lineaSinSignosDePuntuacion = borrar_signos_de_puntuacion(texto.lower()) palabras = ESPACIO_COMPILER.split(lineaSinSigno...
314f1647925efee965df423077c4867c9ae2f74e
Ming-er/light-web-crawler
/projects/landmark_comment_crawler.py
8,435
3.75
4
"""一个从马蜂窝(http://www.mafengwo.cn/)网站抓取评论信息的脚本。 利用Selenium自动化操作,打开马蜂窝首页,使用搜索栏搜索地区。 在搜索结果中,查看该地区的景点,利用元素获取打开景点页面。 在景点页中,按元素和class获取评论并下载。 Args: LOCATIONS: 计划抓取评论的地区(需为准确的专有名词,即在马蜂窝中可直接搜索到) GET_LANDMARK_NUM: 计划在选定的地区抓取的景点数量 """ import json import os import re import time from pathlib import Path, PureWindowsPath ...
d7e3ce5ad077e15065c5f976659809d401196110
karlderkaefer/scikit
/tutorial/tutorial.py
2,990
3.75
4
import pandas as pd # df is type if pandas DataFrame df = pd.read_csv('input/train.csv') # print first 5 rows print(df.head()) # print some statistics for each column print(df.describe()) # select one column df1 = df['temp'] print(df1.head()) # select two columns df2 = df[['temp', 'weather']] print(df2.head()) # add ...
65351178598889796f024633c53ec9b16aa57a14
kienphan301/task
/Brackets Stack.py
368
3.953125
4
Brackets = '{}' count = 0 if len(Brackets) % 2 == 0: for i in range(len(Brackets)): if (Brackets[i] == '(') or (Brackets[i] == '[') or Brackets[i] == '{': count += 1 if (Brackets[i] == ')') or (Brackets[i] == ']') or (Brackets[i] == '}'): count -= 1 if count == ...
3774a9dbc6323ca7d15d3ecec8aa4afc2201a42b
m47jiang/T2P
/sendData.py
797
3.515625
4
from urllib.request import Request, urlopen import requests import json def setValue(temperature, humidity): payload = {"Plant1": {"name": "Lassie", "temp": temperature, "humid": humidity, }} req = requests.put("https://blinding-infe...
cdda862652c062984278dab9293cfe9f84f2519e
datapro2020/cole
/Turtle01.py
474
3.96875
4
import turtle miTortuga = turtle.Turtle() seleccion = input("Triangulo o Cuadrado (T/C) ") if seleccion == "C": for r in range(4) : miTortuga.forward(50) miTortuga.left(90) print("Cuadrado terminado ;-)") elif seleccion == "T": for r in range(3) : m...
890b6fff6d71d0de17af2c974c5c3be51ed0c345
STProgrammer/PythonExercises
/example-objects.py
1,310
3.9375
4
import math class Apple: def __init__(self, w, c, land, worm): self.weight = w self.color = c self.country = land self.worm = worm def getinfo(self): print("A",self.color,"apple weighing",self.weight, "grams, from the country ",self.country) if self...
aa65975f0e62f0bff822b6a8dabe98e921be974a
STProgrammer/PythonExercises
/KeynesModel.py
2,867
4.0625
4
print("""Welcome to Keynes Model Program. Now type in the exogen values and let the program calculate the endogene values""") zc = float(input("Other consume: ")) zt = float((input("Other taxes: "))) zi = float((input("Other investments: "))) G = float((input("Government spending: "))) X = float((input("Export: ...
94db4a5c592136be5afeccac3323c5c598e41900
STProgrammer/PythonExercises
/Rock Paper Scissor.py
1,571
4.125
4
import random print("Welcome to \"Rock Paper Scissor\" game") print("""Type in "rock", "paper", or "scissor" and see who wins. first one that win 10 times win the game.""") HandsList = ["rock", "paper", "scissor"] while True: x = int() #Your score y = int() #Computer's score while x < 10 and y < 10: ...
208498f48a71a5f7772825f205eb70df0ac09df1
FourthTee/Tutorials
/linklist.py
759
3.71875
4
class LinkList: empty = None def __init__(self, first, rest=empty): assert rest is LinkList.empty or isinstance(rest, LinkList) self.first = first self.rest = rest def __len__(self): if self.rest is None: return 1 else: return 1 + len(self.r...
00b12791b1d16aa3b3a8338fb8a2268de4cf5167
johnngugi/python_assesment
/question_4.py
723
3.875
4
import string import random def password(size=10): user = raw_input("Choose the strength of your password: a) Strong b) Weak: ") if user == "A" or user == 'a': letters_lower = string.ascii_lowercase[:26] letters_upper = string.ascii_uppercase[:25] numbers = str(random.randint(0, 9...
c6223b42183765e9a8743d8b3ec95520f80f9496
j1fig/aoc
/2015-5/solve.py
1,859
3.96875
4
#!/usr/bin/env python3 import argparse import re with open('data.txt') as f: data = f.readlines() def _count_vowels(sentence): vowel_count = 0 vowels = ('a', 'e', 'i', 'o', 'u') for v in vowels: matches = [m.start() for m in re.finditer(v, sentence)] vowel_count += len(matches) ...
b716a6d1bbf0acd284b7743a1e3d7035c947be9f
RubenGevorgyan/Alarm_Clock
/Alarm_clock.py
1,989
3.546875
4
import datetime import os import time import random import webbrowser def check_alarm_input(alarm_time): if len(alarm_time) == 1: if alarm_time[0] < 24 and alarm_time[0] >= 0: return True if len(alarm_time) == 2: if alarm_time[0] < 24 and alarm_time[0] >= 0 and alarm_...
60e2f6682cd2c82aab8d2ea8a1627a4eed363172
yosishin/Python
/19041406.py
167
3.84375
4
tbl1=["a","b","c","d"] for x in tbl1: print("for",x) else: print("end") for x in range(0,len(tbl1)): print("for",x,tbl1[x]) else: print("end")
afe1b528286f3ecbb366067f050ae3ea517ee11d
0pom33pom0/Python
/week3.py
3,444
3.53125
4
""" print(" เลือกเมนูเพื่อทำรายการ\n#########################\n กด 1 เลือกเหมาจ่าย\n กด 2 เลือกจ่ายเพิ่ม") x = input() y = int(input("กรุณากรอกระยะทาง\n")) if x == 1 : if y < 26 : print("ค่าใช้จ่ายรวมทั้งหมด 25 บาท") else : print("ค่าใช้จ่ายรวมทั้งหมด 55 บาท") else : if y < 25 : ...
f2c4dc3412f09cd7691fbdbd9c3073fddc32170b
0pom33pom0/Python
/w2/ex2.1.py
154
3.890625
4
n1=input("Input First Number\n") n2=input("Input Second Numder\n") print(n1," = ",n2,":",n1==n2) print(n1," > ",n2,":",n1>n2) print(n1," < ",n2,":",n1<n2)
6026eedbbb4c72fb676a7fb2d94ab1603a771fe7
PhtRaveller/kharkiv-hpc
/2/hw/filescan.py
3,654
3.71875
4
#!/usr/bin/python import sys import os USAGE_MESSAGE = '''Filename is missing. Usage: python filescan.py FILENAME''' SUFFIX = "_filtered." def scan_straightforward(filein, fileout=None): '''Main work is done here. This function must read file with filename filein, scan it and then output filtered data into f...
8587c4e37871c4560ba1dbaf767f048b03861c9c
Esther-Guo/python_crash_course_code
/chapter4-working with lists/4.1-pizzas.py
124
3.75
4
pizzas = ['Hawaii', 'BBQ', 'Bacon'] for pizza in pizzas: print(f'I like {pizza} pizza.') print('I really love pizza!')
8f7e92a384cf95b4b45ee3eb41d0edf8afdb38ff
Esther-Guo/python_crash_course_code
/chapter4-working with lists/4.10-slices.py
265
4.40625
4
odd = list(range(1,21,2)) for number in odd: print(number) print('The first three items in the list are: ') print(odd[:3]) print('Three items from the middle of the list are: ') print(odd[4:7]) print('The last three items in the list are: ') print(odd[-3:])
a99e2741375cf3894218364c2da6688123963489
Esther-Guo/python_crash_course_code
/chapter10-files_and_exceptions/10.12-favorite_number_remembered.py
348
3.78125
4
import json filename = 'favorite_num.txt' try: with open(filename) as f: num = json.load(f) except FileNotFoundError: num = input('What is your favorite number? ') with open(filename, 'w') as f: json.dump(num, f) print('I have keep your favorite number.') else: print(f'I know your ...
8297d0185398def528b19fe041c334a41550033c
Esther-Guo/python_crash_course_code
/chapter7-user_input_and_while_loops/7.8-deli.py
346
3.875
4
sandwich_orders = ['chicken', 'beef', 'tuna', 'pork'] finished_sandwiches = [] while sandwich_orders: sandwich = sandwich_orders.pop() print(f'I made your {sandwich} sandwich.') finished_sandwiches.append(sandwich) print('\nI have made these sandwiches: ') for finished_sandwich in finished_sandwiches: ...
b56490f7b74a5d92e5e1eab7dc7459dbe80dff5e
Esther-Guo/python_crash_course_code
/chapter8-functions/8.3-t-shirt.py
257
4
4
def make_shirt(size, message): """make a shirt of particular size with message""" print(f'The size of shirt is {size.upper()}.') print(f'The message on the shirt is {message}.') make_shirt('s', 'Merry Chrismas') make_shirt(size='s', message='Merry Chrismas')
0777824a168e8bc5eabcb35a58e2c6aa62e122d2
Esther-Guo/python_crash_course_code
/chapter8-functions/8.8-user_albums.py
651
4.21875
4
def make_album(name, title, tracks=0): """builds a dictionary describing a music album""" album_dict = { 'artist name': f'{name.title()}', 'album title': f'{title.title()}' } if tracks: album_dict['tracks'] = tracks return album_dict name_prompt = 'Please input the name...
c5622ed7cbb6206a255f2a559031e17a10270eac
Esther-Guo/python_crash_course_code
/chapter5-if_statements/5.10-checking_usernames.py
293
4.03125
4
current_users = ['admin', 'esther', 'will', 'jack', 'amy'] new_users = ['esther', 'will', 'a', 'b', 'c'] for new_user in new_users: if new_user in current_users: print(f'{new_user}:Please enter another username.') else: print(f'{new_user}:This username is available')
76d7b84995d75ce07a1ff1f304ac23fd7427f425
Esther-Guo/python_crash_course_code
/chapter10-files_and_exceptions/10.3-guest.py
150
4.09375
4
filename = 'guest.txt' with open(filename, 'w') as f: f.write(input('What is your name? ')) print('Hi, I already add your name in the file.')
b9bb6fd67446dde3986ac4060cbf9f4aa86f7f1f
Esther-Guo/python_crash_course_code
/chapter3-introducing lists/3.2-greetings.py
232
3.625
4
names = ['will', 'esther', 'erica', 'tony'] print(f"Hi, how are you, {names[0].title()}?") print(f"Hi, how are you, {names[1].title()}?") print(f"Hi, how are you, {names[2].title()}?") print(f"Hi, how are you, {names[3].title()}?")
6ccf701750c5c098f1055159a1ad800d49c98ce7
Esther-Guo/python_crash_course_code
/chapter11-testing_your_code/11.3-employee/test_employee.py
581
3.65625
4
import unittest from employee import Employee class TestEmployee(unittest.TestCase): """Tests for the class Employee""" def setUp(self): """Create an employee and test the salary methods""" self.my_employee = Employee('Esther', 'G', 100000) def test_default_raise(self): self.my_e...
e33210307ce93483f31b5ff2e65190bbcfc3fc75
loftusa/General-Projects-And-Scripts
/Replays/.ipynb_checkpoints/Data-Structure-Singly-Linked-List-checkpoint.py
4,407
3.828125
4
class Node(object): def __init__(self, value, nextNode = None): self.value = value self.nextNode = nextNode def __repr__(self): return ("Node object - attributes: value = {0}, nextNode at {1}." .format(self.value, id(self.nextNode))) def getValue(self): return self.value def setV...
f7cd1bd913f3cc4fd6bcfdbf3389a51b052b059e
Agustin978/Gestor_Clientes
/Gestor/helpers.py
366
3.71875
4
"""Funciones de ayuda""" import os import platform #Funcion para limpiar boofer def clear(): if platform.system() == "Windows": os.system('cls') else: os.system('clear') def input_text(min_lenght, max_lenght): while True: text=input(">") if len(text) >=min_lenght and le...
5e29635e085e9f0199f8e7e6b7e97e47fae30fcd
hefeholuwah/wejapa_internship
/Hefeholuwahwave4 lab/Scripting labs/match_flower_name.py
1,388
4.34375
4
#For the following practice question you will need to write code in Python in the workspace below. This will allow you to practice the concepts discussed in the Scripting lesson, such as reading and writing files. You will see some older concepts too, but again, we have them there to review and reinforce your understan...
c42a9c5c91fdb9c5189e8cf80bd3f52d93841177
pyrish/currency_converter
/currency_converter.py
4,704
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Python script using Selenium Webdriver to calculate the conversion rate of a given amount, selecting the source and target currencies. All these variables are provided by the user. All data has been validated accordingly""" __author__ = "Mariano Vazquez" __...
6116d7b2a96315c0c8d34d1d3f8b6bebba91eb29
huioo/byte_of_python
/main/function.py
8,137
4.375
4
# 函数 """ 函数是程序中可以复用的部件。函数允许你为一个语句块取一个特定名字;通过使用这个特定的名字,你可以随时随地地调用这个语句块。 这个过程被称为 调用 这个函数。例如:len() 、 range() 使用关键字 “def” 来定义函数。紧接着这个关键字,我们定义该函数的 标识符 名称;然后跟上一对小括号,小括号中可能包含一些变量的名字; 最后,我们再在最后一行的末尾写上一个冒号。而接下来便会是一个语句块,它是该函数的一小部分。 """ def say_hello(): # 属于该函数的语句块 print('hello world') say_hello() # 调用 say_he...
2772ed0ba3b1b795437e06cc07b2a859eb026400
huioo/byte_of_python
/main/controlFlow.py
5,886
4.375
4
# 控制流 """ 通常一系列的语句被Python以精确的自上而下的顺序执行。 那么如何改变它的执行流程,例如需要程序根据不同的情况作出一些决定和做不同的事情,像是根据一天中的时间打印“早上好”或“晚上好”。 这可以通过控制语句来实现。在Python中,有 if、for 和 while 三个控制流语句。 """ # if语句 def if_func(): """ if 语句用于检查一个条件:如果条件是真的,我们运行一个语句块(称为 if-block), 否则我们执行另一个语句块(称为 else-block)。else 语句是可选的。 if语句结尾处有一个冒号——表名后面跟着一个语句块。...
100d133d879ff910586c3f5c49ec068ee3c01fb8
huioo/byte_of_python
/main/str_format.py
1,189
4.34375
4
# format 方法 # 有时候我们想要从其他信息中构造字符串。这就是 format() 方法可以发挥作用的地方。 age = 20 name = 'Swaroop' # {0}对应name,format方法的第一个参数 # {1}对应age,format方法的第二个参数 # 使用字符串连接实现相同的效果,name + ' is ' + str(age) + ' years old' template = '{0} was {1} years old when he wrote this book.' print(template.format(name, age)) template = 'Why is {0} playin...
fa46a7f97d969517011217766bfa96d1568f9731
xuyichen2010/Leetcode_in_Python
/269_alien_dictionary.py
1,810
3.640625
4
# Assumptions: # You may assume all letters are in lowercase. # You may assume that if a is a prefix of b, then a must appear before b in the given dictionary. # If the order is invalid, return an empty string. # There may be multiple valid order of letters, return any one of them is fine. # ASK CLARIFYING QUESTION: I...
0367845b229715388e4f909a0de8c4c24ad6182c
xuyichen2010/Leetcode_in_Python
/125_valid_palindrome.py
585
3.734375
4
# https://leetcode.com/problems/valid-palindrome/ # ASK CLARIFYING QUESTIONS FOR INPUT!!!!!!!!!!!!!!!!!!!!! # alphanumeric = character or number # ignore space or other symbols # O(n) # O(1) class Solution(object): def is_palindrome(self, s): s = s.lower() l = 0 r = len(s)-1 while...
735991eafff1ed8bbf32db5686811891e10b02e3
xuyichen2010/Leetcode_in_Python
/199_Binary_Search_Tree_Right_Side_View.py
1,491
3.59375
4
# https://leetcode.com/problems/binary-tree-right-side-view/solution/ # Use BFS Level Order Traversal # O(n) Visit each node exactly once # O(n) Worst space in queue when visiting the last layer which is 0.5N in the worst case (A Complete Binary Tree) # Definition for a binary tree node. class TreeNode: def __i...
73c3bcce9c5509b858bb2d149ded24f592b78207
xuyichen2010/Leetcode_in_Python
/general_templates/tree_bfs.py
1,170
4.1875
4
# https://www.geeksforgeeks.org/level-order-tree-traversal/ # Method 1 (Use function to print a given level) # O(n^2) time the worst case # Because it takes O(n) for printGivenLevel when there's a skewed tree # O(w) space where w is maximum width # Max binary tree width is 2^h. Worst case when perfect binary tree # ...
ff390317fab6b786d585a7679b77722f5de153ef
xuyichen2010/Leetcode_in_Python
/973_k_closest_points_to_origin.py
2,128
3.546875
4
# https://leetcode.com/problems/k-closest-points-to-origin/ # We have a list of points on the plane. Find the K closest points to the origin (0, 0). # (Here, the distance between two points on a plane is the Euclidean distance.) # You may return the answer in any order. # The answer is guaranteed to be unique (except ...
3dffe9f32182da692894c7a0328f1a36fde4eef3
xuyichen2010/Leetcode_in_Python
/211_add_and_search_word.py
1,498
3.953125
4
# https://leetcode.com/problems/add-and-search-word-data-structure-design/discuss/59725/Python-easy-to-follow-solution-using-Trie. # O(N*M) N = num of words M = length of longest string # O(N*K) N = num of nodes and K = size of the alphabet # When encounter a "." search through all .values of children class TrieNode: ...
604f08fee40cfd00b75f95fb93869954a38cbc35
algoritmos-2019-2/clase-1-EzequielCal
/Practica1/Impar.py
186
3.578125
4
print("11.- Primeros n impares") def SerieImpares(i, n): if(n > 0): print (i*2-1) SerieImpares(i+1, n-1) n = int(input("Cantidad de terminos: ")) SerieImpares(1,n)
754a88ee180019f1cb237e657460f1cc0c6dad03
bnmre81/python-foundations
/cashier.py
857
3.875
4
mylist = [] while True: item = input('Item (enter "done" when finished): ') if item == 'done': break price = input("Price: ") quantity = input("Quantity: ") my_dict = {} my_dict['name'] = item my_dict['price'] = price my_dict['quantity'] = quantity mylist.append(my_dict) print(''' ------------------- re...
3a7a90b1adbcf881f09eb4f0b29912502f9b89d6
vernieri/Information-Security
/pyttern-matching/finder_pattern.py
571
3.875
4
#Starts Here #Pattern Matching Generator def starter(): arq_name = raw_input("Manda ai o nome do arquivo que esta os patterns: ") f = open(arq_name, 'r') s = f.read() number = raw_input("Passa o Pattern: ") finder(s, number) f.close() def find_str(s, char): index = 0 if char in s: c = char[0]...
72a38cfe565d7a57e5247ea3a49cf17b96011f0f
Frestho/AoPS-Auto
/Homework saving script.py
862
3.65625
4
import keyboard, time #change this!!! NUMBER_OF_WEEKS = 24 #change this if you want to start at a week which isn't 1 week = 1 time.sleep(5) while week <= NUMBER_OF_WEEKS: keyboard.press_and_release('ctrl+l') time.sleep(0.1) #wait for browser to respond keyboard.write('https://artofproblemso...
48948ad1a5e96000be0cd3cd9955f7bfc48dcc11
stevenrkeyes/2.12_Code
/stretch.py
2,053
4
4
#Stretch Program, Testing Leg movements #Version 1.0 #Date: 12.1.2014 #Details about Robot System: #L1 refers to link 1, L2 -> link 2 and so forth #Point A connects Link 1 and 2, B connects 2 and 3, C connects 3 and 4 import math from workspace import Workspace from robot_kinematics import Robot_Kinematics #ronaldo is...
7188c6826f1f45f921d868617afdbd0ca477bcbf
stevenrkeyes/2.12_Code
/workspace.py
2,107
3.625
4
#Workspace.py #Version 1.0 #Date 11/29/2014 #Details about Robot System: #L1 refers to link 1, L2 -> link 2 and so forth #Point A connects Link 1 and 2, B connects 2 and 3, C connects 3 and 4 import math #Class designed to represent the Workspace of the Striker Bot class Workspace: """ Constructor for the Wor...
9cbc4a52b1c41a5aa5054d882b7a55edaea601f0
MariosPitsali/algorithms-practice
/functions.py
895
3.890625
4
def python_food(a): word = "Spam and eggs" left_margin = (a - len(word))//2 print (" "* left_margin + word) #calling the function def center_text(*args, sep=" "): text = "" for arg in args: text += str(arg) + sep left_margin = (80 - len(text))//2 return (" "* left_margin + text) ...
c8c75607b2deeaba33a2419f4030074351780dff
MariosPitsali/algorithms-practice
/oop.py
1,109
3.90625
4
#makes use of imperative programming #handles data and methods on those data class Kettle(object): power_source = "electricity" def __init__(self, name, price): self.name = name self.price = price self.on = False def switch_on(self): self.on = True kenwoo...
5c0988643ccacd1d23f14a8a52bf5f7b0562a95d
MariosPitsali/algorithms-practice
/assignment.py
293
3.859375
4
#challenge time ip = input("Please type in the IP Address: ") segments = 1 length = 0 for i in range(0, len(ip)): if (ip[i] == '.') or (ip[i]==""): print ("Segment no. %2d has length %2d" % (segments, length)) segments += 1 length=0 else: length += 1
d30b2ae256a0f8af6125e0a45dd1cde4b976d635
MariosPitsali/algorithms-practice
/fibonacci.py
355
3.5
4
def fibinacci(): current, previous = 0, 1 while True: yield current current, previous = current+ previous, current fib = fibinacci() print (next(fib)) print (next(fib)) print (next(fib)) print (next(fib)) print (next(fib)) print (next(fib)) print (next(fib)) print (next(fib)) ...
6c4faa0ee5216db49ec574cbe91a1191fc831e51
kszhao552/CS111
/problemSets/problemSet9/ps9pr2.py
1,100
3.65625
4
# # ps9pr2.py (Problem Set 9, Problem 2) # # A Connect-Four Player class # from ps9pr1 import Board # write your class below class Player(Board): def __init__(self, checker): """initializes the player with the given checker and 0 moves""" assert(checker =='X' or checker =='O') self.ch...
f6bbc510baeb9e51951797d834a0643e004255c7
kszhao552/CS111
/labs/lab3/lab3.py
754
3.8125
4
# # Name: CS 111 Staff # # lab3.py # def num_consonants(s): """ returns the number of consonants in s parameter: s is a string of lower-case letters """ if s == ' ': return 0 else: num_in_rest = num_consonants(s[1:]) if s[0] not in 'aeiou': return num_in_rest...
79bc2986a7ea3832040f090593d0eb453a668274
kszhao552/CS111
/problemSets/finalProject/finalproject.py
8,950
3.703125
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 25 16:10:55 2019 @author: krado """ import math class TextModel(): def __init__(self, model_name): """initializes text model with name and empty dictionaries""" self.name = model_name self.words ={} self.word_lengths = {} self....
69f87819ac8a5751f008bf2dd89d98b1eab48562
kszhao552/CS111
/problemSets/problemSet6/ps6pr5.py
4,441
4.34375
4
# # ps6pr5.py (Problem Set 6, Problem 5) # # TT Securities # # Computer Science 111 # import math def display_menu(): """ prints a menu of options """ print() print('(0) Input a new list of prices') print('(1) Print the current prices') print('(2) Find the latest price') ## Add the n...
21b0b1b297d1a361c379c872758a3d22a76d0216
kszhao552/CS111
/problemSets/problemSet4/ps4pr3.py
1,193
4.0625
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 9 00:15:47 2019 @author: krado """ def bitwise_and(b1, b2): """takes two binary numbers and ands them together. If one is shorter than the other, the longer one gets compared to 0's for blanks input: two strings consisting of 1's and 0's""" if b1 =='' and b2...
3fa20a78471d18cfe52efd6a86e82ace0e47db76
PouryaMansouri/Python_prog
/multiple.py
968
3.921875
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 17 09:50:28 2019 title: Largest palindrome product @author: Pourya Mansouri # TODO : smallest number divisible by each of the numbers """ from prime_divisors import isprime def prime_divisors(num) : #TODO: check divisor is prime or not divisors = list(filter(...
c910a5fc39664283b7dfdaa40b6aa1fb896db63e
psymen145/LeetCodeSolutions
/662.maximum-width-of-binary-tree.py
1,347
3.71875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def __init__(self): self.hashtbl = {} def dfs(self, node, lvl, node_id) -> int: ...
9ebcc1d63589327df5792e3bcd3dece668cd9edc
psymen145/LeetCodeSolutions
/49.group-anagrams.py
604
3.75
4
class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: # for each string in the list... # count how many charactesr of each string there are ( store in hash table ) # after we count the entire string, and it doesn't match and existing hash tables # ... create ne...
52f28d05697d6dd1ba8cb72fd9c7e488d9807d78
psymen145/LeetCodeSolutions
/41.first-missing-positive.py
1,114
3.546875
4
class Solution: """ def _firstMissingPositive(self, nums: List[int]) -> int: # trivial, sort the list if not nums: return 1 nums.sort() # loop through 1 and max number in array max_num = nums[-1] if max_num <...
3d8fddcace92681e32baee45fabbddb6245f107f
psymen145/LeetCodeSolutions
/101.symmetric-tree.py
1,550
4
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right =...
5d291f7d0e4246a12e5960c28ed6eb20ac9d5928
ksualcode/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/100-print_tebahpla.py
165
4.09375
4
#!/usr/bin/python3 for i in range(26): if i % 2 == 0: print("{}".format(chr(122 - i)), end='') else: print("{}".format(chr(90 - i)), end='')
6637ca5eaf76b84cf3eea31dcf4e295667b883db
phganh/CSC110---SCC
/xTriangle - extra credit/3rd attempt (shortest ver.).py
268
3.953125
4
# fixing the problem in 2nd attempt - extra blank line at 1st def xTriangle(): intHeight = int(input("Enter triangle's height: ")) for i in range(intHeight): print( "X" * (i+1) ) # start @ 0 -> +1 to start printing 1st X xTriangle()
0b1e40f7d82d113980449d50def4ad15835aba09
phganh/CSC110---SCC
/Labs/Lab 9/main.py
2,687
3.78125
4
# Project: Lab 9 (TrinhAnhLab09Sec03.py) # Name: Anh Trinh # Date: 02/02/16 # Description: The program shows off a students's scores imported # from a file. (bar chart form) from graphics import * import random #Function creating a scale score def scale(x,y,win): for i in ran...
c03486f525084d5fd5f06c48f371db8cbdfa9666
phganh/CSC110---SCC
/Labs/Lab 3/coffeeShop.py
984
4.15625
4
# Project: Lab 03 (TrinhAnhLab03Sec03.py) # Name: Anh Trinh # Date: 01/20/2016 # Description: Calculate the cost of a coffee # shop's products def coffeeShop(): #Greeting print("Welcome to the Konditorei Coffee Shop!\n") #User's Input fltPound = float(input("Enter ...
02cf5510fb1edd89a53edb3c85b72f41307934b4
phganh/CSC110---SCC
/Statements for String.py
750
4.21875
4
## ------ STATEMENTS FOR STRING ------ ## def main(): print("Numeric Value of A Character") print("'a':",ord("a"),"\n'b':",ord("b")) print("\nString Value of A Number") print("'97':",chr(97),"\n'98':",chr(98)) print("\nNumeric Length of A String") string = "How a...
1edd360dd71a8fdaa7cebc6f52ec19d74998d187
phganh/CSC110---SCC
/Discussion/Module 7/scholarship.py
1,562
3.71875
4
def GPA(intClasses): print("\n**** GRADES ****\nA = 4.0\nB = 3.5\nC = 3.0\nD = 2.5\nF = 0.0\n****************") #Calculating grades and credits fltSumGrades = 0.0 intSumCredits = 0 #Grades for i in range(intClasses): print("\nClass",i+1) intCredits = int(input("Enter credits ...
b72815336ce0cb62c50a8d2979bc901eeb9c2ba5
lewfer/web-controlled-robot-full
/web-server/webcam_player.py
3,254
3.671875
4
# www.thinkcreatelearn.co.uk # # Video player class for webcams # # Implements a class that can be used by the web page to stream video images from a webcam # # Requires installation of OpenCV and numpy # Installation of OpenCV on the Raspberry Pi can be a bit problematic. # See my web page for details # from time imp...
95cf0f086b73eba45184bce51725a65cf0395cb9
hubbm-bbm101/lab5-exercise-solution-b2200765010
/exercise3.py
363
3.953125
4
import numpy as np random_number = np.random.randint(0, 101) guess = int(input("Number:")) while guess != random_number: if guess < random_number: print("increase your number") else: print("decrease your number") guess = int(input("Number:")) if guess == random_numbe...
791b60f473bb4e746ad6b7ccd9861e3932983cfb
jacobunna/pyconuk2019
/2_use_right_data_type.py
2,327
3.53125
4
# ----------------------- # Example 1: Enumerations # ----------------------- from enum import Enum customer_1 = {"first_name": "John", "last_name": "Smith"} def swap_names_bad(customer): if "first_name" not in customer or "last_name" not in customer: return False customer["first_name"], customer["l...
87e17398c4d92b459d8d3a48c7c4ce100e0d9ecc
carlosnanez/Modelos2
/Haskell a python/(43) invertir.py
158
3.671875
4
def invertir(lista): if lista==[]: return [] else: return invertir(lista[1:]) + [lista[0]] print(invertir([5,4,7,8]))
8332a35a91900dcb875398c7290bdde30c0c4509
carlosnanez/Modelos2
/Haskell a python/(42) Funcion suma.py
134
3.578125
4
def suma(lista): if lista == []: return 0 else: return lista[0]+suma(lista[1:]) print (suma([5,4,7,8]))
3d32f8332e7855b7121e1da7826b6d79bc0db241
Jaceyli/COMP9021-17S2
/Lab/Lab_7/target.py
5,664
3.671875
4
from random import choice, sample from collections import defaultdict class Target: def __init__(self, dictionary='dictionary.txt', target=None, minimal_length=4): self.dictionary = dictionary self.minimal_length = minimal_length with open(self.dictionary) as file: # 这句厉害了 d===...
0f0ae4bc224d49e3f834e60870982ed8a193eb49
Jaceyli/COMP9021-17S2
/Quiz/quiz6/quiz_6.py
4,847
3.96875
4
# Creates a class to represent a permutation of 1, 2, ..., n for some n >= 0. # # An object is created by passing as argument to the class name: # - either no argument, in which case the empty permutation is created, or # - "length = n" for some n >= 0, in which case the identity over 1, ..., n is created, or # - the n...
11b8b454a1f3250b88225e8a6cb82700abfe5c21
Jaceyli/COMP9021-17S2
/Quiz/quiz10/quiz_10.py
2,171
3.890625
4
# Randomly generates N distinct integers with N provided by the user, # inserts all these elements into a priority queue, and outputs a list # L consisting of all those N integers, determined in such a way that: # - inserting the members of L from those of smallest index of those of # largest index results in the sam...
ac69a83288e9681a494ad03fdc3d2d591ff33e13
Jaceyli/COMP9021-17S2
/Lab/Lab_6/longest_sequence.py
580
3.546875
4
def solution(l, sequence, code): # print(sequence, code) if not sequence: return [] for e in list(sequence): if e == chr(code + 1): l.append(e) return solution(l, sequence, code + 1) return l sequence = input('Please input a string of lowercase letters: ') # prin...
61201c58c054761ba7f64ddbd47459df57c6c223
dinesh2805/guvi
/B10.py
290
3.65625
4
bbb,s=map(str,input().split("|")) c=input() if len(bbb)>len(s): if len(bbb)==len(s)+len(c): print(bbb+"|"+s+c) elif len(bbb)<len(s): if len(s)==len(bbb)+len(c): print(bbb+c+"|"+s) elif len(bbb)==len(s) and len(c)>1 or (len(s) or len(bbb)): print("impossible")
7dacf4e2164c5bda1dcda4f9f2d6dc1e58aa30db
UNASP-SISTEMAS-DE-INFORMACAO/introducao-ao-github-yugo-harago
/aula02.py
163
3.921875
4
import pandas as pd print("cadastro produto") d1 = {'id':[1,2,3],'name':['frozen','fire','gun'],'price':[10,15,30]} df1 = pd.DataFrame(d1) print(df1) print(df1)
e4a0c5e09ab794c51090546cbb7e35c072963ef9
youxiue/python-learn
/demo12.py
514
3.78125
4
# youxiue # createTime: 2021/1/23 21:25 # 输出一个三行四列的 * 矩形 for _ in range(3): for _ in range(4): print('*', end='\t') # end='\t' 不换行输出 print() # 打印直角三角形 for i in range(1, 10): for j in range(1, i + 1): print('*', end='\t') print() # 打印 9*9乘法表 for i in range(1, 10): for j in range(...
7bd969081d0679c89b6d8fe73ef39572eb1655b1
catr1ne55/stepik_prog_python
/3_funcs/3.2.2.py
218
3.515625
4
str = [str(s).lower() for s in input().split(' ')] dict = {} for s in str: if s not in dict.keys(): dict.setdefault(s, 1) else: dict[s] += 1 for key, value in dict.items(): print(key, value)
60357647015686ebbb09aee4122feb1fec8a8511
huahuijay/learn-python-with-L
/dict_set.py
1,446
4.15625
4
# -*- coding: utf-8 -*- # dict: 字典 ,使用key——value存储 d = {'Michael': 95, 'Bob': 75, 'Tracy': 85} print d['Michael'] d['Adam'] = 67 print d['Adam'] #一个key只能对应一个value,多次对一个key放入多个value,前面的值会被冲掉 #如果key不存在,dict会报错 #为避免key不存在的错误,两种办法: #1 'Thomas' in d #2 d.get('Thomas') d.get('Thomas', -1) #其中-1为key不存在时自己指定的返回的value,不指定的话为N...
ad3c87d17bf9ac5bcfcd86db9510ba03f0a8ad19
jmaccabee/advent-of-code-2019
/puzzles/day03/part2.py
7,363
3.921875
4
from puzzles.day3.part1 import ( read_inputs, get_vector_coordinates, vector_from_string ) def get_intersection_with_minimum_distance( intersections_with_distances ): # sort the intersections by distance, ascending # and return the one with the shortest distance return sorted( ...
0cba91af5ad396c12312656b9c1f9f2f54b94fed
jmaccabee/advent-of-code-2019
/puzzles/day04/part1.py
2,068
3.53125
4
from puzzles.utils import run_test from puzzles.day4.constants import PUZZLE_INPUT, REQUIRED_LENGTH def parse_password_int_range(): password_int_range = tuple( int(int_string) for int_string in PUZZLE_INPUT.split('-') ) return range(*password_int_range) def is_valid_password(password): ...
120d1d4e5b00301ad878a7e2aa041d0059420f67
ferchislopez0910/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/base.py
295
3.53125
4
#!/usr/bin/python3 """1. Base class """ class Base: """ Class""" __nb_objects = 0 def __init__(self, id=None): """class constructor""" if id is None: Base.__nb_objects += 1 self.id = self.__nb_objects else: self.id = id
823f7a36f4f4b7e6e8a140dbab3b8b3a1d47b983
ferchislopez0910/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/tests/test_models/test_rectangle.py
1,307
3.6875
4
#!/usr/bin/python3 """ Unit test for base""" import unittest from models.base import Base from models.rectangle import Rectangle class TestRectangle(unittest.TestCase): """test rectangle""" def test_Rectangle(self): r1 = Rectangle(10, 2) self.assertEqual(r1.id, 1) self.assertEqual(r1...
9543642c69d31832289c3876450b81da65cc2d6d
ustbwang/LeetCode
/102.二叉树的层次遍历.py
1,441
3.890625
4
# # @lc app=leetcode.cn id=102 lang=python3 # # [102] 二叉树的层次遍历 # # https://leetcode-cn.com/problems/binary-tree-level-order-traversal/description/ # # algorithms # Medium (61.14%) # Likes: 561 # Dislikes: 0 # Total Accepted: 159K # Total Submissions: 252.2K # Testcase Example: '[3,9,20,null,null,15,7]' # # 给你一个二...
9b5e19465353a8d06f2d259175ae53325778eef1
zhenfang95/Hello-World
/mystudy/定时任务/schedule_demo.py
1,809
3.578125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # @time:2020/10/9 16:39 import datetime import schedule import time def func(): now = datetime.datetime.now() ts = now.strftime('%Y-%m-%d %H:%M:%S') print('do func time :',ts) def func2(): now = datetime.datetime.now() ts = now.strftime('%Y-%m-%d %H:%...
ddb4efb5589ee09fc53417aa4ba76ffac0bdbe97
zhenfang95/Hello-World
/mystudy/python多线程/xx02.py
977
3.859375
4
#!/usr/bin/env python #-*- coding:utf-8 -*- # @time :2020/6/15 19:58 # @author:AlexFu import threading import time exitFlag = 0 def print_time(threadName,delay,counter): while counter: if exitFlag: threadName.exit() time.sleep(delay) print("%s:%s" %(threadName,time.ctime(tim...
9a7083097f584ff12e590e50c2338388392ddd41
Dev-Castro/EA_FATEC-FRV
/modfunctions.py
17,606
3.96875
4
def entrada_de_dados(arquivo): found = False # Tente abrir o arquivo e adicionar os valores a lista. try: valores = [] # Abre o arquivo de entrada no modo Leitura. with open(arquivo, "r") as entrada: # Lê um por um dos valores do arquivo. for valor in ent...