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
48f0f9b1f8dec60acc9b4e586c9618a24ccb241e
garciacello/Python-Exercises
/Ex005.py
113
3.984375
4
N=int(input('Digite um numero:')) print('O antecessor é {}'. format(N-1)) print('O sucessor é {}'. format(N+1))
e4e804d89714e04a4d56fb9a7bd296be2fb40bca
garciacello/Python-Exercises
/Ex003.py
138
3.859375
4
N1=int(input('Digite um valor: ')) N2=int(input('Digite outro valor: ')) S= N1 + N2 print('A soma entre {} e {} é {}'.format(N1, N2, S))
afef38879fd1dd8eada8abb37cda5fd162ee68a4
CBNU-AILAB/n3ml-python
/Bohte2002.py
4,125
3.640625
4
""" Bohte2002 example. Now, spikeprop algorithm can be applied to only feed-forward neural network. It means that when we construct neural network only consider a sequential structure. We achieve this using nn.Sequential. """ import argparse import torch import n3ml.model import n3ml.data import n3ml...
532593abb84e86695df761cd1a0892efc7cf96fd
osumorodgers/IMDB_scraper
/scraper.py
17,264
3.515625
4
#!/usr/bin/env python # coding: utf-8 # # SCRAPING IMDB SITE # In[43]: from bs4 import BeautifulSoup from requests import get url = 'https://www.imdb.com/search/title?release_date=2017&sort=num_votes,desc&page=1' response = get(url) print(response.text[:500]) # In[44]: from bs4 import BeautifulSoup html_soup = ...
af4029b17a6ccf72c51d5ef293dbd14ed4af5bd9
vibhore-vg/Learning-Python
/Python/Dictionary/Advanced/SortDict.py
319
3.8125
4
import operator x = {'a':5,'b':4,'c':3,'d':2,'e':1} print "Dictionary",x # data in dictionary is stored in random order sortValues = sorted(x.items(), key=operator.itemgetter(1)) print "Sorted data by value",sortValues sortKeys = sorted(x.items(), key=operator.itemgetter(0)) print "Sorted data by key",sortKeys
fafb3755b0d5809e1d45b04ee6523dfbd96402ce
vibhore-vg/Learning-Python
/Python/List/Basic/list.py
659
3.828125
4
list1=["iit's","niit's","bits","vit"] for i in list: print i listnos=[1,2,3,4] #concatenation of two lists listfinal=list1+listnos #indexing listfinal[3] #Slicing listfinal[3:] ['vit', 1, 2, 3, 4] #calculating length len(listfinal) #nesting of two list listnest=[list1,listnos] ###m...
49b3857ebdaac0c5a7c86f4fd92debfcec5f66ff
vibhore-vg/Learning-Python
/advancedExamples/dict_3.py
544
4.25
4
#Python that counts letter frequencies # The first three letters are repeated. letters = "abcabcdefghi" frequencies = {} for c in letters: # If no key exists, get returns the value 0. # ... We then add one to increase the frequency. # ... So we start at 1 and progress to 2 and then 3. freque...
4a8cf1a7269357530bcda2a58e3c651f8b25e011
AutumnColeman/python_functions
/sin2.py
266
3.8125
4
# Write a function f(x) that returns the sin of x using arange. import matplotlib.pyplot as plot import math from numpy import arange def f(x): return math.sin(x) xs = arange(-5, 6, 0.1) ys = [] for x in xs: ys.append(f(x)) plot.plot(xs, ys) plot.show()
827d16eafdd4f252eae58dd02931234d72ec2d52
JarredStanford/Intro-Python-I
/src/14_cal.py
1,249
4.46875
4
""" The Python standard library's 'calendar' module allows you to render a calendar to your terminal. https://docs.python.org/3.6/library/calendar.html Write a program that accepts user input of the form `14_cal.py month [year]` and does the following: - If the user doesn't specify any input, your program should ...
1627497a21da5d0157c8fde900e4166f78994e02
ElenaBonan/Python_projects
/Food_recognition/Custom_functions/plots.py
3,741
3.546875
4
import matplotlib.pyplot as plt def plot_acc_loss(history): """ Plot the loss and accuray for the training and validation""" # Get the values from the model history acc = history['acc'] val_acc = history['val_acc'] loss = history['loss'] val_loss = history['val_loss'] epochs = range(1, len(...
567496a8ee5849b1c0d80312f57067b4342d7050
Roberick313/Workshop
/project_4.py
504
4.21875
4
###### Fibonacci number def fibonacci(number): '''This function will calculate the fibonacci of the\n \rEntery parameter''' b = 0 result = '' c = 1 for _ in range(1,number+1): while b < number: result += str(b) + "," b = b+c ...
5a980930c33e53cc84087a556fdfa829896f59a0
Roberick313/Workshop
/project_16.py
994
4.03125
4
##### calculate the water bill for each family in an apartment Apartment = {1:5,2:3,3:6,4:2,5:1,6:4,7:3,8:2} cost = int(input("enter the cost of water use of the apartment: ")) ppl = 0 for first_for in range(1,9): p = Apartment[first_for] ppl += p EMC = cost / ppl for second_for in range(1,9...
0926efcd0f0298ec703fe45f63acf4921b6af2e5
Roberick313/Workshop
/project_10.py
1,013
4.09375
4
####### finding The Greatest and The least Number with For and while loop a = [20,10,60,45,100,35,78,37,71,53,8.53,47,23.4,74,89,345,123,68,72.34,34.312] MinNumber = a[0] MaxNumber = a[0] for FirstVal in a: if MaxNumber < FirstVal: MaxNumber = FirstVal elif Mi...
fd8bd5a8ba087bc5f94e65447fb7b68214eb8206
cvbuchem/numerical_recipes
/a1/old/Numerical_recipes1_1.py
669
4.0625
4
import numpy as np # Exercise 1 from tutorial 1 def average(l): return sum(l)/len(l) def std_dev(l): return np.std(l) l = list(range(1,101)) print('Average:',average(l)) print('Std. dev:',std_dev(l)) l_odd = l[0::2] l_even = l[1::3] print('Average for odd:',average(l_odd)) print('Std. dev for odd:',std_dev(l_...
764588a896a8a3bf25e952d3126508d83dedd1b8
biueo/SortInPython
/selectSort.py
569
3.84375
4
def selectSort(L): l = len(L) if l <=1:return L minvalue = None for i in range(l): minvalue = L[i] minindex = i for j in range(i,l): if L[j]< minvalue: minvalue = L[j] minindex = j L[i],L[minindex] = L[minindex],L[i] return ...
295bf4048a3960e7de1daf9460d7f31b3a02dbd7
wangxiaolinlin/python
/yinhang.py
961
3.546875
4
#银行取钱 kahao = 10086 mima = 10086 i = 0 while i<3: i+=1 kh =int(input("请输入您的银行卡号:")) mm =int(input("请输入您的银行卡密码,请注意周边环境:")) if kh == kahao and mm == mima: print("输入正确,请选择以下您需要的服务") moshi =int(input("1存钱 2取钱 3查看余额")) if moshi == 1: money = 1000 cunqian =int(input("请输入你要存的金额")) if cunqian > 0: print(...
3bd32f6b04193f6f2ecbace11d25b529ead24124
wangxiaolinlin/python
/3.py
555
3.5625
4
zhanghao =int(input("欢迎来到王者荣耀,请输入账号:")) mima =int(input("请输入密码:")) zh = 123 mm = 123 i = 1 k = 0 if zhanghao == zh and mima == mm: print("登录成功") yx = input("请选择英雄范围1.adc 2.坦克 3.fashi") if yx == "1": print("鲁班") if yx == "2": print("程咬金") if yx == "3": print("王昭君") if zhanghao != zh or mima != mm: while i...
bb385421ae1f5c28700813251fe5c64a82081462
Karthik-Kashyap/machine-learning
/week5-Machine learning/math of intelligence/SVM.py
481
3.5625
4
import numpy as np from matplotlib import pyplot as plt import tkinter #input form={x value,y value,bias term} x=np.array([ [-2,4,-1], [4,1,-1], [1,6,-1], [2,4,-1], [6,2,-1], ]) #output y=np.array([-1,-1,1,1,1]) for d, sample in enumerate(x): if d<2:#plot negative samples plt.scatter(sample[0],sample[1],s...
bbed7305b6dc305dde17f33fb5a34621e3419aa4
gaurav19gupta/LetsUpgrade-Python-b7
/Assignment1-Day4.py
418
3.765625
4
#!/usr/bin/env python # coding: utf-8 # # Armstrong Number # # In[6]: lower = 1042000 upper = 702648265 for num in range(lower,upper+1): order = len(str(num)) sum = 0 temp = num while temp>0: digit = temp % 10 sum += digit ** order temp //= 10 if num == sum: ...
ad9a10fa9bdfd087d2143cd1375d02ee5d3e8c9a
patrickmgebhard/Learn_python_the_hard_way
/Ex_14.py
727
3.765625
4
from sys import argv #man muss also neben dem Namen des Skripts noch seinen eigenen Namen übergeben script, user_name = argv prompt = '> ' # das %s im String sagt mit welchem Format die Variable am Ende eingefügt werden soll # man nennt das python formatter print "Hi %s, I'm the %s script." % (user_name, script) prin...
7fcc76b10f5fb4cc880f36aa481e0f5497d85691
gertadam/P2-simple-image-classifier
/dlnd_image_classification.py
37,716
3.640625
4
# coding: utf-8 # # Image Classification # In this project, you'll classify images from the [CIFAR-10 dataset](https://www.cs.toronto.edu/~kriz/cifar.html). The dataset consists of airplanes, dogs, cats, and other objects. You'll preprocess the images, then train a convolutional neural network on all the samples. Th...
5c5db1f3720a3b18d9e724c9f63d9a25bf66881c
handyhan/isc-work
/python/tuples.py
463
4.03125
4
t = (1,) print t[-1] nums=tuple(range(100,201)) print nums[0],nums[-1] mylist=[23,"hi",2.4e-10] for (count,item) in enumerate(mylist): print count,item first, middle, last = mylist # tuple on RHS only exists as tuple on this like! is a smart way to unpack sing a,b,c is interprated as a tuple, once line is lef...
9a051209e7b31261aa0188c645a01b92f55f0fff
parknkim/Chawon
/combination.py
1,856
3.671875
4
"https://www.quora.com/Is-there-a-combination-function-for-lists-in-Python" import random as rd #a = range(0,8145061) # 45 combination 6 #a = range(0,10) # 45 combination 6 import operator as op import math ''' def ncr(n, r): r = min(r, n-r) if r == 0: return 1 numer = reduce(op.mul, xrange(n, n-r...
c140273397379bac82ef84de5cc6e2248122aa07
omprakash-nd/om
/BICA.py
713
3.671875
4
class Employee: empCount = 0 def __init__(self, name, dept): self.name = name self.dept = dept Employee.empCount += 1 def displayCount(self): print "Total Employee %d\n" %Employee.empCount def displayEmployee(self): print "Name:" , self.name ,"Department: ", s...
670e7a7be784958acc6d1b6121d97c57f3314c00
drewtuley/teasers
/the_post_office.py
1,244
3.875
4
# After a local Post Office burglary, five suspects were being interviewed. # Below is a summary of their statements. # Police know that each of them told the truth in one of their statements and lied in the other. # From this information can you tell who committed the crime? Alan = 1 Brian = 2 Charles = 3 Derek = 4 E...
51ac8d5732d89a8e91b6a8d4ca53965bba9cf955
Ubaid7867/Assignmentletsupgrade
/Assignment Day2/DAY2.py
359
3.90625
4
lis = [1, 10, 50.56, "Hello", 'zero', 7] list = ['car', 'bike', 'sleep', 'wake', 'eat'] print(lis) #list 1st function lis.append(70) print(lis) #list 2nd function lis.insert(3,"my name") print(lis) #list 3rd function lis.pop(0) print(lis) #list 4th function lis.extend(list) print(lis) #list 5th...
d16295031617f6fc5f4a4815a9f0165b629eb65f
aman-s23/airline_sentiment
/feature.py
597
3.625
4
import nltk import re from nltk.stem import WordNetLemmatizer #from nltk.corpus import stopwords from nltk.corpus import stopwords def remove_punctuation_stopwords_lemma(sentence): filter_sentence = '' lemmatizer=WordNetLemmatizer() stop_words = stopwords.words('english') sentence = re.sub(...
c043bcef1d2a3d650e960adb80f73f6e1597b82d
johnvtan/advent-of-code-2018
/6/solution.py
1,308
3.5625
4
#!/usr/bin/env python3 with open('input') as f: content = f.readlines() def get_coords(line): coords = list(map(lambda x: x.strip(), line.split(','))) return int(coords[0]), int(coords[1]) def manhattan_distance(p1, p2): return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1]) coords = [(get_coords(line)) for...
be8bebb0e607ac9b3ca7d4b0a62117231c367d97
giuseppe-dandrea/PossibleNumberOfPies-dailyprogrammer
/pies.py
2,264
3.734375
4
# https://www.reddit.com/r/dailyprogrammer/comments/87rz8c/20180328_challenge_355_intermediate_possible/ class Pies: pumpkinrecipe = [1, 3, 4, 3] applerecipe = [1, 4, 3, 2] def __init__(self, pumpkin, apple, egg, milk, sugar): self.pumpkin = pumpkin self.apple = apple self.egg = e...
68ee5fd73be5aa42006b35b597ac69004c567fce
thejmdw/python-server
/locations/request.py
1,103
3.78125
4
LOCATIONS = [ { "id": 1, "name": "Nashville North", "address": "8422 Johnson Pike" }, { "id": 2, "name": "Nashville South", "address": "209 Emory Drive" }, { "name": "Nashville Kennels East", "address": "702 S. 13th Street", "id": 3 }, { ...
127c25fe4d2f07fe5c087617a72c77314f0af972
ZachGoooolik/PPC---Book-1
/Challenge 5.py
331
4.03125
4
#Challenge 5 #Created by: Zach Golik name=input('What is your first name? ') surname=input("What is your surname? ") print(surname, name, surname, name, surname, name) #Completed successfully? Yes #Did you have any errors? Yes, logic errors #How did you solve them? I made the program more simple #What did you find diff...
bff8f321bfd02e8d15d2b41469c3fb56b328738a
ZachGoooolik/PPC---Book-1
/Challenge 13.py
286
3.75
4
#Challenge 13 #Created by: Zach Golik import random import time length=0 while length != 30: print (random.randint(0,100)) time.sleep(3) length=length+3 #Completed successfully? Yes #Did you have any errors? No #How did you solve them? N/A #What did you find difficult? Nothing
a25a9235c4dd984173403b8e210dd1571f5e6ed0
aernesto/meaning_project
/two_word_game.py
6,495
3.90625
4
# -*- coding: utf-8 -*- import numpy as np MAX_FOOD_PLAYER = 4 MAX_WATER_PLAYER = 4 MAX_WATER_PLANT = 4 P_WATER = 0.5 INTRO = ':) :) :) Welcome to the 2-word language game!!! :) :) :)' EXIT = 'exitting game' RULES = f""" you must take care of yourself and of your plant\n \nto survive, your food and water reserves must ...
16bb8fff020149610c0dd479d3b868b7f0fb86f2
Sekou-teck/Worksapce
/last_recursivite.py
408
3.609375
4
def add(a): a += 1 print(a) if a < 15: add(a) add(2) #TP : une fonction pour calculer le nombre de voyelles dans un mots # - définir une fonction get_vowels_numbers(mot) # - créer un compteur de voyelles # - pour chaque lettre du mot, il faut vérifier s'il s'agit d'un voyelle # - SI c'est le cas...
e8e04f10198f5cad029549c8baa9c4f71e229b5f
Sekou-teck/Worksapce
/continue.py
326
3.828125
4
for i in range(4): print("debut iteration", i) print("bonjour") if i < 2: continue print("fin iteration", i) print("apres la boucle") # Boucles for i in range(10): print("debut iteration", i) print("bonjour") if i == 2: break print("fin iteration", i) print("apres la bo...
c6ead19db12ad137036599239bcfd0d2c61fdb2e
oryband/code-playground
/sliding-window/medium-truncate-str-by-k.py
2,173
4.15625
4
#/usr/bin/env python """ Given a string constructed from ascii chars and spaces, and a non-negative integer k, truncate the message to size k or less, while also stripping spaces such that the result must end with a word. also, words must not be truncated in the middle. either include whole words or non at all. example...
5ef17e75bae15b24bd45fb01287c0156fefbd96c
Earthcrusher/Blackbirds
/typeclasses/abilities.py
959
3.734375
4
""" The primary ability class. All abilities inherit from this. """ class Ability(): def __init__(self): self.key = "UndefinedAbility" self.name = "Undefined Ability" self._can_train = True self._costs_rubric = False self._levels = 10 self._cur_level = 0 self...
53a9e78ed96e9560da970f79f944cb395884e266
elvirr/Python-Snippets
/dummy_data.py
449
3.671875
4
from itertools import product def dummy_dataframe(columns, *args): """Generates a dataframe shell of all possible combinations available in the cross-section of multiple lists. Args: columns (list): column headers to use Returns: dataframe: dataframe of all combinations of the cross-secti...
4a9c1b5cf9beb9ff3721cff84b1982b03e59d4bc
ElinaBukhanov/my_projects
/system_for_analysis_and_calculating_of_investments/python_code/tickCompare.py
2,024
3.609375
4
""" tickCompare: This program gets from the user a period of time, a list of tickers and the index for comparison. The program will create a graph for a comparison. """ import pandas as pd import matplotlib.pyplot as plt import TickersProcess as tp import urllib.request try: b=input('Please enter a ...
945c7709e2ede8d155cd7a14fde4147a17a825c6
danieleldjarn/University-of-Iceland
/HBV401G_Throun_hugbunadar/Verkefni_3/E3/Nem5/pondukapall.py
1,261
3.78125
4
import random import string from msvcrt import getch class Card(object): suit_names = ["L", "T", "H", "S"] rank_names = [None, "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"] def __init__(self, suit=0, rank=2): self.suit = suit self.rank =...
cc1a30c0dcee00052f927e2dce241076bf6427cc
danieleldjarn/University-of-Iceland
/HBV401G_Throun_hugbunadar/Verkefni_2/pondukapall.py
6,105
3.53125
4
#!/usr/bin/python import sys import random # Used to shuffle the deck (randomize array) class CardTranslator: card_names = [ 'HA', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'H10', 'HG', 'HD', 'HK', 'SA', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10', 'SG', 'SD', 'SK', 'TA', '...
eecf53aefafa2b8cc6449db62b88423b440c3d5e
indrajithbandara/uri-questions
/uri_1192.py
227
3.78125
4
def op(a, sign, b): if(a == b): return a * b else: if(sign.isupper()): return b - a else: return a + b times = input() for i in range(times): word = raw_input() a,sign,b = word print op(int(a), sign, int(b))
47e4008ab4ce209b11004e6f2d48458d8f0695c0
abrow454/git_projects
/madLibsList.py
333
3.78125
4
def printRequest(request): for x in (request): input ("Give me a "+ x) return input #main print("Give us the following things for our Mad Lib!") request = ["adjective: " , "animal: " , "vehicle: " , "verb: " , "color: " , "noun: " , "1st food: " , "2nd food: " , "person: " , "saying: "] print(printRequ...
8f1ed4bd7f36ddd5bf7da9196fa9195798724072
wittnils/numerik0
/nichtNumerik0/euler (1).py
1,983
3.625
4
''' Dies ist ein kleines Python-Programm zur numerischen Loesung von First-Order ODEs, d.h. von DGL mit y'=f(x,y) und y(x_0)=y_0. Dabei wird die sog. Eulermethode verwendet. Sie basiert auf dem Differentialquotienten aus der Analysis, der bekanntermassen die Abl. f'(x) def. als lim_{h -> 0} (1/h*(f(x+h)-f(x))) =: f...
b93ec088728b49d05c59bc5116da6bf9d2df62ba
mdasifullah09/python-practice
/inventory.py
579
3.6875
4
import time inventory={'rope':1,'torch':6,'gold coin':42,'dagger':1,'arrow':12} item_number=0 print('Inventory:') for i,v in inventory.items(): print(str(v), i) item_number=item_number+inventory.get(i,0) print('Total number of item:',item_number) stuff={'rope':1,'rope':4,'torch':6,'gold coin':42,'dagger':1,'arr...
c7e6ddb8630dc73de0cf35b197c5feb003e5be39
mdasifullah09/python-practice
/wcalc.py
305
3.859375
4
def calc(): print('Weekly loan calculator\n') l=int(input('Enter the amount of loan:')) r=float(input('Enter the interest rate(%):')) y=int(input('Enter the number of years:')) i=(r/5200) wp=i*l/((1-((1+i)**-(52*y)))) print('Your weekly payment will be: $',round(wp,2)) calc()
0807ac86bd993211c77683553dfb8776b3f88d90
mdasifullah09/python-practice
/sedefault.py
153
3.578125
4
#dic={'color':'black','friend':'three','versity':'aiub'} dic='I want peace' dic1={} for char in range(2,11): dic1.setdefault(dic,0) print(dic1)
e14f690d8abb6ae1090f01708cfd10dbecd8fe94
dewanshu/-Assignment-3
/Interpolate.py
3,614
3.734375
4
''' class Interpolate: def solve(self,L,M,method): if(method=="newton"): return (self.Newton(L,M)) else: return (self.Lagrange(L,M)) def Lagrange(self,L,M): from numpy import array from...
48e564f13dbc1755c39c51e93865e6fa01c8b1b0
ryanyu9/machine-learning-toolbox
/logit_hess.py
3,506
3.71875
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 12 23:11:09 2017 @author: ryanyu Define a class, used to solve Logistic Regression with L2 Regularization. It uses Newton-Conjugate-Gradient method by providing Hessian matrix. An example followed. """ import numpy as np from scipy.optimize import minimize from __future...
379a78d2bf1985a509601cd35ae386e32c55bcf8
torbval/nlp_data
/split_data.py
1,826
3.6875
4
import os import csv def split(_file_handler, _file_name, delimiter=',', row_limit=10000, output_path='.', keep_headers=True): """ Splits a CSV file into multiple pieces. A quick bastardization of the Python CSV library. Arguments: `row_limit`: The number of rows you want in each output file ...
4ee4ef6fafca49233b60d969af9c69a97e44b11c
Hadisaeed/Learning-Python
/Variables & Data Types/variables.py
496
3.734375
4
#What is variable? #variable are nothing but reserved memory location to store value. #Based on data type of a variable, the interpreter allocates memory and decide what can be stored in reserved memory 'you can store integers, decimal and characters in these variables' #A String Assigment message="Welcome To Python...
7cb2ab72bf187c005b638ecfe886069c4e6231e9
m-tkach/ProjectEuler
/[005] Smallest multiple/solution.py
191
3.765625
4
def gcd(x, y): while (x * y != 0): x, y = y, x % y return x + y def lcm(x, y): return x // gcd(x, y) * y res = 1 for x in range(1, 21): res = lcm(res, x) print(res)
34d41b808d9d67474c71beb9f0be783dae14952f
m-tkach/ProjectEuler
/[020] Factorial digit sum/main.py
130
3.609375
4
N = 100 def fact(x): if x < 2: return x return x * fact(x-1) ans = sum(int(c) for c in str(fact(N))) print(ans)
6057ee2cdb3b7856cd90435292622809069df51e
m-tkach/ProjectEuler
/[035] Circular primes/main.py
1,588
3.515625
4
N = 1000000 def search(space, v): l, r = 0, len(space) while l + 1 < r: mid = (l + r) // 2 if space[mid] > v: r = mid else: l = mid return l if space[l] == v else -1 def has_even_digit(x): n = x while n > 0: d = n % 10 ...
0102ef3e24de490226395f9abf4f3b194eb99fb8
KeianBarton/KBAutomateTheBoringStuffExamples
/ch7_regex_phone_number_extractor.py
1,602
3.65625
4
#! python3 """ ch7_regex_phone_number_extractor Program that searches the text in the clipboard for phone numbers and email addresses, and replaces them with just the phone numbers and e-mail addresses Keian Barton 10/01/2018 """ import pyperclip, re, sys # American phone numbers phone_regex = re.compile(r'''( ...
0aaa3807eea810c1c7380e616a246f87e2af796d
river-sneed/maze_for_coop
/maze_game_RiverSneed/maze_game_RiverSneed.py
20,452
3.578125
4
#MAZE #RIVER SNEED #Jan 12 2016 # Imports import pygame import intersects import random # Initialize game engine pygame.init() # Window WIDTH = 1000 HEIGHT = 800 SIZE = (WIDTH, HEIGHT) TITLE = "PEPE MAZE" screen = pygame.display.set_mode(SIZE) pygame.display.set_caption(TITLE) # Timer clo...
fb819bc9b469b787f9fde992ac2182e4391718b8
surfman-k/100DaysOfMLCode
/Day 7 - Handling Missing Values/Handling Missing Values.py
3,436
4.3125
4
# A 2 bedroom house wouldn't include an answer for How large is the third bedroom # Someone being surveyed may choose not to share their income # Python libraries represent missing numbers as nan which is short for "not a number". You can detect which cells have missing values, and then count how many there are in eac...
ec238f678941e428db05721a74b110ac1ad2bf32
magicmonty/bash-git-prompt
/gitstatus.py
4,857
3.5
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- """This module defines a Print function to use with python 2.x or 3.x., so we can use the prompt with older versions of Python too It's interface is that of python 3.0's print. See http://docs.python.org/3.0/library/functions.html?highlight=print#print Shamelessly ripped...
584e1f1e8df9d3f6dc303fa2433df02e394a3909
ntduong/FunApps
/FindMeWord/find_me_word.py
4,390
3.90625
4
""" Created on 2014/05/25 @Author: Duong Nguyen @Email: ntduong268@gmail.com @Problem: Given an English word, find the most probable previous word. E.g: Find the top 10 most probable adjectives that might come right before "book" Here is the answer from my program along with their scores. ...
cf77b96341ff986dd35b1c5f3100adbb5752bfe1
iamAdarshh/Data-Structures
/Stack.py
1,317
4.21875
4
#Simple Stack. class EmptyStackError(Exception): pass class Stack: def __init__(self): self.items = [] def is_empty(self): return self.items == [] def size(self): return(len(self.items)) def push(self, item): self.items.append(item) def pop...
2c7bb1d9e25306149e166a3d3eb5f35971d35f30
kkundann/Algorithm
/BasicPython.py
677
4.375
4
# developed by van Rossum in 1991 # difference between Python 2 and python 3 # python 2:- print statement is not print_function # python 3: has function and invoked with parantheses # print ("Hello, World.") # # print(type('default string ')) # print(type(b'string with b ')) # # for i in range(0,5): # print(i) #py...
9d182bae928d849b1bd72de1fb443d8d59a0dd5e
topatlant/AdventOfCode-python
/common/itertools.py
584
3.875
4
from itertools import tee def pairwise(iterable): """s -> (s0,s1), (s1,s2), (s2, s3), ...""" a, b = tee(iterable) next(b, None) return zip(a, b) def triplewise(iterable): """Return overlapping triplets from an iterable""" # triplewise('ABCDEFG') -> ABC BCD CDE DEF EFG for (a, _), (b, c) ...
2b2c5573cbb863b51ad84e0b1dfd91ec32cf8931
topatlant/AdventOfCode-python
/y2022/day02.py
1,725
3.6875
4
def get_input(): with open("inputs/02.txt") as f: return f.readlines() def main(): puzzle = get_input() print("Part 1:", part1(puzzle)) print("Part 2:", part2(puzzle)) def part1(puzzle): score = sum(get_score_part1(line) for line in puzzle) return score def part2(puzzle): score...
eb8d39d10a7055d270bdfa929b7af9d449ec147f
topatlant/AdventOfCode-python
/y2015/day03.py
882
3.78125
4
def get_input(): with open("inputs/03.txt") as f: return f.read() def main(): print("Part 1:", part1(get_input())) print("Part 2:", part2(get_input())) def part1(puzzle): return len(set(get_visited_spots(puzzle))) def part2(puzzle): santa = get_visited_spots(puzzle[::2]) robo_santa...
7ff8f4fb523dc2ff6a10beca0611b1a0945b8537
abou123/sierra_python_module06
/3_methods.py
11,550
4.625
5
# String objects have many useful methods # to do things like replacing characters, converting to lowercase, # capitalizing the first character, etc. # The methods are made possible due to a string's implementation as a class, # which for purposes here can just be thought of as a mechanism supporting # a set of me...
1d36296e8eb2abd0517c3d2e42ad85e40f975bd8
RogerPina2/7-logica-da-computacao
/0.0 - first version/old_main.py
2,349
4.03125
4
import sys def main(): #Junta todos argumentos após o nome do arquivo numa string arg = ''.join(sys.argv[1:]) try: #Verifica se o argumento esta no modelo de entrada (cadeia de operações entre aspas simples) # if arg[0] != "'" or arg[-1] != "'": # raise ValueError ...
b077d8462f3ceaeca8f57659945728c329b3d3d6
TrinidadJoaquin/pythonworkshop
/Factorial of an Integer Trinidad Joaquin.py
210
4
4
from math import* sum=1 x=input("Give a number: ") for i in range(1,x+1): print (i,"squared is",i*i) sum=sum*i print "sum of first ", x ," squares is ", sum raw_input("Press ENTER to exit")
662e20cca17dfc16c1ccd67c1b3c2467070ca8be
Wibbox/CursoEmVideo-PythonDesafios
/CursoEmVideo PytonBasico/ex009.py
174
3.765625
4
#Taboada print('Calcula Taboada') n = int(input('Número para cálculo: ')) t = 0 while t <= 10: i = n * t print("{} x {} = {}".format(n, t, i)) t += 1
76cd7c300ca9fa679a98f45437595308a8226cd0
Wibbox/CursoEmVideo-PythonDesafios
/CursoEmVideo PytonBasico/ex013.py
187
3.765625
4
print('Você acaba de receber 15% de aumento!!! =D') sal = float(input('Qual é o seu salário atual? ')) nsal = sal + (sal*(15/100)) print('Seu novo salário é: R${}'.format(nsal))
a6586ccae2d752536921d497d08d681e72ce182c
H4rliquinn/Intro-Python-I
/src/14_cal.py
1,842
4.53125
5
""" The Python standard library's 'calendar' module allows you to render a calendar to your terminal. https://docs.python.org/3.6/library/calendar.html Write a program that accepts user input of the form `14_cal.py month [year]` and does the following: - If the user doesn't specify any input, your program should ...
44205d26951d841ffe5aa661b330c41c9016c699
ParulProgrammingHub/assignment-1-mp-mohit
/program11.py
242
3.5
4
def compound_intrest(p,t,r) : s=float(p*((1+r)**t)-p) print("Compound intrest is",s) p=float(input("Enter principal amount:")) r=float(input("Enter intrest rate (in %) :")) r=r/100 t=int(input("enter time:")) compound_intrest(p,t,r)
8a5bbd3e39c480a7d9e6afa413855d03f13b3cb7
elliterate/xpath.py
/tests/helpers.py
691
3.8125
4
from lxml import etree def inner_text(node): """ Returns the inner text of a given XML node, excluding tags. Args: node (lxml.etree.Element): The node whose inner text is desired. Returns: str: The inner text of the node. """ # Include text content at the start of the node. ...
d3857af92ea1df200f76ed3b09235129a11660b5
alhung/gameoflife
/src/main.py
2,472
4.4375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Game of Life This program is an implementation of Conway's game of life. The purpose of the game is to calculate the next state/generation of a multidimensional grid given an initial state/generation of the grid This implementation resembles a forecasting/prediction...
a587cdfda0f8af0294b244ae60c3fd4d63b12e23
dchemishanov/amy-city
/amy_city/engine/engine.py
1,716
3.53125
4
from typing import Dict, List, Optional class Engine: def __init__(self, data: List[Dict]): self.data = data @staticmethod def _is_candidate(city: Dict, query: str) -> bool: """ Simple euristics for sifting through the candidates. """ return query.lower() in city.g...
c95bd00fac4112b10ff0218ba9e2200781beb45b
Kevinrobot34/atcoder
/abc/abc_042_125/abc056/a.py
102
3.671875
4
a, b = input().split() if a == 'H': ans = b else: ans = 'D' if b == 'H' else 'H' print(ans)
a5363fd07412abe99094c6ade9d55a0b6523da32
Kevinrobot34/atcoder
/abc/abc_042_125/abc101/b.py
144
3.5625
4
n_s = input() n = int(n_s) s = 0 for i in range(len(n_s)): s += (n // (10**i)) % 10 if n % s == 0: print("Yes") else: print("No")
f7802838c09861275e51f51174d41665c0556459
Kevinrobot34/atcoder
/abc/abc_042_125/abc053/c.py
114
3.609375
4
x = int(input()) ans = (x // 11) * 2 x = x % 11 if 0 < x <= 6: ans += 1 elif 6 < x: ans += 2 print(ans)
4f5a301fe2e01d958164a74953b6b6b7d8fb65d8
Kevinrobot34/atcoder
/abc/abc_042_125/abc049/c.py
351
3.5625
4
import sys sys.setrecursionlimit(10**8) s = input() words = ['dream', 'dreamer', 'erase', 'eraser'] def dfs(idx): if idx == len(s): return True ans = False for word in words: if s[idx:idx+len(word)] == word: ans = ans or dfs(idx + len(word)) return ans if dfs(0): prin...
0e33f890193d5a49fa4072ab264e914ff863db1b
Kevinrobot34/atcoder
/abc/abc_126_211/abc158/d.py
456
3.71875
4
from collections import deque s = input() q = int(input()) is_reverse = False d = deque(list(s)) for _ in range(q): qi = input() if len(qi) == 1: # query 1 is_reverse = not is_reverse else: # query 2 _, f, c = qi.split() f1 = f == '1' if f1 == is_reverse: ...
6ee3cf851dc82e9820daf75647d801f9c2327fc9
Kevinrobot34/atcoder
/data_structure/bit/BIT_bisect.py
1,754
3.578125
4
class BIT1(): """ Binary Indexed Tree (1-indexed) """ def __init__(self, n): self.n = n self.bit = [0] * (self.n + 1) self.data = [0] * (self.n + 1) def build(self, data): pass def add(self, idx, x): # add x to idx-th element # idx: 1-indexed ...
0284311f794d8815b0dd64c6bd7cad6b068b259b
Kevinrobot34/atcoder
/arc/arc026/b.py
460
3.84375
4
def get_divisor(n: int) -> list: divisor = [] for i in range(1, n + 1): if i * i > n: break if n % i == 0: divisor.append(i) if n // i != i: divisor.append(n // i) # divisor.sort() # if you want sorted divisors return divisor n = int(...
4555762e20c74cac943c55ae1847eff4649ad7cc
Kevinrobot34/atcoder
/abc/abc_126_211/abc181/c.py
509
3.5
4
from itertools import combinations def simple_ccw(pa, pb, pc): # Simple Counterclockwise test ax, ay = pa bx, by = pb cx, cy = pc vx, vy = bx - ax, by - ay wx, wy = cx - ax, cy - ay return vx * wy - vy * wx == 0 n = int(input()) points = [tuple(map(int, input().split())) for _ in range(...
e5c06477ed824c033fe4edaa6241cce13cfd9a0a
Kevinrobot34/atcoder
/abc/abc_126_211/abc166/d.py
1,324
3.71875
4
def get_divisor(n: int) -> list: divisor = [] for i in range(1, n + 1): if i * i > n: break if n % i == 0: divisor.append(i) if n // i != i: divisor.append(n // i) # divisor.sort() # if you want sorted divisors return divisor x = int(...
0458bfb5c5ccd02bc22fb07be20e57ac48e965ee
Kevinrobot34/atcoder
/abc/abc_126_211/abc149/c_eratosthenes.py
379
3.75
4
def eratosthenes(n: int) -> list: is_prime = [True] * (n + 1) is_prime[0] = is_prime[1] = False for i in range(2, n // 2 + 1): if is_prime[i]: for j in range(2, n // i + 1): is_prime[i * j] = False return is_prime x = int(input()) is_prime = eratosthenes(x * 2 + 100...
c0c102bb3fb3c8a0b9f49e6500b13c68edea6a05
Kevinrobot34/atcoder
/arc/arc054/b_ternarysearch.py
285
3.671875
4
p = float(input()) def func(t): return t + p * 2**(-t / 1.5) left = 0.0 right = p while right - left > 1e-8: c1 = (2 * left + right) / 3 c2 = (left + 2 * right) / 3 if func(c1) < func(c2): right = c2 else: left = c1 ans = func(left) print(ans)
d18efa6531602ded6f6f6cc3044e7ac86ecaf491
Kevinrobot34/atcoder
/agc/agc034/a.py
349
3.640625
4
n, a, b, c, d = map(int, input().split()) s = '#' + input() def check(l, r): return "##" not in s[l:r] if c < d: if check(a, c) and check(b, d): print("Yes") else: print("No") else: # c > d space = "..." in s[b-1:d+2] if space and check(a, c) and check(b, d): print("Yes") ...
a8a15e681757c5cfd861074db9581a1373b530bc
Kevinrobot34/atcoder
/abc/abc_001_041/abc035/d.py
982
3.53125
4
from heapq import heappush, heappop def dijkstra(graph: list, n: int, v_s: int, INF: int = float('inf')) -> list: # graph[v_from] = [(cost, v_to), ...] dist = [INF] * n dist[v_s] = 0 heap = [(0, v_s)] # heap = [(dist[v], v), ...] while heap: _, v_from = heappop(heap) for cost, v_...
52e4df2853e09e90eab1108bacb14ee3cccc820e
Kevinrobot34/atcoder
/abc/abc_126_211/abc177/e.py
830
3.6875
4
from collections import Counter def GCD(a: int, b: int) -> int: return a if b == 0 else GCD(b, a % b) def check_pairwise_coprime(a): m = max(a) cnt_a = Counter(a) is_prime = [True] * (m + 1) for i in range(2, m // 2 + 1): if is_prime[i]: cnt = cnt_a[i] for j in ra...
61c482f9c20f2b28ec6587a22a064252151cb96c
Kevinrobot34/atcoder
/abc/abc_126_211/abc131/c.py
140
3.84375
4
def GCD(a, b): return a if b == 0 else GCD(b, a % b) def LCM(a, b): return a * b // GCD(a, b) print(GCD(8, 12)) print(LCM(9, 12))
328d298ecfaa33bd7b05edb2cf330b667dcd84f6
IswaryaNidadavolu/python
/distance.py
201
4.03125
4
import math x1=int(input("enter the x1\t")) x2=int(input("enter the x2\t")) y1=int(input("enter the y1\t")) y2=int(input("enter the y2\t")) result=math.sqrt( ((x1-x2)**2)+((y1-y2)**2) ) print(result)
a9ae59ae1b172b64342ffdae9a539b9771c84791
IswaryaNidadavolu/python
/list1.py
107
3.875
4
list=[1, 5, 8, 3] n=int(input("enter the number")) if n in list: print("true") else: print("false")
a91ec17713f9ff9d38d60ea11a2b02ff9cc93a4e
IswaryaNidadavolu/python
/check.py
131
3.84375
4
while True: try: a=int(input("enter the number\t")) break except: print("this is not number\t")
ea37bfa89cb44a3a69d8cb3d1dbc98293e7dca23
IswaryaNidadavolu/python
/add.py
133
4.125
4
x=int(input("enter the number")) y=int(input("enter the number")) result= x*x+2*x*y+y*y print("({} + {})^2) = {}".format(x,y,result))
48b0be6dc2fa4b9d103c3ec4125a5cc08acf37ce
A-ichi11/sample-python
/set.py
480
3.765625
4
# 集合 a = {1,2,2,3,3,4,4,5,5,5,6} # 同じ値は削除される print(type(a),a) b = { 2,3,4,7} # aのsetから2.3.4を取り除いた値を出力 print(a-b) # aにもbにもある値を出力 print(a & b) # aとbにある全ての値を出力 print( a | b) # aとbで重複していないものを出力 print( a ^ b) # 集合にはindexがない # これをするとエラーになる # print(a[0]) # 追加は出来る a.add(7) print(a) # 削除 a.remove(7) print(a)
94f622c52f020e87163b0c84300efb3e7d05d8ab
A-ichi11/sample-python
/try.py
171
3.59375
4
while True: try: x= int(input("please enter a number")) print(x) except ValueError: print("Oops! That") finally: print("exec")
11c58f4c75a3744801f17af2ddd15f7668229dec
mrlsdvd/flight-price-prediction
/src/custom_flight_revenue_simulator.py
3,750
3.796875
4
import json from numpy.random import uniform, seed from numpy import floor from collections import namedtuple def _tickets_sold(p, demand_level, max_qty): quantity_demanded = floor(max(0, demand_level - p)) return min(quantity_demanded, max_qty) def simulate_single_action(days_left, demand_level, tick...
5e1d1995658ccdd41cf502136e1148d9ffd0d163
deepandas11/Python-ADS
/binary_search_tree.py
1,849
3.828125
4
class Node: def __init__(self, val): self.val = val self.leftChild = None self.rightChild = None def set_val(self, item): self.val = item def get_val(self): return self.val def get_children(self): children = [] if self.leftChild is...
a35a6f56396bad2f52f1ab773b55745f4a2dd113
ferdinandmudjialim/Sudoku
/sudokuSolverNorvig.py
4,203
3.859375
4
def cross(A, B): """Cross product of elements in A and elements in B.""" return [a + b for a in A for b in B] digits = '123456789' rows = 'ABCDEFGHI' cols = digits squares = cross(rows, cols) unitlist = ([cross(rows, c) for c in cols] + [cross(r, cols) for r in rows] + [cros...
126497ab4bccf3aac6d5f1152a0c86459271cc34
suhang319/exercise
/作业/作业.py
1,935
3.5625
4
#_*_ coding:utf-8 _*_ #@Time :2020-12-1920:21 #@Author :lemon_suhang #@Email :1147967632@qq.com #@File :作业.py #@Software:PyCharm # 1.5层打印,外层循环 m=5 m=1 # 内层循环控制个数你n<=m m=1 while m<=5: n=1 while n<=m: print("*",end='') n +=1 print() m +=1 # 字符串去重 # str1 ="aabbbcddef" str2='...
1cea2ac27f38d7d9fb2ce0c98c49d62a2fa1d72d
suhang319/exercise
/第二天/元组.py
612
3.765625
4
#_*_ coding:utf-8 _*_ #@Time :2020-11-2216:16 #@Author :lemon_suhang #@Email :1147967632@qq.com #@File :元组.py #@Software:PyCharm t1 =(10,20,30) print(type(t1)) print(t1) t2=(20,) print(t2) print(type(t2)) t3 =20 print(type(t3)) t4 ="hello" print(t4) print(type(t4)) tuple1= ('aa','bb','cc','dd') print(tup...