blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d469a02d2cae764004432ddf2911fc6166242c44
vickymg/learn-python-the-hard-way
/exercise_18.py
639
4.34375
4
# Names, Variables, Code, Functions # Functions do three things: # 1. They name pieces of code the way variables name strings and numbers # 2. They take arguments the way your scripts take argv # 3. Using #1 and #2, they let you make your own mini-scripts or "tiny commands" def print_two(*args): arg1, arg2 ...
b377b46f627560d4a8eb05dc7f6488f625f8fa6a
Genei-Ltd/genei-data-model
/geneidatamodel/merge.py
1,128
3.6875
4
""" Takes a list of Resource, Section or Blocks and combines them. """ from typing import List from copy import deepcopy from . import Resource, Section, Block def merge_resources(resources:List[Resource], allow_overwrite:bool =True) -> Resource: """ Merges a list of Resources into 1 Resource. Sections are...
793a542cc4e9842dc6817044dca6fe168b72fab5
LievenPetersen/walking_wolfgang
/controllers.py
13,912
3.609375
4
import math import abc from sim_interface import SimInterface class Controller: @abc.abstractmethod def update(self): pass class SmoothMotorController(Controller): """provides abstract control for a given joint""" def __init__(self, name, interface: SimInterface): super().__init__(...
0d35a1092db18a3bcd6f3cd4d3c6d508d7901f79
eoershova/fictional-barnacle
/hw6/hw_6.py
1,635
4.15625
4
# хайку на немецком import random def read_words_from_file(filename): with open(filename, 'r', encoding='utf-8') as f: text = f.read() words = text.split(', ') return words def article(): articles = read_words_from_file('articles.txt') return random.choice(articles) def noun(): ...
245604e79c8ed31ee158f3c24837dbecbe034729
pydroponics/Hardware
/trunk/ACAMP/PythonTests/TimerTest.py
1,019
3.609375
4
#!/usr/bin/python # Python Test Programs: Timer Threads # Author: Stark Pister # 5/20/13 import threading import time import io import string def printTime(): print time.strftime("%H:%M:%S", time.localtime()) def lightOff(): print 'Light Off' printTime() def lightCycle(): #if no cycleStartTime.db st...
43f88ad96c4e824b45d6914674ca6554a5ae4c1a
Harvey-46904/ejemploTT
/ejemplos.py
257
3.578125
4
#variables #int , str, bool, float def persona(nombre,apellido): print("hola",nombre, "su apellido es :",apellido) def suma(a,b): resultado=a+b print("la suma es : ",resultado) a=int(input("Digite a: ")) b=int(input("Digite b: ")) suma(a,b)
773dccf9d22d56e1cd09b46a197da33f24643330
raisulsohan/letter-counter-app
/main.py
361
4.15625
4
print("Welcome to the letter counter app") name = input("What is your name? ") greet = ("hello") print(f'{greet.title()} {name.title()}!') msg = input("Please enter a message: ") letter = input("which letter you want to count? ") letter = letter count = msg.count(letter) print(f"{greet.title()} {name.title()}! You...
1d9e399e357f34180b280b50dd4e91bfc2b32acf
nazlitemur/oware
/oware.py
12,023
3.53125
4
import game_state import game_player # Subclass of GameMove describing a single move in a game of Oware class OwareMove(game_state.GameMove): # Sets the player making the move, the pit being emptied, # and whether the move is a forfeit on creation # # "player" is a valid player ID for an OwareState # "pit" is a...
5b3b05230a49b1e9925ac3de7aec76bb77fbe435
FabianSuarezBotero/TrabajosPython
/py2_retos1/reto4.py
217
4
4
a = int(input('Ingrese un numero:')) b = int(input('Ingrese otro numero:')) if (a < b): print(f'{a} es menor que {b}') elif (a > b): print(f'{a} es mayor que {b}') elif (a == b): print(f'{a} y {b} son iguales')
ce0fdb29d69335193fcdb72fdce7c1884f56cab5
FabianSuarezBotero/TrabajosPython
/py6_retos2/reto06.py
461
3.734375
4
import random num_rand = random.randrange(121) if num_rand > 10 and num_rand < 50: print (f'El numero random {num_rand} se encuentra entre 10 y 50') else: if num_rand > 50 and num_rand < 100: print (f'El numero random {num_rand} se encuentra entre 50 y 100') else: if num_rand > 100: print (f'E...
d7de9f45bb04ebc70f020139a82344c62e973118
MicroFish91/Python-Basics
/data_structures/queues.py
491
3.859375
4
# Queues - FIFO (First in first out) # Normally expensive to pop off front of large lists O(n) # Deque (double ended queue) is preferred over list in the cases where we need quicker append # and pop operations from both the ends of container, as deque provides an O(1) # time complexity for append and pop operations as...
e541572447b6d7bead08fc0e7f8f8330681966f4
MicroFish91/Python-Basics
/data_structures/arrays.py
422
3.734375
4
# Arrays can store data very compactly and are more efficient for storing large amounts of data. # Arrays are great for numerical operations; lists cannot directly handle math operations. For # example, you can divide each element of an array by the same number with just one line of code. from array import array # ty...
15f25c6df987735c14289fe46f185d08bbc7073b
silenc3502/ESPython001
/ans/2/python/5.py
403
3.53125
4
import random def quiz20_game(): cnt = 20 rand_num = random.randint(0, 100) print("1 ~ 100사이의 난수를 맞춰보시오.") while(cnt > 0): din = int(input("{0} 번의 기회가 남았습니다.\n".format(cnt))) if(din == rand_num): print("정답") break elif(din > rand_num): print("입력이 더 크다.") else: print("입력이 더 작다.") cnt -= 1 q...
e7fe433cdf5f67fe7ff08ac6aeadbeaf33c08fa3
roni97/Arkademy-Batch15-Kloter4
/4.py
361
3.875
4
def validateColor(input): c = ['9','2','5','2','1','1','2','2','4','4,'] output = [i for i in input if i not in c] if (output == []): print("input yang di terima adalah string") else: print("input yang di terima bukan string") # Main program hex_number = str(input("Input Hex ...
dcdba8ac0d3d82a18ff39072b3717a15e6b607ec
agoetz/MB-Fit
/mbfit/calculator/model.py
950
3.59375
4
class Model: def __init__(self, method, basis, cp = False): """ Constructor for the Model class. Args: method - The method of this model. basis - The basis set of this model. cp - Is counterpoise correction used in this model? Default: False Returns: None. """ self.method, self.ba...
59e21ee581c51d26e2f92460899618a502816e04
metafridays/SkillFactory-QA-Public
/Task15_4_3.py
167
3.53125
4
list_to_sort = [25, 47, 13, 5, 77, 12] list_to_sort.sort(key = lambda x: str(x)[0]) list_to_sort = [str(item) for item in list_to_sort] print(", ".join(list_to_sort))
e6f56cd3afcca31094c8c9134fac49d34aaeb124
metafridays/SkillFactory-QA-Public
/Task12_6_6.py
498
3.5625
4
string = "info@value.com, value@info.com, com@value.info, q@value.com, q@vlue.c, 1asaf.asdf, qwe@wer@sdhjkfhs.dfsd" emails = string.lower().split(', ') dict = {} for i in range(len(emails)): str = emails[i] if str.count('@') != 1: dict.update({str:False}) elif str.index('@') < 2: dict.update({str:False}) ...
a396ee3209bb6cc8f2931b867e0dfb7f30da9272
JoyNwGit/ECE-143-Indiviual-Project
/IndivProject.py
17,705
3.96875
4
# -*- coding: utf-8 -*- """ Created on Fri May 18 08:49:11 2018 @author: Joy Nwarueze This is a python script that adds random rectangles of various sizes and locations to a region specified by the user. Each new rectangle appears as green then changes to gray when integrated into the total coverage area. ...
45d778c09a76655d3637ffb28aae16ca7771cc61
jcpsimmons/MovieCritics
/archiveThis-gettingMovieTitles.py
815
3.640625
4
import urllib2 from bs4 import BeautifulSoup #repl. with a way to scrape this from https://www.rottentomatoes.com/critics/authors name_list = ["armond-white", "anthony-lane", "peter-rainer"] critics = {} ## initialize critics key value pair with score for name in name_list: critics[name] = .5 #testing test_pag...
997009f06978372e49e1256bf223115cfb38aaa0
bstk0/python
/basics/test2.py
309
3.890625
4
s=["BRAZIL","USA","INDIA"] print(s) #s.add("ARGENTINA") #print(s) s.insert(len(s),"ARGENTINA") print(s) s.append('Russia') print(s) s.remove("USA") print(s) s.insert(1,'Japan') print(s) #----------------------------- lista={"india","china"} lista.append("russia") lista.remove(2) print(list)
62b81f4b30e62a44eb1540d7d5f464eb2355f8b9
ericnordelo/crypto-algorithms
/scripts/SubstitutionCipher.py
700
3.75
4
import random def generate_key(): letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" cletters = list(letters) key = {} cnt = 0 for c in letters: key[c] = cletters.pop(random.randint(0, len(cletters) - 1)) return key def encrypt(key, message): cipher = "" for c in message: if c in...
9ed8a55e2919685f0310333b4c8194b8e1b85702
zhouyijiabc/csv
/csv_file.py
979
4.0625
4
#!/usr/bin/python # -*- coding:utf-8 -*- import csv # 写入csv文件 def csv_writer(data, filename): with open(filename, 'wb') as csv_file: writer = csv.writer(csv_file, delimiter=',') for wline in data: writer.writerow(wline) # 读取csv文件 def csv_reader(filename): with open(filename, 'rb')...
2a90ebc4c70c15d8c09b8f448f8c7e8614ec7e47
NCdJ/eBikeIUL_projA94789
/Viatura.py
3,965
3.84375
4
class Viatura: # Teoria: # O construtor é o que define os atributos da classe def __init__(self, nome, modelo, tipo_eletrica, preco_base): # Não deverá ser possível alterar nenhum dos atributos além do preco_base se...
efa71b6309d859b7bd16e75ae6afe56b246b82df
UjjwalKumar5/Palindrome
/palindrome.py
1,218
4.21875
4
# how to print the reverse the given Word or number a = 0 def reverse_number(num): reverse_num = 0 while num > 0 : remin = num % 10 reverse_num = (reverse_num * 10) + remin num = num//10 print(reverse_num) reverse_number(112233) abc = "Hello World" print(abc[::-1]) bcd = "The...
817732617cc081631953b3e9e0f077a962b6cdcf
Naea1996/bootcamp
/dia1.py
4,410
3.984375
4
#operacion aritmetica print(2+2) print(2/2) print(30/5) print(4*4) #lo siguiente es una concatenacion de strings print("hola mundo") #imprimir un texto 4 veces print("hola"*4) print("hola"+"que tal") #variables las variables son cajas donde se pueden cargar numeros letras etc a=2 b=4 print(a*b) c="nora" d=5 print(c*...
35f1585854f946dee0ec6839e48dacda2952816b
jarangol/ParallelClustering
/kmeans.py
1,394
3.515625
4
#coding=utf-8 '''Implementation and of K Means Clustering''' import numpy as np # el de nosotros def kMeans(X, K, maxIters = 10): # generamos k centroides con valores aleatorios centroides = np.random.rand(K,len(X[0])) for i in range(maxIters): # assinacion de centroides C = asignar(X,centr...
bf61b573f4ed38194cb5ed0cec1a3fbc9c410878
SajjanKarn/mailsender
/main.py
1,808
3.8125
4
from tkinter import * # For GUI import smtplib # Module for sending mails from tkinter import messagebox # for displaying message box root = Tk() # This fucntion will be called when the user will click on send mail button def send_mail(): server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls()...
dbedad1ac31a5d049aa905470b7b6f2b891b42d1
issacianmutiara/Issacian-Mutiara-Paska_I0320053_Tiffany-Bella_Tugas6
/I0320053_Soal 2.py
299
3.796875
4
print('=====Menghitung rata rata=====') print() x = int(input('Masukkan jumlah data input: ')) data = [] i = 1 while i <= x: score = float(input("Masukkan nilai : ")) data.append(score) i += 1 rata2 = sum(data)/x print() print("Nilai rata rata dari data yang telah di input adalah : ")
542692384c7a6321e31a5ef2441880057862339c
xiaohuixianone/py-patterns
/Facade/facade1.py
1,167
4.03125
4
""" 门面设计模式 又叫外观设计 整个模式的执行方式就是,门面接收客户端的需求,去安排系统完成工作。用一个简单的例子举例:去快餐店,我们向服务员点了一份xx套餐,套餐里有一杯冰可乐,一个汉堡,一份薯条,这时服务员听到你的点餐后,扭头告诉后厨需要一份xx套餐,于是后厨有三个人开始行动,一个做可乐,一个做汉堡,一个做薯条。这个例子里,你就是客户端,服务员为门面,后厨的三个人做东西为三个子系统,他们组合合作完成这份套餐的制作。这样看来,门面模式的理解便非常简单了 原则: 1 最少知识原理 减少对象之间的交互 2 """ class facade: def __init__(self): self.b...
592922a825bbf7cefe176bee43992d2af5f04cf2
xiaohuixianone/py-patterns
/Factory/fac1.py
1,430
3.90625
4
class ShapeFactory(object): def getShape(self): return self.shape_name class Circle(ShapeFactory): def __init__(self): self.shape_name = "Circle" def draw(self): print('draw circle') class Rectangle(ShapeFactory): def __init__(self): self.shape_name = "Retangle" d...
7356f20252282ea3eb55298f7c23fbf1b0b03839
SaiPrasadRaju37/Python_DL-2020Summer
/Python/ICP2/Sourcecode/alternative.py
372
4.09375
4
def string_alternative(value): list_input=list(value) list_output=[] for i in range(len(list_input)): if(i%2==0): list_output.append(list_input[i]) string=''.join(list_output) return string def __main(): Str = input(("Enter Input String:")) print("Input:", Str) retur...
5d3590d9b8f3f38649e7cdeea490afa7e0c2e63b
zyken/BachelorProject
/inselect-master/inselect/lib/rect.py
2,432
3.71875
4
import collections # Simple representations of Points and rectangles Point = collections.namedtuple('Point', ['x', 'y']) Coordinates = collections.namedtuple('Coordinates', ['x0', 'y0', 'x1', 'y1']) class Rect(collections.namedtuple('Rect', ['left', 'top', 'width', 'height'])): @property def area(self): ...
cf2c6acd99390b0fa548fc1cdc8bb2ad8a1bd8f2
lirui-boom/Python
/20190407/7.Salary.py
228
3.546875
4
time = float(input("请输入员工工时:")) if time < 60: pay = time * 80 - 700 elif time <= 120: pay = time * 80 elif time > 120: pay = 120 * 80 + (time - 120)*(80*(1+0.15)) print("该员工工资为:",pay,"元")
b5c41b0af036fe9ad6a72ee2f4ed0d9eecb1f0c2
MDRODGERS17/Apprenticeship-Workspace
/Python Practice/caesar.py
842
3.78125
4
import sys from cs50 import get_string def main(): # Checks for CLA and prints error message along with system exit of 1 if len(sys.argv) != 2: print("Usage: My name is Maximus Decimus Meridius, Commander of the Armies of the North.") sys.exit(1) # Prompts for ptext and prints out cipherte...
a5be6ae2fd05612614762c3c6cbd2bb192b20f62
DoHwanYoon/Python
/BAEKJOON/8393.py
74
3.625
4
a=int(input()) result=0 for i in range(a+1): result += i print(result)
47a124caa6533df26c154df7ac5abe46c5820e25
VolatileDream/dot-files
/intersperse
723
3.609375
4
#!/usr/bin/env python3 import sys import argparse def args(): parser = argparse.ArgumentParser(description="plot characters on the command line") parser.add_argument("files", nargs="+", help="list of files to intersperse, - for stdin") return parser def intersperse_files( files ): fds = [] for name in files:...
4e7218300f843c21acb3508fad8249bf1581018c
pkdasgupta/py-learning
/multable.py
107
4.03125
4
num=int(input("Enter the number : ")) def mlt(n): for i in range(1,11): print(i*n) mlt(num)
e0591f1a3312cf1d613d8be3441cc84b384f28c5
pkdasgupta/py-learning
/pycalc.py
499
4.15625
4
# Write a class calculator capable of finding square, cube and the square root of a number. class Calculator: def __init__(self, numval): self.numval = int(numval) def sq(self): return self.numval ** 2 def cb(self): return self.numval * self.sq() def sqt(self): retur...
c2558c152a9c286abd1f5d4bd1f3a8d069171f36
LtHoangTran/PythonPracticeSimple
/TryAndExceptStatements2_Improve.py
692
3.625
4
def numberOfCat(numCat): try: if int(numCats)<0: return 'Negative number input.' elif int(numCats)>0: if int(numCats)>=4: return 'Lots of cats.' else: return 'That is not that many cats.' except: return 'Input ...
f50dc20b87e427e25f7462b39cc30cc8d0b10e1b
LtHoangTran/PythonPracticeSimple
/USPhoneNumber.py
910
4.0625
4
def isPhoneNumberUS(text): if len(text) != 12: return False # not phone number-sized for i in range(0,3): if not text[i].isdecimal(): return False # no area code if text[3] != '-': return False # no dash for i in range(4,7): if not text[i].isdecimal()...
cb17722e72ee8882165519405be80624b8afae2a
NgZhengWei/CS50
/pset6/dna/dna.py
1,224
3.859375
4
from sys import argv, exit import csv if len(argv) != 3: print("Usage: python dna.py data.csv sequence.txt") exit(1) with open(argv[2], newline='') as csvfile: reader = csv.reader(csvfile) for row in reader: unknownSeq = row[0] #get seq to identify as a string with open(argv[1], 'r') as csvfi...
8eaa55e645f6175b3d3d0b28a7116b7e284973af
dvu4/udacity
/Project 5/Project5-1 Reducer.py
564
3.828125
4
import sys def reducer(): ''' Given the output of the mapper for this assignment, simply print 0 and then the average number of riders per day for the month of 05/2011, separated by a tab. There are 31 days in 05/2011. Example output might look like this: 0 10501050.0 ''' ...
07263c88ff8f21f0b147447542a82f8af39d8eb2
anbellouzi/Spaceman
/spaceman.py
5,502
3.921875
4
import random # returns random word from words.txt def load_word(): f = open('words.txt', 'r') words_list = f.readlines() f.close() words_list = words_list[0].split(' ') secret_word = random.choice(words_list) return secret_word # Did not utilize this function def is_word_guessed(secret_word,...
722d62e2073c4ec3e43a83fadb27444cd5090d34
atm1504/tkinter-learn
/canvas.py
541
3.75
4
from tkinter import * from PIL import ImageTk, Image root = Tk() root.title("Learning Tkinter") root.iconbitmap("./images/quality.ico") root.geometry("400x400") myCanvas = Canvas(root, width=300, height=200, bg="white", bd=5) myCanvas.pack(pady=20) # Create a straight line myCanvas.create_line(0, 100, 300, 100, fil...
0599bc1efc7385934fd2f8a709160405a2a2705a
atm1504/tkinter-learn
/speak.py
463
3.515625
4
from tkinter import * from PIL import ImageTk, Image import pyttsx3 root = Tk() root.title("Learning Tkinter") root.iconbitmap("./images/quality.ico") root.geometry("400x400") def talk(): engine = pyttsx3.init() engine.say(myEntry.get()) engine.runAndWait() myEntry.delete(0, END) myEntry = Entry(roo...
cabb104d87bdf63bb02610a3e2c897e5df3cf3fd
atm1504/tkinter-learn
/color_picker.py
471
3.78125
4
from tkinter import * from PIL import ImageTk, Image from tkinter import colorchooser root = Tk() root.title("Learning Tkinter") root.iconbitmap("./images/quality.ico") root.geometry("400x400") def color(): my_color = colorchooser.askcolor()[1] my_label = Label(root, text= "You picked a color : " + my_color, ...
657ac595842a07ae810e4cb1905ca0d4dd48aabb
atm1504/tkinter-learn
/hovering.py
680
3.921875
4
from tkinter import * from PIL import ImageTk, Image root = Tk() root.title("Learning Tkinter") root.iconbitmap("./images/quality.ico") root.geometry("400x400") def buttonHover(e): myButton["bg"] = "white" statusLabel.config(text="I'm Hovering over the Button!") def buttonHoverLeave(e): myButton["bg"] =...
d7aa496c7f801b85a11a1a538d82fcc32f3823d2
atm1504/tkinter-learn
/calculator.py
3,424
4.125
4
from tkinter import * root = Tk() root.title("Calculator") # Input box e = Entry(root, width=29, borderwidth=5) e.grid(row=0, column=0, columnspan=3, padx=10, pady=10) # Numbers click functionlities def button_click(number): #e.delete(0, END) current = e.get() e.delete(0,END) e.insert(0, str(current)...
b2325e7d4a0eea783f19d7e66bc45fed5960cb98
Gchesta/space_allocator
/app/room.py
554
3.65625
4
class Room: """A class for the class Room""" def __init__(self, name): self.name = name self.occupants = [] def __repr__(self): return self.name class Office(Room): """A class for Office which inherits from Room""" def __init__(self, args): self.available_capacity = 6 self.category = "Office"...
2abd329a373a94914cbe1050b23327b6a29f8335
SMAshhar/back-up
/task_3/task_3.py
2,238
3.515625
4
# # # # MAIN CLASS DEFINITION # # # # class PIAIC(): def __init__(self, name, resid, alies): self.name = name self.resid = resid self.alies = alies # # # Following the Student's path # # # class Student(PIAIC): def __init__(self, name, resid, alies, r_no, batch, course): ...
719868126e42d08431ba784fe20488c4af68fb7e
qoelet/psypy
/psypy/ciphers/vigener.py
904
3.65625
4
# Vigener cipher, from 16th century ALPHASET = "abcdefghijklmnopqrstuvwxyz" def encrypt(k, msg): # assumes message only contains alphabets encrypted = "" k_store = list(k) k_store.reverse() for c in msg: x = ALPHASET.index(c) if len(k_store) > 0: k_store = list(k) k_store.reverse() y_c = k_store.po...
34774505f3ddbf057a36680a3dec81af0b244fa4
ApocalypseMac/LeetCode
/Code/py3/archived/1-50/33.py
1,204
3.625
4
class Solution: def search(self, nums: List[int], target: int) -> int: if len(nums) == 0: return -1 elif len(nums) == 1: if nums[0] == target: return 0 else: return -1 lo, hi = 0, len(nums) - 1 while lo <= hi: ...
4df9f2d629e585251da1f947d496153dc6443185
ApocalypseMac/LeetCode
/Code/py3/archived/51-100/58.py
376
3.5
4
class Solution: def lengthOfLastWord(self, s: str) -> int: s = s.strip(' ') # remove space(s) at the end if len(s) == 0: return 0 else: count = 0 for i in range(1, len(s) + 1): if s[-i] != ' ': count +=1 ...
467239af45a2446f1645669f3059cccc4c1f6447
ApocalypseMac/LeetCode
/Contest/LCCUP2020_T/2-魔术排列.py
734
3.640625
4
class Solution: def isMagic(self, target: List[int]) -> bool: def shuffle(deck): return deck[1::2] + deck[::2] n = len(target) deck = list(range(1, n + 1)) # first shuffle decide k (greedily) deck = shuffle(deck) k = 0 while k < n and deck[k] == ta...
5b3db9c103f6f0f3db5cbd0519b16b1296aadea5
ApocalypseMac/LeetCode
/Contest/WC218/1678.设计-Goal-解析器.py
377
3.59375
4
class Solution: def interpret(self, command: str) -> str: res = "" n = len(command) for i in range(n): if command[i] == ')': if i > 0 and command[i-1] == '(': res += 'o' elif command[i] == '(': continue e...
668b6174e0cefe93bcc59836bf352156cd16df56
ApocalypseMac/LeetCode
/Contest/BWC42/5621.无法吃午餐的学生数量.py
493
3.5
4
from collections import deque class Solution: def countStudents(self, students: List[int], sandwiches: List[int]) -> int: st = deque(students) sw = deque(sandwiches) cnt = 0 while sw and cnt < len(students): if st[0] != sw[0]: st.append(st[0]) ...
4722eb87339d9c2223508010529b336b8dd12898
ApocalypseMac/LeetCode
/Code/py3/archived/51-100/92.py
656
3.734375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def reverseBetween(self, head: ListNode, m: int, n: int) -> ListNode: dummyhead = ListNode(None) dummyhead.next = head prev = dummyhead ...
5fd84ee1516a9cee0ef615fcf765a694833c913f
ApocalypseMac/LeetCode
/Code/py3/380.常数时间插入、删除和获取随机元素.py
1,538
3.9375
4
# # @lc app=leetcode.cn id=380 lang=python3 # # [380] 常数时间插入、删除和获取随机元素 # # @lc code=start import random class RandomizedSet: def __init__(self): """ Initialize your data structure here. """ self.count = 0 self.index = [] self.elem = dict() def insert(self, val...
a9f629ab30a5c056ef57261317b4943493880d42
theakers/Class5-Python-Module-Week6
/main.py
2,655
4.34375
4
from client import Client #Client and Bank Classes are imported. from bank import Bank bank=Bank("Asya") # i give a bank name to my bank object print(f"Welcome to International {bank.name} Bank") while True: # I used while to return the code until user press 3 button print("""Choose an option: 1. Open new b...
7979c35f2931886c21874f428da3fa21d59d2ae1
chyld/tdd-unit-test-prep
/stats.py
644
3.625
4
def mean(numbers): return sum(numbers) / len(numbers) def median(numbers): numbers = sorted(numbers) size = len(numbers) if size % 2 == 0: start = (size // 2) - 1 return mean(numbers[start:start + 2]) else: return numbers[size // 2] def mode(numbers): d = {} for n...
80f21da53200daee9942452e7516e7d92acf79b9
lizamaria/Project-PDF-to-JSON
/dict-structure.py
1,347
3.53125
4
# This file contains a function to combine key-value pairs # extracted from sections of text with their respective # section headers # # Author(s): Maja Minnaert import json def create_skeleton_dict(headers, keyvals): """Makes nested dict based on list and dict or list *currently only supports one level down ...
367e1b6a138dcd382d6eb9219542c918d8b70276
breezyaloo123/python-tp
/note.py
816
3.71875
4
#programme qui permet de savoir ceux qui sont admis ou recales apres un exam def entry_note(): for i in range(5): student_mark = float(input("Donnez la note de l'Etudiant: ")) if student_mark >= 10.0: with open("C:/Users/HP/Documents/setup/projet/python/filenote.txt","a") as mark: ...
05b70564fcb62ac0366bc5521a6388855448bfe7
hrrarya/PythonProgram
/Python Program/bubblesort.py
146
4.0625
4
a = int(input("enter a number: ")) b = int(input("Enter another number: ")) print(a,b,sep=" | ") temp = a a =b b=temp print(a,b,sep=" | ")
e6f805c0546472b285ff3cdbafee219f555dc309
vinidu4rte/pythonExercices
/exerc059.py
1,125
4.25
4
#programa que lê dois valores e peça pro usuario escolher as opções do menu n1 = int(input("Digite um número inteiro: ")) n2 = int(input("Digite mais um número inteiro: ")) print("""OK! Recebi os seus dois valores! Escolha no menu abaixo qual operação quer realizar: [ 1 ] Somar [ 2 ] Multiplicar [ 3 ] Maior [ 4 ] Nov...
4f4d08e877133a39bbec76d117b5438fd7adba72
hamidvalad/Quera
/ReturnPark-3078-3029.py
267
3.5
4
#https://quera.ir/problemset/contest/3029/%D8%B3%D8%A4%D8%A7%D9%84-%D8%A8%D8%A7%D8%B2%DA%AF%D8%B4%D8%AA-%D8%A7%D8%B2-%D8%A8%D9%88%D8%B3%D8%AA%D8%A7%D9%86 x, y = input().split() x1, y1 = input().split() if int(x1) > int(x): print('Right') else: print('Left')
c7465f3ced34806cb5415aae8cd419a829ad1863
bteger508/Heap-basedPriorityQueue
/HeapSort.py
7,611
4
4
#!/usr/bin/python3 import unittest import math """ A HeapSort module. For more information on how to implement the functions, refer to + CLRS3, chapter 6: the module's organization follows the text's exposition faithfully. + The slides for this course "Heaps: the Owner's Manual": they contain a few useful tips about...
c17182360892e1ce010c09290ea6b2ab4d009bb5
blankazucenalg/2013b
/src/Algorithms/Practice3.py
1,598
3.71875
4
''' Exponenciacion de numeros Created on Aug 29, 2013 Lopez Garduno Blanca Azucena Resendiz Arteaga Juan Alberto ''' class Practica3(object): def iterative(self,a,n): resultado = 1 for i in range(n): resultado *= a print "El resultado es: ",resultado def recursive(self,a,n)...
e2145830f8b07c84848a2feeca43a44f7e458994
t-oz/Beginner-Projects
/Projects/99-bottles/bottles.py
669
3.796875
4
# 99 Bottles # Python 3.5.1 # Written by alfredmuffin count = [i for i in range(1, 100)] count = count[::-1] for num in count: if num != 1: print("{0} bottles of beer on the wall, {0} bottles of beer.".format(num)) print("Take one down and pass it around, {0} bottles of beer on the wall!\n".format...
b8da3963e47b990702b5a9db067b699c7f04f82b
pinto8/Intro-Python
/src/days-2-4-adv/player.py
806
3.53125
4
from item import Key # Write a class to hold player information, e.g. what room they are in # currently. class Player: def __init__(self, name, room): self.name = name self.room = room self.items = [] self.score = 0 def __repr__(self): return f"{self.name}: Score: {self....
ab92847e5e997c790047c7b8b43488615c7aeb86
Navjeet220/Assignment
/assignment16.py
2,364
4.125
4
` #ASSIGNMENT16 #QUESTION:1 Create a database. Create the following tables: # 1. Book # 2. Titles # 3. Publishers # 4. Zipcodes # 5. AuthorsTitles # 6. Authors #Refer to the diagram below #SOLUTION: import pymysql db=p...
72dced413b9864c0ba4648f983ae0f932d89314f
Navjeet220/Assignment
/assignment13.py
3,325
4.03125
4
#ASSIGNMENT13 #QUESTION:1 Name and handle the exception occured in the following program: # a=3 # if a<4: # a=a/(a-3) # print(a) #SOLUTION: #in above code there is an indentation error in line if a<4: and print(a).after resolving the #indentation e...
f8a4cfc016af1612bdd6fb0c5338c565ad14929a
cosmolgj/charm_stimulate_brain
/raise_again.py
491
3.8125
4
def some_function(): print("input number 1-10: ") num = int(input()) if num < 1 or num > 10: raise Exception("invalid number: {}".format(num)) else: print("input number is {}.".format(num)) def some_function_caller(): try: some_function() except Exception as err: ...
a1b5a16fe28ee43de01893ead5e0f3bb08b2b46a
cosmolgj/charm_stimulate_brain
/DerivedCMember.py
218
3.609375
4
class A: def __init__(self): print("A.__init__()") self.message = "Hello" class B(A): def __init__(self): A.__init__(self) print("B.__init__()") obj = B() print(obj.message)
2a389fd9b2b7388584e37d4334c1bddef94602bf
ChadGoymer/r-python-workshop
/Exercises/solutions/Ex2a_source(solution).py
1,054
3.515625
4
import requests import time import sys # You will need to register for a Wunderground API key and set it below # API_KEY = 'Your API key here' def get_weather(date, location): """ Return the json response as a Python dictionary""" base_url = "http://api.wunderground.com/api/{api_key}/histo...
1cb0a368fdededb7cc4c0a2683085a0da7de837e
FarzaneMah/Automate_the_Boring_Stuff_with_Python
/Files/DeletingFiles.py
400
3.5625
4
"""os.unlink() will delete a file. os.rmdir() will delete a folder (but the folder must be empty). shutil.rmtree() will delete a folder and all its contents. Deleting can be dangerous, so do a "dry run" first. send2trash.send2trash() will send a file or folder to the recycling bin.""" import os print(os.getcwd()) file ...
c51f6708d97151d4d231a4f5834d2f229a2b6445
fernandoe/study
/codewars/kata/fundamentals/6-kyu/unique-in-order-54e6533c92449cc251001667/other-solutions.py
1,052
3.59375
4
# ------------------------------------------------------------------------------------------------- def unique_in_order(iterable): result = [] prev = None for char in iterable[0:]: if char != prev: result.append(char) prev = char return result # ------------------------...
97bcadc4d3838c1bedcbdc274427ce4e8d94b0cb
fernandoe/study
/codewars/kata/fundamentals/7-kyu/complementary-dna-554e4a2f232cdd87d9000038/code.py
1,697
3.8125
4
MAP = {"A": "T", "T": "A", "C": "G", "G": "C"} def DNA_strand(dna): return "".join([MAP[c] for c in dna]) if __name__ == "__main__": import codewars_test as test # Sample tests test.assert_equals(DNA_strand("AAAA"), "TTTT", "String AAAA is") test.assert_equals(DNA_strand("ATTGC"), "TAACG", "Str...
88c05b7c942fe6aaa2eec466c757867d1bf1a292
fernandoe/study
/codewars/kata/fundamentals/6-kyu/replace-with-alphabet-position-546f922b54af40e1e90001da/other-solutions.py
1,847
3.8125
4
# ------------------------------------------------------------------------------------------------- def alphabet_position(text): return ' '.join(str(ord(c) - 96) for c in text.lower() if c.isalpha()) # ------------------------------------------------------------------------------------------------- def alphabet_...
39dfa4cacd63f8d43a860ea6cd8f732da467ca15
hnkingsolver/Python_stack
/python/fundamentals/Functions_Basics_2.py
798
3.90625
4
# 1) Countdown # def countdown(num): # for x in range(num, 0, -1): # print (x) # countdown(5) # def print_return(arr): # print (arr[0]) # return arr[1] # print_return([1,2]) # def first_plus_length(arr): # print(arr[0] + len(arr)) # first_plus_length([1,2,3,4,5]) # prints 6 # def values_great...
26d244317650287a767fcb50ab5063a0a2e5214e
hnkingsolver/Python_stack
/python/fundamentals/Basics.py
757
3.640625
4
# # 1) Basic # for x in range(151): # print(x) # # 2) Multiples of Five # for x in range(0, 1001, 5): # print(x) # # 3) Counting, the Dojo way # for x in range(101): # if x % 10 == 0: # print("Coding Dojo") # elif x % 5 == 0: # print("coding") # else: # print(x) # 4) W...
27d3fd0411d6fc6324367d46fa15e084c66ac98f
hnkingsolver/Python_stack
/python/OOP/OOP_Intro.py
930
3.953125
4
class Llama: def __init__ (self, nameOfLlama, catchphrase, blades_of_grass_eaten): # print("__init__ has run!") self.name = nameOfLlama self.catchphrase = catchphrase self.blades_of_grass_eaten = blades_of_grass_eaten self.owner = {"name": "Joey", "age": 29} ...
4decf6184d0d43b9155160c6e44c231f95c7ef4e
Nicktatorship/mAGIc
/scratchfiles/shipper.py
1,481
3.53125
4
import sys from math import * class shipper(object): def __init__(self, x=0, y=0, sp=5, head=90): self.coords = (x, y) self.speed = sp self.heading = head def update(self): new_x, new_y = self.coords if self.speed > 0: new_x = self.coords...
6310946e43d9277012640b68b29324edd87c4a74
Ginjinator/IST-440-Team_Boil
/MongoClient.py
1,211
3.578125
4
# Project: Brewing Automation System - Capstone Project # Purpose Details: class for connecting to MongoDB # Course: IST 440W - 001 # Author: Team Boil # Date Developed: 3/20/2020 # Last Date Changed: 3/30/2020 # Rev 1 import datetime from pymongo import MongoClient class MongoDB: def __init__(self): tr...
2e9d1d7b0225085c15aaac2b13726afa92a268f0
v4s1levzy/practicum_1
/40.py
226
3.609375
4
import random N = int(input("Количество элементов массива")) A = [random.randint(-10,10) for i in range(0, N)] print(A) for i in range(N): if A[i] < 0: A[i] = A[i]**2 print(A)
ed20f25b9b47cab20ed34b16eab33e9722cc6d9f
v4s1levzy/practicum_1
/39.py
206
3.546875
4
import random N = int(input("Введите количество элементов массива ")) A = [random.randint(-1, 1) for i in range(0, N)] print(A) B = filter(bool, A) print(list(B))
eb2edabfedc684061b34035d41abbc49a258690c
v4s1levzy/practicum_1
/10.py
248
3.859375
4
num = int(input("Введите число для проверки:")) if num % 2 == 0 and num % 10 == 0: print("Число", num, "четно и кратно 10") else: print("Число не соответсвует условию")
fa3b98d8d49062e1b115fe384269173b428d150c
v4s1levzy/practicum_1
/51.py
241
3.796875
4
A = [A * 3 for A in 'abc'] print(A) B = ['Hello', 'world!', 'qwe'] print(B) list.sort(B, key=len) print(B) for i in range(len(B)): if len(B[i]) < len(B[i+1]): list.insert(0, '*') i = i + 1 print(B)
29b1e07f67d6271b7f7d8f4207013d54579e7be2
pyazdani621/python
/checkerboard.py
78
3.71875
4
for i in range(0, 9): if i % 2 == 0: print "* " * 6 else: print " *" * 6
4b9075b7d808ab54410266dcf060da922b807ca3
pyazdani621/python
/dictionary.py
601
4.15625
4
# create a dictionary with information about myself ### BELOW IS JUST TO SEE HOW TO CREATE DICTIONARIES ### # weekend = {"Sun": "Sunday", "Sat": "Saturday"} #literal notation # capitals = {} #create an empty dictionary then add values # capitals["svk"] = "Bratislava" # capitals["deu"] = "Berlin" # capitals["dnk"] = "C...
ee679caecdb15ac6a3c95640046f1f89590f2637
pyazdani621/python
/functions.py
442
3.984375
4
# #function with two parameters(inputs to the function) # def add(a,b): # x = a + b # return x # print(3,5) # < ---- invoking/calling our function, followed by "()"...prints 8 # def say_hi(name): # print "Hi, " + name # #invoking the function # say_hi("Michael") # say_hi("Anna") ########## #debugging section def...
1a28fdf3d3b228a629bb4aac29632911df1b4b5e
pyazdani621/python
/python_fundamentals.py
619
4.03125
4
>>> words = "It's thanksgiving day. It's my birthday, too!" >>> words.find("day") 18 >>> words.replace("day","month") "It's thanksgiving month. It's my birthmonth, too!" >>> x = [2, 54, -2, 7, 12, 98] >>> print min(x) -2 >>> print max(x) 98 >>> x = ["hello", 2, 54, -2, 7, 12, 98, "world"] >>> x[0], x[-1] ('hello', 'w...
b8e5f995921ce859168a5e8c0cdd1d83879a6502
BandBand-z/CINTA
/作业五/第8题.py
1,437
3.578125
4
def phi(a): #进行欧拉函数的计算 n = 1 i = 0 while n < int(a) : if int(a)%n != 0: i=i+1 n=n+1 return i+1 def findgenerator(p): #找出可能的生成元 i = 1 n = 0 list = [] maybegen = [] while i < int(p): list.append(i) i=i+1; while n< in...
df6bd31e4c011170e7bf29f56b9f7cdd7fe918c8
DevinRosales/WeightCalc.py
/WeightCalc.py
1,783
3.96875
4
#!/usr/bin/python # get user input for max weight, case as int and assign to the variable: weight weight = int(input('Please enter your max weight for this lift: ')) while True: if weight < 60: print ("Get Stronger!") weight = int(input('For real, enter your max weight:')) else: brea...
79f82c463448bd4b9befad06410afcf2c837fa74
mamaladzegeorge/X-O-python
/tic tac toe.py
1,875
3.921875
4
import random import time print(''' a b c 1 _|_|_ 2 _|_|_ 3 | | ''') time.sleep(2) print('''instruction: your move:a1 result: X|_|_ _|_|_ | | valid moves: a1,a2,a3, b1,b2,b3, c1,c2,c3.''') valid_moves=[] valid_moves=['a1','a2','a3','b1','b2','b3','c1','c2','c3'] time.sleep(2) print('\n\n...
335ade7b479a14ec4714eeb9be6e9e494976502a
Stpka/numberTOn4m63r
/numberTOn4m63r.py
251
3.625
4
words = ['zero', 'one', 'two', 'free', 'four', 'five'] def conntow(number): # convert number to word print(words[number]) def conwton(word): #convert word to number for i in range(6): if word == words[i]: print(i) break else: i+=1
8f458608c9f69caecac082ebef71ab1c2b4689cd
AlbaCallejas/M03
/Deberes para 11-05-2017/ArboldeNavidad.py
460
3.6875
4
#coding: utf-8 def my_range(inici, fi, increment): while inici <=fi: yield inici inici=inici + increment for fil in my_range(1,6,1): for col in my_range(1,5,1): if (fil==4): print "A" , else: if (fil==3): if (col==fil or col%2==0): print "A", else: if (col==3): if (fil==1): ...
9498368557b7687b9b758a26eef97efaea9155e1
AlbaCallejas/M03
/Deberes para 31-03-2017/PiedraPapelTijera.py
606
3.578125
4
#coding: utf-8 import os import time os.system('clear') J1=raw_input("Jugador 1: Piedra, papel o tijera?: ") time.sleep (1) print J2=raw_input("Jugador 2: Piedra, papel o tijera?: ") time.sleep (1) print if ( J1 == "piedra" and J2 == "papel"): print ("J2 WINS!") if ( J1 == "piedra" and J2 == "tijera"): print ("J1 ...
f3037a2d9a5c004e14728d19130e87876158edd4
h-mayorquin/coursera
/algorithms_01_stanford/6_week/median_maintenance.py
1,490
3.796875
4
import heapq filename = './Median.txt' heap = 0 numbers = [] with open(filename) as f: for line in f: numbers.append(int(line)) k = 10 heap_min = [] heap_max = [] # Initialize numbers_init = numbers[0:2] numbers_init.sort print numbers_init # Put to heap max heapq.heappush(heap_max, -numbers_init[1]) ...
a5f4f54586282da3615a228004abe87299bc8ece
loitd/pythonpractical
/lession2 - assertion/main.py
166
3.6875
4
from types import * def test(a=0): assert(a>=0), "a must greater than 0" assert(type(a) is IntType), "please put integer" return True test(1) # test(-1) test("a")
9939ed66aa4e8e23f12013866cf3ca9355517eb1
amogorkon/datenine
/datenine.py
727
3.828125
4
class Date: def __init__( self, year: int = None, month: int = None, day: int = None, hour: int = None, minute: int = None, second: int = None, ): self.year = year self.month = month self.day = day self.hour = hour s...