blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7ba405c326942ff7586d7431ca17d9f95bdba192
Captain02/LearningNotes
/python/code/lesson_04/06.遍历列表.py
610
3.953125
4
# 遍历列表,指的就是将列表中的所有元素取出来 # 创建列表 stus = ['孙悟空','猪八戒','沙和尚','唐僧','白骨精','蜘蛛精'] #遍历列表 # print(stus[0]) #通过while循环来遍历列表 i = 0 while i < len(stus): print(stus[i]) i += 1 #通过for训话来遍历列表 #语法: # for 变量 in 序列: # 代码块 #for循环的代码块会执行多次,序列中有几个元素就会执行几次 #每执行一次就会将序列中的一个元素赋值给变量, #所以我们可以通过变量,来获取列表中的元素 for s in stus: prin...
aa067121432b8f134d5c574d77105376142e2613
sbaloyi/hangman3
/hangman.py
4,121
4.15625
4
import random import sys def read_file(file_name): file = open(file_name,'r') return file.readlines() def get_user_input(): return input("Guess the missing letter: ") def ask_file_name(): file_name = input("Words file? [leave empty to use short_words.txt] : ") if not file_name: retur...
14ca486aa60f50ee31c8150d34f5cc1c583f659b
lex-pan/Wave-1
/volume_of_a_cylinder.py
163
4.03125
4
import math radius_of_cylinder = int(input()) height_of_cylinder = int(input()) volume = math.pi*radius_of_cylinder**2*height_of_cylinder print(round(volume, 1))
8c99bbddd5c648148e9e8cdc8cd7983099019d81
loggar/node
/node-process-interactions/python-shell/test/python/stderrLogging.py
776
3.578125
4
# logging example taken from https://docs.python.org/3/howto/logging-cookbook.html # Note that logging logs to stderr by default import logging # set up logging to file - see previous section for more details logging.basicConfig(level=logging.DEBUG) # Now, we can log to the root logger, or any other logger. First th...
16cf53d32b778af7f9aaf516ff2c8ed55ad01693
Zerocrossing/text-combat
/verbs.py
2,240
3.671875
4
""" Verbs Module Contains all the classes derived from Verb Each verb represents an action an actor may take during their turn While all verbs must implement setup and execute, they can be passed if they are not required """ import random from words import * class Kick(Verb): """ Kick is a basic physical att...
22b2d22e16bf987882dd5392643533253010d1d1
NazarTrilisky/FunTranslations
/characters/valley_girl.py
1,169
3.734375
4
import re from random import randint # text combinations to replace replace_dict = { ' the ': " thuh ", '(\W)I(\W)': r'\1I totally\2', '(\W)You(\W)': r'\1you totally\2', '(\W)he(\W)': r'\1he totally\2', '(\W)she(\W)': r'\1she totally\2', '(\W)it(\W)': r'\1it totally\2', '(\W)they(\W)': r'\...
36a9de27e460a2e4422d2cd4d0be76738c502239
IKnawDeWae/crypto-Eyadaabdellatif
/decodage/don2d.py
297
3.765625
4
def flatten(lst): return [i for sublst in lst for i in sublst] def decdon2(): i=0 s=input('code: ') n = int(input('nombre de chiffrage souhaiter :')) m=s while i < n : i=i+1 m=m[::-1] half = len(m) // 2 m =flatten(zip(m[half:], m[:half])) print (m) decdon2()
78681d1f4832828b256e8be3afc3184337a31722
smartyaya/Python-Shapely-Examples
/shapelyExample.py
2,679
3.578125
4
''' I'm trying to calculate if an objext is within a circle on a 2d coordinate system. First of all I have no way of currently plotting images of a 2d coordinate system or interacting with the coordinate system directly - so I'll have to work on a tool that accomplishes this later. For right now -> Just trying to calcu...
997152bef1342510dcebcda7e5d791bfa1d11b84
RaphCayou/Python-RSA
/rsa.py
3,570
3.59375
4
# generer_cles() : cle_privee, cle_public # chiffrer(cle_public,message) : message_chiffré # dechiffrer(message_chiffré) : message import math import random from math import gcd class RSA: """ A simple RSA implementation based on https://en.wikipedia.org/wiki/RSA_(cryptosystem) (Supports: 256 ascii characters) #C...
6a49b7cb73503a986d9e1d51b347c4b92b28ae71
abijithring/classroom_programs
/42_classes_objectoriented/inheritance/4_multiple.py
268
3.734375
4
class x: def m1(self): print "In method1 of X" class y(x): def m2(self): print "In method2 of Y" class z(x,y): def m3(self): print "In method3 of Z" z1 = z() z1.m1() z1.m2() z1.m3() y1 = y() y1.m2() x1 = x() x1.m1()
cf74fd7ae6b469f459d58638cab484dd5d4f7230
abijithring/classroom_programs
/42_classes_objectoriented/inheritance/program2.py
210
3.59375
4
class x: def m1(self): self.i = 1000 class y(x): def m2(self): self.j = 2000 def display(self): print self.i print self.j y1 = y() y1.m1() y1.m2() y1.display()
c5522a3d0a1c8bfe18bb0bc46bcfbbfeacdf7c6a
abijithring/classroom_programs
/42_classes_objectoriented/inheritance/3_hierarchical.py
248
3.671875
4
class x: def m1(self): print "In method1 of X" class y(x): def m2(self): print "In method2 of Y" class z(x): def m3(self): print "In method3 of Z" y1 = y() y1.m1() y1.m2() z1 = z() z1.m1() z1.m3()
f5b88565b4e3b9febee145ba79af7c55f8468e88
Aniketg1998/ECC
/grouping.py
1,201
3.6875
4
def padder(k): #this function padds the string asci=k l=len(asci) if (len(k)%64)!=0: asci.append('0') padder(asci) return asci def splitter(gp): #this function makes a list of lists gp=gp ngp=list() j=0 passes=len(gp)/64 for i in range(0,int(passes)): ...
4f09ece4d143eb05cfdc4a2734f9c066465b138a
brindasachi97/Airline-Reservation-system-using-client---server-commuication
/clientthread.py
3,239
3.515625
4
import threading from threading import Thread from seatmap import SeatMap from student import Student import socket def recieveLine(socket): """ This function recieve a line from the requested socket till it reach an enter (\n) @return a string recieve line """ data = "" line = "" while(da...
3f855241e5409ee81badb1550650a8b9223b94e0
clairerhoda/Python-Programs
/hw5_prog4.py
4,755
3.96875
4
#Claire Rhoda #1068768 #Program 4 #This program uses a tkinter module for a Loan program import tkinter class LoanProgram: def __init__(self): # Create the main window. self.main_window = tkinter.Tk() self.main_window.title("Loan Calculator") # Create the six frames....
7c686e578868a10bb2721b7adcfb1982d43ef1cb
clairerhoda/Python-Programs
/lab4_prog4.py
1,179
4.375
4
#Claire Rhoda #1068768 #Program 4 #This program creates a tuple with descending positive numbers. def getTuple()->tuple: """recieves tuple""" user_tuple = (-10,1,2,-9,3,4,-8,5,6) #tuple is given to main func return user_tuple def getNewTuple(user_tuple:tuple)->tuple: user_list = list(user_tuple) #tupl...
7febc39d66f167bffb3a3029d4c672a3825cfe72
clairerhoda/Python-Programs
/hw5_prog1.py
1,322
3.71875
4
#Claire Rhoda #1068768 #Program 1 #This program organizes a given text file alphabetically into rows and columns def rowTotal(teaData)->dict: teaDict = {} teaLines = teaData.split('\n') for index in teaLines: numList = [] elements = index.split(":") sum = 0 for number in element...
97b905ecada3fdc5779b79607536c3fe1a27da28
clairerhoda/Python-Programs
/hw3_prog1.py
1,846
3.890625
4
#Claire Rhoda #1068768 #Program 1 #This program calculates the Profit or Loss of inputed stock #information using functions def load()->(str,float,float,float,float): """stock info is inputed here""" sName = input("Enter a stock name or -1 to quit") if sName == "-1": return (None,None,None,None,No...
ff403b213e3bf19776cfceba611e4c00e472d9ac
RibRibble/python_april_2017
/JeffreyAD5F9/grades.py
475
3.921875
4
def grades(arr): letter = " " for i in range(0, len(arr)): if arr[i] >= 90: letter = "A" elif arr[i] >= 80: letter = "B" elif arr[i] >= 70: letter = "C" else: letter = "D" print "Score: " + str(i) + "Your Grade is " + lett...
0bdcac9f78851c0dcfdf75685ab6e55ae4132476
RibRibble/python_april_2017
/md_rahaman/python/python_OOP/animal/animal.py
276
3.625
4
class Animal(object): def __init__(self, name, health=100): self.name = name self.health = health def walk(self): self.health-=1 def run(self): self.health-=5 def displayHealth(self): print "Animal Name: ",self.name print "Animal Health: ",self.health
9205cfb0820b5111a705f1ecc29a4844c1752b45
RibRibble/python_april_2017
/john_pham/Assignments/OOP/products.py
1,738
3.65625
4
class Product(object): def __init__(self, price, item, weight, brand, cost, status = "for sale"): self.price = price self.item_name = item self.weight = weight self.brand = brand self.cost = cost self.status = status # self.display_all() def sell(self): ...
b6b3e06521e03b76f9df1ee9bf2cf2714dbd481c
RibRibble/python_april_2017
/briana_bennett/python_oop/Product.py
1,459
3.71875
4
class Product(object): def __init__(self, price, item_name, weight, brand, cost, status = "for sale"): self.price = price self.item_name = item_name self.weight = weight self.brand = brand self.cost = cost self.status = status def sell(self): se...
9a6fa62b94613917cf10a6d41d6602b5f53bf96d
RibRibble/python_april_2017
/andy_li/Python Fundamentals/Making Dictionaries.py
416
3.9375
4
def make_dict(lst1, lst2): if len(lst1) > len(lst2): new_dict = zip(lst1, lst2) elif len(lst1) < len(lst2): new_dict = zip(lst2, lst1) return dict(new_dict) name = ["Anna", "Eli", "Pariece", "Brendan", "Amy", "Shane", "Oscar"] favorite_animal = ["horse", "cat", "spider", "giraffe"...
197967558ed7e969a41f85e91c3f366e8f0cc6b3
RibRibble/python_april_2017
/Jason/Type_List.py
745
3.9375
4
# -*- coding: utf-8 -*- """ Python Fundamentals Assignment Autho: Jason Lee """ def type_list(list): sum = 0 string = "" for element in list : if(isinstance(element,type("abd)"))): string+=element if(isinstance(element,type(1))): sum += element ...
02bd7b2aa63921462d800b546898cb64d7e953d1
RibRibble/python_april_2017
/md_rahaman/python/Python_fundamentals_assignments/scores_grades/scores_grades.py
549
4.0625
4
import random def random_score(): for x in range(0,10): random_num = random.randint(60,100) print random_num if random_num>=60 and random_num<=69: print "Score: {};".format(random_num)+" Your grade is D" elif random_num>=70 and random_num<=79: print "Score: {};".format(random_num)+" Your grade is C...
9261ee3caa56bfc08e92ab4bc082ecfa07502674
RibRibble/python_april_2017
/andy_li/Python Fundamentals/String and List Practice.py
1,132
3.984375
4
# # Find and Replace # str = "It's thanksgiving day. It's my birthday,too!" # # print (str.find("day")) # print (str.replace("day", "month")) # # # Min and Max # def min_max(lst): # min_num = lst[0] # max_num = lst[0] # for num in lst: # if num < min_num: # min_num = num # ...
049dd3208e76c6f23944fc90371a2a8f7bc73adc
RibRibble/python_april_2017
/Jason/Turtle.py
437
4.34375
4
# -*- coding: utf-8 -*- """ Python Fundamentals Assignment Autho: Jason Lee """ import turtle # the distance we want the pointer to travel each time. DIST = 100 for x in range(0,6): print "x", x for y in range(1,5): print "y", y # turn the pointer 90 degrees to the right turtle.right...
13465d1893362eea059fd89c04d9465a6b876506
RibRibble/python_april_2017
/Jason/Store.py
1,793
3.96875
4
# -*- coding: utf-8 -*- """ Python OOP Assignment Author: Jason Lee """ ### Create class of Product class Product(object): def __init__(self, price, item_name, weight, brand, cost, status= "for sale"): self.price = price self.item_name = item_name self.weight = weight self.brand = brand self.cos...
3bbf820ade7088e07e10ed3e65ca7bc86f1257f6
RibRibble/python_april_2017
/md_rahaman/python/python_OOP/animal/cards.py
510
3.703125
4
import random class Deck(object): def __init__(self,*arg): self.arg = arg def create_cards(self): suits = ["Hearts", "Spades", "Clubs", "Dimonds"] list_of_card = ["A",2,3,4,5,6,7,8,9,10,"J","Q","K"] for i in range(0,len(suits)): print suits[i] for i in range (0,len(list_of_card)): print list_...
d3c45147a3fd02f878ea1a807c863603b723d1cf
xiebin95/tensorflow-learning-tutorials
/vggnet_17flowers/gen_images_labels.py
1,517
3.5625
4
# coding: utf-8 import os import os.path import TxtStorage as txts def get_files_list(dir): ''' 实现遍历dir目录下,所有文件(包含子文件夹的文件) :param dir:指定文件夹目录 :return:包含所有文件的列表->list ''' # parent:父目录, filenames:该目录下所有文件夹,filenames:该目录下的文件名 files_list=[] for parent, dirnames, filenames in os.walk(dir): ...
d9e90b9aa323647632eb1eb666e5b512e049f30a
wolfier/code
/movie-matching.py
1,129
4.1875
4
# Source: Interview Cakes # You've built an in-flight entertainment system with on-demand movie streaming. # Users on longer flights like to start a second movie right when their first one ends, # but they complain that the plane usually lands before they can see the ending. # So you're building a feature for choosing...
2bfdb4cbd7b76464f18df6ae5790e00eeb7544b0
tomMoulard/python-projetcs
/threadTests/python-threads.py
558
3.59375
4
#This is a test on how to use threads in python3 #made by tomMoulard import threading def thr(name): #This is the actual function used in threads global nbs for x in range(nbs): print(name, "->", x) threads = [] n = int(input("How many threads ?\n")) # n = 42000 nbs = int(input("How many loops ?\...
46b3f2b6e05f75d13bc153468ee682482fd6cfd0
tomMoulard/python-projetcs
/scripts3/exoPerso0.py
1,889
3.78125
4
#-*-coding:utf8;-*- #qpy:3 #qpy:console #made by moular_b def bubbleSortT(l): #bubble sort of a tuple list for x in range(len(l)-1, 0, -1): for i in range(x): if l[i][1] < l[i+1][1]: tmp = l[i] l[i] = l[i+1] l[i+1] = tmp def maxLi...
3c74c45064b7880eb7320f0509189f92e30d88de
tomMoulard/python-projetcs
/sudAuCul/suAuCul.py
636
3.625
4
#-*-coding:utf8;-*- #qpy:3 #made by moular_b def loadFile(fA): f = open(fA) line = f.readline() f.close() lines = [] for x in line: lines.append(str2int(x.strip().split(" "))) return lines def str2int(l): for i in range(len(l)): l[i] = int(l[i]) return l def printMat(m...
84695857e417f6956caa822ab7b70d8157a205bd
tomMoulard/python-projetcs
/heap/huffman-moular_b.py
9,762
3.703125
4
__license__ = 'GolluM (c) EPITA' __docformat__ = 'reStructuredText' __revision__ = '$Id: huffman.py 2016-04-04' from binaryTrees import * ################################################################################ # # COMPRESSION def buildFrequencyList(outputList, dataIN): """Build a tuple...
0142f4e9fc5981bb2bf124f68cae297788d7b397
ZenSwordzhang/python-learning
/function/test_reduce.py
999
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from functools import reduce DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} def add(x, y): return x + y def fn(x, y): return x * 10 + y # 将字符串转成数字 def char_num1(key): digits = {'0': 0, '1': 1, '2': 2, '3': 3, '...
182c4001e8430caec9327939d2cf515949a89ac8
bottlecapper/alg
/bfs.py
1,262
4.03125
4
# visits all the nodes of a graph (connected component) using BFS def bfs_connected_component(graph, start): # Store all visited nodes res = [] # Keep track of nodes to be checked queue = [start] levels = {} # Keeps track of levels of each node levels[start] = 0 # Depth of start node...
80811d762bdf4781f72f36f3322c7d63605a1d2e
Sqweejum/Ch.05_Looping
/5.1_Coin_Toss.py
591
4.25
4
''' COIN TOSS PROGRAM ----------------- 1.) Create a program that will print a random 0 or 1. 2.) Instead of 0 or 1, print heads or tails. Do this using if statements. Don't select from a list. 3.) Add a loop so that the program does this 50 times. 4.) Create a running total for the number of heads and the number of ta...
43c36a55b8edf6bf1bc4cb4323dee93963cbe84d
rohankrgupta/AI-Chess
/minimax.py
1,386
3.53125
4
from test_helpers import heuristic_gen, get_successors def minimax(board_state, heuristic, next_moves, current_depth=0, max_depth=4): current_depth += 1 if current_depth == max_depth: # get heuristic of each node return next(heuristic) if current_depth % 2 == 0: # min player's turn ...
f4b7f39665c491b94789311b2d91447f3d726b3f
facedesk/sandbox
/squirrels.py
495
4.28125
4
sunny = input("is it sunny? y/n") hour = input("what is the hour of day?") hour = int(hour) ''' if it is sunny outside and the hour is between 4 and 8, then print the squirrels are playing outside otherwise, print that they are sleeping ''' isSunnyOutside = sunny == "y" isBetween4and8 = hour >=4 and hour <=8 prin...
4aa877e4fbc220d9f61a0ea58ee5033aee8e078c
facedesk/sandbox
/login.py
193
4
4
password = "" while(password != "dinosaur" and password !="dogs"): username = input("Enter your username\n>") password = input("Enter your password\n>") print("you are logged in")
23d58ed0f7ac1f121e9c12044468933f0b530dc0
markusmkim/DL-NeuralNetwork
/network/layers/utils.py
492
3.515625
4
def reshape_to_4d(tensor): if len(tensor.shape) == 3: """ if data is two dimensional: wrap each data case inside an extra single dimension (channel) """ return tensor.reshape((tensor.shape[0], 1) + (tensor.shape[1:])) # else len == 2 always """ if data is one dimensi...
abc1098cd478784def36e9b1057aa91089d2c7f5
gmvdm/qingwen
/qingwen/formatter.py
368
3.578125
4
# -*- coding: utf-8 -*- # Copyright (c) 2012 Geoff Wilson def format_output_line(vals): """Given a dict, produce a tab separated output line""" if len(vals) < 3: return '' defns = ' / '.join(vals.get('defs', '')) return u'%s\t%s\t%s' % (vals.get('hanzi', ''), defns...
aee61a0539e9dce6135c95de35b9a64ceb2b7f6e
sietzemm/Codecloud
/DNAprocessor/randomDNAgen.py
767
3.71875
4
import sys import random import os # print(sys.version) def writeToFile(sequence): path = __file__ path = path[:-15] print(path) outputname = path+'sequence.txt' print(outputname) f = open(outputname, "a") f.write(str(sequence)) f.close print("Generated DNA sequence with length : "...
33ecc10d34f3cd4310e43d19bda021effb284519
sietzemm/Codecloud
/SierpinskiTriangle/CC2_SierpinskiTriangle.py
10,652
3.609375
4
# Date 13-12-2018 # Author : Sietze Min from tkinter import * import math import random import sys print(sys.version) class App: bg_color = "red" seed_points = [] def __init__(self,root, width=750, height=550): screen_width = width screen_height = height fullscreen_width = root....
60b0fa3439778586365add03a15879d005a85294
betados/cursoPython
/listas.py
765
3.75
4
lista = list("python is awesome") print("lista[4]: ", lista[4]) print("lista[-2]: ", lista[-2]) """"[: 6], [7: 9], [10:], [2::5], [-3::-6] """ print("lista[: 6]: ", lista[: 6]) print("lista[7: 9]: ", lista[7: 9]) print("lista[10:]: ", lista[10:]) print("lista[2::5]: ", lista[2::5]) print("lista [-3::-6]: ", lista[-3:...
e297377f708d072a04f7d008e2b17e265bb49e77
afilsinger3/PHYS344
/Homework 2/Homework2.py
2,408
3.765625
4
from __future__ import division from numpy import * from math import * from pylab import * import matplotlib.pyplot as plt import random #HW02 Random Walk # constants d = 1 # distance of a step N = 20 # total number of steps steps = [0] * N # generate a vector # function of one dimensional random walk def Walk(n...
6f41ff4497506120e893c917634c6e1f79873af2
jdue/project-utils
/simeeg/sphere.py
10,938
3.828125
4
""" Various tools for working with spheres. - Generate equally spaced points on a unit sphere. - Vectorized analytical solutions for leadfields in one and three layer spheres. - Sampling normally distributed points around a (seed) point on a sphere """ from numbers import Integral import numpy as np from scipy.spat...
710d7d590d21aee2f564e67fec939881d5a82b1c
okellogabrielinnocent/data_structure_gab
/sliding_window.py
1,196
4.0625
4
# 121. Best Time to Buy and Sell Stock # You are given an array prices where prices[i] is the price of a given stock on the ith day. # You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. # Return the maximum profit you can achieve ...
b5054c8345ac9154d58e77d71bbe1a7245452548
okellogabrielinnocent/data_structure_gab
/selection_sort.py
1,916
4.5625
5
# Selection Sort # Another typical sorting method uses the idea of finding the biggest item in the list and moving it to the end # which is where it belongs if the list is to be in increasing order. # Once the biggest item is in its correct location, you can then apply the same idea to the remaining items. # That is, ...
771655387cfb5fa72266a7fb0667d7cffc0b62e2
okellogabrielinnocent/data_structure_gab
/merge_m+n.py
1,355
4.15625
4
# Merge an array of size n into another array of size m+n # There are two sorted arrays. First one is of size m+n containing only m elements # Another one is of size n and contains n elements. # Merge these two arrays into the first array of size m+n such that the output is sorted. # Algorithm: # Let first array be m...
63bfad94352608fe51732bdf47bc991240fbf105
AnaLinsDev/MovieManager
/view/userView.py
1,931
3.640625
4
from controller.MovieController import MovieController class UserView(): def __init__(self): self._movie_controller = MovieController() def get_movies(self): movies = self._movie_controller.get_movies() for m in movies : print ( m.get_key() , " ) " , m.get_name(...
ea433ac068c20121d7f2a3a6d927c8080ba11cee
yindanqing925/py-script
/demo/function.py
376
3.921875
4
# 如果为整数 +1 为负数 -1 def plus_one(num): plus = False if num >= 0: num = num + 1 plus = True else: num = num - 1 plus = False return num, plus num = 20 print(plus_one(num)) if num >= 18: print('adult') else: print('teenager') def print_details(nums): print(nu...
cbea87aefe217e4255ac4ab18b8717dc736f0668
gi009088/products
/products.py
1,406
3.65625
4
#讀取檔案 def read_file(filename): products = [] with open(filename,'r', encoding = 'utf-8') as f: for line in f: if '商品,價格' in line: continue #挑過本回合 name, price = line.strip().split(',') #先去掉"\n"再用逗點分割使 products.append([name, price]) #將讀取的檔案放到主要清單中 return products #讓使用者輸入 def user_input(products): whi...
38228149d0401c00f6d3bf9a7dc4c6985c3626df
OldFuzzier/Data-Structures-and-Algorithms-
/HashTable/136_Single_Number.py
759
3.59375
4
# # coding=utf-8 # 136. Single Number # Myway: hashset, search in hashset O(1), then Time Complexity: O(n) class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ s = set() for num in nums: if num in s: # Trickie...
3b536f547f239cc741f84398bc12932a17e791cc
OldFuzzier/Data-Structures-and-Algorithms-
/graph/shortest_path.py
1,077
3.765625
4
# # coding=utf-8 # 无权图有(无)向最短路径 from collections import defaultdict # init graph = defaultdict(dict) graph[1][2] = 1 graph[1][3] = 1 graph[2][3] = 1 graph[2][4] = 1 graph[3][5] = 1 graph[4][3] = 1 graph[4][5] = 1 graph[5][6] = 1 graph[4][6] = 1 dist = dict.fromkeys([point for point in range(1, 7)], -1) path = dict.f...
b2cb903eef543db09b785f15130c7ea2c3600d77
OldFuzzier/Data-Structures-and-Algorithms-
/DynamicProgramming/322_Coin_Change.py
927
3.703125
4
# # coding=utf-8 # 322. Coin Change # 硬币问题 # Solution: https://leetcode.com/problems/coin-change/solution/ class Solution(object): # PCway DP button-up def coinChange(self, coins, amount): """ :type coins: List[int] :type amount: int :rtype: int """ dp = ...
20febbce25feb5fb29269a88d568c5000649398f
OldFuzzier/Data-Structures-and-Algorithms-
/Heap/heap_operating.py
3,000
3.640625
4
# # coding=utf-8 # Trickier: index属于(1, n)注意位置是1至n的索引 # index/2位置的node一定是该node的father_node # index*2与index*2+1分别是node的child的左右index # 自定义list, 为了实现自己的索引方式 class MyQueue(list): def __init__(self, lst=None): if not lst: self._lst = [] else: self._lst = ls...
00c1fd69bb1fff69540822e2a3ca98afbd3b8932
OldFuzzier/Data-Structures-and-Algorithms-
/BackTracking/79_Word_Search.py
3,149
3.671875
4
# -*- coding: utf-8 -*- # 79. Word Search # 单词搜索 # my way class Solution(object): def exist(self, board, word): """ :type board: List[List[str]] :type word: str :rtype: bool """ rowLength = len(board) colLength = len(board[0]) siteList = [] # 创建一个...
2f5de669665e53f2ec23c87575ad2436b7481035
OldFuzzier/Data-Structures-and-Algorithms-
/Tree/BinaryTree/145_Binary_Tree_Postorder_Traversal.py
1,280
3.796875
4
# # coding=utf-8 # 145. Binary Tree Postorder Traversal # 后序遍历二叉树 # PCWay # stack(node, right, left) + flag # class Solution: # @param {TreeNode} root # @return {integer[]} def postorderTraversal(self, root): traversal, stack = [], [(root, False)] # trickier: (root, flag) while stack: ...
4f8e874786de0c07e31a03ebec042312745a6f4d
DevmashPython/image-downloader-varunsudharshan
/savefrom.py
905
3.640625
4
import urllib import re import os #download function def downloadimgs(): file1=open('links.txt','r') for line in file1: line = line[:-1] #print os.path.basename(line) urllib.urlretrieve(line, os.path.basename(line)) file1.close() url = "http://"+raw_input("enter url:\thttp://") #accept input f = urllib.urlope...
d6dc656c90ee90b4a8c342433242397802c8e051
LXSkyhawk/cp2015
/practical2/q03_determine_grade.py
1,033
4.1875
4
check = False while not check: score = input("Enter score (between 0 and 100 inclusive): ") try: score = int(score) if score < 0 or score > 100: print("Invalid! Score must be within 0 and 100.") elif score == 100: print("Full marks! Straight A, good work!") ...
b498ce7c65b339dd9b6161897afa5368efa52063
LXSkyhawk/cp2015
/practical1/q3_miles_to_kilometre.py
507
4.03125
4
check = False while check == False: miles = input("Enter distance in miles: ") if any(c == "." for c in miles) == True and any(c.isdigit() for c in miles) == True: miles = float(miles) check = True elif any(c.isdigit() for c in miles) == True: # to prevent a single "." entered from ruining t...
0037dc01953442cab252ddcf22ec8961813d0a63
LXSkyhawk/cp2015
/practical3/q7_milliseconds_to_hours_minutes_seconds.py
662
3.765625
4
def convert_ms(n): s = int(n / 1000) if s > 60: min = int((s - (s % 60)) / 60) s = s % 60 if min > 60: h = int((min - (min % 60)) / 60) min = min % 60 print("%s:%s:%s" % (h, min, s)) else: print("0:%s:%s" % (min, s)) else: ...
c7028c97aa3e7f8be5aceffd27b7270b0528db3d
LXSkyhawk/cp2015
/practical2/q05_find_month_days.py
745
4.15625
4
def in_check(x): check = False while not check: month_year = input("Enter %s in integer form: " % x) try: return int(month_year) check = True except ValueError: print("Integers only!") month = in_check("month") year = in_check("year") months = ["Janu...
a3a9b373adfe0b1751d4fa36172f6784570a2b1a
VKUtla/Distributed-Relational-Database-Management-System
/DBMSM2/venv/DBMS.py
2,348
3.609375
4
import Table class DBMS: def __init__(self, DBMSName): self.DBMSName = DBMSName self.databases = set() self.tables = {} def getTables(self): return tables def getDBMSName(self): return self.DBMSName def addDatabase(self, database): for databaseRecord...
65e39d5419a56401ba5660d05c6434d3248aabdb
NoeClariNista/imw
/ut2/a3/program2.py
190
3.703125
4
# PROGRAMA 2. import sys numero = int(sys.argv[1]) if (numero <= 0): print("Error.") else: suma = 0 for i in range(1, numero + 1): suma += i**2 print("El Resultado Final Es", suma)
0b53030a2da38db592ff43ffa1dd8e88c95df873
omarmohamud23/Lab-2--Python-Basics
/noduplicatebooks.py
887
4.0625
4
#author is created as class class Author: def __init__(self, name): self.name = name self.books = set() def publish(self, title): #no duplicate allowed if title in self.books: print('No duplicate allowed') #books gets added after checking for no duplic...
40b6ae000bae3f8af50c3568a6afcadde84f8412
funnydog/AoC2019
/day7/day7.py
6,651
3.625
4
#!/usr/bin/env python3 from collections import deque from itertools import permutations ADD = 1 # add [a], [b] into [c] MUL = 2 # mul [a], [b] into [c] IN = 3 # read stdin and store to a OUT = 4 # write a to stdout JN...
e769bf5aa07b578ca863fec37ab8a2de384f3385
yosefBP/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/1-search_replace.py
211
4
4
#!/usr/bin/python3 def search_replace(my_list, search, replace): new_list = my_list.copy() for i in my_list: if search == i: new_list[new_list.index(i)] = replace return new_list
fa1c7859fe0aaa556303b59ef563090b0af4df00
yosefBP/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-read_lines.py
501
4.25
4
#!/usr/bin/python3 """Read n lines""" def read_lines(filename="", nb_lines=0): """function that reads n lines of a text file (UTF8) and prints it to stdout """ with open(filename, encoding="utf-8") as file: num_lines = file.readlines() if nb_lines <= 0 or nb_lines >= len(num_lines): ...
9a80e100908ae6b9621eaafa800d743971a90ccc
yosefBP/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/square.py
1,494
3.953125
4
#!/usr/bin/python3 """ Model Square that inherits from Base """ from models.rectangle import Rectangle class Square(Rectangle): """ Class that defines a Square Object """ def __init__(self, size, x=0, y=0, id=None): """ Constructor """ super().__init__(size, size, x, y, id) @property ...
a8b6bff23b520303f70c5c9a5dbf859cf039f498
yosefBP/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/rectangle.py
3,435
3.90625
4
#!/usr/bin/python3 """ Model Rectangle that inherits from Base """ from models.base import Base class Rectangle(Base): """ Class that defines a Rectangle model """ def __init__(self, width, height, x=0, y=0, id=None): """ Constructor """ self.width = width self.height = height ...
a1415c4506961d22954407464f600fc6e2946839
ShayHa/CodingInterviewSolution
/python/6_Find_Max_Element.py
361
4.3125
4
""" Find the max element of a given list of integers. """ # If we can use max function def max_element(ls): return max(ls) # If we can't use max but can use sort def max_element_v2(ls): return sorted(ls)[-1] # If we can't use either max or sort def max_element_v3(ls): n = 0 for num in ls: if n...
067de6da16f8592bed5e1ba1570063e13778aa06
aiforai/PhonePhreak
/phoneLook2.py
796
3.546875
4
import random areacode = input("Define your area-code: ") howmany = (int(input("Specify generation amount: "))) def generator(): n = '0000000000' while '9' in n[3:6] or n[3:6]=='000' or n[6]==n[7]==n[8]==n[9]: n = str(random.randint(10**9, 10**10-1)) #billions return areacode + '-' + n[3:6]...
f8615160f4b51d4bff465bfcb394eeee00737086
LeandriB/movie_website
/media.py
1,003
3.828125
4
import webbrowser #Calls the built in web browser class Movie(): """Class that stores information related to the class Movie""" def __init__(self, movie_title, movie_storyline, movie_release_date, poster_image, trailer_youtube): """Initialises the instance variables that are created ...
b15c691a47900fe559157ea988af108b67c339f4
sheethal23/Rational-Number
/rational.py
4,799
4.0625
4
#importing sys module import sys #implementation of a rational class class Rational: #def __init__ ( self, num = 0, den = 1 ): This function (constructor) creates a Rational number with the numerator num and denominator den. def __init__(self, num=0, den=1): #constructor self.num = num ...
388b6ae81168de807a401977daf887f166a3349e
gongshichina/mnist
/minist_net.py
13,049
3.515625
4
import numpy as np import matplotlib.pyplot as plt from mnist_data import fetch_traingset, fetch_testingset from gradientCheck import gradCheck ####################################################################################################### # Task of this project: MNIST digits classification using your own neur...
9905bf28d5d05ed4fe870d979fbd245cf4dfd015
AnyaChurkina/BI_2020-2021_Python
/units_converter.py
2,925
4.25
4
a = input("Which parameter would you like to convert: length, weight, \ pressure, volume, speed?") if a == "length": unit1 = input("Which unit would you like to convert from? \ Available units: sm/m/km") unit2 = input("Which unit would you like to convert to? \ Available units: sm/m/km") number = float(inpu...
d0e1aeb2a5964dc0c6b25006b72180f701b44cea
timomak/superheroes.py
/superheores/superheroes.py
15,489
4
4
from random import randint import random class Hero: def __init__(self, name, starting_health=100): ''' Initialize these values as instance variables: (Some of these values are passed in above, others will need to be set at a starting value.) abilities:List name: sta...
8baf32289b1bb89bab71c59e47dc390c95228791
AliceHincu/FP-Assignment12
/iterative.py
1,468
3.78125
4
class Iterative: def generate_parentheses(self, n): """ --- Description Generate all sequences of n parentheses that close correctly. (Method: recursive) --- Parameters :param n: the number of parentheses (type: <int>) """ array = [] for i in range(...
6e57bb2ffdacecea54b25aa928f8beb502e24098
Fortune-Adekogbe/Python-Intermediate-30daysofcode.xyz
/day 20/2D ARRAY.py
1,974
3.96875
4
def rot_line(arr,st,end): #rotates a particular loop of an array n=len(arr)-1 for i in range(st,end): temp=arr[st][i] a,b=st,i for i in range(3): arr[a][b]=arr[n-b][a] a,b=n-b,a arr[a][b]=temp def read_loop(arr,st,m,n): ''' Read...
a67eb3557bdf909a84eb445dc3895463a56cdb05
Fortune-Adekogbe/Python-Intermediate-30daysofcode.xyz
/day 8/backToBase.py
527
4.125
4
def to_base(num,base): ''' converts a number in base 10 to a number in base 2,4,8 or 16 ''' assert type(num)==int and type(base)==int and base in set([2,4,8,16]) n=base-1 shift=1 #detrmines by how many bits we are going to shift after aech iteration while 2**shift<base: shift+=1 ans='' while num: x=num&n ...
45a586ec3eeb764713b3726bc24e1ef0241919d6
ryanarbow/lessonprojects
/linear_regression.py
1,395
3.59375
4
import pandas as pd loansData = pd.read_csv('https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv') #Remove '%' from Interest.Rate loansData['Interest.Rate'] = loansData['Interest.Rate'] .map(lambda x: round(float(x.rstrip('%')) / 100, 4)) #Remove 'months' from Loan.Length loansData['Loan.Length'] = loan...
fed4d1e472fa794da3bd05979b292befb35e57e5
atlierq/algorithms
/selection_sort.py
348
3.59375
4
import CESHI def selection_sort(mylist): length = len(mylist) for i in range(length - 1): least = i for k in range(i + 1, length): if mylist[k] < mylist[least]: least = k mylist[least], mylist[i] = \ (mylist[i], mylist[least]) return mylist ...
7316c1a770ab97fdcf847c4f90f85390823eeab7
NelsonGomesNeto/Compilers
/Syntactic Analyzer/Reading.py
1,681
3.6875
4
from Printing import colors separator = "{}()[]+-*/,^;" def reading(): print("Reading: ", colors.yellow+input()+colors.end, sep='') def readER(): reading() grammar, nonTerminals, terminals = {}, [], [] while (True): line = input() if (line == "END"): break left, right = line.sp...
4c69855f5b085805369b0c9a6966b8788d5af417
Dotown/py_practice
/1-5/day3_2.py
180
3.90625
4
x = float(input('请输入x的值')) if x>1: y = 3*x-1 elif x >= -1 and x >= 1: # else if 在python中简写为elif y = x+2 else: y = 5*x+3 print('y的值为%d' % y)
4a8a8974ef9ab34ae4fd884c6a8a12179fc4de49
Dotown/py_practice
/1-5/day4_p3.py
1,164
4
4
num = int(input('请输入行数')) for i in range(1,num+1): while(True): if i == 0: print() break else: print('*',end = '') i-=1 for i in range(1,num+1): a = 0 while(True): if a == num: print() break elif a<num-i...
9d54737e4a9d7bde169e923f1b72f0a304a86371
Dotown/py_practice
/6-10/day8_p1.py
788
3.890625
4
import time class Click(object): def __init__(self, hour = 0, minute = 0, second = 0): self.__hour = hour self.__minute = minute self.__second = second def run(self): self.__second += 1 if(self.__second >= 60): self.__second = 0 self.__minute += ...
ab76cae3fb22efa3ac7fbdadf1ae7e05529def60
ActionHorse/Test-of-the-learn-py
/ifthen.py
155
3.859375
4
print("at line 200") A=input("Pick a number: ") print(A) if A==A: print("TRUE") elif A!=A: print("FALSE") print() input("Press ENTER to continue ")
a8367954dc26ede0bead5b547a5a477fda8130b1
latecomer04/codeforces-solutions-in-python
/Keyboard.py
308
3.53125
4
n=input() s=input() l=list(s) a="qwertyuiopasdfghjkl;zxcvbnm,./" if n=="R": for i in range(len(s)): m=l[i] b=a.index(m) p=a[b-1] l[i]=p else: for i in range(len(s)): m=l[i] b=a.index(m) p=a[b+1] l[i]=p print("".join(str(e) for e in l))
9771b86171b667ebe797076284bbfa3e4146d40b
latecomer04/codeforces-solutions-in-python
/Registration System.py
188
3.625
4
n=int(input()) dict={} for i in range(n): s=input() if s not in dict: dict[s]=1 print("OK") else: a=dict[s] dict[s]=a+1 print(s+str(a))
d97006c551924fb53dc6b44fb7e49c25c245e630
HoSingWong/LeetCode
/图解算法数据结构/Offer06从尾到头打印链表/Offer06.py
670
3.703125
4
class ListNode: def __init__(self, x): self.val = x self.next = None class Offer06: def reversePrint(self, head: ListNode)-> list: res = []#初始化数组 while head:#只要链表不为空就循环 res.append(head.val)#将链表的值添加进数组中 head = head.next#将链表指向下一位 return r...
a6617256d14002ba3d8434e237d823728b5f9e47
RailsMcguines/GitAct2
/simplycalc.py
865
4.25
4
print("Calculadora Basica") #operadores def arp(val1,val2,oper): if oper == '/': res = val1 / val2 if oper == '+': res = val1 + val2 elif oper == '*': res = val1 * val2 elif oper == '-': res = val1 - val2 elif oper == '/': res = val1 / val2 else: ...
db5646f6739583672e4af9a8de2125292d02b613
ram-jay07/Code-Overflow
/Python/pascal's triangle.py
885
4.28125
4
# Python 3 code for Pascal's Triangle # A simple O(n^3) # program for # Pascal's Triangle # Function to print # first n lines of # Pascal's Triangle def printPascal(n) : # Iterate through every line # and print entries in it for line in range(0, n) : # Every line ...
c710a1927ff24bfe74d0f43cc2de0e662ddd4713
ram-jay07/Code-Overflow
/Arithmetic calc
601
4.1875
4
num1 = int(input('Enter First number: ')) num2 = int(input('Enter Second number ')) add = num1 + num2 dif = num1 - num2 mul = num1 * num2 div = num1 / num2 floor_div = num1 // num2 power = num1 ** num2 modulus = num1 % num2 print('Sum of ',num1 ,'and' ,num2 ,'is :',add) print('Difference of ',num1 ,'and' ,num2 ,'is :',...
4b77f308fac7bcaa3547b901906f020bbf4c6b96
ram-jay07/Code-Overflow
/rev_arr.py
221
3.953125
4
''' Program to reverse the array Created by Shouvik Dutta Pls Merge my PR ''' def rev(l): ans=[] for i in range(len(l)-1,-1,-1): ans.append(l[i]) return ans if name==main: l=[1,2,3,4,5,6] ans=rev(l) print(*ans)
e976b8611d600f6987bcb6fe04b7101c436796b2
ram-jay07/Code-Overflow
/Binary2octal.py
155
4.28125
4
# python program to convert binary to octal binary = input("Enter number in Binary Format: ") temp = int(binary, 2) print(binary,"in Octal =",oct(temp))
de7efa4ef3b73385ecd3be72e47e6a731c997767
ram-jay07/Code-Overflow
/Constraint Satisfaction Problem - Graph coloring.py
3,207
3.6875
4
class Vertex: def __init__(self, name): self.name = name self.neighbors = [] self.heuristic = 0 self.visited = 0 self.color = ['red', 'blue', 'green'] def add_neighbor(self, vertex): if vertex not in self.neighbors: self.neighbors.append(ver...
59890e7c816e7c48a98482585adc17e2b1b025f6
ram-jay07/Code-Overflow
/Reverse an Array using python
297
3.609375
4
def arrayRev(array): length = len(array) revArray = [] i=length-1 while i >= 0: revArray.append(array[i]) i-=1 return revArray if __name__=="__main__": array = map(int,input().split()) array = list(array) result = arrayRev(array) print(result)