blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
0516cf4a9993dc466b921122bedb4c085fd55124
Trevor-droid/TDR
/grading system.py
513
3.921875
4
mark = 56 """ 0 - 35 - F9 36 - 44 - P8 45 - 49 - P7 50 - 54 - C6 55 - 59 - C5 60 - 65 - C4 66 - 74 - C3 75 - 79 - D2 80 - 100 - D1 Grading system that assigns grade to students based on marks """ if mark <= 35: print("F9") elif mark <= 44: print("P8") elif mark <= 49: print("P7") elif...
b8df8b021f762b6701830929db14a706e0f9e70c
KKrishnendu1998/COMPUTATIONAL_PHYSICS_ASSIGNMENT_1
/Gauss_Elimination.py
344
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 12 15:11:06 2020 @author: krishnendu code: solve a set of linear eqaution using numpy.linalg.solve """ import numpy as np A=np.array([[1,0.67,0.33],[0.45,1,0.55],[0.67,0.33,1]]) #the given matrix b=np.array([2,2,2]) print(np.linalg.solve(A,b)) ...
1ad53b3e8ce734ee3d5ef4b24963ad0c0a2c978e
endreujhelyi/endreujhelyi
/week-03/guess_game/guess_the_number.py
4,231
3.921875
4
import random def escape_from_hell(bottom, top, tries): number_of_guesses = 0 tries_remaining = tries ### welcome sentences and adding name print ("\n>>>>>>>>>>>>>> ESCAPE FROM HELL <<<<<<<<<<<<<<\n") print ("OK human! My name is Beelzebub the King of the Hell.\nIf you wanna be free you have to gu...
adfdfcef8df2c83bf122fef38b54335628aef52b
endreujhelyi/endreujhelyi
/week-05/day-3/number_1_2_3.py
1,050
3.953125
4
# create a function that takes a number and divides ten with it and prints the result # it should print "fail" if it is divided by 0 def divider(user_num): try: return (10 / user_num) except ZeroDivisionError: return ('fail') # write a function that takes a filename and returns the ...
5e447702f51cd3318fd5595a131da34c2bc498d5
endreujhelyi/endreujhelyi
/week-04/day-3/04.py
528
4.3125
4
# create a 300x300 canvas. # create a line drawing function that takes 2 parameters: # the x and y coordinates of the line's starting point # and draws a line from that point to the center of the canvas. # draw 3 lines with that function. from tkinter import * top = Tk() size = 300 canvas = Canvas(top, bg="#222", he...
0c2563d42a29e81071c4a2667ace0495477ac241
endreujhelyi/endreujhelyi
/week-04/day-3/08.py
534
4.1875
4
# create a 300x300 canvas. # create a square drawing function that takes 2 parameters: # the x and y coordinates of the square's top left corner # and draws a 50x50 square from that point. # draw 3 squares with that function. from tkinter import * top = Tk() size = 300 lines = 3 canvas = Canvas(top, bg="#222", heigh...
4d61e0d7c4ba7e4c7bd85e9952a9b38ba32c5545
endreujhelyi/endreujhelyi
/week-04/day-3/03.py
286
3.90625
4
# create a 300x300 canvas. # draw its diagonals in green. from tkinter import * top = Tk() x = 300 canvas = Canvas(top, bg="#333", height=x, width=x) canvas.create_line(0, 0, x, x, fill='light green') canvas.create_line(0, x, x, 0, fill='light green') canvas.pack() top.mainloop()
02a8078775b4475bc6452f44aa6ee23226433427
endreujhelyi/endreujhelyi
/week-04/day-3/11.py
707
3.859375
4
# create a 300x300 canvas. # create a square drawing function that takes 2 parameters: # the square size, and the fill color, # and draws a square of that size and color to the center of the canvas. # create a loop that fills the canvas with rainbow colored squares. from tkinter import * import webcolors top = Tk() s...
a2490191fa88fa20e923235a2f7f4dff1177cbfe
endreujhelyi/endreujhelyi
/week-03/day-2/40.py
552
3.671875
4
students = [ {'name': 'Rezso', 'age': 9.5, 'candies': 2}, {'name': 'Gerzson', 'age': 10, 'candies': 1}, {'name': 'Aurel', 'age': 7, 'candies': 3}, {'name': 'Zsombor', 'age': 12, 'candies': 5} ] # create a function that takes a list of students, # then returns how many candies are own by ...
02ea4490a77eb5991c68828967de8b95480393bd
endreujhelyi/endreujhelyi
/week-04/day-2_dojo/03.py
188
4.09375
4
m1 = 124 m2 = 456 # tell if m1 and m2 are both even numbers def is_even(x,y): if x % 2 == 0 and y % 2 == 0: return True else: return False print (is_even(m1,m2))
506d0bbf89cbbeeb0a5343c43d955b853a526556
endreujhelyi/endreujhelyi
/week-04/day-4/02.py
212
4.1875
4
# 2. write a recursive function # that takes one parameter: n # and adds numbers from 1 to n def recursive(n): if n == 1: return (n) else: return n + recursive(n-1) print (recursive(5))
13faefce6f80192d15de6da93614a22936c1b75c
Calata/PythonLearningShit
/Vectores.py
878
3.71875
4
def vectorProporcional(): print "Introduzca el Vector 1" vector1a = int(raw_input()) vector1b = int(raw_input()) print "Introduzca el vector 2" vector2a = int(raw_input()) vector2b = int(raw_input()) Cociente1 = vector1a/vector1b Cociente2 = vector2a/vector2b if Cociente1 == Cociente2: print "Los Vectore...
cfe575c3753cddfb1ce180cb1ac4b35f524368cd
anithashok1910/pythonautomationscripts
/directory reader.py
1,609
4.03125
4
# Script file to read all the files of the specified directory and # store it in a text file called "file content.txt" in the current # working directory import os # for functions os.listdir(), os.path.join() and os.path.getsize() functions fout = open('file contents.txt','w') # opens the text file or creates if ...
8ab3f8149c94c31f738d48eeb7681c0b8a66cc9d
pentazoid/Computer-programming-projects
/bar_chart_lecture_89.py
293
3.6875
4
import matplotlib.pyplot as plt x=[2,4,6,8,10] x2=[1,3,5,7,9] y=[4,7,4,7,3] y2=[5,3,2,6,2] plt.bar(x,y,label="One",color='m') plt.bar(x2,y2,label="Two",color='g') plt.xlabel('bar number') plt.ylabel('bar height') plt.title('Bar Chart tutorial') plt.legend() plt.show()
3f3d4ccb46d3788720412c8b47058a6aabdda539
sunshield123/PythonTotal
/Controlflow.py
265
4.03125
4
# for i in range(1,11): # print(i) # i=1 # while i<=10: # print(i) # i=i+1 # a=10 # b=20 # if a<b: # print("{} is less than {}".format(a,b)) # elif a==20: # print("{} is equal to {}".format(a,b)) # else: # print("{} is greater than {}".format(a,b))
5a10b290ea8db139050502ebd0fd98d5afb3f47a
CTEC-121-Spring-2020/mod-3-programming-assignment-EPisano526
/Prob-1/Prob-1.py
516
3.953125
4
# Module 3 # Programming Assignment 4 # Prob-1.py # Esther Pisano def shippingCost(orderSubTotal): shippingCost = 2.99 # enter code here to test for free if orderSubTotal >= 10: shippingCost = 0 return shippingCost def unitTest(): print("Shipping cost if subtotal < 10.00:\n", shi...
ce4e17153201cab5095bff5ef5bf7df3b769987e
Miguel-Fuentes/Spam_Ham_ML
/spam_ham_util.py
906
3.609375
4
from sklearn.feature_extraction.text import CountVectorizer import numpy as np import pandas as pd def df_to_numeric(train_df, test_df): # This will ingore any words that appear in more than 85% of documents # or less than %5 of documents count_vec = CountVectorizer(max_df=0.85,min_df=0.05) # Here...
7003ea04149f15b591f728fc505da70218a1a9c8
fengjixuchui/Image_Processing_Practice
/XYZ/Digital-Image-Processing-master/collage_pics_divider/collage_border_detection.py
2,090
3.78125
4
import cv2 as cv #import OpenCV #This method is used to show images without being enlarged. Try only with `cv.imshow` to see the difference def showimage(img): screen_res = 1280, 720 scale_width = screen_res[0] / img.shape[1] scale_height = screen_res[1] / img.shape[0] scale = min(scale_width, scale_h...
4082583f119dc9702058674bcb3de779be24b5e4
a7med-tal3at/Data-Structure
/Queue/linkedListQueue.py
1,003
3.9375
4
class Node: def __init__(self, val): self.val = val self.next = None class Queue: def __init__(self): self.front = self.rear = None def isEmpty(self): return not self.front def enQueue(self, val): newNode = Node(val) if self.isEmpty(): self....
0a76c3c5203cdd4f81775984fe7d8a6af9e811d8
chpurdy/pgzero-blackjack
/main.py
1,290
3.59375
4
from random import shuffle WIDTH = 1024 HEIGHT = 768 class Card: def __init__(self, suit, rank): self.suit = suit self.rank = rank def __str__(self): return f"{self.rank} of {self.suit}" def value(self): # return a tuple of values to handle the Ace fac...
589dc8e59bb0c5f46839e25ef1b5aebd60c82db7
mtsznowak/pjn
/lab3/dict.py
357
3.515625
4
class Dict: def __init__(self): filepath = 'polimorfologik-2.1/polimorfologik-2.1.txt' self.dict = set() with open(filepath) as fp: line = fp.readline() while line: splitted = line.split(';') self.dict.add(splitted[1].lower()) line = fp.readline() def has_key(self, ...
17a2337bfd3ee42411d71e76757dcdbe6feb6cb2
dmckenzie79/web-336
/week-8/if_else_ex01.py
343
4
4
even_numbers = [2,4,6,8,10] odd_numbers = [1,3,5,7,9] number01 = 4 number02 = 7 if number01 in even_numbers: print(str(number01) + " is an even number") else: print(str(number01) + " is an odd number") if number02 in odd_numbers: print(str(number02) + " is an odd number") else: print(str(number02) +...
b03233c66c8b5f19b835c70816db5690ce5600d6
Georgia2308/StrongPasswordChecker
/password.py
10,477
3.890625
4
# Strong Password Checker # written by Georgia Berar as a technical test for UMT Software # password checker class # validates a strong password and constructs the strongest password with minimal changes class PasswordChecker: def __init__(self, password): self.password = password self.__...
c4a05684bbb0b0ae64be021d151ca65ffc826a07
DistriI1/ProyectoPrimerParcial
/Cliente Check In/checkin.py
5,992
3.609375
4
#!/usr/bin/env python import socket import sys import md5 import time import datetime import Turista def get_specific_input(valid_length, datatype): resp=None prompt=' -> '# muestra > mientras espera input if (datatype == 'int'): resp = get_input(prompt, lambda x:x.isdigit(), "Maximo "+str(valid_len...
8cc92ae7e896ec6538591b73a49dd7850058a2ef
LVicBlack/learn-python
/demo/hifun_closure.py
1,375
3.53125
4
# 函数作为返回值 # 高阶函数除了可以接受函数作为参数外,还可以把函数作为结果值返回。 # 闭包 ### 返回闭包时牢记一点:返回函数不要引用任何循环变量,或者后续会发生变化的变量。 def count(): fs = [] for i in range(1, 4): def f(): return i * i fs.append(f) return fs # print(count()[0]()) # # 元组拆封 # f1, f2, f3 = count() # f4 = count() # print(f1()) # print(f2()...
c9482831e1ae58563407a1266ed7ddf816ae3542
LVicBlack/learn-python
/demo/hifun_filter.py
1,527
3.859375
4
# 和map()类似,filter()也接收一个函数和一个序列。 # 和map()不同的是,filter()把传入的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素。 def not_empty(s): return s and s.strip() # print(list(filter(not_empty, ['A', '', 'B', None, 'C', ' ']))) # 素数 def arr_start_2(): num = 2 while True: yield num num = num + 1 def is_p...
68ecde6a54b0be44c15b86e0fbdec4400c0d6f3c
vidyasridhar0/Coding-puzzles
/LCP_horizontal.py
580
3.6875
4
#LCP(string)= LCP(LCP(string1, string2), string3) def LCP(str): new = "" prefix = str[0] for x in str: new = find(prefix, x) if new == "": print ("No LCP") quit() prefix = new return prefix def find(str1, str2): newstring = "" for i, j in zip(s...
8502202133de46f0b14432650b3f149cdc966efe
Sai-Ram-Adidela/hackerrank
/challenges/strings/string_formatting.py
127
3.765625
4
def dec_to_oct(n): n = int(input()) for i in range(1, n): print(i+' '+dec_to_oct(i)+' '+dec_to_hex(i)+' '+dec_to_bin(i))
2f0dde5084c3803098b9edfd67164e5918c51de4
Sai-Ram-Adidela/hackerrank
/30_days_Of_Code/day2_operators.py
545
3.59375
4
""" Title : day2_operators Subdomain : 30 days of code Domain : Python Author : Sai Ram Adidela Created : 18 April 2018 """ if __name__ == "__main__": meal_cost = float(input().strip()) tip_percent = int(input().strip()) tax_percent = int(input().strip()) tip = float(meal_cost*(tip_percent/1...
561e22ed476f75f9ad72c5e72d7955f8ddde91e2
Sai-Ram-Adidela/hackerrank
/challenges/sets/set_symmetric_difference.py
692
3.71875
4
""" Title : Set Symmetric Difference Subdomain : HackerRank/Python/Challenges/sets Domain : Python Author : Sai Ram Adidela Created : 2 May 2018 """ if __name__ == '__main__': set1_n = int(input()) set1 = set(map(int, input().split())) set2_n = int(input()) set2 = set(map(int, inp...
6ce3b9e2e4084d4a5a94765d7f3a1abeef5e9a51
Sai-Ram-Adidela/hackerrank
/challenges/collections/collections.counter().py
521
3.546875
4
""" Title : collections.Counter() Subdomain : HackerRank/Python/Challenges/Collections Domain : Python Author : Sai Ram Adidela Created : 15 May 2018 """ from collections import Counter no_of_shoes = int(input()) shoe_sizes = Counter(map(int, input().split())) no_of_customers = int(input()) t...
25664d3446b179d6ebc6de7d329a5ff94c8d65e0
Sai-Ram-Adidela/hackerrank
/challenges/basic data types/lists.py
728
3.796875
4
""" Title : Lists Subdomain : HackerRank/Python3/Challenges/Basic Data Types Domain : Python Author : Sai Ram Adidela Created : 23 April 2018 """ if __name__ == '__main__': N = int(input()) L = [] for i in range(0, N): tokens = input().split() if tokens[0] == 'insert': ...
e1371fb9d9c3b4f9f7b938d9b5421f5c4aad4b87
Sai-Ram-Adidela/hackerrank
/challenges/collections/company_logo.py
389
3.578125
4
""" Title : Company Logo Subdomain : HackerRank/Python/Challenges/Collections Domain : Python Author : Sai Ram Adidela Created : 22 May 2018 """ from collections import Counter s = sorted(input().strip()) s_counter = Counter(s).most_common() s_counter = sorted(s_counter, key=lambda x: (x[1] * -1...
07e837def498b93c4f3091bce2af0eb45395f318
mjpinsk/python-challenge
/PyBank/main.py
3,142
4.34375
4
""" The following script opens a csv file with bank data and returns the following results: 1) The total number of months included in the dataset 2) The net total amount of "Profit/Losses" over the entire period 3) The average of the changes in "Profit/Losses" over the entire period 4) The greatest increase in pr...
1ed8060c5b681b02ccc7f188adb825ef0617c598
ramya-nagarajan/Academic-Research-Network-Generator
/project/project/keyphrase_extraction/phraseSelect.py
4,562
3.578125
4
import string; import fileHandle; patterns = [('JJ', 'NN'), ('NN', 'NN'), ('JJ', 'NNS'), ('NN', 'NNS'), ('NN'), ('NN', 'NN', 'NN')]; #make 3 word patters also #forget noun phrase idea.. find better patterns #write a learning algorithm to find patterns --- any database of keywords should do to get candidates since POS...
a0de4bef78d37450f14b7cac40fb380814980845
malikyilmaz/Class4-PythonModule-Week2
/1.lucky numbers.py
1,661
4.0625
4
""" Write a programme to generate the lucky numbers from the range(n). These are generated starting with the sequence s=[1,2,...,n]. At the first pass, we remove every second element from the sequence, resulting in s2. At the second pass, we remove every third element from the sequence s2, resulting in s3, and we ...
dc27b4d07c81d4faed52867851a4b623ac3a7ca3
jonathan-potter/MathStuff
/primes/SieveOfAtkin.py
1,824
4.21875
4
########################################################################## # # Programmer: Jonathan Potter # ########################################################################## import numpy as np ########################################################################## # Determine the sum of all prime numbers l...
2923cb3c964c77b3925aefced32818e3f56a3bdc
TeMU-BSC/mesinesp-workflow
/Evaluation/scripts/excel_utils.py
2,430
3.71875
4
''' Util functions to analyze Excel files for the initial phase of indexers' selection for MESINESP task. Author: alejandro.asensio@bsc.es Based on the original script made by: aitor.gonzalez@bsc.es ''' import re import os import xlrd from typing import List def read_excel_file(filename: str) -> List[list]: '''...
29f8bd56a5591f9caf22f96dfde852172aae6938
RameshVasudev-Shankar/Assignment1
/Ramesh Vasudev Shankar A1.py
3,102
3.8125
4
# ''' # CP5632 Assignment 1 2016 # Items for Hire # Shankar Ramesh V - 3rd April 2016 # # Pseudocode: # # function main(): # # display Welcome Message # display list of items loaded from file # display menu # choice # while choice not Q # if choice = L # function list_all_items()...
6733b7b848e1e271f7f3d313284348f9e9fab0a8
gyhou/DS-Unit-3-Sprint-2-SQL-and-Databases
/SC/northwind.py
2,546
4.5625
5
import sqlite3 # Connect to sqlite3 file conn = sqlite3.connect('northwind_small.sqlite3') curs = conn.cursor() # Get names of table in database print(curs.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;").fetchall()) # What are the ten most expensive items (per unit price) in the database...
7a456406252bf4050a51e609fc33d15e327b3021
trauzti/CompetitiveProgramming
/datastructures/priorityqueue.py
711
3.921875
4
from Queue import PriorityQueue """ Entries are typically tuples of the form: (priority number, data). """ class minpriorityqueue(): def __init__(self): self.pq = PriorityQueue() def push(self, x): rank, key = x self.pq.put((rank, key)) def pop(self): rank, key = self...
8a85cbbaab5aaa7f332e4d332425e15d3964d980
vasanthigopisetti/Becomecoder
/descending sort list.py
100
3.703125
4
list = [int(i) for i in input('Enter values: ').split()] list.sort() list.reverse() print(list)
125317f1ea8b7693528e0c6ea2993680faff2e3b
vasanthigopisetti/Becomecoder
/pattern.py
259
3.828125
4
num=int(input()) for i in range(1,num+1): if i%2: temp=1 else: temp=0 for j in range(1,num+1): print(temp,end="") if temp==0: temp=1 else: temp=0 print()
26a64398a7d8c3b757bdd05c0f81efdcb6ba1b7f
vasanthigopisetti/Becomecoder
/list_4.py
127
3.625
4
n=int(input()) data=[0 for i in range(n)] for i in range(n): val=int(input()) data.append(val) print(data)
433779fb71af65a1a40717aa1b22340802a1c150
wesky93/studyML_base
/from_scratch/1_perceptron_basic2.py
1,226
3.78125
4
import unittest # 계산한 값과 편향(theta)를 비교하지 않고 0과 비교 할수 있도록 식을 변경 # func <= theta --> func-theta <= theta-theta --> func-theta <= 0 def AND( v1, v2 ) : w1,w2,theta = 0.5,0.5,0.7 func = v1*w1+v2*w2 if func <= theta: return 0 elif func > theta: return 1 def OR( v1, v2 ) : w1,w2,thet...
86fb110e3756aea836e2bd40ffdd2bb4edfba728
brekimanason/TileTraveller
/TileTraveller.py
2,492
3.8125
4
# https://github.com/brekimanason/TileTraveller # Geri Fall fyrir hvert herbergi og svo hoppar notandi milli falla og þar með milli herbergja def room1_1(): print("You can travel (N)orth.") direction = input("Direction: ") if direction == "n" or direction == "N": room1_2() else: print(...
42d09562d90592f53f1e6e4ba4df03b1a3257869
GeorgianaLoba/Python-Games
/obstruction/gui/gui.py
2,565
3.921875
4
import tkinter from tkinter import Button class Gui: #TODO: GUI prettier def __init__(self, master, game): self.master = master self.game = game master.title("OBSTRUCTION") self.start() def start(self): """ Our board consists of buttons. When ...
adc2d2ef1ac83d912f4488ea51fa426fb531cf92
AHipWhale/Machine-Learning
/P3/code/neuron.py
940
3.625
4
import math class Neuron: def __init__(self, weights, bias): self.bias = bias self.weights = weights self.sumInvoer = None def calculate_input(self, invoer: [float]): """Deze functie berekent de som van de inputs met we weights en telt daarbij de bias op""" self.sumInvo...
c0069c46ea1866f745746d24ea3e3f6fb23ca8cd
strixcuriosus/sierpinski
/triangulator.py
801
3.65625
4
numGens = int(raw_input("how many generations? (enter an integer)")) G1 = [0 , 1, 0] rules = {7:0, 6:0, 5:0, 4:1, 3:0, 2:0, 1:1, 0:0} G2 = [] output = '' baselength = len(G1) + numGens * 2 def printout(myList): global baselength while len(myList) < baselength: myList.insert(0,0) myList.append(0) output = '' f...
331dcf92483afb69c9f9493cb094112dbb3da1fa
rakshith-mand/my-first-blog
/python_intro.py
148
3.75
4
def hi(name): print('Hi ' + name + '!') people = ['Rakshith','silu','harvester','tracter','manchester'] for name in range(1,6): print(name)
4ebf0c7a8bfd10b7aea07f9d6e7f2557ba0dc3d9
woleywa/python_for_everybody
/1_class/Week6/ex_04_02.py
210
3.875
4
def computepay(): hrs = input("Enter Hours:") rate = input("Enter rate:") h = float(hrs) r = float(rate) if h<41 : pay=h*r else : ot=h-40 pay=(h-ot)*r+ot*(1.5*r) return(pay) print(computepay())
797e49abfd0e26dadc39b70a907fc6accd56150d
TakezoCan/sandbox
/trafficLight.py
2,185
3.859375
4
#!/usr/bin/env python3 # # Filename: trafficLight.py # Date: 2018.10.31 # Author: Curtis Girling # Function: Runs three LEDs as a traffic light when button is pressed # from time import sleep # import sleep function for delay timing import RPi.GPIO as GPIO # import GPIO library to use GPIO pins # Lables for BCM pin...
52047b3445a5e24f1975fe4c882a56b4fe0dcce6
li2ui2/Python_Personal_DEMO
/sqrt_.py
183
3.78125
4
def _sqrt(a): x1 = a x2 = a/2 while abs(x1-x2) > 0.00000001: x1 = x2 x2 = (x1+a/x1)/2 return x1 if __name__ == '__main__': print(int(_sqrt(25)))
654a1ce712b7ec83e861feb4097434684707fe72
li2ui2/Python_Personal_DEMO
/DATA_STRUCTURE/jianzhi_offer/Tree/二叉搜索树与双向链表.py
1,038
3.8125
4
""" 输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。 要求不能创建任何新的结点,只能调整树中结点指针的指向。 """ class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def Convert(self, pRootOfTree): # write code here if pRootOfTree is None: return None ...
1cb0122ab0cef46e5def7cad03c68a870462a97e
li2ui2/Python_Personal_DEMO
/DATA_STRUCTURE/leetcode/矩阵置零.py
440
3.78125
4
def setZeroes(matrix): n = len(matrix) if n == 0: return [] m = len(matrix[0]) for i, li in enumerate(matrix): for j in range(len(li)): if li[j] == 0: matrix[i] = [0 for _ in range(m)] for i in range(n): matrix[i][j] = 0 ...
581f3ce15faa2ff8ebd8cdc0207023a42ff6c8f4
li2ui2/Python_Personal_DEMO
/DATA_STRUCTURE/jianzhi_offer/其他/翻转单词顺序列.py
797
4.03125
4
""" 将像"I am a student."这样的字符串进行翻转,翻转后结果为:"student. a am I"。 思路:先转单词,再转句子。 """ def reverse(words): for i in range(len(words) >> 1): words[i], words[-i - 1] = words[-i - 1], words[i] return words def ReverseSentence(s): # write code here wordstart = 0 s = list(s) for i in range(len(s))...
fca4ea31aa9d970b6b3c2d5985a80f1a71977ff0
li2ui2/Python_Personal_DEMO
/DATA_STRUCTURE/jianzhi_offer/其他/数值的整数次方.py
520
4
4
""" 给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。 保证base和exponent不同时为0 """ class Solution: def Power(self, base, exponent): # write code here if exponent == 0: return 1 ret = base if exponent > 0: for i in range(1, exponent): ret *...
7e2d0e3179c141d8c7df35e8ecc62e9f8410c1d8
li2ui2/Python_Personal_DEMO
/DATA_STRUCTURE/leetcode/滑动窗口/找到字符串中所有字母异位词.py
1,031
3.703125
4
""" leetcode 438 给定一个字符串 s 和一个非空字符串 p, 找到 s 中所有是 p 的字母异位词的子串,返回这些子串的起始索引。 输入: s: "cbaebabacd" p: "abc" 输出: [0, 6] 解释: 起始索引等于 0 的子串是 "cba", 它是 "abc" 的字母异位词。 起始索引等于 6 的子串是 "bac", 它是 "abc" 的字母异位词。 """ import collections def findAnagrams(s, p): pLen = len(p) sLen = len(s) if sLen < pLen or s == [] or p == [...
75ee01282c6ac7032782e7c7c5e41918976ea2f4
mattwu4/Python-Easy-Questions
/Check Primality Functions/Solution.py
638
4.15625
4
while True: number = input("Choose any number you want! ") number = int(number) if number == 2: print("PRIME!") elif number == 3: print("PRIME!") elif number == 5: print("PRIME!") elif number == 7: print("PRIME!") elif number == 11: print("PRIME!") ...
26360515333bf4face0c980dc1c89243b5383b96
Gilvenf/GilvenfransiscoL_064002100039_PrakAlgo2
/Prak2Elkom2.py
220
3.796875
4
a = int(input("masukan nilai a: ")) b = int(input("masukan nilai b: ")) c = int(input("masukan nilai c: ")) maks = 0 if a > b: maks = a else: maks = b if c > maks: maks = c print ("terbesar:",maks)
c653a1e85345ac2bd9dabf58da510c86a43afdac
jrabin/GenCyber-2016
/Base_Day.py
309
4.21875
4
# -*- coding: utf-8 -* """ Created on Wed Jul 6 10:24:01 2016 @author: student """ #Create your own command for binary conversion #// gives quotient and % gives remainder ''' hex_digit=input("Hex input:") print(chr(int("0x"+hex_digit,16))) ''' letter=input("Enter letter:") print(hex(int(ord(letter))))
f39cf918e485fe5795fcb269bb424f2d841fa887
QAKyle/qacourse2
/qacourse3.py
1,128
3.796875
4
import random import sys secret_number = random.randint(1, 100) #secret_number = 50 #wish statement print "Use your 3 wishes to guess the magic number!" print "If you fail you will be fed to the Kraken!" #wish checker function def process_user_guess(asked_count): print "With your {} wish, which number would yo...
e77d25be0d2652163b0366a06a2e610c9b632a33
jirvingphd/dsc-1-07-07-object-oriented-shopping-cart-lab-online-ds-ft-021119
/shopping_cart.py
1,896
3.765625
4
class ShoppingCart: # write your code here def __init__(self, employee_discount=None): #, total=0 , items=[]): self.employee_discount = employee_discount self.total=0 self.items=[] def add_item(self, name, price, quantity=1): q=0 while q <quantity : ...
7fad66210bb197c684aec12fc9581c7aa1cc835f
Buffer0x7cd/fabulous
/fabulous/services/google.py
1,321
3.53125
4
"""~google <search term> will return three results from the google search for <search term>""" import re import requests from random import shuffle from googleapiclient.discovery import build import logging my_api_key = "Your API Key(Link: https://console.developers.google.com/apis/dashboard)" my_cse_id = "Your Custo...
8de2a3d8d21d1ccc75b71500424728f5ec707a5f
yestodorrow/py
/init.py
486
4.15625
4
print("hello, Python"); if True: print("true") else: print("flase") # 需要连字符的情况 item_one=1 item_two=2 item_three=3 total = item_one+\ item_two+\ item_three print(total) item_one="hello" item_two="," item_three="python" total = item_one+\ item_two+\ item_three print(total) # ...
56a0882cfc7bd368133f7dec3d265f3800550958
zhanna-naumenko/test
/home_work_13_naumenko.py
1,982
3.625
4
from random import randint import io import os import random class EmailGenerator: def __init__(self, path_domains, path_names): self.path_domains = path_domains self.path_names = path_names self.get_names() self.get_domains() def get_domains(self): """Opens file doma...
f7c954329701b44dd381aa844cf6f7a11ba1461e
KritiBhardwaj/PythonExercises
/loops.py
1,940
4.28125
4
# # Q1) Continuously ask the user to enter a number until they provide a blank input. Output the sum of all the # # numbers # # number = 0 # # sum = 0 # # while number != '': # # number = input("Enter a number: ") # # if number: # # sum = sum + int(number) # # print(sum) # # sum = 0 # # number...
8ec78f5a756a67b986ec892397bf0774816c955b
mathcoder3141/doomsday
/doomsday.py
8,410
4.34375
4
import math from constants import * def date_prompt(): """ Prompts the user to enter a month, year, and date. :return: A tuple of the entered month, date as an integer, and the year. """ month = input('Enter a month: ') while month not in months: month = input('Enter a valid month: ')...
2be618d75a390af1e6ebb7a4c8b87fb327d613de
Nevilli/unit_ten
/class_file.py
1,259
4.0625
4
# Liam Neville # 12/11/18 # This program draws a 5 layer brick pyramid of different colors import brick import pygame, sys from pygame.locals import* GREEN = (0, 102, 71) RED = (255, 0, 0) BLUE = (0, 0, 255) GOLD = (255, 209, 63) PURPLE = (255, 0, 255) SPACE = 5 HEIGHT = 20 x_number_bricks = 9 colors = [RED, BLUE, G...
3c95d2c49f74342f1b17f6653607b22774d5af66
sensito/Aprendiendo-py
/pruebas.py
1,401
3.78125
4
# -*- coding: utf-8 -*- import os MENU = ''' -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- 1.-Agregar nueva moneda 2.-Borra una moneda 2.-Cambio de divisa 3.-Salida''' class modifi_coins(): """docstring for coin.""" def add_coin(coins): coins_clas = dict(**coins) print(c...
f4fad1a73dd03e6fe1cb2a18d77a7a82f853d107
sensito/Aprendiendo-py
/13.py
489
3.90625
4
# -*- coding : utf-8 -*- import random def run(): number_foud = False rand_number = random.randint(0, 20) while not number_foud: number = int(input('Intenta un numero: ')) if number == rand_number: print('Felicidades encontraste el numero') number_foud = True ...
7f5c247cf0525364ff168c36d11cc9309cd201d6
KingOfBraves/ChatClient
/ChatWindow.py
1,065
3.6875
4
import curses def main(stdscr): newline = False userinput = "" chatlog = [] # Clear screen begin_x = 0; begin_y = 0 height = 24; width = 80 stdscr = curses.newwin(height, width, begin_y, begin_x) myscreen = curses.initscr() stdscr.border(0) stdscr.addstr(0, 0, "Python curses in...
efe3953f77767369a3490903b0ee91f27db552d6
nao-tarrillo/trabajo06
/doble8.py
777
3.609375
4
import os # BOLETA DE VENTA # Declarar variables cliente,kg,P.u ="",0,0.0 # Input cliente=os.sys.argv[1] kg=int(os.sys.argv[2]) P.u=float(os.sys.argv[3]) #Procesing total= (p.u * kg) #Verificador comprador_compulsivo=(total>30) #Output print("#########################") print("######Boleta de vent...
288b522a5b80d0f0388988f41bb5792e688cff65
nao-tarrillo/trabajo06
/doble1.py
791
3.5625
4
import os # BOLETA DE VENTA # Declarar variables cliente,nro_granadillas,p.u = "",0,0.0 # Input cliente=os.sys.argv[1] nro_granadillas=int(os.sys.argv[2] p.u=float(os.sys.argv[3]) #Procesing total= (p.u * nro_granadillas) #Verificador comprador_compulsivo=( total > 34 ) #Output print("###########...
011e851683a46a904c0a736522cfd67fc1839469
nao-tarrillo/trabajo06
/multiple11.py
1,587
3.59375
4
import os # BOLETA DE VENTA # declarar variables cliente,RUC,carro01,carro02,carro03,precio_del_carro01,precio_del_carro02,precio_del_carro03="",0,"","","",0.0,0.0,0.0 # INPUT cliente=os.sys.argv[1] RUC=int(os.sys.argv[2]) carro01=os.sys.argv[3] carro02=os.sys.argv[4] carro03=os.sys.argv[5] precio_del_car...
56a9cc1f77675f8e1c51a85c6d52d97a9d858795
Pratyush576/python
/src/com/python/coding/magicNumber.py
563
3.984375
4
''' Created on 16-Jun-2018 @author: pratyusk WAP to return kth magic number where magic number is defined as M=5^m+s^n and m,n>=0 ''' def getMagicNumber(k): m = 0 n = 0 index = 1 if k == index: print m,n return 5 ** m + 5 ** n while True: if m == n: m=0 ...
9c37bf9b3d645c2d319dd0e8aee018c1cf81d548
Risoko/Algorithm
/sorting_algorithm.py
6,355
3.78125
4
from random import randint class Sorting: def __init__(self, table): assert type(table) == list, "Must be list" self.table = table def sort(self, number_sort=4): """You can check sorting algorithm 1. Bubble Sort 2. Selection Sort 3. Insertion Sort 4. Qu...
5ccb8364af409094c7017bc46701e2978bbf1f40
Risoko/Algorithm
/hash_table_the_chain_method.py
1,931
3.859375
4
from collections import namedtuple Position = namedtuple('Position', 'Index_in_HT Data') class HashTable: """Hash table using chain method.""" def __init__(self, size): assert type(size) == int, "Must be type int" self.size = size self.table = [[] for _ in range(size)] def _functi...
c5b507b6029076bafb35dc6879dc402f2449eefc
jvasallo/madness-calc
/madness_calc.py
1,645
3.84375
4
#!/usr/bin/python ''' Every year, I play a March Madness pool where we pay out based on the last digits of the score. This year, I am too busy to watch all the games or even keep track. So I created this to calculate how much money I will win! Sign up for API access @ https://www.kimonolabs.com/signup ''' import json ...
079850ec49ec482a6407feb5e5c975e36d896a10
stelzriede/iRobot
/coloreye.py
1,871
3.75
4
# PIL Image module (create or load images) is explained here: # http://effbot.org/imagingbook/image.htm # PIL ImageDraw module (draw shapes to images) explained here: # http://effbot.org/imagingbook/imagedraw.htm from PIL import Image from PIL import ImageDraw import time from rgbmatrix import RGBMatrix, RGBMatrixOpt...
151272434faf8bfb07b328227b8357c9f19aee83
geekidharsh/elements-of-programming
/primitive-types/palindrome_number.py
1,405
3.765625
4
import math # solution 1 def palindrome_num(x): #brute force algorithm # considering x>0 # complexity is O(n) where n is the number of digits in x # space complexity is O(n). # idea: # We can use log10 function to cut down space complexity to O(1) reverse = 0 temp = x if x<=0: return 0 else: try: ...
dbe0e4b02b87fc67dd2e4de9cbaa7c0226f9e58e
geekidharsh/elements-of-programming
/primitive-types/bits.py
1,870
4.5
4
# The Operators: # x << y # Returns x with the bits shifted to the left by y places (and new bits on the right-hand-side are zeros). # This is the same as multiplying x by 2**y. # ex: 2 or 0010, so 2<<2 = 8 or 1000. # x >> y # Returns x with the bits shifted to the right by y places. This is the same as //'ing x by ...
456b6a62ba7b9c3c6a0493d74ff483498ed58ab3
geekidharsh/elements-of-programming
/linked-lists/listNode.py
592
3.90625
4
class ListNode: """docstring for ListNode. implementing a singly linked list class""" def __init__(self, data=0, next=None): self.data = data self.next = next def search_list(L, key): while L and L.data != key: L = L.next # if key is not present then None will return return L def insert_after(no...
3a60bae93f01f1e9205430277f924390825c598f
geekidharsh/elements-of-programming
/binary-trees/binary-search-tree.py
1,229
4.15625
4
"""a binary search tree, in which for every node x and it's left and right nodes y and z, respectively. y <= x >= z""" class BinaryTreeNode: """docstring for BT Node""" def __init__(self, data=None, left=None, right=None): self.data = data self.left = left self.right = right # TRAVERSING OPERATION def preor...
4c05bf6d559bd0275323dbdb217edc1a2208f59c
geekidharsh/elements-of-programming
/arrays/generate_primes.py
613
4.1875
4
# Take an integer argument 'n' and generate all primes between 1 and that integer n # example: n = 18 # return: 2,3,5,7,11,13,17 def generate_primes(n): # run i, 2 to n # any val between i to n is prime, store integer # remove any multiples of i from computation primes = [] #generate a flag array for all elem...
0c41b846d2ff0652d15e6301af071e71b0ad3ebf
premeromb/sistemas_multimedia
/kew_word.py
355
3.53125
4
import speech_recognition as sr r = sr.Recognizer() file = sr.AudioFile("output.wav") print("eeee") while(True): with file as source: r.adjust_for_ambient_noise(source) audio = r.record(source) result = r.recognize_google(audio,language='es') if "hola" in result.split(' '): b...
c19d6e9bca7165a6876df918ca2914fba4b8c21d
jinger02/testcodes
/1.py
211
3.953125
4
x=float(input('Enter number of hours...\n')) while True: try: type (x) != float print('Please enter a number') except: print ('Number of hours is', x) break
4c281a3e6b6ff68ee870dc9914072507f649d105
iepping1/DataProcessing
/Week 1/tvscraper.py
2,244
3.875
4
#!/usr/bin/env python # Name: Ian Epping # Student number: N/A ''' This script scrapes IMDB and outputs a CSV file with highest rated tv series. ''' import csv from pattern.web import URL, DOM TARGET_URL = "http://www.imdb.com/search/title?num_votes=5000,&sort=user_rating,desc&start=1&title_type=tv_series" BACKUP_HTM...
416311218b2fd044c5d9e6ad0e3d51e55e93b722
laganojunior/Toy-FS
/FSNode_File.py
1,077
3.78125
4
from FSNode import FSNode class FSNode_File(FSNode): """ A file in the file system. Just contains text data """ def __init__(self, name, parent): FSNode.__init__(self, name, parent) self.data = "" def get_type(self): return "FSNODE_FILE" def write(self, offset, data): ...
51a3ae2e607f52ab2c79c59344699e52030e1c15
justindarcy/CodefightsProjects
/isCryptSolution.py
2,657
4.46875
4
#A cryptarithm is a mathematical puzzle for which the goal is to find the correspondence between letters and digits, #such that the given arithmetic equation consisting of letters holds true when the letters are converted to digits. #You have an array of strings crypt, the cryptarithm, and an an array containing the ma...
ce6aaa278d8068d8c31bbf5b3dd7ecae192b4019
Naesen8585/dlive-auto-bot
/text_generator.py
491
3.609375
4
""" Use AI TextGen to generate a response in kind based on the given input. """ from aitextgen import aitextgen import random ai=aitextgen(model="minimaxir/reddit") #ai=aitextgen(model="minimaxir/hacker-news") #ai=aitextgen() def returngeneratedtext(inputtext,minsize=20, maxsize=50): return random.choice(ai.gene...
9c01fc72c243846886a7e1f44e5a0ebcce008f7b
sgirimont/projecteuler
/euler1.py
1,153
4.15625
4
################################### # Each new term in the Fibonacci sequence is generated by adding the previous two terms. # By starting with 1 and 2, the first 10 terms will be: # # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # # By considering the terms in the Fibonacci sequence whose values do not exceed four million, ...
47c8701c1157d685b845423b8dfd66db568c03fa
dayelu/PythonLearning
/automate-the-boring-stuff-with-python/imgs_operate/img_operte.py
2,013
3.734375
4
import os from PIL import Image #Pillow库的模块名是PIL,与python的Python Image Library向后兼容所以不是from Pillow .... class ImgOperate(): """图像处理的几个例子""" def __init__(self): # def __init__(self, catIm): self.catIm = Image.open("zophie.png") #生成图片对象 def save_as(self): """图片另存为其他格式""" try: catIm = self.catIm print...
69feee82e499cc62d01de5fd4bcba5bf94dcd9e9
prasadboyane/tictactoe
/tictactoe.py
2,507
3.671875
4
from os import system, name cnt=1 move_player=1 p1='' p2='' win_flag=0 l_row1 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] def clear(): if name == 'nt': _ = system('cls') def print_board(): global win_flag clear() b1=' {} | {} | {} '.format(l_row1[0],l_row1[1],l_row1[2]) b3=' ...
1a927dd83e50b1cb4839a5dcb26f2de25b65c336
elimanzodeleon/simple-ftp
/client/client.py
5,963
3.5
4
import socket import sys HEADER = 10 MAX_SIZE = 65536 # ________________ # HELPER FUNCTIONS # ________________ # Send all data, either control or data connection # from the specified socket def send_msg(sock, data): bytes_sent = 0 # Keep sending till all is sent while len(data) > bytes_sent: bytes_...
b0b771a0664e93a79f4a83accee25ba5ef25b28e
schipkovalina/Programming
/hw12/hw12.py
577
3.625
4
#Вариант3 import os import re def search(): folders = [] for folder in os.listdir(): if os.path.isdir(folder): dirpath, filename = os.path.split(folder) r = re.search("[a-zA-Z0-9]|[,—\[\]↑№!\"\'«»?.,;:-|/+*{}<>@#$%-^&()]", filename) if not r: folders...
d0017e98c44520ead1b1220b3b6fdb38be5f9c4e
schipkovalina/Programming
/hw3/homework3.py
204
3.921875
4
#Вариант3 word = input('Введите слово ') print(word) for i in range(0, len(word)-1): a = [] a.append(word[1:]) a.append(word[0]) b="".join(a) word = b print(b)
625d06f5ed42042e6c4b30527a0f374f5e22cb4e
Hikari9/Matching
/clustering.py
7,441
3.78125
4
from collections import defaultdict from suffix import SuffixArray from edistance import * import numpy as np ''' Algorithm: stem_cluster(data [, mode, length_at_least] ) A clustering algorithm that bases from word frequency and stem trimming/lemmatizing. The goal of the algorithm is to reduce the data int...
0cb9e3c2b63ef3790fedf2bc06b7a6e15e4c7e1d
dmangialino/shopping-cart
/shopping_cart.py
7,433
3.890625
4
# shopping_cart.py # Program utilizes to_usd function provided by Professor Rossetti to convert values to USD format def to_usd(my_price): """ Converts a numeric value to usd-formatted string, for printing and display purposes. Param: my_price (int or float) like 4000.444444 Example: to_usd(4000.4444...
a9b4eca6c841bea81483fb8e048c53323b2c49d1
paulionele/particle-diffusion
/misc/cell_creator.py
574
3.6875
4
''' This script is functioning as expected. Creates a list of values, elements of either 1 or 0 depending on specifications. ''' j = 1 #flip the j,k bits to start with cellular or extracellular. k = 0 lic = 4 #number of cells in intracellular unit cell. lec = 2 #number of cells in extracellular unit cell. lsc = 7 #to...