blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
533649bd73ab578e1bc0b7d6b43cd368bd6664a4
eunchae2000/codeup
/codeup 1510-1514.py
2,844
3.5
4
# 1510 홀수 마방진 """ n = int(input()) matrix = [[0]*n for i in range(n)] result = 1 x = 0 y = 0 xx = 0 yy = int(n/2) matrix[xx][yy] = 1 for i in range(2, n*n+1): x = xx y = yy xx -= 1 yy += 1 if xx<0: xx = n-1 if yy>n-1: yy = 0 if matrix[xx][yy] == 0: matrix[xx][yy] = ...
f2020abd136f03dfdcce04b0ba4f990de8b812c4
bobiwang/study
/06network_bandwide.py
197
3.625
4
# 带宽计算 bandwidth = 100 ratio = 8 print(bandwidth/ratio) import sys;x = 'runoob';sys.stdout.write(x + '\n') string1 = '123' string2 = '456' print(string1,end="") print(string2,end="")
a81a1db40551c08a0ab4ff3ca7458f6fb07b700c
bobiwang/study
/class_dictionary/exercise_dictionary1.py
131
4.25
4
# 定义字典 dict = {'a': 'hello', 'b': 'world', 'c': 'nice to', 'd': 'meet you'} dict[c]='cake' print(dict) n = dict[d] print(n)
894627712f1efea2ee3341eb1bf1e2fbf70c2d2d
bobiwang/study
/class_file/file_open.py
833
3.65625
4
# 写入文件 # file1 = open('name.txt', 'w') # file1.write('劉備''曹操''孫權''關羽''張飛''呂布''周瑜''趙雲''龐統''司馬懿''黃忠''馬超') # file1.close() # # # file2 = open('name.txt', 'r') # print(file2.read()) # # file2.close() # # # file3 = open('name.txt','a') # file3.write('新增') # file3.close() # # file4 = open('name.txt') # print(file4.readline()...
12f728f64d6b5d580c5655db2df5631537e6970b
victorozoh/atm_controller
/controller.py
4,246
4.53125
5
#!/usr/bin/env python3 class Bank: """ Implements a simple Bank Class where Users/Customers can only operate Checking or Savings Accounts """ def __init__(self, account_name='Foo', account_number='0000'): self.account_name = account_name self.account_number = account_number ...
6a15956c9ca43ba7496277f4a8a06636cea2a8c4
MosesofEgypt/snippets
/python/beep.py
513
3.5
4
def beep(interval=0, count=1): """ Makes the computer beep by printing the bell character. Wont work outside of printing to a system terminal. """ if "sleep" not in globals(): from time import sleep try: for i in range(max(1, int(count))): print(b"\x07".dec...
9eded044ebf3b3f4949b40e080bf2617f9513c16
dimazyr/exchange_app
/file_reader.py
502
3.9375
4
def read_file(filepath: str): """ function to extract data from input file :param filepath: path to input text file :return: dataset/ two-dimensional array of each change per row """ with open(filepath, "r") as f: lines = f.read().splitlines() data = [] exchange_classes = [] ...
cf19f8ba2b158a4c7eb3cadadaa01ba6b9573c13
zaki951/Euler
/exo17.py
1,254
3.796875
4
def numberToStr(nb): numbers = ["","one","two","three","four","five","six","seven","eight","nine","ten", "eleven"," twelve","thirteen","fourteen","fifteen","sixteen","seventeen", "eighteen", "nineteen","twenty","thirty","forty","fifty","sixty","seventy", "eighty","nin...
ea6ea5cbd43d7d695349e1e0c28cd19499b69e05
arthurhonjo/curso-em-video-python
/exercicios/soma_de_dois_numeros.py
162
3.984375
4
num1 = input('Insira um número: ') num2 = input('Insira outro número: ') soma = int(num1) + int(num2) print('A soma entre os dois números é: ', soma)
3fc6af66a07dae42870cc08f9d9de44ff3ac7e7b
smlz/python-theorie
/03_variablen.py
728
3.84375
4
# Wir können einer Zahl einen Namen geben, mit dem Gleichheitszeichen # Achtung: der Name muss immer links stehen # Funktioniert nicht: #42 = r # Funktioniert r = 42 # Danach können wir den Namen anstelle des Wertes verwenden print(r) # Achtung, Variablen müssen zuerst erstellt werden, bevor sie verwendet werden k...
ffbad07394f8b1b4e24b8eebea7c70eefb3c05ed
flexxui/pscript
/pscript/parser3.py
15,586
3.65625
4
""" Python Builtins --------------- Most builtin functions (that make sense in JS) are automatically translated to JavaScript: isinstance, issubclass, callable, hasattr, getattr, setattr, delattr, print, len, max, min, chr, ord, dict, list, tuple, range, pow, sum, round, int, float, str, bool, abs, divmod, all, any, ...
eabd91f11eb02efd4abd25d0ffa10ba28c76bbdd
Aubergines/BasePython
/com/cn/main/structure/mytree.py
1,966
3.828125
4
# coding=utf-8 #树 #树的基本构造 #Tree=[2,3,[58,6,[5]]] #print Tree[0] #print Tree[1] #print Tree[2] #Tree2=Tree[2] #print Tree2[0] #二叉树的构造 ''' 比如要构造一个二叉树: 7 8 9 23 36 57 58 可以这样分析: base=(-->8也就是jd2,-->9也就是jd3,base) jd2=(no,-->23也就是jd4,8) jd3=(no,-->36也就是jd5,9) jd4=(-->57也就是jd6,-->58也就是jd7,23) jd5=(no,no...
c7c825dea11108a8b33a0dfe406e1c6b2f9ed008
EricCoolPC/grabDataFromURL
/trash.py
1,714
3.5
4
##import requests ##from bs4 import BeautifulSoup ## ##url = "https://en.wikipedia.org/wiki/2013_New_England_Revolution_season" ##html = requests.get(url) ##soup = BeautifulSoup(html) ## ### kill all script and style elements ##for script in soup(["script", "style"]): ## script.extract() # rip it out ## ### get t...
2bf0a4567ff1de743842ce2d88383c45bf10cccd
Ragavi18/python
/HANGMAN.PY
1,255
4.0625
4
import time import random name = input("What is your name? ") print ("Hello, " + name, "Time to play hangman!") print("") time.sleep(1) print ("Start guessing...") time.sleep(0.5) words=['umbrella','chocolate','ice-cream',' parris','india','pink'] word=random.choice(words) guesses = '' if word=='umbrella': print ("...
ef8de1d98d20ac2027eaa9097a91b3c199b63433
vivibruce/dailycodingproblem
/univaltrees/univaltrees.py
1,814
4.125
4
''' A unival tree (which stands for "universal value") is a tree where all nodes under it have the same value. Given the root to a binary tree, count the number of unival subtrees. For example, the following tree has 5 unival subtrees: 0 / \ 1 0 / \ 1 0 / \ 1 1 ''' class Value: def __init__(se...
cde07ac6c553490c51626a9c9169741cf9d32b46
machariamarigi/shopping_list
/app/models.py
6,291
4
4
""" Module for the application's User, ShoppingList, ShoppingItems and Storage models """ class User(): """Class modeling a real world user""" def __init__(self, username, email, password): """Constructor for user object""" self.username = username self.email = email s...
e035abbc31d0792614fcee8a505b61adf85fa0bb
NeroNL/algorithm
/src/main/python/employeeFreeTime.py
769
3.609375
4
""" # Definition for an Interval. class Interval: def __init__(self, start: int = None, end: int = None): self.start = start self.end = end """ class Solution: def employeeFreeTime(self, schedule: '[[Interval]]') -> '[Interval]': if not schedule: return [] m,cur, res...
4468e503389c9078d3a7ee927df6fe76ddd0a6cb
NeroNL/algorithm
/src/main/python/mergeIntervals.py
857
4
4
""" Definition of Interval. class Interval(object): def __init__(self, start, end): self.start = start self.end = end """ class Solution: """ @param intervals: interval list. @return: A new interval list. """ def merge(self, intervals): # write your code here if ...
c32ba6cc1367973681a07003a3a61a92efb5cb25
NeroNL/algorithm
/src/main/python/lowestCommonAncestor3.py
907
3.84375
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): this.val = val this.left, this.right = None, None """ class Solution: """ @param: root: The root of the binary tree. @param: A: A TreeNode @param: B: A TreeNode @return: Return the LCA of the two nodes. ""...
e6415a1d05207eb31f38bdcad3aefbe2af7b830e
bhavikjadav/Python_Crash_Course_Eric_Matthes_Chapter_5
/5.6_Stages of Life.py
1,176
4.3125
4
#!/usr/bin/env python # coding: utf-8 # # 5-6. Stages of Life: Write an if-elif-else chain that determines a person’s stage of life. Set a value for the variable age, and then: # # • If the person is less than 2 years old, print a message that the person is a baby. # # • If the person is at least 2 years old but less ...
be4e3e669e1f276942798c651a36567ec275c2c0
picadokevin/Proyecto3-B65412
/PythonApplication5/BulkLoad.py
861
3.515625
4
import psycopg2 import pandas as pd import sys from conf import postgreSql_Connection def pg_load_table(file_path, table_name): ''' This function upload csv to a target table ''' try: conn = postgreSql_Connection() print("Connecting to Database") cur = conn.cursor() f = ...
2f96b3133346dd2685451400f887b6c222087023
shansb/boss_grabbing
/boss_grabbing/sqlite.py
845
3.609375
4
import sqlite3 import time con = sqlite3.connect('sqlite3.db') cur = con.cursor() print("sqlite连接成功") class Sqlite(object): # 检查公司是否存在 @classmethod def select_db(cls, company_id): sql = 'select count(1) from company where id=?' return cur.execute(sql, (company_id,)).fetchall() @class...
848fa46c96f51649bf264a4f239289c2aca71738
simonandreashuber/fibonacci-numbers
/fibonacci_numbers/fibo.py
367
3.984375
4
import time def fib(nr): a = 0 b = 1 while nr > 0: b = a + b a = b - a nr = nr-1 print(a) def fib_even_or_odd(nr): if nr%3 == 0: print("gerade") else: print("ungerade") print("ex: (nr,fib_nr), (0,0), (1,1), (2,1), (3,2), (4,3), (5,5), (6,8)") nr = int(input("nr? ")) ...
6f56f25fa65f29e53ea13721103f5aee18584d07
pocession/ptt
/database_searcher.py
426
3.921875
4
import sqlite3 article_number = int(input("How many articles you want to search for? ")) inputlist=[] i = 0 while i < article_number: inputlist.append(input("Enter your {a}th article: ".format(a=i))) i+=1 conn = sqlite3.connect('ptt.db') c = conn.cursor() for element in inputlist: cursor = c.execute("SELECT...
3f24a5778e74635d1d995bdfd96a5fc28224ed21
DjangoGirlsSeoul/emotiontracker
/server/audio.py
1,002
3.5
4
"""PyAudio Example: Play a wave file.""" import pyaudio import wave import sys import threading CHUNK = 1024 def play_audio(audio_file_location=None): wf = wave.open(audio_file_location, 'rb') # instantiate PyAudio (1) p = pyaudio.PyAudio() # open stream (2) stream = p.open(format=p.get_format_...
7aa9ece60b3574e3b90f60a4a510830ac1e22101
JustinWhalley-Carleton/Space_Invaders
/how_to_play.py
2,203
3.515625
4
import pygame from colors import * # display how to play text def how_to_play(width): TEXTSPACING = 20 HEADERSPACING = 25 PARAGRAPHSPACING = 10 display_surface = pygame.display.set_mode((width,width)) pygame.display.set_caption('How To') header_font = pygame.font.Font('free...
af152b6602ae22786a7ae542f489c11864b46462
MurtazaMushtaq/final-scores-calculator
/project/finalassignment120.py
11,379
3.84375
4
##################################################################################################### #### CMPT 120 Final Project (Scantron) #### #### Authors: Murtaza Mushtaq(301347189) #### #### ...
6b9527ac26a2be8b19fdf73d9437372b5ac07f99
AmeyaK95/Traffic-Simulation
/HE final.py
3,139
3.5
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 05 21:03:36 2016 @author: Ameya """ import numpy as np import matplotlib.pyplot as plt import scipy class heatexchanger: L=10 P=10 U=100 Ma=1 Mb=2 n=110.0 guess=350 # define guess value outside function definition ...
847ddc814009a3df4911094f8361f02aa9de1d6c
CanerErdogan/aoc2020
/week1/day03.py
655
3.5625
4
with open('day03.txt') as fp: area = fp.readlines() def trees_count(area): x = -3 trees = 0 for line in area: x += 3 row = line.replace('\n', '') if row[x % len(row)] == '#': trees += 1 return trees print(trees_count(area)) def trees_multiplied(area): slopes = [(1, 1), (3, 1), (5, 1),...
5dacab0d11bf00630f7d8f271d47658f471d7f70
awildstone/Water-Mate
/solar_calculator.py
11,872
3.609375
4
"""Solar Calculator & helper methods.""" import requests, json from datetime import date, datetime, timedelta from tzlocal import get_localzone BASE_URL = 'https://api.sunrise-sunset.org/json' class SolarCalculator: """A class to get the solar forcast calculations based on a user' location, the current date...
7d2af1c4b0e3290e6abef847daa5401444d3e342
DaviNakamuraCardoso/Use-a-Cabeca-Aprenda-a-Programar
/Code/JogodaVida/model.py
3,663
3.515625
4
import random altura = int(100) largura = int(100) def randomizar(grade, largura, altura): for i in range (0, largura): for j in range(0, altura): grade[i][j] = random.randint(0, 1) modelo_de_grade = [0] * altura proxima_grade = [0] * altura for i in range(0, altura): modelo_de_grade[i]...
85352636e9e412d7cfe1173628354c81d818c9eb
DaviNakamuraCardoso/Use-a-Cabeca-Aprenda-a-Programar
/Code/FibonaccieFractais/fibonacci_recursao.py
461
3.78125
4
import time cache = {} def fibonacci(n): try: n = int(n) global cache if n in cache: return cache[n] if n == 0: result = 0 elif n == 1: result = 1 else: result = fibonacci(n-1) + fibonacci(n-2) cache[n] =...
e83b7cb32ef8d307611cc79d5d14c135360ccb16
DaviNakamuraCardoso/Use-a-Cabeca-Aprenda-a-Programar
/Code/FibonaccieFractais/dicionario.py
936
3.5625
4
users = {} movie = [] users['Kim'] = {'email': 'kim@oreilly.com', 'gender': 'f', 'age': 27, 'friends': ['Josh', 'John']} users['Josh'] = {'email': 'josh@wickedlysmart.com', 'gender': 'm', 'age': 32, 'friends': ['Kim']} users['John'] = {'email': 'john@abc', 'gender': 'm', 'age': 24, 'friends': ['Kim', 'Josh']} def user...
9682a61b49e527c3d1ecc019518da093329bafe7
DaviNakamuraCardoso/Use-a-Cabeca-Aprenda-a-Programar
/Code/CalculadoraCanina/calcudadoracanina.py
298
3.671875
4
nome_do_cachorro = input("Qual é o nome do seu cachorro? ") idade_do_cachorro = input("Qual é a idade do seu cachorro? ") idade_humana = int (idade_do_cachorro) * 7 print('Seu cachorro', ',' , nome_do_cachorro , ',' , 'tem' , idade_humana, 'anos em idade canina' )
9bf81481fb577ffa33430778db09df7d0dc25e64
DaviNakamuraCardoso/Use-a-Cabeca-Aprenda-a-Programar
/Code/Funções/auau.py
335
3.671875
4
def latido (nome, peso): if peso > 20: print (nome, 'diz WOOF WOOF') else: print(nome, 'diz woof woof') latido('Codie', 40) latido('Jackson', 12 ) latido('Fido', 50 ) latido('Sparky', 9 ) nome = input('Qual é o nome do seu cachorro? ') peso = input('Qual é o peso do seu cachorro? ') latido(nome...
f0f81ec09dba5b6198788e041de95c1bc74b9465
dzakub77/python_basics
/python_code_basic/kreator_postaci.py
4,044
3.9375
4
""" Witaj w Kreatorze Postaci. Na początek otrzymujesz pule 30 pkt. które, możesz spożytkać na cztery atrybuty. Siła, Zdrowie, Mądrość, Zręczność. """ strenght = 0 health = 0 intelligence = 0 dexterity = 0 points = 30 x = None """ Masz możliwość przyznania pkt. do dowolnego atrybuty, a także możliwość odebrania pkt. i...
df6dfe9d595c7e75bd59b76af1c90446d985fb63
dzakub77/python_basics
/zadania_domowe/zgadywanie_liczb.py
429
3.734375
4
import random number = random.randint(1, 50) tries = 1 guess = int(input("Zgadnij co to za liczba: ")) while guess != number: if guess > number: print("Za duża!") else: print("Za mała!") guess = int(input("Zgadnij co to za liczba: ")) tries += 1 print(f"Brawo! Udało ci się odganąć co t...
3041cfa8a41577657ba506c2df157cc5db31ceb3
dzakub77/python_basics
/zadania_domowe/rysowanie1.py
143
3.609375
4
import turtle turtle.speed(0) def figury(n): for i in range(n): turtle.left(360/n) turtle.forward(100) print(figury(9)) turtle.done()
cb20c7d2245b464fc6c45a4d07cfe6a79d780f78
dzakub77/python_basics
/zadania_domowe/zadanie13.py
359
3.609375
4
def fib(): num = int(input("Ile numerów wygenerowac? ")) i = 1 if num == 0: c_fib = [] elif num == 1: c_fib = [1] elif num == 2: c_fib = [1, 1] elif num > 2: c_fib = [1, 1] while i < (num - 1): c_fib.append(c_fib[i] + c_fib[i -1]) ...
d2629a51424df595a2b42af10e866c14a422b3c7
DivaChen666/Learn_Python
/Lab_04.py
1,499
4.34375
4
""" Author: PLMM Jiayu Chen Date: 2020/07/05 Goal: 1. ASCII 2.FOR LOOPS 3.STRING PROCESSING AND INFORMATION MANIPULATION Ref: USC ITP-115 HW-03 """ # Welcome word print welcome_word = "Would you like to :\n" \ "a) See the ASCII code for the alphabet\n" \ "b) Translate ...
f66091efe8ad7227411f8151779f2c0ffc28e258
otunba32/user-data-validation
/main.py
1,622
3.875
4
from uuid import uuid1 from models.user import User if __name__ == '__main__': # list to store all users users = [] # generate a unique user ID user_id = str(uuid1()) # input first name first_name = input('Enter first name: ') # input last name last_name = input('Enter last name: ') ...
5191ac2f0e920085552f5d3a2ca0e4e1f24b5933
activehuahua/python
/pythonProject/iterator/using_map.py
253
3.796875
4
import copy def f(x): return x*x r=map(f,[1,2,3,4,5,6,7,8,9]) m=copy.deepcopy(r) print(list(m)) print(next(r)) print(next(r)) print(next(r)) print(next(r)) print(next(r)) print(next(r)) print(list(r)) a = [1, 2, 3, 4, ['a', 'b']] a.remove(1)
dc69b13b5c96a8ff5402a34577f9f5ffc03106b8
activehuahua/python
/Arithmetic/sort/bubleSort.py
546
3.953125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- ''' File Name: bubleSort Description : Author : zhaojianghua date: 2018/12/23 ''' dataList=[3,5,4,1,2,6] def bubleSort(list): n=len(dataList) for i in range(n): flag=False for j in range(n-i-1): if list[j]>...
f213164c1f5bde65d2df87518990016c11b8cada
activehuahua/python
/pythonProject/string/test1.py
341
3.515625
4
def make_great(magicians): for name in range(0,len(magicians)): magicians[name]='the great '+magicians[name].title() # magiccians=['a','b','c'] # make_great(magiccians) # print(magiccians) import itertools counts=[0]*5 a1 = [1, 1, 4, 1] for num in a1: counts[num]+=1 counts=list(itertools.accumulate(c...
5a8aa197da2f3e6826b1f4b2b19ae3c2c4639b2a
activehuahua/python
/pythonProject/base/easy_input.py
107
3.5625
4
print('%s is number %d'%('alex',1000)) s=[x**2 for x in range(8) if x % 2 ==0 ] for i in s: print(s)
58c6bdbc9f86830a57bac9c6b801398e66915054
activehuahua/python
/DataAnalysis/05/0.py
424
3.5625
4
# -*- coding: utf-8 -*- # @Time : 2019/2/20 16:32 # @Author : zhaojianghua # @File : 0.py # @Software: PyCharm # @Desc : # -*- coding: UTF-8 -*- import pandas as pd df = pd.DataFrame([{'col1':'a', 'col2':'1'}, {'col1':'b', 'col2':'2'}]) print(df.dtypes) df['col2'] = df['col2'].astype('int') print('--------...
1a7e74a49ec2a1b3829b9e13b3cf2fdc7e45d714
activehuahua/python
/pythonProject/base/xmath.py
451
3.671875
4
import math def quadratic(a,b,c): xx=[] try: xx.append((-b+math.sqrt(b*b-4*a*c))/(2*a)) xx.append((-b-math.sqrt(b*b-4*a*c))/(2*a)) return xx except Exception as ex: print(ex) print(quadratic(2,3,1)) def enroll(name,gender,age=20,city='Chengdu'): print('name:',name) ...
306f01172fa60d23ba335b1cd162b5312279f116
activehuahua/python
/Arithmetic/queue/circular_queue.py
1,375
3.734375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- ''' File Name: circular_queue.py Description : Author : zhaojianghua date: 2018/12/19 ''' from arithmetic.linkedList.singleLinkedList import Node from typing import Optional from itertools import chain class CirularQueue(): def __init__(self...
a5690ee4ae0de747fa8a288bea045a96dbbfe6d9
activehuahua/python
/pythonProject/exercise/6/6.2.py
488
3.625
4
import string import keyword alphas=string.ascii_letters+'_' nums=string.digits myInput=input('Please input a char').strip() while True: if myInput.lower()=='q': break if len(myInput) <=1: print('Please input again') break if myInput in keyword.kwlist: ...
6cf9b7a6da74d216abc66ea746264f1c18662e70
activehuahua/python
/DataAnalysis/05/7.py
364
3.984375
4
# -*- coding: utf-8 -*- # @Time : 2019/2/25 18:03 # @Author : zhaojianghua # @File : 7.py # @Software: PyCharm # @Desc : import pandas as pd import numpy as np from pandas import DataFrame df=pd.DataFrame(np.random.random([3, 3]), columns=['A', 'B', 'C'], index=['first', 'second', 'third']) print(df) ...
8ebcefd6a4a3eb966900da9935fe2fc4c9d4b420
activehuahua/python
/pythonProject/exercise/8/8.5.py
396
3.859375
4
import string def getfactors(num): list1=[num,1] count=num//2 while count>1: if num % count==0: list1.append(count) count-=1 return list1 if __name__=='__main__': prompt=input('Please input a num:') while prompt.lower()!='q': list2=getfactors(int(prompt)) ...
96cf37701de6a54cafb3fa5ed9e84f0a62522885
miaoxu1com/Python_project
/untitled/day03/cards_tools.py
5,849
3.640625
4
card_list = [] def show_menu(): """显示菜单""" print('*' * 50) print('欢迎使用【会员管理系统】') print('') print('1.新增会员') print('2.显示全部') print('3.搜索会员') print('0.退出系统') print('*' * 50) def new_card(): """新增名片""" print('-' * 50) print('新增会员') # 1.提示用户输入名片的详细信息...
2277dfb7feebf2fae098a2a6bb1e22e6796da2f2
miaoxu1com/Python_project
/untitled/day03/map02.py
716
3.96875
4
map_ ={"name01":"张三01", "name02":"张三02", "name03":True, "name04":"张三05", "name05":4, "name06":"张三06", "name07":"张三07"} # 得到所有key值组成的列表 keys = map_.keys() print(keys) # 直接获取说有的 key:value for key in keys: print(key,map_.get(key)) print("===========...
06d4aa05a78b736955bd3cec6a79701d3a85c749
aribajahan/Projects
/learnPTHW/ex20.py
1,247
4.3125
4
#when calling this file from command line, give a file: test.txt in LearnPTHW from sys import argv #imported aurguements. Still a lil unsure what this does. I think it helps in doing scripts. script, input_file = argv def print_all(f): print f.read() #f. is the variable for functions when using files. It can read,...
6f1d6857c2256e5f8c9171b2ced8343ac51faf0c
aribajahan/Projects
/learnPTHW/ex15.py
508
4.3125
4
from sys import argv script, filename = argv #this calls THIS file as the script and filename you give txt = open(filename) #opens the file print "Here's your file %r:" % filename print txt.read() #reads and shows the text in the file print "Type the filename again:" file_again = raw_input(">") #this time the file...
89b4eac7aeafb19d055c095ec2d179bc3e1eec43
savmasse/multimedia-project
/src/Shuffler.py
2,447
3.671875
4
import numpy as np; import matplotlib.pyplot as plt; import itertools """ Abstract class for all shuffler classes. """ class Shuffler (object): def __init__(self, puzzlePieces): self.puzzlePieces = puzzlePieces; # Get the flattened image self.flattened = 0; self.flatt...
890f2b558b250ec082452e7608b545e3b7a0703f
dmitryro/facebook
/leetcode/875/koko.py
806
3.578125
4
class Solution: def minEatingSpeed(self, piles: List[int], h: int) -> int: """ T: O(n* logk), where k is largest number of bananas in the pile. """ l = 1 r = max(piles) + 1 def count_hr(k): h = 0 for p in piles: h += p ...
0998a0d74726c8849195dbe5572d5109fd2fd882
MarcusMaracaja/CursoemvideoPython
/pythonExercicios/ex019.py
293
3.71875
4
import random print('Sorteio de um aluno para apagar o quadro\nEscreva os nomes dos alunos:\n') A = input('Aluno 1: ') B = input('Aluno 2: ') C = input('Aluno 3: ') D = input('Aluno 4: ') sorteio = [A, B, C ,D] sorte = random.choice(sorteio) print(f'O aluno sorteado foi: {sorte}')
a8a2c92e5ad11473edbbfea6fbda9a7dd20c2214
MarcusMaracaja/CursoemvideoPython
/pythonExercicios/ex016.py
268
3.984375
4
import math print('Leia os catetos e calcule a hipotenusa') co = float(input('Digite o tamanho do cateto oposto: ')) ca = float(input('Digite o tamanho do cateto adjacente? ')) h = math.sqrt(ca**2 + co**2) print('O tamanho da hipotenusa é: {:.2f}'.format(h))
25667b39c6ff3b41f267dfc2e866d2c25780643d
MarcusMaracaja/CursoemvideoPython
/pythonExercicios/ex007.py
207
3.796875
4
print('Lê as duas notas do aluno e mostra sua média') n1 = float(input('Digite a primeira nota: ')) n2 = float(input('Digite a segunda nota: ')) print('A média do aluno é: {:.1f}'.format((n1+n2)/2))
b4e18c9f1a27a125c555f154a02be57560c81ce9
MarcusMaracaja/CursoemvideoPython
/pythonExercicios/ex024.py
290
4.03125
4
print('Lê o nome de uma cidade e diz se ela tema palavra santo') cidade = input('Escreva o nome de sua cidade: ') cidade = cidade.title() tem = cidade.find('Santo') print(cidade) if tem != -1: print('A cidade com Santo! Parabéns!') else: print('Cidade sem Santo!')
0c2d052253e1792cdb78d3a4da240c0bacb4e13b
jakerye/notebook
/threading/example1.py
303
3.578125
4
# Example 1: Workers output concurrently import threading, time def worker(name): for j in range(100): print("Worker {} - {}".format(name, j)) time.sleep(0.5) threads = [] for i in range(5): t = threading.Thread(target=worker, args=(i,)) threads.append(t) t.start()
9b890add766b6954da91210980228b6abd75d904
Alex7lav81/Group_22
/Python_HW/HW_2_script_7.py
715
4.40625
4
""" Задание 7 Написать скрипт используя функцию input(). 1. Функция должна на вход принимать целое число. 2. Выводить должна "Вы вели число = (введённое число), которое (меньше/больше/равно) 30" """ print("Введите целое число:") var_int = int(input()) if var_int > 30: print("Вы вели число = ", var_int, "...
558f58b15d5eaf21d8275c54d55559581176e274
brunellafl/GUIA-FINAL
/codigo1.py
1,332
4.09375
4
print("Bienvenido al programa...") # Diccionario que recopila los datos del usuario persona={" Nombre":""," Apellido":""," Edad":0," Peso":0," Altura":0," Dirección":""," Telefono":""} # Función que, según el valor final del IMC, te devuelve la categoría en la que estás. def cat_imc( imc ): if imc < 1...
db00c22499f299a630175ca1539ec37550df2e69
bangrenc/work_algorithm
/array/215 Kth Largest Element in an Array_facebook_Microsoft_amason_Bloomberg_Apple.py
411
4.0625
4
""" Name: 215 Kth Largest Element in an Array_facebook_Microsoft_amason_Bloomberg_Apple.py Author: bangrenc Time: 19/1/2020 12:20 AM """ def Kth_largest_Element_in_an_Array(nums, k): nums = sorted(nums) print(nums) result = nums[-k] print(result) if __name__ == '__main__': nums = [3,2,1,5,6,4] #[3...
427440dcc132c3e1644dea2e11738d75ea4a6818
junhyukko/Assingment
/assignment 1/Chopsticks.py
4,317
3.953125
4
from strategy import * from current_state import * class Chopsticks: """ Choose a positive whole number and keep subtracting squares of various numbers if the result is not a negative number. """ def __init__(self, is_p1_turn: bool) -> None: """ Initialize the game with instantiatin...
bb8201acf6b7b65f17ee4c519d6e92d4e0d03a5f
usrfrann/pythonGamesAndGraphics
/snake.py
2,810
3.578125
4
#Snake import random, turtle as t t.bgcolor('yellow') snake = t.Turtle() snake.color('red') snake.speed(0) snake.penup() snake.hideturtle() leaf = t.Turtle() leaf_shape = ((0, 0), (14, 2), (18, 6), (20, 20), (6, 18), (2, 14)) t.register_shape('leaf', leaf_shape) leaf.color('green') leaf.penup() leaf....
dcd0bf01b87bf3909d3134962bbc4618848f5b56
sherri-22/Day-one
/python/inputs.py
215
3.921875
4
print ("\n This is Going to be First Line \n" ) name = input (" Enter your Name : " ) col = input (" Enter your favourite Color : " ) print("\n Thank you \n") print(name + " Your Color of the Day is " + col + "\n")
b5aaaa6fb5d3eeffe5c334dfee8e305e7ba5fa66
raxod502/cs121-whales
/whales/neural_net/chess_alpha_data.py
4,291
3.578125
4
""" Module to convert from a python-chess Board representation of a chess board to the list representation understood by the chess_alpha_zero neural network. The majority of this file is copied directly from chess-alpha-zero/src/chess_zero/env/chess_env.py. """ import enum import numpy as np def board_to_arrays_alph...
fe9ac35d6b84716b63f51682083c69300f2dd25b
swallowsyulika/ML_practice
/6Best_Fit_Slope.py
352
3.78125
4
from statistics import mean import numpy as np import matplotlib.pyplot as plt xs = np.array([1, 2, 3, 4, 5, 6], dtype=np.float64) ys = np.array([5, 4, 6, 5, 6, 7], dtype=np.float64) def best_fit_slope(xs, ys): m = (((mean(xs) * mean(ys)) - mean(xs * ys)) / ((mean(xs) ** 2) - mean(xs ** 2))) return m m = b...
a2f949f9e598ccc900bc3a689ca2d75e2a84b50e
yivash/hate_crimes
/Hate_crime_underground_stations.py
3,134
3.5
4
from math import sqrt import pandas as pd import json data = pd.read_csv("C:/Users/Stasya/Desktop/HateCrime/DS_project/Hate_crime_data.csv") geo_crime=data.loc[:,['Маркер_lat','Маркер_lng']] crime_locs=[] for index, row in geo_crime.iterrows(): crime_locs.append((row['Маркер_lat'],row['Маркер_lng'])) ...
3e6ea47b36eeaa9dcecf96f02e7055c2889f2e6c
hackoregon/hack-u-py-foundations-sum16
/projects/oregon_day2.py
546
3.921875
4
player1 = input('What is your name?: ') player2 = input('What is your player2 name?: ') player3 = input('What is your player3 name?: ') player4 = input('What is your player4 name?: ') player5 = input('What is your player5 name?: ') inventory = { 'oxen':5, 'bullets':1000, 'clothes':15, 'food':1000, 'spare parts':{...
6320f2956d2cf47483b9f04f76ac6733917dfc24
saemundo/ALICE
/alice/wonderland.py
1,602
3.640625
4
class _search: def __init__(self,*args,**kwargs): pass class RabbitHole(_search): """ The RabbitHole search algorithm will drag the search further and further into insanity and utilise solutions from all of the other algorithms""" def __init__(self,*args,**kwargs): super().__in...
149ae0f4642067f03bcbd0ab4092180e8415a164
yigitcode/Ejercicios_python
/E10.py
686
3.9375
4
#coding: utf-8 """ Elabore un porgrama en Python que permita mostrar el estado del alumno, según la nota final del curso . Para ello debe tener en cuenta los siguientes criterios: - Si la nota es menor de 10.50 está desaprobado. - Si la nota es mayor de 10.50 y menor de 20 está aprobado. """ num_alum = int(...
e0b7034f02f74a17c4d1dabcf6ec9249962cbfb4
yigitcode/Ejercicios_python
/E14.py
708
4.03125
4
#coding: utf-8 """ La universidad ofrece una beca de 30% para los estudiantes que cumplan ciertos requisitos. Luego de haber culminado el primer ciclo de su carrera. Los requisitos son los siguientes: - Tener un promedio ponderado mayor o igual a 15. - No tener ninguna falta. Con esta información elabore un alg...
f7e675379c1f2d98cdd42b156bab85c57baadc73
eduardo-mior/URI-Online-Judge-Solutions
/Iniciante/URI 1012.py
772
3.90625
4
retangulo = None quadrado = None trapezio = None circulo = None triangulo = None b = None a = None c = None lista = None def read_line(): try: # read for Python 2.x return raw_input() except NameError: # read for Python 3.x return input() lista = read_line().split(" ") a = float((lista[0])) b = fl...
f202c3106e03f82d519ccfd87d48f8063c92c6ca
eduardo-mior/URI-Online-Judge-Solutions
/Iniciante/URI 1963.py
339
3.640625
4
aumento = None A = None B = None lista = None def read_line(): try: # read for Python 2.x return raw_input() except NameError: # read for Python 3.x return input() lista = read_line().split(" ") A = float((lista[0])) B = float((lista[1])) aumento = (B * 100) / A - 100 print(str("{:0.2f}".format(au...
8eb3dfbd724dcc5f8f16f8cd543b021a3eff54a7
eduardo-mior/URI-Online-Judge-Solutions
/Iniciante/URI 1078.py
622
3.859375
4
n = None def read_integer(): try: # read for Python 2.x return int(raw_input()) except NameError: # read for Python 3.x return int(input()) n = read_integer() print("1 x " + str(n) + " = " + str(n * 1)) print("2 x " + str(n) + " = " + str(n * 2)) print("3 x " + str(n) + " = " + str(n * 3)) print("...
6574e7ed05318a4895a657d7af2a5d4ae04bef14
eduardo-mior/URI-Online-Judge-Solutions
/Iniciante/URI 1015.py
525
3.875
4
import math distancia = None y1 = None y2 = None x1 = None x2 = None lista2 = None lista1 = None def read_line(): try: # read for Python 2.x return raw_input() except NameError: # read for Python 3.x return input() lista1 = read_line().split(" ") lista2 = read_line().split(" ") x1 = float((lista1...
b4c645cad44e6e49a50a5c48b8551a8f06143c50
Dsblima/python_e_mysql
/mysql/connect.py
955
3.546875
4
import pymysql print("teste") aServidor = "localhost" aUsuario = "root" aSenha = "root" aBanco = "universidade" db = pymysql.connect(aServidor, aUsuario, aSenha, aBanco) cursor = db.cursor(pymysql.cursors.DictCursor) # RETORNA OS RESULTADOS EM FORMA DE DICIONÁRIO # EXECUTA CONSULTAS MYSQL def Executa_SQL(pSQL):...
4b1191de9cc9b06b3ecbff1ab7707ba47d775a5a
Dsblima/python_e_mysql
/index.py
346
3.609375
4
""" COMENTÁRIOS Se houver problemas com caractéres acentuados inserir o código abaixo -*- coding: utf-8 -*- """ print("Criando o projeto") #COMENTARIO EM LINHA print("Testando Comentário") """ Comentario em blooo print('teste') """ print('após o comentario') #OPERAÇÕES MATEMÁTICAS #POTÊCIA a**b, significa a elevado...
5c0fc46071cb10c4dc76292e2814ea381af92578
Nadeemk07/Band-Name-Generator
/bandnamegenerator.py
175
3.75
4
print("Welcome to the band generator\n") a=input("What's name of the city you grew up in?\n") b=input("What's your pet's name?\n") print("Your band name could be "+ a +" "+b)
1dac5c8cb9c737cc3b60be509cd3b58eec9e8c03
ansh8tu/Programming-with-python-Course
/String_Rotation.py
427
4.34375
4
# This is a python program to rotate string left and right by d length def rotate(input,d): # slice string in two parts for left and right Lfirst = input[0 : d] Lsecond = input[d :] Rfirst = input[0 : len(input)-d] Rsecond = input[len(input)-d : ] # now concatenate two parts tog...
287b45d4bda04318b82a2907c9a29bd6b22c4c39
tonylixu/python-notebook
/notebook.py
1,623
3.859375
4
from note import Note class Notebook: ''' Represent a collection of notes that can be tagged, modified and searched. ''' def __init__(self): '''Initialize a empty notebook list''' self.notes = [] def new_note(self, memo, tags=''): ''' Create a new note and appe...
c8abec58cb831f217919c92664cb3869ce3ddb26
rohitraghavan/D03
/HW03_ex06.py
4,647
4.03125
4
#!/usr/bin/env python # HW03_ex06 # (1) Please comment your code. # (2) Please be thoughtful when naming your variables. # (3) Please remove development code before submitting. ############################################################################### # Exercise 6.2 # See 6.1: "write a compare function takes two v...
a03e574e81c83e735b00ebb569483e977775a034
kory0005/python-lab-10
/updateRow.py
439
3.703125
4
import sqlite3 # CONNECTION conn = sqlite3.connect('week10.db') c = conn.cursor() # CREATE NEW DATA while True: city = input('City: ') country = input('Country: ') student = input('Student: ') newId = input('id: ') c.execute("UPDATE lab10 SET City='{}', Country='{}', Student='{}' WHERE id={}".form...
39859ebeb22f90808a8696e181f94646b1817a0a
vastopol/practical
/leetcode/Mock/rand1/rotstr.py
674
3.90625
4
# We are given two strings, A and B. # A shift on A consists of taking string A and moving the leftmost character to the rightmost position. # For example, if A = 'abcde', then it will be 'bcdea' after one shift on A. # Return True if and only if A can become B after some number of shifts on A. class Solution: def...
d630455d9b259c8831a104e8250b874b7a29e550
qasimriaz002/LearnPython
/LearnGUI_5_BindingFunctionsToGuiLayoutAndEvents.py
1,072
4.28125
4
from tkinter import * root = Tk() def func(): print("Hello Function Is Called Directly ") def funcLeftClick(event): print("Hello Function Is Called Using The Event Left Click On Mouse") def funcScrollClick(event): print("Hello Function Is Called Using The Event Scroll Click On Mouse") def funcRigthClic...
7e6fe164d08ab540b47da4cf52f0659d3d025df5
architpandita/dataStructure
/select_sort.py
955
4.46875
4
#selection sort ''' 1. The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. 2. Inplace sorting algo 3. Worst time complexity O(n^2) ''' def select_sort(arr,order='asec'): for i in ra...
13a5f4e6f187d4e53086025d079b88dc18ddc37b
freezees/wxpython
/practice/class/Myclass.py
317
3.65625
4
class Human: def __init__(self, name , age ): self.name=name self.age=age def hello(self): print('I am human') class Chinese(Person): def __init__(self,high, weight): self.high = high self.weight=weight hair='black' p1 = Chinese(180,75) p1.hello()
2799d1dc2790bdaf873d217e5bea3a48ab6d2d86
oliver-nowak/nos
/insertion_sort.py
623
3.859375
4
from numpy import loadtxt def insertionsort(arrayToSort): for i in xrange(1, len(arrayToSort)): j = i # iterate through the rest of the list while j > 0 and arrayToSort[j-1] > arrayToSort[j]: # swap tmp = arrayToSort[j] arrayToSort[j] = arrayToSort[j-1...
0b6d727eee724a0c360c88d2a46983612a12c785
juvaber/kivy
/aprendekivy/aprendekivy03/main.py
2,018
3.515625
4
from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label from kivy.uix.button import Button from kivy.uix.textinput import TextInput from kivy.core.window import Window # Definimos la clase MiLayoutRaíz que hereda de BoxLayout class MiLayoutRaiz(BoxLayout): def __init__(sel...
844233107e47b0e9ddc266da78922a7ce12b35bb
MinCheol-JOO/thisiscodingtest
/2장.주요알고리즘이론/06.정렬/6-4.py
567
3.9375
4
array = [5, 7, 9, 0, 3, 1, 6, 2, 4, 8] def quickSort(array, left, right): if left >= right: return pivot = left s = left + 1 d = right while s <= d: while s <= right and array[s] <= array[pivot]: s += 1 while d > left and array[d] >= array[pivot]: d...
59209698db7b53859d7c357029460b92d68a5dd5
MinCheol-JOO/thisiscodingtest
/2장.주요알고리즘이론/06.정렬/6-10.py
113
3.703125
4
n = int(input()) list =[] for _ in range(n): list.append(int(input())) list.sort(reverse=True) print(list)
1e9d31ff55f6281ddf6b8aa628cbaef60feacfa8
cduvallet/pyjanitor
/janitor/functions.py
11,102
3.6875
4
import datetime as dt from functools import reduce import pandas as pd from .errors import JanitorError import re def _strip_underscores(df, strip_underscores=None): """ Strip underscores from the beginning, end or both of the of the DataFrames column names. .. code-block:: python df = _s...
065187b99697f5385559f1fe76498da8b2a6434b
Qwlouse/MontyLearning
/datasets/toy_examples.py
1,765
3.546875
4
#!/usr/bin/python # coding: utf-8 from __future__ import division, unicode_literals, print_function from bunch import Bunch import numpy as np def load_xor(): xor = Bunch() xor.DESCR = "The XOR function from logic. A Toy Example for Neural Networks. "\ "Needs at least two hidden units." x...
5bcf132d12fbc3bd976a09b970d3eb2fd7dd087c
Heroftime/euler
/problem3.py
553
3.90625
4
""" Largest prime factor Problem 3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? """ # Number to find the largest prime factor for number = 600851475143 factors = [] prime = 1 flag = True while flag: if (number / prime).is_integer(): factors...
7b5ba6fb3934aef08ffbddd17b6c3e93be9ebb57
jeremykid/Algorithm_project
/trial_division.py
1,193
3.6875
4
import math import time def primeGenerate(number): largest = number prime_list = largest*[1] if (number<4): return [2,3] prime_list[1] = 0 for i in range(0,largest,2): prime_list[i] = 0 prime_list[2] = 1 for i in range(3,largest,2): if (prime_list[i] == 1): ...
dfd356bbf59a6e6f64b7dc01328319df787c0751
kabhari/Project_Euler
/P0016-Power-Digit-Sum/power_digit_sum.py
420
3.921875
4
''' Q: 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? ''' ''' final answer: 1366 ''' # init constant pwr = 1000 base = 2 # compute def compute(): result = str(base ** pwr) digits = [int(d) for d in result] return (sum(digits)) if _...
7d016701d33e568615a2bef6cf1c499deff7bca5
annaQ/annaWithLeetcode
/findSumSet(not leet code).py
798
4.0625
4
#The goal here is to find all the sets of integers which sum up to a given number #for example: 2 = 1+1; 3 = 1 + 1 + 1 = 1 + 2; 4= 1 + 1 + 1 + 1 = 2 + 1 + 1 = 3 + 1 = 2 + 2 def findSumSets(n): #for number n, there could be the very basic n-size set, sum up of n 1s, to two-element sets #They will be all different from...