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
4082d4cc3a18ac4915f8fb340efa7e35bd5ae96b
blackhen/Python
/luck.py
273
3.8125
4
'''Hello''' def lucky_sum(): '''lucky''' num1 = input() num2 = input() num3 = input() if num1 == 13: print 0 elif num2 == 13: print num1 elif num3 == 13: print num1+num2 else: print num1+num2+num3 lucky_sum()
8222ca77df35cfae33a806eb24af88d63d76e941
blackhen/Python
/Lab_Missing.py
377
3.8125
4
'''Lab_Missing''' def missing(number_digit): '''fide number missing''' list_number = [] for i in range(number_digit): number_input = input() if number_input != 0: list_number.append(number_input) else: break for i in range(1, number_digit+1): if i ...
7ca5df8c654fb1dfa25abf8c539198544896ebbb
blackhen/Python
/100time.py
565
3.515625
4
'''time''' def time(loop, zzz): '''time''' if zzz == loop: print loop else: print zzz time(loop, zzz+1) print zzz def time2(loop, zzz): '''time''' if zzz == loop: print loop else: print zzz time2(loop, zzz-1) print zzz def cheak(): ...
1faaaa552dc1a6ecab0b2a6654edbf2fe9e3d0ac
blackhen/Python
/Lab_Bigram.py
414
3.828125
4
'''Lab_Bigram''' def bigram(string): '''bigram''' dict_1 = {} for i in range(len(string)-2): word = string[i:i+2]#'iiiiii' number = 0 for k in range(len(string)-1): if word == string[k:k+2]: number += 1 dict_1[number] = dict_1.get(number, word) ...
5c752c7d1dc6cd6a3cf303cb36686d156578027c
blackhen/Python
/ceacar.py
427
3.71875
4
'''ceasar''' def cea(num, word): '''ceacar''' ans = "" big = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' small = big.lower() for i in range(len(word)): if word[i].isupper(): ans = ans+big[(big.find(word[i])+num)%len(big)] elif word[i].islower(): ans = ans+small[(small.find(w...
9927e65afa9914267124e4180ab9bbe4d59eb3c7
blackhen/Python
/Lab_Olympic.py
588
3.890625
4
'''Lab_Olympic ''' def olympic(dic, count): '''sort score of the country''' for _ in range(input()): num = raw_input().split() num2 = num[1]+num[2]+num[3] if num2 not in dic: dic[num2] = dic.get(num2, [num[0]]) else: dic[num2].append(num[0]) sor = sort...
efafefaf8ae85276969c917ddc5bcad4e331b5e4
blackhen/Python
/gdc.py
508
3.671875
4
'''GDC''' def gdc(num1, num2): while num1 % 6 == 0 and num2 % 6 == 0: num1 = num1/6 num2 = num2/6 while num1 % 5 == 0 and num2 % 5 == 0: num1 = num1/5 num2 = num2/5 while num1 % 4 == 0 and num2 % 4 == 0: num1 = num1/4 num2 = num2/4 while num1 % 3 == 0 and ...
926eb5e5cfdb387a52d28f11732719dfa924ffd1
blackhen/Python
/deeplen.py
246
3.546875
4
'''deeplen''' def deeplen(zzz): '''if list[] >= 2:''' num = 0 xxx = map(str, zzz) for i in xxx: if len(i) >= 2: num = num + len(i.split()) else: num = num + 1 print num deeplen(input())
200461bfce6d1434eb71e2711cd449f7c01cb29c
CozyGwen/MY-FIZZBUZZ-IIIII
/gah.py
760
3.671875
4
x = 0 f = "Fizz" b = "Buzz" q = "Fizz Buzz" def unless(): o = 1 o = o + 1 y = 15 y = y + 15 if o % 3 == 0: print(end='\r', flush=True) if o % 5 == 0: print(end='\r', flush=True) if o == y: print(end='\r', flush=True) else: '\n' whi...
71671911d60303d0304d672fcc7872bec5e4992d
ovanov/cosSim
/cosSim/parseClass.py
2,795
3.5625
4
""" This class uses static methods to operate with the other helper classes to get a corpus or parse / crawl a directory or file. The filename(s) is sent to the processor class which takes care of parsing the files. Lastly the similarity class is called, that vectorizes the text and calculates the similarity using nump...
3c531a1e68224261ddc3dc15474aabd4236e958c
kushaan20/Project-111
/z-score.py
2,171
3.71875
4
import plotly.figure_factory as ff import plotly.graph_objects as go import statistics import random import pandas as pd import csv df = pd.read_csv("medium_data.csv") data = df['reading_time'].tolist() def random_set_of_mean(counter): data_set = [] for i in range(0,counter): random_index = random...
347a1acc1db3bae869270ff4ff223540b1600709
shrivastava12/MachineLearning
/Part 4 - Clustering/Section 24 - K-Means Clustering/K_Means/kmeans_clusster.py
1,521
3.625
4
# Kmeans Clustering # Importing the libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt # Importing the datasets dataset = pd.read_csv('Mall_Customers.csv') dataset.head() X = dataset.iloc[:,[3,4]].values # using the elbow method to find the optimal number of clusters from sklearn.cluste...
eae729ca9e377af2c030152c7fb61400cbf49ab3
eddir/Assembler
/Code.py
2,871
3.78125
4
"""Транслирует мнемоники языка ассемблераHack в бинарные коды """ def dest(mnemonic: str): """Возвращает бинарный код мнемоники dest. :param mnemonic: мнемоника dest, которую необходимо преобразовать в бинарное представление команды :return: string """ instructions = { 'null': "000", ...
521f7092961eafb8ec49952366a9457e6549341f
HackerajOfficial/PythonExamples
/exercise1.py
348
4.3125
4
'''Given the following list of strings: names = ['alice', 'bertrand', 'charlene'] produce the following lists: (1) a list of all upper case names; (2) a list of capitalized (first letter upper case);''' names = ['alice', 'bertrand', 'charlene'] upNames =[x.upper() for x in names] print(upNames) cNames = [x.title() f...
bf4b0f1b742501d986080b3fb43afb7f68155778
HackerajOfficial/PythonExamples
/classInheritance.py
254
3.6875
4
#Class Inheritance class Person(): def __init__(self,name,age): self.name=name self.age=age def out(self): print("Name:" +self.name + " Age:" +self.age) class child(Person): pass kid=child("Sumi","9") kid.out()
2a85c44544a22bac0f15b800f208ce82abb701e1
HackerajOfficial/PythonExamples
/FetchWebDetails.py
144
3.53125
4
import sys import urllib2 url=raw_input("Enter Website:") #http://google.com url.rstrip() header=urllib2.urlopen(url).info() print(str(header))
12568504b91ed1a6576637ebc8ef97f6d771c0f0
HackerajOfficial/PythonExamples
/pop.py
167
3.90625
4
'''The pop method on a list returns the "rightmost" item from a list and removes that item from the list:''' a = ['11','aaa','15','26',] b = a.pop() print(b) print(a)
1e0ac370459914f2a8741324768dbe26723b1f18
alanwuuu/python_project_linear_regression
/Linear_Regression_Reggie.py
5,855
4.375
4
#Creator: Alan Wu #Contact Info: alanwu379@gmail.com #Senior studying Mathematics at CUNY Baruch #Project: Linear Regression # info: #Reggie is a mad scientist who has been hired by the local fast food joint to build their newest ball pit in the play area. #He is working on researching the bouncine...
fd9c99441cba0d403b6b880db4444f95874eeb0c
micriver/leetcode-solutions
/1684.py
2,376
4.3125
4
""" You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed. Return the number of consistent strings in the array words. Example 1: Input: allowed = "ab", words = ["ad","bd","aaab","baa","ba...
aab785831638f7e29f6ca68343eff9c5cdc29c0e
micriver/leetcode-solutions
/1470_Shuffle_Array.py
983
4.375
4
""" Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn]. Return the array in the form [x1,y1,x2,y2,...,xn,yn]. Example 1: Input: nums = [2,5,1,3,4,7], n = 3 Output: [2,3,5,4,1,7] Explanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is [2,3,5,4,1,7]. Example 2:...
997b9c7df5170f1a26fa421af330508897866f59
KbDinesh87/Python-Tutorial
/hello.py
858
3.90625
4
print("Hello Python") x = 23.6 if x == 1: # indented four spaces print("x is 1.") else: print("x is NOT 1.") floatv = float(55) print "my float value is", floatv intv = float(55.26) print "my integer value is", intv round2 = round(55.2352356,2) print "my rounded value is", round2 amount = 1000 balance =...
191756085fa94750a2432ca24db949aa08b0c59e
LongNguyen0024/Ciphers
/rowTransposition.py
2,022
3.953125
4
def encrypt(key, plaintext): key = key.replace(" ", "") plaintext = plaintext.replace(" ", "") # For extra letters to add to table alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] # Initialize empty d...
fd8a18476da2f6ad0ca93ca4ec1ab7144a8d122c
TrendingTechnology/deduplipy
/deduplipy/blocking/blocking_rules.py
2,710
3.53125
4
import re def whole_field(x): x_trimmed = x.strip() if len(x_trimmed): return x_trimmed else: return None def first_word(x): x_trimmed = x.strip() if len(x_trimmed): return x_trimmed.split()[0] else: return None def first_two_words(x): x_trimmed = x.stri...
f0a446dd94d7f02abf085078591ed370d94c53b1
DawidMiroyan/RL_Lab
/lab_session6/1.bandits/bandit.py
4,621
3.6875
4
""" Module containing the k-armed bandit problem Complete the code wherever TODO is written. Do not forget the documentation for every class and method! We expect all classes to follow the Bandit abstract object formalism. """ # -*- coding: utf-8 -*- import numpy as np class Bandit(object): """ Abstract conce...
93c0bc6d46032081c7cd621ace401fa4935c66aa
BennettB123/Python-Maze-Generator
/mazeGenerator.py
9,009
3.640625
4
import curses from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN import random import statistics import time # Character encodings for various assets WALL = u'\N{FULL BLOCK}' PLAYER = u'\N{WHITE SMILING FACE}' # Function to setup the screen def setup(): strscr = curses.initscr() strscr.keypad(True) ...
bb007eb48ba89f03af3227b33d30108ba7b98373
mdsiegel/unit4
/rectangle.py
177
3.640625
4
#Matthew Siegel #10/16/17 #rectanlge.py - finding rectangles def rectangle(len,wid): print('There area is',len*wid) print('The perimenter is',len*2 + wid*2) rectangle(3,4)
74903ca44e197f6a2d98dde1104c59171c8248aa
mdsiegel/unit4
/bubbles.py
781
3.5625
4
#Matthew Siegel #10/25/17 #bubbles.py - making bubbles!!!!! from ggame import * from random import randint red = Color(0xFF0000,1) green = Color(0x00FF00,1) blue = Color(0x0000FF,1) black = Color(0x000000,1) blackOutline = LineStyle(1,black) #pixels,color def bubble(event): randnum = randint(1,4) if randnum ...
430ffa1c594df821a2d0b8bec36d884a5469ccbb
agalotaibi/Rock-Paper-Scissor-Game
/RPS.py
3,445
3.515625
4
import random mv = ['rock', 'paper', 'scissors'] s_moves = ['r', 'p', 's'] def beats(one, two): return ((one == 'scissors' and two == 'paper') or (one == 'rock' and two == 'scissors') or (one == 'paper' and two == 'rock')) def c_hum_inp(s_moves): if s_moves == 'p': return ...
e7f39b31e71e9ece4f4de8e3d391b27814fb4e26
Si-ja/Unit-Testing-Python
/Checker/ToolsUpdate.py
1,799
3.828125
4
class Functions: @staticmethod def binary(a, b) -> list: """ Check whether values in respect to their positions match per two arrays. Parameters ---------- a : list or an array (numpy) First list/array holding variable. b : list or an array (...
e3669d643eda2fdbc7e6e38b26aa5300e288d40b
firelab/goes-fire
/mythreads.py
1,547
3.78125
4
import queue import threading class ThreadManager(object) : """Creates and manages threads and queues for bidirectional communications with the worker.""" def __init__(self, worker, collector=None, num_threads=4, killsig=None) : self.worker = worker self.collector = collector ...
26b569a159c98d69b9bdadbb2c8e498bacc41edf
sumibhatta/iwbootcamp-2
/Data-Types/26.py
348
4.3125
4
#Write a Python program to insert a given string at the beginning #of all items in a list. #Sample list : [1,2,3,4], string : emp #Expected output : ['emp1', 'emp2', 'emp3', 'emp4'] def addString(lis, str): newList = [] for item in lis: newList.append(str+"{}".format(item)) return newList print(a...
d740522b95d886aeef403569b0a299760a45b78b
sumibhatta/iwbootcamp-2
/Data-Types/30.py
515
4
4
#Write a Python script to check whether a given key already exists #in a dictionary. def checkDuplicate(dict, key): if key in dict: print("Oh! the there is duplicate key") else: print("No duplicate :) ") # def checkDuplicate(dict, key): # li =[] # li = dict.keys() # li.append(key)...
47b4e0234552f6811a1f6d30d7a3c5424bc80362
sumibhatta/iwbootcamp-2
/Functions/13.py
118
3.90625
4
#Write a Python program to sort a list of tuples using Lambda. hi = lambda tup: sorted(tup) print(hi((2,3,1,4,5)))
3151f1dd3c21b3603d8c616b643cdfb3f25d79a3
sumibhatta/iwbootcamp-2
/Data-Types/12.py
218
4.21875
4
#Write a Python script that takes input from the user and # displays that input back in upper and lower cases. string = "Hello Friends" upper = string.upper() lower = string.lower() print(string) print(upper) print(lower)
f97d8fa2d1303999ae58af1ead1d8553fcc08dcf
sumibhatta/iwbootcamp-2
/Data-Types/31.py
172
4.4375
4
#Write a Python program to iterate over dictionaries using for loops. myd = {1: 10, 2: 20, 3: 30, 4: 40, 7: 50, 6: 60} for key, value in myd.items(): print(key,value)
595b55d7e6466d3bf99558d30947c34747658ff5
sumibhatta/iwbootcamp-2
/Data-Types/9.py
223
3.96875
4
#Write a Python program yo change the given string # to a new string where the first and last chars have been exchanged. def firsLas(string): return string[-1:]+string[1:-1]+string[0:1] pr = firsLas("Sumi") print(pr)
4714d27ba2e270f63757e3c36e9b5f1fa17e3b8a
sumibhatta/iwbootcamp-2
/Data-Types/42.py
119
3.828125
4
#Write a Python program to convert a list to a tuple. lis = [10, 20, 30, 40, 50, 60, 70] tup = tuple(lis) print(tup)
4968e2a134c4a2620a9437e2589ef8899e362737
sumibhatta/iwbootcamp-2
/Data-Types/29.py
324
3.765625
4
#Write a Python script to concatenate following dictionaries #to create a new one. #Sample Dictionary : #dic1={1:10, 2:20} #dic2={3:30, 4:40} #dic3={5:50,6:60} #Expected Result : {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60} dic1={1:10, 2:20} dic2={3:30, 4:40} dic3={5:50,6:60} dic1.update(dic2) dic1.update(dic3) print(d...
9e8af25f5f6d921219dbf3b71368729e89ae1e6f
Jamaliela/A-Bug-s-Life
/A04 - Jamalie - Alfaroz.py
7,637
4.21875
4
###################################################################### # Author: Ela Jamali, Emely Alfaro Zavala # Username: jamalie, Alfaroe # # Purpose: Learn the impact a bug can have in the real world. # Explore life path numbers. # Practice creating your own fruitful functions. # Learn to use modulus to capture re...
63f14fdae94a896ef64d6553f889ca4a47e15321
dagss/oomatrix
/oomatrix/symbolic.py
13,377
3.734375
4
""" Symbolic tree... Hashing/equality: Leaf nodes compares by object identity, the rest compares by contents. By using the factory functions (add, multiply, conjugate_transpose, inverse, etc.), one ensures that the tree is in a canonical shape, meaning it has a certain number of "obvious" expression simplifications ...
1a4cd38c80329b1f322a2097ee28174011e2fa14
dagss/oomatrix
/oomatrix/heap.py
552
4.03125
4
import heapq class Heap(object): """ Wraps heapq to provide a heap. The sorting is done by provided cost and then insertion order; the values are never compared. """ def __init__(self): self.heap = [] self.order = 0 def push(self, cost, value): x = (cost, self.order, v...
e8e33e330ba94a130439ce22cae53b450e3d3a42
vid2408/Day5
/python_clouser2.py
241
4.09375
4
def nth_power(exponent): def pow_of(base): return pow(base,exponent) return pow_of square = nth_power(2) print(square(2)) print(square(3)) print(square(4)) print(square(5)) cube = nth_power(3) print(cube(2)) print(cube(3))
a4b2234ea23fb4c2dab818eb9e26d55c3c5d8324
amyfranz/python_practice
/mostRepetition.py
344
4.0625
4
string = "this is a some words and it is my test" def highest_value(string): string = string.replace(" ", "").lower() dict = {} for item in range(len(string)): dict[string[item]] = dict.get(string[item], 0) + 1 x = sorted(dict, key=(lambda key: dict[key]), reverse=True) return x[0] print...
b797fe31c35ba7e71bd3f4001dc7dc980851804a
owenbrown/python_stack
/linked_list.py
2,432
3.78125
4
import unittest class Node(object): def __init__(self, val): self.value = val self.next = None class SList(object): def __init__(self): self.head = None def add_to_front(self, val): new_node = Node(val) current_head = self.head new_node.next = current_hea...
f51585ec6e8cd68dabd29429ef8d0ba2eb340d50
avidalh/udacity-fsnd-p2
/tournament.py
7,737
3.5625
4
#!/usr/bin/env python # # tournament.py -- implementation of a Swiss-system tournament # import psycopg2 # used to generate pairs from itertools import combinations # used to random assigning 'bye' from random import choice def connect(): """Connect to the PostgreSQL database. Returns a database connection."...
efa5491f8219eecca5a44b00984aed3174e6a0d4
shootk/git_vc
/python_practice/challenge7.py
983
3.671875
4
#charenge7 """ #1 movie = ["ウォーキング・デッド","アントラージュ", "ザ・ソプラノズ","ヴァンパイア・ダイアリーズ"] for show in movie: print(show) #2 for i in range(25,51): print(i) #3 movie = ["ウォーキング・デッド","アントラージュ", "ザ・ソプラノズ","ヴァンパイア・ダイアリーズ"] for i,show in enumerate(movie): print(i,":",show) #4 righ...
4dbb730d7301e9915567b9ffaa2fa118c1237ed4
svveet123/testxx
/demo1.py
1,698
3.6875
4
''' 为了代码复用 # def 固定 # sum:方法名 # g,h 在调用方法时要传的数据 # return 返回值 def sum(g,h,i): he = g+h+i return he a = 1 b = 2 c = 3 s1 = sum(a,b,c) s2 = sum(b,c,c) print(s1) print(s2) ''' ''' def test1(): print("用户") print(123) print(2.333) print([1,2,3]) print((23,43,21)) test1() ''' ''' 参数的数据类型可以是任何形式...
1b8baef05584e1d74546ef90b45d618d9cda1e77
serignefalloufall/Python_Repository
/exercice21.py
636
3.734375
4
print("-------------------- ********** --------------------") print("User1 veillez saisir un nombre que user2 doit essaier de le trouver :") nbr_user1 = int(input()) print("User2 devine le nombre que user1 a saisie:") nbr_user2 = int(input()) score = 100 while(nbr_user1 != nbr_user2): if(nbr_user1 > nbr_user2): ...
9e49f16585cbf976e9bacb79fa5a52fe38d5c1bb
serignefalloufall/Python_Repository
/exercice15_b.py
187
3.8125
4
print("Saisir un nombre") nombre = int(input()) som = 0 for i in range(1, nombre + 1): # de 1 à nombre +1 exclu --> de 1 à nombre inclus som += i moy = som / nombre print(moy)
424aa2c13cd4092ec799168ceea99cc5d2ff9be9
dilanmorar/monsters_inc_oop_basics
/Spooky_Workshops_class.py
772
3.609375
4
from Student_Monsters_class import * class Spooky_Workshops(): def __init__(self, subject, staff, location, student_list): self.scary_subject = subject self.staff = staff self.list_students = student_list self.location = location def add_students(self, student): student...
0ffe93f65e3470129a4d22f9fb32552f02e0b83e
ANJI1196/Assignment3
/USE CASE4.py
439
4
4
#MENU APP: while True: print("MY TO DO APP") print("==============") print("1. Add Task") print("2. View All Tasks") print("0. To Exit") option=int(input("Choose Option:")) if option==1: n1=input("Enter Task Name:") print("Task added") elif option==2: ...
6d03285682d26e44fa55d69d14a947fa9261dd6a
srininara/pykidz
/sessions/session-8-modular_programming/code/return.py
635
3.75
4
def age_commenter(age): if age < 0: print("Mr Unborn") return if age <= 12: print("Whizzo Kiddo") return if age < 20: print("Super Teen") return if age < 30: print("Vibrant Youth") return print("Oldie Moldie") def simple_interest(prin...
e36282ae463014cb228241b4b6ff7dbfb48e3a65
srininara/pykidz
/sessions/session-7-loops/code/while_path_change.py
271
3.921875
4
fruits = ['apple', 'apricot', 'banana', 'chickoo', 'fig', 'guava', 'mango', 'orange'] while fruits: fruit = fruits.pop() if fruit == 'chickoo': print(fruit, "! Yuck... I will skip this one") continue print("I love", fruit) print("I am done!")
091eb10c7f430a46e145614f3da84eafe77ec083
dachen123/algorithm_training_homework
/week5/LRUCache.py
1,950
3.875
4
#146.LRU缓存机制 class doubleLinkNode: def __init__(self,key,val): self.val = val self.key = key self.prev = None self.next = None class LRUCache: def __init__(self, capacity: int): self.cache = {} self.head = doubleLinkNode(-1,-1) self.tail = doubleLinkNo...
72004f108fca8cb388ab8e9c12b99b1e6bd79d46
dachen123/algorithm_training_homework
/week3/minPathSum.py
1,466
3.78125
4
#最小路径和 #空间复杂度为n^2 class Solution1: def minPathSum(self, grid) -> int: m = len(grid) n = len(grid[0]) dp = [[0]*(n) for i in range(m)] #dp[i][j]表示从(0,0)到(i,j)的最小路径 dp[0][0] = grid[0][0] for i in range(1,m): dp[i][0] = dp[i-1][0] + grid[i][0] for j in range...
e98c4539c86315543c57669adee72077ad0e0381
dachen123/algorithm_training_homework
/week5/reverseStr.py
1,232
3.703125
4
#541.反转字符串II #我的解法:直接模拟,比较考验下标指针的移动 class Solution1: def reverseStr(self, s: str, k: int) -> str: if k <= 1:return s i = 0 s = list(s) while i+2*k-1 < len(s): for j in range(k//2): s[i+j],s[i+k-1-j] = s[i+k-1-j],s[i+j] i += 2*k if i + ...
0edaf402a1fe2275d181fae2dc040f6ad669c3a3
dachen123/algorithm_training_homework
/week4/minMutation.py
996
3.65625
4
#题目:最小基因变化 #双向bfs解法,参考单词接龙题目即可 class Solution: def minMutation(self, start: str, end: str, bank: List[str]) -> int: bank = set(bank) if end not in bank: return -1 front = {start} back = {end} step = 0 while front: next_front = set() ...
96df21ca9673790184335bdd4b0ee9a353e76aef
dachen123/algorithm_training_homework
/week3/coinChange.py
1,282
3.703125
4
#题目:322.零钱兑换 #傻递归,超时 class Solution: def coinSelect(self,coins,path,amount,res): if amount==0: res['num'] = min(res['num'],len(path)) for c in coins: if amount - c >=0: self.coinSelect(coins,path+[c],amount-c,res) def coinChange(self, coins: List[int], am...
aa5cdbd2c62421ab8a68d3112e4703ff70504bff
KenFin/sarcasm
/sarcasm.py
1,715
4.25
4
while True: mainSentence = input("Enter your sentence here: ").lower() # making everything lowercase letters = "" isCapital = 0 # Re-initializing variables to reset the sarcastic creator for letter in mainSentence: if letter == " ": # If there's a space in the sentence, add it back into the final sentence...
dff13d9fdfaf28f16cd203929bbdbb4b80503aea
Markers/algorithm-problem-solving
/ARCTIC/free-lunch_ARCTIC.py
1,606
3.6875
4
import sys import collections # Visit all vetex using BFS def decision(stations, power): n = len(stations) q = collections.deque() visited = [False] * n q.append(0) visited[0] = True while q: here = q.pop() for there in xrange(n): if not visited[there]: ...
daea3ff04e6c81bdeb3e6c6eb57dd9dbd42eb118
Gr3atJes/pythonweek2
/test/test_article.py
538
3.609375
4
import unittest from app.models import Article class TestArticle(unittest.TestCase): """ Test class to test the behaviour of the movie class """ self.new_article = Article("Bob","Random Title", "Short","random.com","random.jpg","12/12/12","None") def test_instance(self): """ Tests if ins...
f44e6b5789ee7c3d75a1891cb4df186016ff8d1a
tgm1314-sschwarz/csv
/csv_uebung.py
2,240
4.34375
4
import csv class CSVTest: """ Class that can be used to read, append and write csv files. """ @staticmethod def open_file(name, like): """ Method for opening a csv file """ return open(name, like) @staticmethod def get_dialect(file): """ Me...
e41c38694d82e9abdb33e7d1642c7cdc66368d26
karelbondan/Programming_Exercises_2
/1.py
341
3.859375
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 23 08:29:52 2020 @author: karel """ feet,inch = eval(input("Enter your height (in feet, followed by inch separated by a comma):", )) print("Feet:", feet) print("Inches:", inch) float(feet) inch=inch/12 feet+=inch board = feet*30.48*88/100 print("Suggested b...
f0df0c613720e02d3e55628722e11c8b4c83088b
chihuanbin/Gaia_Cluster_Search
/cluster_hdbscan.py
7,814
3.78125
4
"""Clusters Gaia DR2 data into groups with open cluster characteristics""" import hdbscan import numpy as np import pandas as pd import warnings from cluster_plot import cluster_plot warnings.filterwarnings("ignore") # This selects which output cluster data the program will write to a csv file # for subsequent analys...
5f69620a7ce1c8a4b3a7cb32abe697fa4ef522da
danhagg/python_bits
/CrashCourseInPython/kafah.py
261
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jul 27 16:22:26 2017 @author: danielhaggerty """ answer = "Kafah tells lies" question = input("Does Kafah prefer Dan or crappy Persian TV: ") if 'Dan': print(answer) else: print(answer)
fe731fd040a7288811f1486979ffaf69245fff29
danhagg/python_bits
/CrashCourseInPython/while_loops.py
153
4.1875
4
# while loops, the += operator == "current iterator + 1" current_number = 1 while current_number <= 5: print(current_number) current_number += 1
00e6c625791d1dba687996916e173461dd76f72e
Zihad07/Coding_for_Job_Interview
/Array_01/03_is_one_array_rotaion_of_another.py
1,482
3.671875
4
# for BIG O(n) def is_Rotation_my_method(A,B): len_A = len(A) result = {} for i in range(len_A): if A[i] not in result: result[A[i]] = 1 else: result[A[i]] += 1 if B[i] not in result: result [B[i]] = 1 else: result ...
c285779a11d17b02bda0bb45204f304db05cb12d
Fadzayi-commits/Python_Programming_Assignment_9
/Disarium_btwn.py
536
3.875
4
def calculateLength(n): length = 0; while (n != 0): length = length + 1; n = n // 10; return length; def sumOfDigits(num): rem = sum = 0; len = calculateLength(num); while (num > 0): rem = num % 10; sum = sum + (rem ** len); num = num /...
a5059ea989573a23128d9f9eb670827e09f72bea
teazzy1/Python-Basics
/Conversion Program.py
275
4
4
print("Program running.....") x= int(input("type a number in the box ")) #Defines input function def conversion (unit): #Declare the functions mililiters = unit * 29.57353 # Set the parameters return mililiters print(conversion(x)) #substitute 'x' for any number
a6a11c4a34f95565baee0f8dbb5885134106f72f
accubits/AI-ML_Marian_Sessions
/advertisement_app/predict.py
714
3.796875
4
import numpy as np import pandas as pd # Data Visualisation import matplotlib.pyplot as plt import seaborn as sns from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression advertising = pd.DataFrame(pd.read_csv("Data/simple_lr_application/advertising.csv")) X = advert...
c1249eca315f652960a09c2b903c93121c8a19c4
saiso12/ds_algo
/study/OOP/Employee.py
452
4.21875
4
''' There are two ways to assign values to properties of a class. Assign values when defining the class. Assign values in the main code. ''' class Employee: #defining initializer def __init__(self, ID=None, salary=None, department=None): self.ID = ID self.salary = salary self.departme...
97e0ec7c4c0f59ba57726ee9dce2fa51440e0afe
saiso12/ds_algo
/study/recursion/sum_of_digits.py
298
3.75
4
#Sum of digits # 10 = 1 # 120 = 122 % 10 => 12,2 => 12/10 => 1,2,2 def sumofDigits(n): assert n >= 0 and int(n) == n, 'n must be positive and a whole number' if n == 0: return 0 else: return int(n%10) + sumofDigits(int(n//10)) print(sumofDigits(1111111111111111111))
ac4e5c7b2a3b4e8f6c73e1ebe586a0aa921615e4
boblespatates/Regex_tuto
/regex_2.py
1,399
3.9375
4
import re #https://github.com/CoreyMSchafer/code_snippets/tree/master/Python-Regular-Expressions text_to_search = ''' azertyuiop azertyuio azertyuHZZHZHA abc ''' sentence = 'Start a sentence and then bring it to an end' # Allow to separate the patterns into a variable # And make it easier to reuse that variable to ...
c3fa48aaa5e4c241218c25d5b70c2e89a4f9142d
NguyenQuyPhuc20173302/thuctaptuan2
/Sort_the_Lists1.py
714
3.890625
4
list1 = [1, 4, 7] list2 = [1, 3, 4] list3 = [2, 6] count1 = 0 count2 = 0 count3 = 0 total_len = len(list1) + len(list2) + len(list3) ls = [] # hàm này từ 2 dành sách rồi chuyển thành 1 danh sách đã được sắp xếp def Sort_two_list(a1, a2): a = [] dem1 = 0 dem2 = 0 while 1: if dem1 == len(a1): ...
135ab7dcac0c4aff3b8c628965d2bf6e3d3bde07
sirbrave21/Python
/TaşKağıtMakas.py
567
4.09375
4
import random print("1-Taş") print("2-Kağıt") print("3-Makas") kullanıcı = int(input("1 ile 3 arası bir sayı seçiniz : ")) pc = random.randrange(3)+1 print("Bilgisayarın seçimi : ",random.randrange(3)+1) if (kullanıcı == 1 and pc == 2) or (kullanıcı == 2 and pc == 3) or (kullanıcı == 3 and pc == 1): print("...
3355e006e673b9be9917c552b0532a9e132e6122
doonguk/algorithm
/20200406/90.py
176
3.59375
4
def solution(s): stack = list() for v in s: if stack and stack[-1] == v: stack.pop() else: stack.append(v) return not(stack)
579bb05dbb04a51bde52a643c0b0bcb3a247ff41
doonguk/algorithm
/20200303/22.py
747
3.578125
4
import sys sys.stdin = open("input22.txt", "rt") n, target = map(int, input().split()) a = list(map(int, input().split())) a.sort() start = 0 end = n-1 while start <= end: mid = (start + end) // 2 if a[mid] == target: print(mid+1) break elif a[mid] > target: end = mid - 1 else:...
cafc89d0019f391457ac72a2d98acd4cfce049c4
nashit-mashkoor/Coding-Work-First-Phase-
/practice-pandas/.ipynb_checkpoints/CAPM MODEL-checkpoint.py
1,192
3.515625
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 9 21:08:49 2018 @author: MMOHTASHIM """ import pandas as pd import matplotlib.pyplot as plt import quandl from statistics import mean import numpy as np from IPython import get_ipython api_key="fwwt3dyY_pF8LyZqpNsa" def get_data_company(company_name): df=quandl.get("...
bdb79ff3274d007e9fdf9c5d3fdbc237f4ce1392
nashit-mashkoor/Coding-Work-First-Phase-
/sentdex machine learning projects/Regression part 10 and Part 11.py
1,179
3.65625
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 3 14:15:33 2019 @author: MMOHTASHIM """ #Linear Regression Model from scratch: from statistics import mean import numpy as np import matplotlib.pyplot as plt from matplotlib import style style.use("fivethirtyeight") xs=np.array([1,2,3,4,5,6],dtype=np.float64) ys=np.arra...
800b8ea97a00f569ec7182a3084808cab5b97b41
EarlHikky/CursaTetra
/ct_cell.py
1,782
3.71875
4
import curses as crs """ Gets the character value (as an int) of a cell in the board; As blocks take up two curses-coordinate spaces, a cell is defined as such, and its identifying symbol will be in the righthand space; In theory, the cell will either be empty (". "), have an old block (two ACS_BLOCK chars), or have a...
8889124922ceecc18ee9ece4af6246f6ec9b4dcb
radiolariia/Python
/Labs/lab_5_HRYNEVYCH.py
505
4
4
print('lab5\nSofiia Hrynevych \nІПЗ-11 \nVariant 3') def binomial_coefficient(n, k): if n < k: return (print('It`s impossible to calculate a factorial value of negative number!')) if k == 0 or k == n: return 1 else: return binomial_coefficient(n - 1, k - 1) + binomial_coefficient(n - 1, k) while True: ...
21353b0049094df9e13a6a152f1ad84d15e6f91c
radiolariia/Python
/Labs/lab_2_HRYNEVYCH.py
521
3.828125
4
import math print('Lab 2 \nSofiia Hrynevych \nIПЗ-11 \nTASK 1') def s(): print('\n') s() while True: a = float(input('Основа рівнобедренного трикутника = ')) b = float(input('Бічна сторона трикутника = ')) if (a > 0 and b > 0) and ((2 * b) > a): break s() print('It`s an impossible triangle! \nTry again!'...
9c7474fb68c1c9edf9855ed4d5c5f7a1234c181f
radiolariia/Python
/Labs/lab_1-2_HRYNEVYCH.py
1,041
3.71875
4
import math print('Lab 2 \nSofiia Hrynevych \nIПЗ-11 \nVariant 3\n \nTASK 1') def s(): print('\n') s() r = float(input('R = ')) length = (2*math.pi)*r area = math.pi*(r**2) s() print('Length of the circle: {0:5.3f} \nArea of the circle: {1:5.3f}'.format(length,area)) s() print('TASK2') s() d2 = float(input('D =')...
a5f0ce5dbb96b3360d565604bc12ac97d92a9e70
bibiacoutinho/Python-Para-Zumbis
/Lista 5_bibiacoutinho.py
3,149
3.734375
4
##Questão A x = 2 y = 5 if y > 8: y = y * 2 else: x = x * 2 print (x + y) ##Questão B lista = [] for i in range(9): if i != 3: for j in range (6): print (f'oi') lista.append(j) print (len(lista)) ##Questão C lista = [] listafinal = [] for n in range...
e83c1927d506cdbe6817d2f9571cd0a548bb5c41
MarcoVillegasCampos/Dojo-Pets
/Ninja/Ninja.py
650
3.59375
4
from Pet import Pet class Ninja: def __init__(self, first_name, last_name, treats, pet_food, pet): self.first_name=first_name self.last_name= last_name self.treats=treats self.pet_food=pet_food self.pet=pet def walk(self): self.pet.play() retu...
00b72fd38c0c9d04f1f952ca6dd2ad7db0766217
spiderbeg/100
/answer/ex98.py
292
3.796875
4
# coding:utf8 import math def FindHim(): for x in range(10): for y in range(10): if x != y: result = x * 1100 + y * 11 test = math.sqrt(result) if test.is_integer(): return result print (FindHim())
cbf294b5deb0aa61a3dcce122eac4770522a4de9
spiderbeg/100
/answer/ex39.py
152
3.703125
4
# coding:utf8 num = input('请输入字符: ') if num.isdigit(): print('您输入的是数字:%s'%num) else: print('您输入的不是数字')
6f29cb3b97b356d5fe8b3104a305a0e4c4b22337
spiderbeg/100
/answer/ex48.py
486
3.8125
4
# coding:utf8 # 定义一个函数 def mcd(x, y): """该函数返回两个数的最大公约数""" # 获取最小值 if x > y: smaller = y else: smaller = x for i in range(1,smaller + 1): if((x % i == 0) and (y % i == 0)): mc = i return mc # 用户输入两个数字 num1 = int(input("输入第一个数字: ")) num2 = int(input("输入第二个数字:...
b048fe3ff7a7d09967f564da005c5b7d150ac699
pombreda/mpython-to-dalvik-compiler
/ex6.py
221
4
4
num1 = raw_input("Digite o primeiro número: ") num2 = raw_input("Digite o segundo número: ") if num1 > num2: print("O primeiro número é maior que o segundo") else print("O segundo número é maior que o primeiro")
7af186adfb6bbc16b72a792fac137a13e4d9206c
pombreda/mpython-to-dalvik-compiler
/ex5.py
149
3.546875
4
print("=-=-=-=-=- Tabela de conversão: Celsius -> Fahrenheit -=-=-=-=-=") cel = raw_input("Digite a temperatura em Celsius: ") far = (9*cel+160)/5
0d6a3e36bf67579802704014fcec59c8c6745fa1
gnduka17/My-Code-Samples
/ITP115_project_Nduka_Gloria/MenuItem.py
1,048
3.640625
4
#this class represents a single menu item on the menu class MenuItem(object): def __init__(self, nameparam, typeparam, priceparam, descripparam): self.name = nameparam self.type = typeparam self.price = priceparam self.description = descripparam #the getter functions for name, t...
87d3c0a689334c7072d0301528a4d011d1716c8b
yourboirusty/advanced_python_seminar
/02_Iterators/modifiers.py
964
3.9375
4
def isEven(x): if x % 2 == 0: return True return False def isUpper(x): return x.isupper() def square(x): return x**2 def grade(x): if x >= 95: return "5.5" elif x >= 80: return "5" elif x >= 70: return "4" elif x >= 65: return "3" elif x >...
a93d96372ed9207bf03fba2c71edae9c93025c08
valdimirbarrosti/sistemaescolarharvard
/cadastro.py
49,783
3.578125
4
## funcao para cadastrar professor no banco de dados ## def cadastrarProf(nomeProf,discProf,userProf,senhaProf): import sqlite3 conectar = sqlite3.connect("bancodeDados.db") interagir = conectar.cursor() sqlInserir = "INSERT INTO professor VALUES ('{}','{}','{}','{}')".format(nomeProf,discProf,user...
649775ab8379b634ce41de17027514c2de97ae6d
spen0t/Honap-Nap
/honapos_vegleges.py
662
3.6875
4
honapok= ["Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"] napok=[31,29,31,30,31,30,31,31,30,31,30,31] h=input("Hónap: ") n=input("Nap: ") def szamHiba(): try: int(n) return True except ValueError: ...
01fcaaf1d2c6c6f9c785e619296e247dbaab938f
sthomen/pyselcall
/pyselcall/tones/square.py
538
3.578125
4
from math import floor from .tone import Tone class Square(Tone): """ This class continually produces a 50% duty cycle square wave centered in the cycle (meaning it starts at halfway through the low cycle and then shifts to high for 50% of the cycle and then back down to 0 at 75%. """ def __iter__(sel...
718ca423c56962b1cff82428ccd57e9b4dfece98
FarukOmerB/Problem-Solving
/patika/patika_python_project.py
687
3.90625
4
# Ömer Faruk BAYSAL -- Patika Python Project #%% Part 1 def flatten(inp): """ Recursive flatten function """ out=[] for i in inp: if type(i)==list: [out.append(j) for j in flatten(i)] else: out.append(i) return out; inp= [[1,'a...
50e51ae174b51f47736e94d3c33d29921573894e
hellothisisnathan/Brain-Efficiency
/monte carlo/starter monte carlo.py
1,041
3.75
4
import numpy as np import math import random from matplotlib import pyplot as plt from IPython.display import clear_output x = np.linspace(0, 100, 2000) y = (1/7)*np.sqrt(2500+np.power(x,2))+(1/2)*np.sqrt(2500+np.power((100-x),2)) def get_rand_num(min_val, max_val): range = max_val - min_val choice = random.u...
a251923e6e161f12d54d117338cafb68a2b24961
whhxz/leetcode
/python3/0435_non-overlapping-intervals.py
445
3.5
4
from typing import List class Solution: def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int: if not intervals: return 0 intervals.sort(key=lambda x: (x[1], x[0])) before = intervals[0] res = 0 for i in range(1, len(intervals)): if inte...
157f5e9d58d469789db3ed60dfebec534cf5da61
YaroslavBulgakov/study
/beetroot_dz/linked_list.py
5,964
4.03125
4
class Stack(): def __init__(self): self.list=[] def push(self,data): self.list.append(data) def pop(self): return self.list.pop() def get(self): return self.list mystack=Stack() mystack.push('Data1') mystack.push('Data2') print(mystack.pop()) print(mystack.get()) class ...
8d0b9fcc6273c721e40b81a35c3c04e63180adb4
YaroslavBulgakov/study
/beetroot_dz/linked_list2.py
4,011
3.859375
4
class Stack(): def __init__(self): self.list=[] def push(self,data): self.list.append(data) def pop(self): return self.list.pop() def get(self): return self.list mystack=Stack() mystack.push('Data1') mystack.push('Data2') print(mystack.pop()) print(mystack.get()) class ...