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
7ea3a2a0d099f8f4bbdefcc8f130582a14dfe85f
jell0720/Python27_Sublime_Dondon
/src/ClassContens/firstClass/20160429Class.py
454
3.734375
4
#coding=utf-8 # Python三大資料結構 # Python Tuple # Pythonlist # Python Dictionary # Python Tuple # 裡面的值不能再做修改 a=(1,2) # Pythonlist # 可以自由伸縮,類似Java的Arraylist b=[1,2,3] print b b.append(4) print b # Python Dictionary # 找資料的速度很快 # 要為所有資料配置空間 # 如同書籍要快速尋找,需要建立索引 pages=range(1,501) print p...
b0fefad0005b21db49ff893461fbfc8d6f4cb32e
angelricardoh/Intro-Robotics
/PA1/task1.py
352
3.75
4
def mysum1(A): result = 0 for integer in A: result += integer return result def myfib1(n): if n <= 1: return n return myfib1(n - 1) + myfib1(n - 2) # Test cases 2.1 print(mysum1([1, 5, 7])) print(mysum1([])) print(mysum1([-5, 3])) print("\n") # Test cases 2.2 print(myfib1(3)) pr...
2cddfcca5ba5885135c7cf4271166db2a18b12a3
weishanlee/6.00.1x
/PS01/1_3.py
2,047
4.28125
4
# create random letter lists to test PS1 import random import string def test(tests,a,b): ''' tests: int, the number of tests to perform a: int, the length of the shortest string allowed b: int, the length of the maximum string allowed ''' n = 0 while n < tests: s = genera...
0b204934269b03e929537727a134c4e5685a964f
weishanlee/6.00.1x
/PS03/3_3.py
1,389
4.21875
4
secretWord = 'apple' lettersGuessed = ['e', 'i', 'k', 'p', 'r', 's'] def getGuessedWord(secretWord, lettersGuessed): ''' secretWord: string, the word the user is guessing lettersGuessed: list, what letters have been guessed so far returns: string, comprised of letters and underscores that represents ...
a51e50f0fdcad1787d9cb0a7ab7f7cab50a4eda6
weishanlee/6.00.1x
/Lecture 12/Lecture_12_05.py
1,052
4.3125
4
print "Prime generator" def genPrimes(): primes = [] last = 1 while True: last += 1 for p in primes: if last % p == 0: break else: primes.append(last) yield last primeList = genPrimes() for i in range(1,11): print primeList.ne...
3144e1ae17f0d6f8207ba7d5c293c2d84926454d
weishanlee/6.00.1x
/PS04/4_4.py
284
3.96875
4
hand = {'a':1, 'p':2, 'l':0, 'e':1, 's':1, 'x':1} def calculateHandlen(hand): """ Returns the length (number of letters) in the current hand. hand: dictionary (string int) returns: integer """ return sum(hand.values()) print calculateHandlen(hand)
8e9cdeefc25ef792cf212378321b87a36d1bfdfe
weishanlee/6.00.1x
/Exam/Problem 6.py
3,384
4.21875
4
# -*- coding: utf-8 -*- class Frob(object): def __init__(self, name): self.name = name self.before = None self.after = None def setBefore(self, before): # example: a.setBefore(b) sets b before a self.before = before def setAfter(self, after): # example: a.setA...
3b5db557711710d79a80e3c008ab4b04fe29e1aa
josephantony8/GraduateTrainingProgram2018
/Python/Day5/Listcommand.py
1,828
4.5
4
Consider a list (list = []). You can perform the following commands: insert i e: Insert integer e at position i. print: Print the list. remove e: Delete the first occurrence of integer e. append e: Insert integer e at the end of the list. sort: Sort the list. pop: Pop the last element from the list. reverse: Reverse t...
78cd5840077212f397087df6c7a3efc55c5ee114
indysreeram/python-kata
/idempotence.py
904
3.796875
4
message = ''' The property of certain operations in mathematics and computer science,that can be appied multiple times without changing the results beyond the initial application.''' print(message) def add_ten(num): return num+10 # f(f(x)) =f(x) # f(f(10)) =30 | f(10) =20 hence not idempotent print (add_ten(10)) p...
a658d6472087f7b452dca423756a5d093bdc7c0e
guilherme-kunsch/jokenpo0
/Jogo.py
1,523
3.71875
4
from random import randint from time import sleep itens = ('PEDRA', 'PAPEL', 'TESOURA') sentinela = True while (sentinela == True): computador = randint(0, 2) print('''Suas opções: [0] PEDRA [1] PAPEL [2] TESOURA''') jogador = int(input('Qual sua jogada? ')) if jogador >= 0 and jogador...
7f3e1c22f5b46b694622060ac1a3246df8824941
DanielSauve/AdventOfCode2020
/day3/day3.py
1,035
3.71875
4
from typing import List from functools import reduce def parse_trees(trees: str) -> List[str]: return trees.split("\n") def traverse_trees(tree_grid: List[str], x_increment: int, y_increment: int) -> int: trees_encountered = 0 current_x = x_increment current_y = y_increment tree_grid_width = len...
e965d03f9701e9ca28435f66a6671fd744abc1a5
olzama/Ling471
/assignments/activity_plots.py
346
3.65625
4
import matplotlib.pyplot as plt # Example plot X = range(-5, 5) # Note the missing +5! Y = [pow(x, 2) for x in X] plt.plot(X, Y) plt.show() plt.xlabel('X', color='fuchsia', fontweight='bold') plt.ylabel('f(x)') plt.plot(X, Y, 'o-', label='squared') # other styles: '--', ':' plt.legend(loc="upper left") plt.savefig...
954fbd695169cf5ca915f4afa14673647e4a77b4
olzama/Ling471
/demos/May13.py
1,688
4.15625
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.linear_model import LinearRegression # Linear regression demo X = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] # Want: y = 2x + 0 (m = 2, b = 0) Y = [2*x for x in X] # list comprehension Y_2 = [x*x for x in X] Y_3 =...
9ea1a32f9970d28b62467514cc319257a57ed3ae
vamsiraju22/DSA
/Hackerrank.py
16,765
3.625
4
#1. https://www.hackerrank.com/challenges/grading/problem grades=[13,45,67,43] new_grade=[] for ind,grade in enumerate(grades): if grade >= 38: if (5-(grade%5))<3: #new_grade[ind]=grade+(5-grade%5) #print(new_grade) new_grade.append(grade+(5-grade%5)) else: ...
0989f58fd3ffd172cb8ebd21606ab9f307c6001c
cqcsyav6952/doWithPython
/数据结构/ds_queue.py
711
3.890625
4
""" queue.py """ class Queue(object): def __init__(self,size = 20): self.size = size self.start = 0 self.queue = [] def put(self,element): if self.start < self.size: self.queue.append(element) self.start += 1 else: print('Full') ...
bb2d196327aad54d8fb47532512ce7e55b325e24
JohamSMC/python
/5-listas.py
464
3.8125
4
my_list=["string", 15 , 20.3 ,True] my_list.append("Al final") #El metodo Appeend() añade un elemeto al final de la lista my_list.insert(1,"insert posicion 1") #El metodo Insert() permite añadir un elemento a uan lista especificando el índice my_list.remove(15) #El metodo Remove(), elimina el elemento que se ...
a8c695a5aa6e34f2bac4aace65c851b4fe0b5474
ronaldo0010/rw334-projects
/Webapp/venv/app/hours.py
1,262
3.84375
4
#splits entire string and returns list def split_times(times_str): comma_index = times_str.find(',') list_output= [] while(comma_index != -1): day_time = times_str[0:comma_index] list_output.append(split_day_time(day_time)) times_str = times_str[comma_index+1:len(times_str)] ...
8fa9a8bf7fe98cf7785f5a40d0dc19b0173cfa9d
nbackas/dsp
/python/q8_parsing.py
678
4.125
4
# The football.csv file contains the results from the English Premier League. # The columns labeled Goals and Goals Allowed contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program to re...
a13c3970fe2b6d5c824fece2c2d7773212228e8f
19133/Te-Reo-Maaori-Quiz-Github
/version4.py
4,131
4.0625
4
import random def yes_no(question): valid=False while not valid: response = input (question) .lower() if response == "yes" or response == "y": response = "yes" return response elif response == "no" or response == "n": response = "no" return response def le...
269591fda96b70f86e1f51d60a404e767ac8d23d
acharyas121/Python
/card.py
925
3.78125
4
import random class card: def __init__(self,suit,value): self.suit = suit self.value = value def show(self): print("{} of {}".format(self.value, self.suit)) class deck: def __init__(self): self.cards = [] self.build() def build(self): for s in ...
c16a8ef2d8d2c31baf50fc730c87aa6236dcb0e0
jorgetime/code_exercise
/code_exercise/anagram.py
644
4.0625
4
def is_anagram(word, anagram): if not isinstance(word, str) or not isinstance(anagram, str): raise ValueError('One or more words are not strings') if len(word) == 0 or len(anagram) == 0: raise ValueError('One or more words are empty') if len(word.split()) != 1 or len(anagram.split()) != 1: ...
1cc6e0be877dddd634a51e1058dba48723514616
cbscientist/advent-of-code-2019
/day_03/wires.py
5,235
4.1875
4
""" During the rush back on Earth, the fuel management system wasn't completely installed, so that's next on the priority list Front panel reveals jumble of wires Two wires are connected to a central port and extend outward on a grid You trace the path each wire takes as it leaves the central port, one wire per line...
59f2cb4caf365e9cfb46c7a1d25b9d56a3d5f1ec
AnnaBesk/STO_project
/Вычисления.py
545
3.671875
4
import math v=int(input("Введите скорость ")) l_=int(input("Введите длину стержня "))#натуральная длина стержня c=300000000 #скорость света в м/с b=math.pow(v,2)/math.pow(c,2) #бетта y=1/math.sqrt(1-b)# гамма t=1 #1 секунда в неподвижной СО t_=t/y l=l_/y print('1 секунда в движущейся СО = ', round(t_, 5)) print("Длина ...
0922d228deb7ad6723ca851275050550edbb0b93
sathwikajoginipalli/Machine-Learning-Using-Python
/Class Work/Day 8 - Dict/sample_function.py
376
3.765625
4
#print("Hi") #No param no return def printSquare(): print("Square") #With param w/o return def printSquare2(x): print("Square : ",x*x) #with param with return def getSquare(x,y): printSquare() return x*x def defaultSquare(i=1): print(i*i) #printSquare() #printSquare2(10) #sq = getSquare(5) #pr...
e31873b2251facbb72e96350b29d42769418347b
sathwikajoginipalli/Machine-Learning-Using-Python
/Class Work/Day 10 - OOPS/namespace.py
432
4.09375
4
class Student: x =10 s1 = Student() print(s1.x) # 10 s1.x = 11 # 10 chnaged to 11 in s1 obj print(s1.x) # print 11 s2 = Student() # new s2 obj with value 10 print(s2.x) # 10 inherited from class s2.x = 30 # 10 in s2 changed to 30 Student.x = 100 #Class variable changed to 100 print(s2.x) #30 from s2 obj pri...
48b24e806fa12289779857414b822046f843a9f7
dimagapey/Homework_lesson_2
/Task4.py
726
4
4
# 4. Дано натуральное число. Требуется определить, # является ли год с данным номером високосным. # Если год является високосным, то выведите `YES`, иначе выведите `NO`. # Напомним, что в соответствии с григорианским календарем, # год является високосным, если его номер кратен 4, но не кратен 100, # а также если он кра...
c8bb9db1821143da9f1e9ae5ff9062d479a6b617
mirukuchan/DNN_mnist
/fc_net.py
9,688
3.765625
4
from builtins import range from builtins import object import numpy as np from NN.layers import * from NN.layer_utils import * class TwoLayerNet(object): """ A two-layer fully-connected neural network with ReLU nonlinearity and softmax loss that uses a modular layer design. We assume an input dimension ...
8c1ce3b11bdaee1a2cea312cdd71334fd944ca25
Manpreet-Bhatti/WordCounter
/word_counter.py
1,477
4.28125
4
import sys # Importing the ability to use the command line to input text files import string # Imported to use the punctuation feature def count_the_words(file_new): # Counts the total amount of words bunch_of_words = file_new.split(" ") amount_of_words = len(bunch_of_words) return amount_of_words def mos...
05cc45b763e09a2ac7e7b06b7bb9bc07b35c4e26
Inc175/ll_crowluya-Matplotlib_With_PYQT-master
/Matplotlib_With_PYQT/txt__excel/utils.py
5,521
3.5625
4
import locale import time ''' 为什么要自己写file函数 先上总结 ******结论********** print 的file 想要的是一个对象 ( 使用write方法打开的对象) 我们传入的是文件名是一个字符串 所以要自己写file函数 ******ps******** 写了log_file_is_str() 来说明 错误 test 函数中 运行 test_log_file_is_str() 查看结果 test_log_file_is_str函数已经注释 ********************正文************************* python 的print api如下...
82356f09697f5e32ea16418c3a5e84b5ce1cae0a
barbking/python-algorithm-fun
/simple_binary_search.py
655
3.859375
4
#note data must be in order, O(log n) def search(searchList, key): mid = int(len(searchList) / 2) print("Searching midpoint at ", str(searchList[mid])) if mid == 0: print("Key not found!") return key elif key == searchList[mid]: print("Key found!") return search...
5b2275c4ddd061fee0b422f87ac61f5988e64db2
park950414/python
/第九章/pySum.py
224
3.90625
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 14 09:06:16 2017 @author: park """ import numpy as np def npSum(): a = np.array([0,1,2,3,4]) b = np.array([9,8,7,6,5]) c = a**2 + b**3 return c print(npSum())
58916a470ef9da01b77e1a4af5d0890c4ee9e028
park950414/python
/第四章/微实例/4.3.py
102
3.578125
4
R=eval(input("请输入正整数:")) i,S=0,0 while(i<=R): S=S+i i=i+1 print("累加求和",S)
d03abee78f77bf5a95a6387fe4df6274892ed864
park950414/python
/第六章/程序练习题/5.py
326
3.8125
4
from random import * TIMES=eval(input("请输入随机样本数量:")) count=0 for a in range (TIMES): birthday=[] for i in range (23): birthday.append(randint(1,366)) if len(set(birthday))<len(birthday): count+=1 print("23个人中至少两个人生日相同的概率为:{}".format(count/TIMES))
ae89736ccab41c654c83d71206d4f1e4bf5f4772
sanindra/Interviewbit
/Arrays/minstepsinfintegrid.py
472
3.5
4
class Solution(object): # @param X : list of integers # @param Y : list of integers # Points are represented by (X[i], Y[i]) # @return an integer def coverPoints(self, X, Y): a, b = X[0], Y[0] c = 0 for i in range(1, len(X)): c += max(abs(X[i] - a), abs(Y[i] - b))...
2b06ace377d5b3ad7151df807addfaefbe5a5017
sanindra/Interviewbit
/Math/poweroftwointegers.py
467
3.578125
4
class Solution(object): # @param A : integer # @return a boolean def isPower(self, A): if A == 1: return True for i in xrange(2, int(A ** 0.5) + 1): y = 2 p = i ** y while A >= p > 0: if p == A: return True...
ac09485f57d0b1abed05cbee2900895004b43f0f
jeonsun3629/TIL
/Algorithm/Code13-03.py
612
3.78125
4
def binSearch(ary, fData) : pos = -1 start = 0 end = len(ary) - 1 while (start <= end): mid = (start + end) // 2 if fData == ary[mid] : return mid elif fData > ary[mid] : start = mid + 1 else : end = mid - 1 return pos dataAry = ...
7d594dcdc9163abfe8aa7898c853071533671444
AlexXie1996/Routing
/LS/classes.py
648
3.625
4
class Node(object): """ """ def __init__(self, node_id): """ """ self.id = node_id self.neigbors = {} def insert_neigbors(self,neigbor_id, weight): """ """ assert neigbor_id not in self.neigbors.keys(),"{0} is in {1}'s neigbors".format(neigbor_id, self.id) assert weight >= 0,"{0}'s weight in {1}'s ...
01ee6f04356c140a132310c9b324bb80cf1b7300
pd0wm/exercises
/advent_of_code_2021/solve_02.py
635
3.625
4
#!/usr/bin/env python3 instructions = [(instruction[0], int(instruction[1])) for ln in open('input_02') if (instruction := ln.strip().split(' '))] # Part one depth = 0 horizontal = 0 for move, n in instructions: if move == 'forward': horizontal += n elif move == 'up': depth -= n elif move...
dcc1c20d7a4c9e147dcd41223a0a7a419a7d700a
pd0wm/exercises
/advent_of_code_2017/day_09/01.py
532
3.546875
4
s = "{{},{}}" s = open('input.txt').read().rstrip() score = 0 nest = 0 garbage = False skip = False garbage_count = 0 for c in s: if skip: skip = False continue if c == '!': skip = True continue if c == '>': garbage = False if garbage: garbage_count...
82a380e15ef764255ec9cad3c59edcc1fb6d596a
pd0wm/exercises
/advent_of_code_2021/solve_03.py
928
3.578125
4
#!/usr/bin/env python3 import numpy as np def one_most_common(nums, n): column = nums[:, n] ratio = np.sum(column) / nums.shape[0] return ratio >= 0.5 def filter_list(inputs, upper=True): N = inputs.shape[1] nums = inputs.copy() for n in range(N): if one_most_common(nums, n) == upper...
e7b362645e07bbd32b3c72b89eb6eecf9751359e
xiaolang01/NLP
/Word2Vec/Huffman_tree.py
5,066
3.546875
4
# -*- coding: utf-8 -*- # @Time : 2020/9/19 下午8:51 # @Author : TaoWang # @Description : 构建哈夫曼树 class HuffmanNode: def __init__(self, word_id, frequency): self.word_id = word_id self.frequency = frequency self.left_child = None self.right_child = None self.father = None ...
4db7efbf08f9307fe4dc46446cb30ed61dd9e0e0
ajhofmann/PyEuler
/Problems 30-39/Problem 37.py
1,729
3.671875
4
## Project Euler Problem 37: ## The number 3797 has an interesting property. Being prime itself, it is possible ## to continuously remove digits from left to right, and remain prime at each stage: ## 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3. ## Find the sum of the only eleve...
b8c1dc1f54a25619343340701f9be24bb88e97e6
ajhofmann/PyEuler
/Problems 30-39/Problem 36.py
539
3.515625
4
## Project Euler Problem 36: ## Find the sum of all numbers, less than one million, ## which are palindromic in base 10 and base 2 sum = 0 # converts a number into base 2 def base2_convert(n): if n == 0: return '0' elif n == 1: return '1' else: return base2_convert(n//2) + str(n%2)...
1e9925f2b8cba7763274c1badcfa9e8a846923a1
ajhofmann/PyEuler
/Problems 40-49/Problem 42.py
1,014
3.75
4
## Project Euler Problem 42: ## By converting each letter in a word to a number corresponding to its alphabetical position and ## adding these values we form a word value. ## If the word value is a triangle number then we shall call the word a triangle word. ## Using words.txt, a 16K text file ## containing nearly t...
d368d2802152ac123446efdcddba8df3800c6199
gcd0318/pe
/l3/pe66.py
3,024
3.75
4
""" Consider quadratic Diophantine equations of the form: x^(2) – Dy^(2) = 1 For example, when D=13, the minimal solution in x is 649^(2) – 13×180^(2) = 1. It can be assumed that there are no solutions in positive integers when D is square. By finding minimal solutions in x for D = {2, 3, 5, 6, 7}, we obta...
cb7ea91dd4e6818743eb5b21720585fc091f5622
gcd0318/pe
/l5/pe115.py
1,367
3.625
4
""" NOTE: This is a more difficult version of Problem 114. A row measuring n units in length has red blocks with a minimum length of m units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one black square. Let the fill-count function, F(m, n), rep...
29eddba8098512c06f6628c7bbab16af4fcf043d
gcd0318/pe
/l3/pe70.py
7,219
3.796875
4
""" Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6. The number 1 is considered to be relat...
e540bff9e616ff7d06af68ac2037c11296855a26
gcd0318/pe
/l2/pe50.py
1,155
3.5625
4
""" The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equal to 953. Whic...
82fd9b758b5cbba61a39e3f94707286f199bd128
gcd0318/pe
/l2/pe28.py
994
3.796875
4
""" Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 It can be verified that the sum of the numbers on the diagonals is 101. What is the sum of the numbers on the dia...
25cfb5db84e817269183a1686d9f4ff72edaaae4
gcd0318/pe
/l5/pe102.py
1,454
4.125
4
""" Three distinct points are plotted at random on a Cartesian plane, for which -1000 ≤ x, y ≤ 1000, such that a triangle is formed. Consider the following two triangles: A(-340,495), B(-153,-910), C(835,-947) X(-175,41), Y(-421,-714), Z(574,-645) It can be verified that triangle ABC contains the origin, w...
f729ff911c1ad61faac572f2bb108d08f913dfb5
gcd0318/pe
/l3/pe59.py
3,602
4.40625
4
""" Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107. A modern encryption method is to take a text file, convert the bytes to ASCII, then XOR each b...
43cf14d612c0e82c4be21679cfc82da55882e87f
gcd0318/pe
/l4/pe81.py
1,141
3.859375
4
""" In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right, by only moving to the right and down, is indicated in bold red and is equal to 2427. 131 673 234 103 18 201 96 342 965 150 630 803 746 422 111 537 699 497 121 956 805 732 524 37 331 Find the minimal path sum, in...
9bc7e6a0ab702629a10eaaaaffdfafec51ed9a8b
gcd0318/pe
/l5/pe104.py
964
3.859375
4
""" The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. It turns out that F541, which contains 113 digits, is the first Fibonacci number for which the last nine digits are 1-9 pandigital (contain all the digits 1 to 9, but not necessarily in order). And F2...
6e628544970db9f5f39422803349ff7ae3a98835
gcd0318/pe
/l5/pe103.py
2,693
4.03125
4
""" Let S(A) represent the sum of elements in set A of size n. We shall call it a special sum set if for any two non-empty disjoint subsets, B and C, the following properties are true: S(B) ≠ S(C); that is, sums of subsets cannot be equal. If B contains more elements than C then S(B) > S(C). If S(A) is ...
b5fddf2e670821acf7ae3f1914e1a90f8c977077
gcd0318/pe
/l3/pe68.py
6,141
3.671875
4
""" Consider the following "magic" 3-gon ring, filled with the numbers 1 to 6, and each line adding to nine. Working clockwise, and starting from the group of three with the numerically lowest external node (4,3,2 in this example), each solution can be described uniquely. For example, the above solution can be desc...
d2ff1a76133a673e673927867714cee6df933eef
gcd0318/pe
/l3/pe64.py
2,798
3.9375
4
""" All square roots are periodic when written as continued fractions and can be written in the form: √N = a_(0) + 1 a_(1) + 1 a_(2) + 1 a_(3) + ... For example, let us consider √23: √23 = 4 + √23 — 4 = 4 + 1 = 4 + 1 1 √23—4 1 + √23 – 3 7 If we continue...
aeccfba51ccc2d9fa931f6e0b8827a245cef2777
gcd0318/pe
/l3/pe62.py
2,592
3.921875
4
""" The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube. Find the smallest cube for which exactly five permutations of its digits are cube. """ import m...
b91586f40fb66a606c2d1241169ad3fdc33f2502
gcd0318/pe
/l5/pe123.py
1,397
3.515625
4
""" Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and let r be the remainder when (pn−1)n + (pn+1)n is divided by pn2. For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25. The least value of n for which the remainder first exceeds 109 is 7037. Find the least value of n for which the remainder first exceeds...
9010ea2d997ec82fcd62f887802e1dc6f599f70f
edward408/bicycleproject
/bikeclasses.py
1,717
4.25
4
#Modeling the bicycle industry #Classes layout #Object-oriented programming (OOP) is a programming paradigm that uses objects and their interactions to design applications and computer programs. #Methods are essential in encapsulation concept of the OOP paradigm class Bicycle(object): def __init__(self,model,weight...
1c5cdd7c739227b75af1d04a5f638f4986e80190
pescenck/Loan-Calculator
/creditcalc_commented.py
10,627
4.25
4
'''This code will accept inputs from the Windows Command Line Interface (cp) and utilize those imputs towards calculating different types of loan payments. There are two main loan repayment types that this code can calculate results for: annuity loans and differenciated payment loans. The user will input values as pa...
a42bdc5047de555fe19df13bbd7603697aac8541
jonfairbanks/scripts
/rename-files/rename-files.py
1,857
3.734375
4
# Bulk Rename Images in Directory # # Req: Python 3.x # # Usage: `python3 rename-files.py` import os, sys import readline import time readline.parse_and_bind("tab: complete") def main(): temp = os.system("clear") cwd = os.getcwd() indir = input("Directory to Rename (" + cwd + "): ") outdir = input...
c32587ed6d4c2b363eec8da9096079c6a58feff8
elad123456/EladProject
/first_package/test_lula'a3.py
424
4.09375
4
import random bool=False num=random.randrange(1, 9) a=int(input("guess the number: ")) while bool==False: if a==num: bool=True print("congradulation!!!!!!!!!!!!!!!!!!!!!!!!") else: if a<num: print("bigger") a = int(input("guess the number: ")) else: ...
171b35341056bc5503bf816a5923788df8559e66
annamichalovova/Python
/easy_unpack/Easy unpact.py
136
3.6875
4
def easy_unpack(elements: tuple) -> tuple: return elements[0],elements[2],elements[-2] print(easy_unpack((1, 2, 3, 4, 5, 6, 7, 9)))
eefe1217912f4a9fc9b799e031698cbb425e699a
DanielFord11/python-challenge
/python-challenge/PyBank/main.py
2,183
3.78125
4
import csv import os TotalEarnings = 0 GreatestIncrease = 0 GreatestDecrease = 0 MonthList = [] ProfitList = [] ChangeList = [] input_file = os.path.join("Resources","budget_data.csv") output_file = os.path.join("Analysis","report.txt") data = open(input_file) reader = csv.reader(data) next (reader, None) earnings...
408e927849c8fd823b03b7cc8fe7d388a2e4e714
Grayson-choi/TIL
/python/etc/emample1.py
593
3.703125
4
def rock_paper_scissors(user1, user2): if user1 == user2: return "Draw" elif user1 == "가위": if user2 == "바위": return "Lose" else: return "Win" elif user1 == "바위": if user2 == "보": return "Lose" else: return "Win" eli...
9880c91fa2b9bde84e67ac58dff2819c1665891f
Grayson-choi/TIL
/python/OOP/OOP_practice.py
249
3.53125
4
class User: def __init__(self, name, email): print(self) print(name) print(email) def say_my_name(self): print(self.name) User("Yoonsoo", "yoonsoo@codeit.kr") u1 = User() u1.name = "Yoonsoo" u1.email = "YYY@codeit.kr"
73cfaab0a8470797d890c56b5b8c91f87d915876
Grayson-choi/TIL
/python/Algorithm/merge_sort.py
774
3.984375
4
#리스트를 반으로 나눈다. # 왼쪽과 오른쪽을 정렬한다. def merge(list1, list2): # 코드를 작성하세요. index_a = 0 index_b = 0 list = [] while index_a < len(list1) and index_b < len(list2): if list1[index_a] > list2[index_b]: list.append(list2[index_b]) index_b += 1 else: list.a...
5c79caaa22f8f47f29ceefbf50bf90a2ebc81bdd
Grayson-choi/TIL
/python/practice/lottery.py
1,810
3.546875
4
from random import randint # 무작위로 정렬된 1 - 45 사이의 숫자 여섯개 뽑기 def generate_numbers(): number = [] while len(number) < 6: random_number = randint(1, 45) if random_number in number: continue else: number.append(random_number) number.sort() return number # ...
1628d322c778d7a7e389be6f539d01032619c55c
Allah-The-Dev/python_playground
/set_add.py
147
3.5625
4
no_of_stamp=int(input()) set_of_countries=set() for _ in range(no_of_stamp): set_of_countries.add(input().lower()) print(len(set_of_countries))
a98394ddf3513f6de5de777bd7dfbc1aea5298bd
Allah-The-Dev/python_playground
/merge_the_tool.py
426
3.6875
4
def merge_the_tools(string, k): for i in range(0,len(string),3): list_of_char=list(string[i:i+3]) #removing duplicate keys from a list #using dictionary keys string_to_print=''.join(list(dict.fromkeys(list_of_char))) print(dict.fromkeys(list_of_char)) print(string_...
79ce75f93562680859aa10b83ef9c3d2605df246
michaellu4527/tkinter_exercises
/Ex_Files_Python_Tkinter/Exercise Files/Ch03/02_button.py
1,040
3.8125
4
#!/usr/bin/python3 # button.py by Barron Stone # This is an exercise file from Python GUI Development with Tkinter on lynda.com from tkinter import * from tkinter import ttk root = Tk() button = ttk.Button(root, text = "Click Me") # Creating button with text "Click ME" button.pack() def callback(): #...
2a9952ef3c0d6be0ed61eacedc6a0e99b6db7b7a
michaellu4527/tkinter_exercises
/Ex_Files_Python_Tkinter/Exercise Files/Ch06/02_grid.py
910
3.890625
4
#!/usr/bin/python3 # grid.py by Barron Stone # This is an exercise file from Python GUI Development with Tkinter on lynda.com from tkinter import * from tkinter import ttk root = Tk() # Rows/columns start at 0 then go down/right on the grid ttk.Label(root, text='Yellow', background='yellow').grid(row=0, column=2, ro...
34dfeb18830c74df2a61b6efffe19d8ac4588130
sudhasr/Competitive-Coding-5
/validSudoku.py
2,322
3.90625
4
#Accepted on Leetcode #Time complexity - O(N) as we are visiting every element #Space complexity - O(N) for boolean array class Solution(object): def isValidSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ #Edge Case if board == None ...
30d606984007827e06b1afec7fc812a66e1a79b3
DPF0190/intro-programming
/assignment_6/random_walk.py
1,408
3.8125
4
import random def get_random_direction(): direction = " " probability = random.random() if probability < 0.25: direction = "west" elif probability < 0.5: direction = "north" elif probability < 0.75: direction = "south" else: direction = "east" return direction print(get_rando...
3ce466ec8216bdbb9104aa716ef89297b0bdaa6e
Rejurhf/PycharmProjects
/Navier-Stokes/steps/burgersequation1d.py
2,647
3.640625
4
import numpy as np from matplotlib import pyplot as plt import sympy class BurgersEquation1D: """ Burgers' Equation 1D """ iteration_number = 0 def __init__(self): print("Init Burgers' Equation 1D") def run_simulation(self, _grid_points=101, _grid_length=2, _nt=150, _nu=.07): ...
1e1d88acd4c20de6e3ea514fa10ae38b0eded58f
sytsao/TQC-web-data-capture-and-analysis-Python3
/TQC-web-crawler-and-analysis-Python3/第4章/4-1/PYD401-2.py
349
3.796875
4
# -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt x = np.linspace(-2*np.pi, 2*np.pi, 200) y = np.sin(x) plt.title("My lovely sin function") plt.xlabel('x-axes') plt.ylabel('values') plt.xlim(-6,6) plt.ylim(-1.2,1.2) plt.plot(x, y, lw=3, label='$\sin$') plt.plot(x, np.cos(x), lw=3, label='$\c...
c6270a782361c76762db57cb6f34cf8d975b8254
sytsao/TQC-web-data-capture-and-analysis-Python3
/TQC-web-crawler-and-analysis-Python3/第3章/習題/PYA03範301.py
767
3.625
4
# -*- coding: utf-8 -*- import pandas as pd datas = [[75,62,85,73,60], [91,53,56,63,65], [71,88,51,69,87],[69,53,87,74,70] ] indexs = ["小林", "小黃", "小陳", "小美"] columns = ["國語", "數學", "英文", "自然", "社會"] df = pd.DataFrame(datas, columns=columns, index=indexs) print('行標題為科目,列題標為個人的所有學生成績') print(df) print() print('後二位的...
1a0e961e3f8e28f35d7f7b7ae7da23423c2a9d15
anapereda/Election-Analysis
/pyton_practice.py
207
3.640625
4
counties = ["Arapahoe","Denver","Jefferson"] if counties[1] == 'Denver': print(counties[1]) terminal= ["kite", "surf"] print("hello world") for counties in range(len(counties)): print (["counties"])
477c3a5c1e2cda728b1ecb3cf0cfbbaaa01d9250
sugus86/python_study_2018
/Python_高级知识/列表推导式1.py
1,021
3.921875
4
#------------------------------------------------------------------------------- # Name: 模块1 # Purpose: # # Author: Administrator # # Created: 25/10/2018 # Copyright: (c) Administrator 2018 # Licence: <your licence> #------------------------------------------------------------------------------- ...
1323049081a944e8a939146a0530a4de550f69c0
sugus86/python_study_2018
/Python_高级知识/学习实例/Python使字典变成有序的.py
420
3.859375
4
#字典本身是无序的,当需要有序的使用字典时,可以借助collections模块中的OrderedDict类。 #在迭代操作是它会保持元素被插入时的顺序: #例如: import json from collections import OrderedDict dic_normal = {'a': 1, 'b': 2, 'c': 3} dic_order = OrderedDict() dic_order['a'] = 1 dic_order['b'] = 2 dic_order['c'] = 3 print (json.dumps(dic_normal)) print (json.dumps(dic_order))
d7a24c747fdedf537515c39e1edec37850356776
kravchukpetr/Python
/Stepic/Stepic Course - Программирование на Python/TestScript8.py
286
3.828125
4
a=int(input()) b=int(input()) c=int(input()) if a>b: maxVal = a minVal = b else: maxVal = b minVal = a if c > maxVal: srVal = maxVal maxVal = c elif c < minVal: srVal = minVal minVal = c else: srVal = c print(maxVal) print(minVal) print(srVal)
8f97b42aa0c6803a26b2fadef2c61367a0b970e1
kravchukpetr/Python
/Stepic/Stepic Course - Программирование на Python/TestScript9.py
232
3.578125
4
n=int(input()) s = n % 100 d = n % 10 z = n // 10 % 10 if z!=1 and d==1: print (n,"программист") elif z!=1 and d>=2 and d<=4 : print (n,"программиста") else: print (n,"программистов")
e047af32eff5edff8ab7e5f0fcf3203287101100
pratik-iiitkalyani/Data_Structure_and_Algo-Python-
/interview_problem/convertStringToIntAndSort.py
245
3.984375
4
# list -> ['5', '4', '3', '1', '2'] # sort # Noramal Method l = ['5', '4', '3', '1', '2'] new_list = [] for i in l: new_list.append(int(i)) new_list.sort() print(new_list) # using lambda print(sorted(l, key=lambda i: int(i)))
93fe3bdc09d05d492d4752b3d3300120e9c6b902
pratik-iiitkalyani/Data_Structure_and_Algo-Python-
/interview_problem/reverse_sentance.py
576
4.375
4
# Write a program to print the words of a string in reverse order. # Sample Test Cases: # INPUT: Hi I am example for this program # OUTPUT: Program this for example am I Hi def revrseSentanse(str): # spilt all the word present in the sentance sentance = str.split(" ") # the first letter of last word of sen...
35ad4a9b2a6159766b07a5f7779726aae3511d75
pratik-iiitkalyani/Data_Structure_and_Algo-Python-
/string/reverse_using_stack.py
496
3.96875
4
def createStack(): stack = [] return stack def push(stack, item): stack.append(item) def isEmpty(stack): if len(stack) == 0: return true def pop(stack): if isEmpty(stack): return return stack.pop() def reverse(string): n = len(string) stack = createStack() for i...
486ec7b02b2e894d7c767d5ad687d8b9431c6282
pratik-iiitkalyani/Data_Structure_and_Algo-Python-
/interview_problem/binary_num.py
198
4.03125
4
# num = int(input("number:")) # print(bin(num)) def DecimaltoBinary(num): if num>1: DecimaltoBinary(num//2) print(num%2,end = "") x = int(input("number:")) print(DecimaltoBinary(x))
6d6c68769059fc9e98f45d934c014ca7d1d5c47d
bretuobay/fileutils
/exercises5.py
684
4.1875
4
''' Write a function translate() that will translate a text into "rövarspråket" (Swedish for "robber's language"). That is, double every consonant and place an occurrence of "o" in between. For example, translate("this is fun") should return the string "tothohisos isos fofunon". ''' def translate(str_input): vow...
d857a6d39e3b537539c9e5f74e45a11c78d1545f
bretuobay/fileutils
/exercises7.py
440
4.59375
5
''' Define a function reverse() that computes the reversal of a string. For example, reverse("I am testing") should return the string "gnitset ma I". ''' # this works by slicing from the end #This is extended slice syntax. It works by doing [begin:end:step] - by leaving begin and end off and specifying ...
dae27379e51e88f52d0cc08859b3c9486356acea
AndyTian-Devops/PythonSample
/PhoneBook.py
950
4.28125
4
#简单数据库 #使用人名作为键的字典,每个人用另一个字典表示,其中phone和addr分别表示他们的电话号码和地址 people = { 'Alice':{ 'phone' : '2341', 'addr' : 'Foo drive 23' }, 'Beth':{ 'phone' : '9102', 'addr' : 'Bar street 42' }, 'Cecil':{ 'phone' : '3158', 'addr' : 'Baz avenue 90' ...
edcf0bb838306bb64df8f9629e7f91f65b03a0a2
Bharath21319/bharath
/union of strings.py
266
3.953125
4
str1=input() y=str1 str2=input() x=str1 for i in str2: if i not in x: str1+=i print("Union is",end=" ") print(str1) z=y res="" for i in y: if i in str2 and not i in res: res+=i print("Intersection is ",end=" ") print(res)
e2a160e8f2aa5fee50a6c77c3e5191657ded7e75
JaishaAsad/practice
/list.py
172
3.53125
4
lst =[1,"pakistan", True] #print (len(lst)) print (lst[2]) #removed_val = lst.pop(0) print(lst) lst.append("jaish") print(lst) lst.insert(0,"jaish") print (lst)
dd63f3434fa7a81047400dc0f38e466fdf9122a8
JaishaAsad/practice
/ResultCalculator.py
549
3.84375
4
print ("please enter your english marks:") englishmarks = int(input()) print ("please enter your urdu marks:") urdumarks = int(input()) print ("please enter your maths marks:") mathsmarks = int(input()) print ("please enter your criminal justice marks:") CJmarks = int(input()) print ("please enter your islamia...
63ab96b774c90daf14bf4ff8088f6386804cbe9c
JaishaAsad/practice
/jupyter.py
1,186
3.5
4
class Human(): def __init__(self, name, father_name, cnic): self.name = name self.father_name= father_name self.cnic = cnic def printer(self): print('this is a human') class Student(Human): def __init__(self, name, father_name, cnic , rollnumber): ...
6e79a1ef46c66aa355e7750feb77c559d5ed08f2
jbardet/higgs_boson
/project1/scripts/implementations.py
4,042
3.71875
4
import numpy as np def sigmoid(x): return 1 / (1 + np.exp(-x)) def gradient_logistic(tx, y, w): """Computes the gradient for Logistic Regression""" """INPUTS : vector with data (tx, y), the weights w""" """OUTPUTS : the gradient""" h = sigmoid(tx.dot(w)) return np.matmul(tx.T, (h - y)) def lo...
35b40ee37d55f57f862dd0d76bdf73ce42bf1c92
rozeachus/Python.py
/NumberGuess.py
1,035
4.40625
4
""" This program will allow a user to guess a number that the dice will roll. If they guess higher than the dice, they'll get a message to tell them they've won. If its lower than the dice roll, they'll lose. """ from random import randint from time import sleep def get_user_guess(): guess = int(input("Guess a ...
eac7a94790581f8e36601ff6cc09d36aaf0eccc8
luis95gr/mdh-python01-solutions
/Cod_d5/classhard2.py
1,345
3.546875
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 29 14:55:10 2019 @author: Luis """ class Member(): def __init__(self, name, haircolor, birthdate, coding_level="beginner", lines_of_code=None, num_lines_coded=0): self.name = name self.haircolor = haircolor self.birthdate = birthdate ...
e48d3a6156013fcea2a50ad2eddf5f13815baedf
luis95gr/mdh-python01-solutions
/Cod_d1/prueba5.py
208
4.28125
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 22 17:11:29 2019 @author: luis9 """ import math as mt my_num = int(input('Enter a number to find its factorial: ')) print("Factorial: " , mt.factorial(my_num))
dfcd1c3ba7a2a4c2631682c44a327b3a0fc2c741
luis95gr/mdh-python01-solutions
/Cod_d2/prueba2_dia2.py
282
3.71875
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 23 12:01:38 2019 @author: luis9 """ word = str(input("Enter a word: ")).casefold() lett = str(input("Enter a letter: ")).casefold() times=0 for char in word: if char == lett: times+=1 print('Times: {0}'.format(times))
8dd4777c7214dc77c27cc482deda060271273c70
uthambathoju/30days_leetcode_april_challenge
/perform_strings.py
884
3.75
4
class Solution: def stringShift(self, s, shift): move_left = 0 length_of_string = len(s) for direction , amount in shift: print('dir , amt :: ' , direction , amount) if direction == 0: move_left = move_left + amount print('dir -...
9d445e875905b2cb4482071e1b31709235ea6cfa
cnis444/BetaGo
/go.py
8,527
3.609375
4
import numpy as np BLACK = 1 WHITE = -1 EMPTY = 0 BORDER = 2 class InvalideMoveException(Exception) : def __init__(self, winner, message): self.winner = winner self.message = message def __str__(self): winner = "blanc." if self.winner == WHITE else "noire." return "Les r...