blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
6ca45fdf4f4215d566d243b76e0918885261b5b1
AzizbekHakimov/my_projects
/Assignment2.py
409
3.6875
4
#!/usr/bin/env python # coding: utf-8 # In[3]: print("Which vegetables do you want to buy? ") vegetable = input() print("Which fruits do you want to buy? ") fruits = input() print("Which drinks do you want to buy? ") drinks = input() print("What other things do you want to buy? ") other = input() print(f"You bought...
ef5e0d5fee1b8f0216460e13cdac704ea355602c
logjb/Thesis_GUI
/GUI.py
9,904
3.8125
4
from Tkinter import * class Application(Frame): def say_hi(self): print "hi there, everyone!" print variable.get() print entry.get() def generate_entry_box(self, title, description, example, row): print "generating entry box" Label(self, text=title).grid(row=row, column=...
4a6f84e6dfd4184ed924bdc46b9bdadfdfc67375
phaustin/pythonlibs
/pyutils/pyutils/translate.py
789
3.8125
4
#http://stackoverflow.com/questions/638893/what-is-the-most-efficient-way-in-python-to-convert-a-string-to-all-lowercase-str import string letter_set = frozenset(string.ascii_lowercase + string.ascii_uppercase) ## tab = string.maketrans(string.ascii_lowercase + string.ascii_uppercase, ## string.a...
023132eceb8481e5028b7d715743c26acb2e6d44
phaustin/pythonlibs
/pyutils/pyutils/dirtools.py
1,287
3.640625
4
import os,errno def silent_remove(filename): """remove a directory without failure if directory doesn't exist """ print("{:s} will be destroyed if it exists".format(filename)) try: os.remove(filename) except OSError as e: if e.errno != errno.ENOENT: # errno.ENOENT = no such fi...
5bd9c1d39781cc536fdac46d31b321e5b4e98dab
phaustin/pythonlibs
/pyutils/pyutils/silent_remove.py
685
3.84375
4
import os,errno def silent_remove(filename): """remove a directory without failure if directory doesn't exist """ print(("{:s} will be destroyed if it exists".format(filename))) try: os.remove(filename) except OSError as e: if e.errno != errno.ENOENT: # errno.ENOENT = no such ...
c2e11c256dbf43047aabedd2eee7fe4ac90a8812
ZShiHao/DeepLearning-Excercise
/week2.py
12,908
3.703125
4
# coding: utf-8 import numpy as np import matplotlib.pyplot as plt import h5py import scipy from PIL import Image from scipy import ndimage from lr_utils import load_dataset # ## 2 - Overview of the Problem set ## # # **Problem Statement**: You are given a dataset ("data.h5") containing: # - a training set of m...
e9611e7d2039c90a724c7570f68c9c3b88366e5c
zhengjun1987/PythonBeginning
/chapter05/while.py
192
3.765625
4
x = 1 while x <= 10: print(x) x += 1 # zhengjuns-MacBook-Pro:chapter05 zhengjun$ python3 while.py # 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10
777e393e0b62deb4667ddb25dcbed50a9e119dc0
zhengjun1987/PythonBeginning
/chapter07/private_attribute.py
676
3.609375
4
class Secretive: def __inaccessible(self): print("Bet you cannot see me") def accessible(self): print("The secret message is : ") self.__inaccessible() s = Secretive() # s.__inaccessible() # Traceback (most recent call last): # File "private_attribute.py", line 10, in <module> # ...
92fccc160c4747df8e462e503f4f129eee4d950a
zhengjun1987/PythonBeginning
/chapter09/counter_list.py
686
3.65625
4
class CounterList(list): def __init__(self, *args): super().__init__(*args) self.counter = 0 def __getitem__(self, item): self.counter += 1 return super(CounterList, self).__getitem__(item) cl = CounterList(range(10)) print(f"cl = {cl}") cl.reverse() print(f"cl = {cl}") del cl...
5e525c1191286980ecb6208be461c3ec8a6d1baf
zhengjun1987/PythonBeginning
/chapter07/multiple_bases.py
1,158
3.71875
4
class Calculator: def calculate(self, expression): self.value = eval(expression) class Talker: def talk(self): print("Hi my value is", self.value) class TalkingCalculator(Calculator, Talker): pass tc = TalkingCalculator() tc.calculate("1 + 2 * 3") tc.talk() # zhengjuns-MacBook-Pro:chap...
abc15509a992b81b8dd27c72a48e0b3d6d89a737
derpferd/Connect4
/connect.py
5,387
3.609375
4
#!/usr/bin/env python3 import os import time import sys PLAYER_1_SYMBOL = 'X' PLAYER_2_SYMBOL = 'O' WIN_PATTERNS = [ [(0, 1), (0, 2), (0, 3)], [(1, 0), (2, 0), (3, 0)], [(1, -1), (2, -2), (3, -3)], [(1, 1), (2, 2), (3, 3)] ] class Game(): '''Game class stores game state. Init will generate ga...
0816ffb7f4e26aafd6d45fe22d4d8ab99630604a
abhirungta15/abhishek
/lab2a.py
441
3.96875
4
def find(ordered_list, element_to_find): for element_to_find in ordered_list: return (1) else: return (0) lst2 = [] size = int(input("Enter the size:")) print("Enter the elements:") for i in range(0, size): a=int (input()) lst2.append(a) ele=input("Enter the element to...
d532cfe9da2c06bda94b05ca54a21cba66de8d80
m-engl/time_tool
/gui.py
882
3.78125
4
# pre-modeling, outline, trying out layouts... import tkinter as tk root = tk.Tk() categories = {1 : "Math", 2 : "Literature", 3 : "Logic", 4 : "English"} class Interface(tk.Frame): def __init__(self, master, *args, **kwargs): tk.Frame.__init__(self, master, *args, **kwargs) self.master = mast...
34adf55b11a6b6c45f7b9d25d49b385a3e7cd8c7
karendi/python
/excercise39.py
1,737
4.21875
4
counties = { 'nairobi' :"NRB" , 'Thika':"Tka" , 'Githurai':"GRI" , 'Kakamega':"KKGA", 'Webuye':"WBE", 'Kisumu':"KSM" } #adding towns to the different counties we have towns ={ 'NRB':"Westlands", 'Tka':"Gatundu", ...
4b15b5126564a7013913139564b4c3bb931be75a
karendi/python
/Excercise40.py
514
3.65625
4
#working with classes class Song(object): def __init__(self, lyrics): self.lyrics = lyrics def sing_me_a_song(self): for line in self.lyrics: print(line) happy_bday = Song(["Happy birhday to you.happy birthday to you"]) bulls_on_parade = Song(["they will rally around the family with...
8f2f1766efe6e789c8f625ba91ee60f755700286
kraktos/YELP
/DataProcessor.py
855
3.640625
4
""" pre-process all data formats """ import pandas as pd def json_to_dataframe(json_object): """ takes as input a json file and creates a dataframe object from it """ # # read the entire file into a python array with open(json_object, 'rb') as f: data = f.readlines() # remove the trai...
4e4db3942e0089abc874d58b07dae88111a5c803
markns/hackerrank
/python/hackerrank/warmup/repeated_string.py
312
3.640625
4
def repeatedString(s, n): count_a = s.count("a") repeats = n // len(s) mod = n % len(s) count_mod = s[:mod].count("a") return count_a * repeats + count_mod if __name__ == '__main__': assert 7 == repeatedString("aba", 10) assert 1000000000000 == repeatedString("a", 1000000000000)
8b165f9e6a43a3dd32eba690ad5709643c7a2aae
ShaiYona/Programming_2021B
/tirgulim/tirgul4_loops_strings.py
3,684
3.5625
4
# survey: # who played with the excercise? # Suggestions? # pycharm - a frientdly IDE from jetbrains # Great pycharm tutorials # https://www.youtube.com/watch?v=5rSBPGGLkW0 # Hebrew (starting at 2:10): https://www.youtube.com/watch?v=tu6xYIIf6H4 # GREAT GREAT GREAT python tutorials from "tech with tim"...
f62de2e0ac517ac0e4391632de7a5c68253e5450
CRHS-Winter-2021/first-simple-program-etma3
/main.py
336
4.09375
4
##Simple Program #Name: ____ ## Create a Simple Program that does the following. #1. Asks the user a skill question and compares their guess to the answer. Use a loop to get the user to guess until correct. #2. Write a function that takes a word and a number 'n'. Print the word out 'n' times. #ex. "Hello" 3 = "...
b66d3ee594208c724f53186cd9fd772e1d658053
siddharthgoel88/Coursera
/stanford-algo/Part-1/Assignment2/assignment2-q2.py
1,013
3.875
4
#NOTE: Implementation is not exactly as told. Hence the number of iteration are different. But the array is getting sorted. Third implementation is the general one. Used that one to submit the correct implemtation of both Q2 and Q3. count = 0 c1 =0 def quicksort(array,low,high): global count if(low <0 or low>high)...
97aaa65c47cc1f99e480c683a1a2edf2a170ea5b
SolGirouard/Data-Science-Project-AM209a
/util/models.py
4,508
4.21875
4
import pandas as pd import ast import numpy as np def filter_data(dataframe, filter_attributes = {'categories':['Restaurants', 'Fast Food']}, and_or_flag = 'AND'): ''' Method to filter a given dataframe based on an input dictionary of column to attribute mapping. Input: dataframe: the dataframe tha...
20698066a24af9c89a9d36e2d11ba9a5facd104d
luiz787/uri-problems
/src/uri_1035.py
523
3.609375
4
"""Problem 1035 from URI Judge Online""" # pylint: disable-msg=C0103 line = raw_input() nums = map(int, line.split()) b_greater_than_c = nums[1] > nums[2] d_greater_than_a = nums[3] > nums[0] sum_cd_greater_than_ab = nums[2]+nums[3] > nums[0]+nums[1] c_is_positive = nums[2] > 0 d_is_positive = nums[3] > 0 a_is_even = n...
aa960deeb474ab57d4ef72d675a8fd4742104014
egonnelli/algorithms
/sorting_algorithms/01_bubblesort.py
544
4.34375
4
#Bubblesort algorithm in python #Time complexity - O(N^2) def bubble_sort(array): """ This functions implements the bubble sort algorithm """ is_sorted = False counter = 0 while not is_sorted: is_sorted = True for i in range(len(array) - 1 - counter) if array[i] > array[i+1]: swap(i, i+1, array) i...
d2a84823ddb8d3b8888830e54afb214139299756
MaryVou/Credit-Card-Fraud-Detection
/test_diff_lr.py
1,082
3.53125
4
from assignment1 import load_dataset, train_model, evaluate_model import matplotlib.pyplot as plt ######################################################################## # Test 1 # # Run with different learning_rates ...
9b0cd4bcfb60b99871f75af88136cca9c1b04664
Dushyanttara/Competitive-Programing
/numbers_reader.py
269
3.921875
4
#Dushyant Tara(22-06-2020):This program helps you understand how to load json files and read them import json filename = 'D:\Prep\python crash course book\Basics\data_files\\numbers.json' with open(filename) as f_obj: numbers = json.load(f_obj) print(numbers)
01557a5e8a6d98f13c2cf022de96eb6f07797990
Dushyanttara/Competitive-Programing
/num_distinct_intersection.py
2,034
3.625
4
def solution(A): # write your code in Python 3.6 n = len(A) min_list = [0]*n max_list = [0]*n for i in range(n): min_list[i] = i - A[i] max_list[i] = i + A[i] intersections, active_circles = 0, 0 min_list.sort() max_list.sort() for i in range(n)...
b27b874adb1aaf82782217030d4a85a9e23e5e0d
Dushyanttara/Competitive-Programing
/number_writer.py
267
3.59375
4
#Dushyant Tara(22-06-2020): This program helps you understand json format import json numbers = [2, 3, 5, 7, 11, 13] filename = 'D:\Prep\python crash course book\Basics\data_files\\numbers.json' with open(filename, 'w') as f_obj: json.dump(numbers, f_obj)
4d5b37c3bef7ed5a71b12b3ba30b895af39b6b12
Dushyanttara/Competitive-Programing
/deli.py
730
4.34375
4
#Dushyant Tara(19-06-2020): This program will help you understand while loop through exercises sandwich_orders = ['aloo tikki','bbq chicken','ceasers','pastrami', 'tuna','cheese','pastrami','paneer tikka','ham','pastrami'] finished_sandwiches = [] print("The Deli has run out of Pastrami") while 'pastrami' in sa...
f23fd28772ea1c01d02603cb1d9c79c4e6fa0069
Dushyanttara/Competitive-Programing
/buffet.py
282
3.5
4
#Dushyant Tara(18-06-2020): This program tells you about tubles using an example buffet = ('rice','dal','momos','rajma','dosa') for food in buffet: print(food) #buffet[0] = 'chapati' buffet = ('chapati','halwa','momos','rajma','dosa') for food in buffet: print(food)
2af5b432ac298bebe3343f9ee18ae79e5f368b3e
Dushyanttara/Competitive-Programing
/aliens.py
2,312
4.15625
4
"""#Dushyant Tara(19-06-2020): This program will help you understand dictionary as a data strucutre alien_0 = {'color': 'green', 'points': 5} #print(alien_0['color']) #print(alien_0['points']) #new_points = alien_0['points'] #print("You just earned " + str(new_points) + " points.") #Adding new...
92227c319d91d20194b092dfdbdfd9c37452bd07
sgiardl/LeafClassification
/classifiers/KNearestNeighbors.py
1,199
3.5
4
from sklearn.neighbors import KNeighborsClassifier from classifiers.Classifier import Classifier class KNearestNeighbors(Classifier): """ CLASS NAME: KNearestNeighbors DESCRIPTION: Child class for the KNearestNeighbors classifier, inherits from the Classifier parent class...
bde0aedf205b8ef671db54be02807ff497f9650c
sgiardl/LeafClassification
/classifiers/classifier.py
8,243
3.734375
4
from sklearn.model_selection import GridSearchCV from sklearn.metrics import accuracy_score import matplotlib.pyplot as plt class Classifier: """ CLASS NAME: Classifier DESCRIPTION: Parent class for all classifying methods to be tested. """ def __init__(self): """ ...
1668477e9e2216191d7698819a25796c4b93eac8
PajamaProgrammer/Python_MIT-6.00_Problem-Set-Solutions
/Problem Set 2/ps2.py
1,892
4.09375
4
# Problem Set 2 (Part I\II) # Name: Pajama Programmer # Date: 28-Oct-2015 # """ Problem 1. Show that it is possible to buy exactly 50, 51, 52, 53, 54, and 55 McNuggets, by finding solutions to the Diophantine equation. You can solve this in your head, using paper and pencil, or writing a program. However you chose t...
6b6c88029116d4f5de407c8c8640345bdadb10bb
PajamaProgrammer/Python_MIT-6.00_Problem-Set-Solutions
/Problem Set 2/ps2b.py
2,303
4.15625
4
# Problem Set 2 (Part 4) # Name: Pajama Programmer # Date: 28-Oct-2015 # """ Problem4. Assume that the variable packages is bound to a tuple of length 3, the values of which specify the sizes of the packages, ordered from smallest to largest. Write a program that uses exhaustive search to find the largest number (less ...
2776e986df2c7a0edae3d2ff54c50c6c73d28a91
zelahi/Github_projects
/project_euler/calcSmallestMultiple.py
303
3.8125
4
from fractions import gcd from functools import reduce def lcm(a,b): "Calculate the lowest common multiple of two integers" return a*b//gcd(a,b) multiple_one_to_ten = reduce(lcm, range(1,11)) multiple_one_to_twenty = reduce(lcm, range(1,21)) print multiple_one_to_ten print multiple_one_to_twenty
51cd0c6845a47d78227be9fb15bd7aab3eac8ac0
Akhilgupta17/Acadview_Assignment_17
/Assignment_7.py
717
3.578125
4
import numpy as np #Question1 arr= np.random.random((10,1)) print("Random Numbers are:\n",arr) print("Mean Of These Numbers:",np.mean(arr)) #Question2 arr= np.random.random((20,1)) print("Random Numbers are:\n",arr) print("Standrad Deviation Of These Numbers:",np.std(arr)) print("Variance Of These Numbers:",np.var(...
fa9bbd771cd0f599db27d4d3cf185b68fe36c497
LoveAniuniu/python-learning
/20190514/9.py
289
3.578125
4
# _*_coding:utf-8_*_ #题目:暂停一秒输出。 #程序分析:使用 time 模块的 sleep() 函数。 import time def jisuan(): myD = {1:'a', 2:'b'} for key, value in dict.items(myD): print(key, value) time.sleep(1) if __name__ == "__main__": jisuan()
ca92c8fc0c672e2b5b1029fd5492d88292df5a49
LoveAniuniu/python-learning
/20190514/11.py
538
3.65625
4
# _*_coding:utf-8_*_ #题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子, # 小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? #程序分析:兔子的规律为数列1,1,2,3,5,8,13,21.... def jisuan(): f1 = 1 f2 = 1 for i in range(1,22): print('%12ld %12ld' %(f1,f2)) if (i%3) == 0: print('') f1 = f1 + f2 f2 = f1...
05241cc5a678ab9fe0acbb326a25e4bb8edc3fd0
mglodziak/python
/03/03b.py
474
3.625
4
#wyznacz pierwsze x liczb pierwszych (max 20) def pierwsze(limit): if limit > 20: print("Max value is 20!") limit=20 tab=[2,] # for i in range(2,limit): i=3 while len(tab) < limit: for j in tab: if i % j == 0: break else: ...
2352cc95d3464d4a7f6a7f01781d9de1278b0113
UddeshJain/Master-Computer-Science
/Data_Structure/Python/Stack.py
1,262
4.34375
4
class Stack(object): ''' class to represent a stack Implemented with an array ''' def __init__(self): ''' Constructor ''' self.datas = [] def __str__(self): return " ".join(str(e) for e in reversed(self.datas)) def size(self): ...
e8faa90b2c9b3ee9a1d694bb6a236e80cbd27733
missystem/math-crypto
/mathfxn.py
790
4.53125
5
""" Authors: Missy Shi Date: 05/22/2020 Python Version: 3.8.1 Functions: - largest_prime_factor Find the largest prime factor of a number - prime_factors Given a integer, return a set of factors of the number """ import math def largest_prime_factor(n: int) -> int: """ Return largest prime factor of num...
682d25a675d2b58c48c7359774378ae921405b24
missystem/math-crypto
/prime.py
1,155
4.21875
4
""" Author: Missy Shi Course: math 458 Date: 04/23/2020 Project: A3 - 1 Description: Write a Python function which, given n, returns a list of all the primes less than n. There should be 25 primes less than 100, for instance. Task: How many prime numbers are there which are less than 367400? """ i...
cea5559f924ca0ec895074ca5898c96fc003bc74
sahilkumar4all/HMRTraining
/Day-5/calc_final.py
380
4.125
4
def calc(operator): z = eval(x+operator+y) print(z) print(''' Press 1 for addition press 2 for substraction press 3 for multiplication press 4 for division''') x = input("enter first no") y = input("enter second no") choice = input("enter operation you wanna perform") dict = {"1":"+", "2":"-", ...
92c55213eff12b214b311ed90e31989fcba3edc3
sahilkumar4all/HMRTraining
/Day-5/calc-1.py
367
3.984375
4
a = 10 b = 0 def addition(): z = a+b print(f"addition = {z}") def substraction(): z = a-b print(f"Substraction = {z}") def multiplication(): z = a*b print(f"Multiplication = {z}") def division(): z = a/b if b!=0 else print("can't be divided by zero") print(f"Division = {z}") additio...
cc669352fa7f30b87d40343ab529635289a35884
Miguelmargar/file-io
/writefile.py
698
4.125
4
f = open("newfile.txt", "a") # opens and creates file called newfile.txt to write on it with "w" - if using "a" it means append not create new or re-write f.write("\nHello World\n") # writes Hello on the file opened above - depending on where you use the \n the lines will brake accor...
442be0f93f2da165db88dea5114dba0e56d3ef8d
juniorconfi/calculos-confi
/ferias/calculo_ferias.py
976
3.5625
4
class Ferias(object): def __init__(self, sal_bruto ): self.sal_bruto = sal_bruto #self.salDia = self.ultimo_salario / 30 def CalculoFerias(self): #Calcular o numero de dias entre as datas self.umterco = self.sal_bruto / 3 self.proventos = self.sal_bruto + self.umterco return self.proventos, self.umterc...
7beb2e50d3a5f5c5db414f9da5dc70bb67f08222
SteadBytes/ai-nanodegree
/term-1/L8-intro-to-game-playing/coding-minimax/gamestate.py
2,167
3.515625
4
from copy import deepcopy width = 3 height = 2 class GameState: def __init__(self): self.board = [[0] * width for i in range(height)] # bottom right corner blocked self.board[-1][-1] = 1 self.active_player = 0 self.player_locs = [None, None] def forecast_move(self, m...
dbece6392cef9e58b31a70f64e8dfac28e06f74f
NZ-code/PyGameOfLife
/animal.py
4,193
3.546875
4
import random from organism import Organism class Animal(Organism): def __init__(self,power,initiative,x,y,step_k,world): Organism.__init__(self,power,initiative,x,y,world) self.__step_k = step_k def fight(self,x,y): org = self.world.get_field(x,y) print("Attack") ...
a812ab0b790d96b76dbd75fbdc89840a534127b5
solsarratea/txt2sound
/csound-exp/main.py
2,932
3.5625
4
#!/usr/bin/env python3 import os from os import path # 1. Text to musical notation. Use solfa.py # 2. Musical notation to csound output INPUT ="hello is there anybody in there is not that you can teach me is there anyone home" OUTPUT_FILE="encripted.txt" # Hardcoded options for message encription TONIC_KEY="A" # {...
cab103165fd2695d588523cdcc9441c5929d88d3
cheeseaddict/think-python
/chapter-3/ex-3.1-3.2.py
759
4.09375
4
# Exercise 3.1. Move the last line of this program to the top, # so the function call appears before the definitions. # Run the program and see what error message you get. # Exercise 3.2. # Move the function call back to the bottom and move the definition of print_lyrics # after the definition of repeat_lyrics. What h...
5bfd768ba34df709af7e5c425510b44dc8a63cb0
cheeseaddict/think-python
/chapter-5/ex-5.3.py
419
4.15625
4
def check_fermat(a, b, c, n): if a**n + b**n == c**n and n > 2: print("Holy smokes, Fermat was wrong!") else: print("No that does not work") def input_test_values(): a = int(input("Enter a value for a: ")) b = int(input("Enter a value for b: ")) c = int(input("Enter a value for c: ...
c179bc1e1b537dfaf7aad14f1cdbec033afa2263
cheeseaddict/think-python
/chapter-11/exercise-11.3.py
213
3.78125
4
def histogram(s): d = dict() for c in s: if c not in d: d[c] = 1 else: d[c] += 1 return d def print_hist(h): for key in sorted(h): print(key, h[key]) h = histogram("brontosaurus") print_hist(h)
a153c0f74861ec3c8c786b7b5d9b379331904612
cheeseaddict/think-python
/chapter-6/exercise-6.2.py
667
4.25
4
import math def distance(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 dsquared = dx**2 + dy**2 result = math.sqrt(dsquared) return result print(distance(1,2,4,6)) """ As an exercise, use incremental development to write a function called hypotenuse that returns the length of the hypotenuse of a r...
4cc0a79a526d65d231eda152e071a5434e072a0e
anon-git-repo/WOAH
/datasets/helpers.py
7,742
3.625
4
import os import shutil import zipfile import pandas as pd import json import csv import tarfile from io import BytesIO from urllib.request import urlopen from twarc import Twarc def download_from(url : str, destination_folder : str, file_name : str = "downloaded.file") -> str: """ Downloads a file to the specifi...
503c63fe50d6eea33a190e083e480c5c583d271d
koobeomjin/iot_python2019
/3_Bigdata/03_web_crawling/02_Regular_Expression/02_intermidiate/04_313.py
142
3.515625
4
import re p = re.compile(r'(\b\w+)\s+\1') # p = re.compile('(\b\w+)\s+\1') print(p.search('Paris in the spring. It was really great').group())
4523f1c0f6bbf04c816ee2e40593afc78c131713
koobeomjin/iot_python2019
/01_jump_to_python/exer/codingdojang/3_5_multiple.py
141
3.625
4
a = range(1,1000) r = 0 total = 0 for r in a: if r%3 == 0 or r%5 == 0: total += r print('3과 5의 배수의 총합 : %d' %total)
1b0b8851e7f87ddfbea44e737df4b6215d595ab9
koobeomjin/iot_python2019
/01_jump_to_python/3_control/sub/q2.py
778
3.75
4
#coding: cp949 age = 0 age1 = '' age2 = '' age3 = 'ûҳ' age4 = '' age5 = '' fee1 = '2000' fee2 = '3000' fee3 = '5000' age = int(input("̸ Էϼ")) if age >= 0 and age <= 3: print(" %s̸ Դϴ." %age1) elif age > 3 and age <= 13: print(" %s̸ %s Դϴ." %(age2, fee1)) elif age > 13 and age <= 18: print(" %s̸ ...
859a8702cd25d38d392215af3c6bb8018eedc4a1
koobeomjin/iot_python2019
/01_jump_to_python/3_control/sub/q4.py
3,059
3.53125
4
#coding: cp949 age = 0 age1 = '' age2 = '' age3 = 'ûҳ' age4 = '' age5 = '' choice = 0 fee1 = '2000' fee2 = '3000' fee3 = '5000' prompt = """" 1. 2. ſī """ age = int(input("̸ Էϼ")) if age >= 0 and age <= 3: print(" %s̸ Դϴ." %age1) elif age > 3 and age <= 13: print(" %s̸ %s Դϴ." %(age2, fee1)) ...
beaaea515553780c628ecc6f65e0a034e020264e
theangelsofwar/AlgoEtro
/rottingOranges.py
2,101
4.0625
4
""" In a given grid, each cell can have one of three values: the value 0 representing an empty cell; the value 1 representing a fresh orange; the value 2 representing a rotten orange. Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. Return the minimum number of minu...
7296d80ed276ffdcb3f9496e953a95022723527e
theangelsofwar/AlgoEtro
/TheMartianChronicles/graph_bfs/Leet102.py
668
3.734375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def levelOrder(self, root): """ :type root: TreeNode :rtype: List[Li...
5cc1988480bb9339a0c8d8e3287fa106f0fc3945
NilPatil7087/Python_Practice
/diictionary.py
588
3.890625
4
#constraints print("\t PI :3.14 \n second line") language = "Python " print(language,"_____") print(language.rstrip(),"-----") print(language.lstrip(),"-----") #dictionary is collection of key values pairs student ={"mayur":"1","nilesh":"2"} print(student) print("__"*30) alien={} alien={"color":"green","points":10...
70b060c5eae64b7c630a9d032e266ee5363aa418
NilPatil7087/Python_Practice
/user.py
1,452
3.671875
4
class user: def __init__(self, First_name, Last_name, age, contact_no, login_attempt): self.First_name = First_name self.Last_name = Last_name self.age = age self.contact_no = contact_no self.login_attempt = login_attempt def greet_employee(self): print(f"\n Hii...
3d045213ec7cc8711783ec2e6be8eeedf4ebf6c2
FrankchingKang/phrasehunter
/phrasehunter/character.py
1,774
4.125
4
# Create your Character class logic in here. class Character(object): """The class should include an initializer or def __init__ that receives a char parameter, which should be a single character string.""" def __init__(self,char): """An instance attribute to store the single char string character so...
95f97fba99806c7207828ac26666a7d1f5a1833f
curenosm/interview_practice
/python/Arrays/firstDuplicate.py
779
3.90625
4
def firstDuplicate(a): """ Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second o...
8cf28e4aeda506b02ecf92836bbeeeb19f47d624
nesarasr/Information-Systems-Lab
/Lab 6 29Aug/package_cw/integers.py
526
3.8125
4
def max1(x,y,z): if x>y: M=x sm=y else: M=y sm=x if z>M: sm=M M=z elif z>sm: s=sm sm=z print('Maximum=',M) def min1(x,y,z): if x>y: M=x sm=y else: M=y sm=x if ...
3d35663a2472e6cbccabebce2eda7a7001fdd0b1
nixeneko/nxTokiACF
/replacetobinary.py
1,228
3.515625
4
#!/usr/bin/env python # coding: utf-8 import sys, codecs, re, binascii, os HEXREF = r'<hexdata\s+src="(.+)"\s*/>' def hexdump(filename): with open(filename, 'rb') as f: bin = f.read() hexdump = binascii.hexlify(bin) return hexdump def replace(text): p = re.compile(HEXR...
03e0e54f5b7a51972d3a1b9cf646db1dee65ccc8
mverleg/bardeen
/bardeen/text.py
976
3.78125
4
""" Routines related to changing text, e.g. substitution or escape for some format """ from re import escape as re_escape, compile #todo: unit test def tex_escape(text): """ :param text: a plain text message :return: the message escaped to appear correctly in LaTeX """ conv = { '&': r'\&', '%': r'\%', '$...
898ed9b37e512dca37848a040ff175ce57b65e08
mverleg/bardeen
/bardeen/inout.py
2,011
4.15625
4
""" Routines related to text input/output """ import sys, os def clear_stdout(lines = 1, stream = sys.stdout, flush = True): """ Uses escape characters to move back number of lines and empty them To write something on the empty lines, use :func:sys.stdout.write() and :func:sys.stdout.flush() :param lines: the...
44448774574ad1f8bc11dff05650a286622e0450
mverleg/bardeen
/bardeen/numerical.py
719
3.9375
4
from numpy import eye, float64 def laplacian(N, dtype = float64): """ Create a del2 laplacian matrix of dimension N. E.g. for N = 4: .. math:: \begin{matrix} 2 & -1 & 0 & 0 \\\\ -1 & 2 & -1 & 0 \\\\ 0 & -1 & 2 & -1 \\\\ 0 & 0 & -1 & 2 \\\\ \end{matrix} Used for numerical differentiati...
e7c9ad72c832421eb514cf379970fa1d5c4fb098
ydoublemm/pythoncode
/生成器/demo3.py
161
3.796875
4
def odd(): print('step1') yield 2 print('step2') yield 3 print('step3') yield 5 o = odd() x1= next(o) print(x1) next(o) next(o) next(o)
1d242d816fea05a4d1e038b406118038dea432ba
ydoublemm/pythoncode
/filter/demo1.py
442
3.953125
4
def odd(n): return n%2 x = filter(odd,[1,2,3,4,5,6]) print(list(x)) def _odd_iter(): n=1 while True: n=n+2 yield n def _not_divisible(n): return lambda x:x%n>0 def prime(): yield 2 it = _odd_iter() while True: n = next(it) yield n it = filter(_no...
fe444d360a28aa3e9fc7cb5d9af142e5dc1a8bfb
ydoublemm/pythoncode
/迭代/test.py
516
3.90625
4
def findMinAndMax(list): if(list == None): return None,None if(len(list) == 0): return None,None if(len(list) == 1): return list[0],list[0] return min(list),max(list) # 测试 if findMinAndMax([]) != (None, None): print('测试失败!') elif findMinAndMax([7]) != (7, 7): print('测试失...
48af8858e4d9408a1d41a6cf45254f0f2dbd9a8b
aderbew/Employee-pay
/dinke.py
344
3.65625
4
import sys print('Number of arguments:', len(sys.argv), 'arguments.') print('name is:',sys.argv[1]) print('pay rate:',sys.argv[2]) print('hours:', sys.argv[3]) name = sys.argv[1] payrate=int(sys.argv[2]) hours=int(sys.argv[3]) if hours <=40: pay=payrate*hours else: pay=pay+(hours-40)*1.5*payrate ...
5912707ed92a2ca2330dddfe7586ead1efd85157
miischmi/audio-segmentation
/postprocessing.py
6,406
3.75
4
import numpy as np import librosa from scipy import signal def normalize_feature_sequence(X, norm='2', threshold=0.0001, v=None): """Normalizes the columns of a feature sequence From: FMP-Notebooks, Müller & Zalkow (2019); Notebook: C3/C3S1_FeatureNormalization.ipynb Args: X: Featu...
16ea77a28cef2cdac2822c42e680d2d8c252c443
dannychan11/myFirstPy
/exam/treading1.py
1,415
3.515625
4
import threading import time import multiprocessing # def music(name,loop): # for i in range(loop): # print(' 听歌%s-----%s'%(name,time.ctime())) # time.sleep(1) # def movie(name,loop): # for i in range(loop): # print('看定影%s-----%s'%(name,time.ctime())) # time.sleep(1) # t1=threa...
6e6a154789bccaf51df6f3988051543f9bfeb4cc
howinator/CourseraPrinciplesofComputing
/HW1Q9.py
218
4.03125
4
def appendsums(lst): for i in range(25): threesum = lst[-1] + lst[-2] + lst[-3] lst.append(threesum) def main(): sum_three = [0, 1, 2] appendsums(sum_three) print(sum_three[20]) main()
5533386a84d4b81c08c6680243b037af513a8745
Ana-geek/Python_test_XML
/main.py
1,603
3.609375
4
from drivers import * """ Разработайте на основе XML-файла тест по основам программирования на языĸе Python """ if __name__ == '__main__': driver = XMLDriver('data.xml') driver.get_name() driver.get_question('1') print('>' * 50) driver.set_answer('1', str(input('Введите номер ответа-> '))) ...
da225b6cd4977baee817fbaca77d814e48552d4a
miksik98/Show-Me-tictactoe
/players/ai/square_board.py
1,718
3.59375
4
from math import inf from model import Board class Move: def __init__(self, index, score): self.index = index self.score = score def optimum_move(board: Board, opponent_move, player_move, cur_move): available_spots = board.empty_fields() if board.winning(opponent_move): ...
c824029a5d1ef7317bb98bd39f623292fd392d71
ms-shakil/Some_problems_with_solve
/Extra_Long_Factorial.py.py
401
4.125
4
""" The factorial of the integer n , written n! , is defined as: n! = n * (n-1)*(n-2)*... *2*1 Calculate and print the factorial of a given integer. For example Inp =25 we calculate 25* 24* 23*....*2*1 and we get 15511210043330985984000000 . """ def Factorial(inp): val = 1 for i in range(1,inp): val +...
27ab001a4a2f645f38ec95726976107cd19ffba4
ms-shakil/Some_problems_with_solve
/sum_with_recursion.py
100
3.75
4
### sum function def Add(n): if n < 1: return n return n+ Add(n-1) print(Add(10))
b1c134bd8de15ada92f941b7c3c2ee6e967573a2
kishore0079/guvi
/primenumber_range.py
233
3.609375
4
n=int(input()) def checkprime(i): count=0 for j in range(1,i): if(i%j==0): count=count+1 if(count==1): print(i,end=" ") if(n>=1 and n<=100000): for i in range(2,n): checkprime(i)
173cf0f85bb11562bdf1ee720d2e1c9b7a598221
kishore0079/guvi
/776.py
103
3.9375
4
import math radius = float(input()) circumference = 2 * math.pi * radius print("%.2f" % circumference)
12b784aecca1d4276228b7b7ad13d3cc1d679208
lenncb/safe_password
/main.py
1,319
4.125
4
# This programm will show you how strong your password is # If your password is weak, program will generate new and strong password. # Just write your password import re, password_generator password = input(str('Enter your password: ')) #good password is if it has minimum 8 signs, inculde small and big letters and h...
07b684eaaec97e1ce4370ae893b2c9c56ce97645
AlperNab/TicTacToe-Game
/TicTacToe.py
3,853
3.8125
4
import random from IPython.display import clear_output def display_board(board): print (board[0],'l',board[1],'l',board[2]) print('------------') print (board[3],'l',board[4],'l',board[5]) print('------------') print (board[6],'l',board[7],'l',board[8]) print('------------') test_board = ['1...
6596e27a7dd3cba8028f472960466b057be5bb9f
apatti/csconcepts
/sorting/selectionsort/python/selectionSort.py
348
3.6875
4
#selection sort def Sort(input: list) -> list: for i in range(0,len(input)-1): minimum = i for j in range(i,len(input)): if input[j]<input[minimum]: minimum=j if minimum!=i: temp = input[minimum] input[minimum] = input[i] input...
37693a5b038c83a5eae1f13d6bd0540c4852b9ad
navinduJay/interview
/python/sort/insertionSort.py
635
4.34375
4
#INSERTION SORT array = [] #array declaration for everyValue in range(10): array.append(input("Enter number ")) #adding values to the array print('Unsorted array') print(array) def insertionSort(array): #function declaration for j in range(1 , len(array)): # starting index is 1(2nd position) to array lengt...
0e9595dbb4a687c2b80660217aa471712f463827
anisotropi4/wagtail
/bin/html2json.py
813
3.53125
4
#!/usr/bin/env python3 import sys import argparse import pandas as pd PARSER = argparse.ArgumentParser(description='Converts HTML to JSON') PARSER.add_argument('--encoding', dest='encoding', default='utf-8', help='optional file encoding parameter') PARSER.add_argument('inputfile', type=str, narg...
0681304dd055106d42227843f2839c5368e462dd
BrockMHarris/Poker
/make_rank.py
2,337
3.9375
4
# I affirm that I have carried out my academic endeavors with full academic honesty -Brock Harris import Deck as deck import FiveCardHand as check HIGH_CARD = 0 PAIR = 1 TWO_PAIR = 2 FLUSH = 3 def get_ranks_in_hand(hand): """ puts the ranks for each card in a hand and puts them into a new list :param han...
c574d55303bce0e3e99b39777be42153f3c47a7d
minkyaw17/CECS-328
/Lab 5/lab5.py
2,656
4.15625
4
import random import time def swap(arr, a, b): # swap function to be used in the heap sort and selection sort temp = arr[a] arr[a] = arr[b] arr[b] = temp def max_heapify(arr, i, n): # parameter n for length of array max_element = i left = (2 * i) + 1 right = (2 * i) + 2 max_element = ...
d23d8d7645268bcff3edddcf5f480176df9920c9
minkyaw17/CECS-328
/EC 3/EC3.py
1,465
3.875
4
import random import math def maxSubArray_n(nums): max_sum = nums[0] current_sum = max_sum len_nums = len(nums) for i in range(1, len_nums): current_sum = max(nums[i] + current_sum, nums[i]) max_sum = max(current_sum, max_sum) return max_sum def maxCrossingSubarray(arr, low, mi...
589aada2ad71b067e9602780edd62c7e540169db
carlosmertens/Python-Masterclass
/challenge_control_flow.py
1,456
4.34375
4
# Complete Python MasterClass Course # # This challenge is intended to practise for loops and if/else statements, # so although you could use other techniques (such as splitting the string up), # that's not the approach we're looking for here. # # Create a program that takes an IP address entered at the keyboard and pr...
907ec11a0779e694ee3c0637a4620e0c6690cb8e
retazo0018/Deep-Learning
/dog_cat_image_prediction_using_tf_cnn.py
2,368
3.875
4
# Dataset is available in kaggle. # Training set has 8000 images of dogs and cats and test set contains 2000 images of dogs and cats # Training set accuracy - 85.16 # Test set accuracy - 81.10 # Part 1 # building Convolutional Neural Network # import keras packages from keras.models import Sequential from keras.layer...
54decf67a8db2dd8920fb3317b56ece10aa0269e
DavidAndrade27/DataScienceAndMLBassics
/IA_dovo_r/3_Clustering/Hierarchical Clustering/Hierarchical Clustering.py
1,588
3.828125
4
# -*- coding: utf-8 -*- """ Created on Sat Jul 11 22:09:56 2020 Hierarchical Clustering In this section lets see divisive clustering: starts by treating each object as a singleton cluster. Next, pairs of clusters are successively merged until all clusters have been merged into one big cluster containing all objects...
766a9a8f0458e13dddb7efabb8da3191e8e29ad0
davidlamyc/python-for-data-101
/numpy_demo.py
431
3.734375
4
# numpy - linear algebra library # casting python lists to np arrays my_list = [1,2,3] import numpy as np my_array = np.array(my_list) # cast normal list to np array print(my_array) print(type(my_array)) my_mat = [[1,2,3],[4,5,6],[7,8,9]] my_3d_array = np.array(my_mat) print(my_3d_array) # using ranges & np in...
a3ee1127055b6a9bb3b2e98608bc18dc23a8fac2
Fruitson82/Introducing_Python
/04/4.5.순회하기.for.py
757
4
4
rabbits = ['Flopsy', 'Mopsy', 'Cottontail', 'Peter'] current = 0 while current < len(rabbits): print(rabbits[current]) current += 1 print("========================") for rabbit in rabbits: print(rabbit) print("========================") word = 'cat' for letter in word: print(letter) print("===================...
4c690cec7da258f428e80fa2d57acc8ae30bfd8b
Fruitson82/Introducing_Python
/04/4.7.7.일등 시민-함수.py
601
3.59375
4
def answer(): print(42) def run_something(func): func() run_something(answer) print("=============================") print(type(run_something)) print("=============================") def add_args(arg1, arg2): print (arg1 + arg2) print(type(add_args)) print("=============================") def run_something_w...
90ccad2ff65b82fb17cba440d6afb3722d53c67a
Fruitson82/Introducing_Python
/05/5.5.1.누락된 키 처리하기.py
1,040
3.765625
4
# setdefault() periodic_table = {"hydrogen": 1, "Helium": 2} print(periodic_table) carbon = periodic_table.setdefault("Carbon", 12) print(carbon) print(periodic_table) helium = periodic_table.setdefault("Helium", 256) print(helium) print(periodic_table) print("===================================") # defaultdict() f...
ff5cafd301a0cbcc3e09f133997d34c8550829f9
Fruitson82/Introducing_Python
/04/4.4.2.continue.py
250
4.09375
4
# -*- coding:utf-8 -*- while True: value = input("Integer, please [q to quit]: ") print ("value: ", value) if value == 'q': #종료 break number = int(value) if number % 2 == 0: # 짝수 continue print (number, "squared is ", number*number)
d1edddce032c71b5aeb7d93dea9d08a9e421f1e8
jaleson/Python
/myrun.py
164
3.6875
4
import itertools houses = [1,2,3] orders = list(itertools.permutations(houses)) print orders for (red,blue,green) in orders: print red, blue, green
ea8ad9636da1a925264c55c553bc3070ec5b1f2a
ardaunal4/My_Python_Lessons
/classes.py
1,401
4.0625
4
import datetime # class user: # pass # passes line and that does nothing # user1 = user() # object # user1.first_name = "AHmet" # user1.last_name = "Besr" # print(user1.first_name) # first_name = 'Arthur' # second_name = 'Clark' # user2 = user() # user2.first_name, user2.second_name = first_name, second_name # p...