blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e622d531e1d118979566e8d25748d9b413418f84
Amrit-stack/python-assignments-I
/Q5.py
223
4.125
4
def add_string(string): if len(string)>=3: if string[-3:]!='ing': return string+'ing' else: return string[:-3]+'ly' else: return string a=input('Enter the string ') print(add_string(a))
3b56f60af58d70d715cf71bab5ed0d702352092c
Amrit-stack/python-assignments-I
/Q27.py
87
3.84375
4
mylist1=[1, 3, 5, 7, 9, 10] mylist2=[2, 4, 6, 8] mylist1[-1:]=mylist2 print(mylist1)
38a904be0eac7e54e5729726dbb628c0050826c2
Amrit-stack/python-assignments-I
/func_Q19.py
160
3.625
4
from functools import reduce fib = lambda n: reduce(lambda x, _: x+[x[-1]+x[-2]],range(n-2), [0, 1]) a=int(input('How many terms? ')) print(fib(a))
daff93fd5a0e9e61f7f3412e7afc474179dd427e
Amrit-stack/python-assignments-I
/func_Q3.py
88
3.859375
4
mylist=[1,2,3,4,5] prod=1 for num in mylist: prod*=num print('The product is',prod)
413c25193f27788e086ca49f1ab1ae71c63fbe2a
maciexu/Data-Visualization-with-Seaborn
/Customizing.py
3,093
3.5
4
""" style, palette, context """ # Example 1 # Change the color palette to "RdBu", "Purples" sns.set_style("whitegrid") sns.set_palette("RdBu") # Create a count plot of survey responses category_order = ["Never", "Rarely", "Sometimes", "Often", "Always"] sns.catplot(x="Parents Advice", ...
2a63c8e521513943cf5fd128a3787cda929c1ac3
Lyppeh/PythonExercises
/Introductory Exercises/ex008.py
148
3.734375
4
m = int(input('Quantos metros você mediu?:')) print('valor em centimentros = {}'.format(m*10)) print('valor em milimetros = {}'.format(m*100))
032249f16591b59976474632602aa152b902dee3
Lyppeh/PythonExercises
/Repetition Structure Exercises/ex056.py
950
3.515625
4
soma = 0 media = 0 idade_homem_mais_velho = 0 nome_homem_mais_velho = 0 mulheres_com_menos_de_20_anos = 0 for d in range(1, 5): print('----------- {} PESSOA ----------'.format(d)) nome = str(input('Digite seu nome: ')).strip() idade = int(input('Sua idade: ')) sexo = str(input('Seu sexo [M/F]: ')).stri...
4cf54d6a1d24a49bf4d48498384ee462678fcf0b
Lyppeh/PythonExercises
/Introductory Exercises/ex007.py
148
3.59375
4
n1 = float(input('Quanto vc tirou na primeira prova?:')) n2 = float(input('E na segunda?:')) s = 2 print('a sua media é {:.1f}'.format((n1+n2)/s))
8722b6cc9d2006c8c14ce2cc6d26f6be346fa2f4
IgorG94/compiler-events-python
/nucleoMotorEventos/nucleo_motor_eventos.py
983
3.859375
4
# Classe que implementa o núcleo do motor de eventos. Cada módulo do projeto # que utilizar esse núcleo herda suas variáveis e funções, adicionando outras # quando necessário. class NucleoMotorEventos(): def __init__(self, lista_eventos=[], lista_tipo_eventos=[]): self.lista_eventos = lista_eventos ...
ed6ac75c2fcd47ad6b4a35f3fcc8b5b12534a92b
beingadithya/CodeJam-2019
/Challenge 2/Cryptopangrams.py
3,349
3.921875
4
import sys import math import numbers def getPrimeList(maxPrime): primeList=[] n=int(maxPrime) #Change the number to an integer #for index in range (0, n+1): # primeList.append(index) # populate a list with all numbers starting from 0 to n+1 primeList.extend(range(0, n+1)) squareRoot=math.sqrt(...
f661c7737cad23b1083998ce5cf0f96b516a236a
enicholl/Bash-Python-Webapp-Project
/webform/catmice.py
1,665
4.03125
4
# Code for outputting the list of numbers in the users chosen range, with dog, cat, mouse and cat&mouse replaced in # where required def cat_mouse(player_number=100): # default number 100 if none selected by user results = [] # for every number in the players range, the outcome is appended to this results list ...
a0efa90b1beab9505371c5feaed1ca87ef637d25
evanj2357/natas-solutions
/solutions/natas07.py
814
3.5
4
""" natas7: URL parameters, path traversal """ import requests from typing import Optional from natas_utils import * LEVEL = 7 def solve(url: str, login: LevelLogin) -> Optional[str]: # links on the page use URL parameters to specify pages # solve by passing an absolute path to password file response = ...
d03b2e74c7bb5c8f07328f1a259e2efd29039962
yyexela/LeetCode
/Integer to Roman/code.py
1,936
3.734375
4
#Symbol Value #I 1 #V 5 #X 10 #L 50 #C 100 #D 500 #M 1000 import unittest class Solution: def getRoman(self, n: int, p: int) -> str: """Given an integer of the form n*10^p return its roman numeral""" if n ==...
d6d5999215d93b9eb411d7ebb1e8a77ee1f8da27
mattpaletta/Little-Book-Of-Semaphores
/problems/merge_sort/recursive.py
1,072
4
4
import time import humanfriendly def merge_rec(left, right): """Merge sort merging function.""" left_index, right_index = 0, 0 result = [] while left_index < len(left) and right_index < len(right): if left[left_index] < right[right_index]: result.append(left[left_index]) ...
c2bce13d32eb4372f9bb56498abec1af1eb0ae3d
qiutiandeyanjin/Study
/Python/Basic/fibs.py
1,310
3.890625
4
# coding=utf-8 """ FileName : fibs.py Author : ken Date : 2018-3-18 Describe : 抽象 """ # def fibs(num): # fibs01 = [0, 1] # for i in range(num - 2): # fibs01.append(fibs01[-2] + fibs01[-1]) # return fibs01 # # # num = input('How many numbers do you want? ') # print fibs(num) def...
72b66bf575f17c40ab417b266aea462a7139ca2e
qiutiandeyanjin/Study
/Python/StudyPython/2.2 Array/Built-in functions.py
246
3.5625
4
# coding=utf-8 # 长度函数len、__len__() numbers = [100, 34, 678] print len(numbers) print numbers.__len__() # 获取最大值函数max print max(numbers) print max(2, 3) # 获取最小值函数min print min(numbers) print min(9, 3, 2, 5)
5a2a816db30274b92f2ef9ec440596132daeed78
jmoguilevsky/TDATp1
/Recorrido_Grafos/testHeuristic.py
1,860
3.609375
4
import unittest from Grafo import Digraph from Heuristic import * def heuristicF(a,b): (x1, y1) = a (x2, y2) = b return 1 * (abs(x1 - x2) + abs(y1 - y2)) class HeuristicTest(unittest.TestCase): def setUp(self): self.graph = Digraph(9) self.graph.add_edge(0,1,2) self.graph.add_edge(0,3,2) self.graph.add_e...
1c66fd82428691be25a51ac2e7f9a0ad42919b20
jmoguilevsky/TDATp1
/Estadisticos_orden_k/fuerza_bruta.py
530
3.734375
4
def verificar(conjunto, candidato, k): """ Ordena el conjunto y deuvelve Verdadero si el indice k coincide con el del candidato """ ordenado = sorted(conjunto) return ordenado.index(candidato) == k - 1 def fuerza_bruta(conjunto, k): """ Dado un conjunto y un indice k, devuelve el k elemento mas chico. Si k es...
0e37643c81569af625b905d3d5d419fc3abcc750
mkmicik/C404_Lab2
/serversocket.py
1,825
3.640625
4
#!/usr/bin/env python import socket, os, select serverSocket = socket.socket( socket.AF_INET, # socket on the internet (IP protocol) socket.SOCK_STREAM) # specifies TCP (stream abstraction) serverSocket.bind(( "0.0.0.0", # broadcast to all addresses 12345 # port number )) serverSocket.listen(5) w...
55b7f59b5b5673d515a802ab5e07da918cdde780
austinsonger/CodingChallenges
/Hackerrank/Python/14. XML/XML 2 - Find the maximum depth/main.py
426
3.734375
4
import xml.etree.ElementTree as etree def maximumdepth(node, depth): if len(node) == 0: return depth else: maximum = depth for child in node: maximum = max(maximumdepth(child, depth + 1), maximum) return maximum xml = str() for _ in range(int(input())): xml += ...
12adb0c58bd53cf76dd97efffdaff26dbe0c1b57
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe104.py
1,102
3.859375
4
""" Pandigital Fibonacci ends Problem 104 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 n...
39302d95a6fce20f7f292a23883102b69c6cf7cb
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe113.py
914
3.640625
4
''' Non-bouncy numbers Problem 113 Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a positive integer that...
915a43e1b8c9c04a6a9c08a63a56da611810851e
austinsonger/CodingChallenges
/Hackerrank/Algorithms/median/median.py
916
3.53125
4
#!/usr/bin/env python import bisect, sys if __name__ == '__main__': n = int(sys.stdin.readline()) a = [] len_a = 0 for i in range(n): action, x = sys.stdin.readline().split() idx = bisect.bisect_left(a, int(x)) # Perform requested action if action ==...
caabadf5093c57afc162b36ae1a20b53caae3ef8
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe401.py
831
3.640625
4
''' Sum of squares of divisors Problem 401 The divisors of 6 are 1,2,3 and 6. The sum of the squares of these numbers is 1+4+9+36=50. Let sigma2(n) represent the sum of the squares of the divisors of n. Thus sigma2(6)=50. Let SIGMA2 represent the summatory function of sigma2, that is SIGMA2(n)= ∑sigma2(i) for i=1 to ...
9086c811e31872a17d8d5bc99facccf701d472a7
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe052.py
639
3.609375
4
""" Permuted multiples Problem 52 It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. """ import time __date__ = '14-3-28' __author__ = 'SUN' if __n...
5ced122fd6f4c1978f8b172d363a006c85f51c60
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe112.py
1,357
4.09375
4
''' Problem 112 Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a positive integer that is neither increas...
5ebf89669cd9b9111d098004dab4e678e67c2a4f
austinsonger/CodingChallenges
/Hackerrank/Artifical Intelligence/saveprincess/saveprincess.py
620
3.796875
4
#!/usr/bin/env python import sys if __name__ == '__main__': N = int(sys.stdin.readline()) # Find the locations of Mario and Princess Peach mario, princess = -1, -1 for i in range(N): s = sys.stdin.readline().strip() if 'm' in s: mario = (s.find('m'), i) ...
ddee17193255b7fd873765f7c7dd30ece4f5ba54
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe007.py
283
3.625
4
''' 10001st prime Problem 7 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? ''' from pe069 import prime_sieve __author__ = 'SUN' if __name__ == '__main__': print(prime_sieve(150000)[10000])
8087a6f8ed38915161e53eee9ef7426f5d348aa1
austinsonger/CodingChallenges
/Hackerrank/Python/13. Regex and Parsing/re.split()/main.py
106
3.625
4
import re for numbers in (re.split(r'[.,]+', input())): if len(numbers) > 0: print (numbers)
89c38648872baa80c3ebf4446dfd63dbbe01d7e8
austinsonger/CodingChallenges
/Hackerrank/_Contests/30 Days of Code/Day 20 - Review + More String Methods!/main.py
111
3.84375
4
import re words = re.findall(r'[0-9A-Za-z]+', input()) print(len(words)) for word in words: print(word)
10c4fd314f9b75c77e0ba4855ef80457b9eff682
austinsonger/CodingChallenges
/Hackerrank/Python/3. Strings/stringValidators.py
797
3.8125
4
''' Title : String Validators Subdomain : Strings Domain : Python Author : Kalpak Seal Created : 29 September 2016 ''' inputStr = raw_input() alnum = False alpha = False digit = False lower = False upper = False for i in inputStr: if (i.isalnum()): alnum = True if (i.isalph...
12e6ccfcb0a7eb7136a97958e44833525fc75416
austinsonger/CodingChallenges
/Hackerrank/Mathematics/game-of-rotation/game-of-rotation.py
376
3.53125
4
#!/usr/bin/env python import sys if __name__ == '__main__': N = int(sys.stdin.readline()) A = list(map(int, sys.stdin.readline().split())) max_product = product = sum((i + 1) * a for i, a in enumerate(A)) total = sum(A) for i in range(N): product += total - N * A[-i - 1] max_pro...
de393d61054d06b0c65eb3fd5821b3bb02f2a66d
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe243.py
991
3.6875
4
""" Resilience Problem 243 A positive fraction whose numerator is less than its denominator is called a proper fraction. For any denominator, d, there will be d−1 proper fractions; for example, with d = 12: 1/12 , 2/12 , 3/12 , 4/12 , 5/12 , 6/12 , 7/12 , 8/12 , 9/12 , 10/12 , 11/12 . We shall call a fraction that can...
d9fe957f38eba226dbd6502cfe1908e2e2b971a9
austinsonger/CodingChallenges
/Hackerrank/Python/15. Closures and Decorators/Standardize mobile number using Decorators/main.py
341
4
4
numbers = list() for i in range(int(input())): numbers.append(input()) def mobile(function): def input(numbers): return sorted([function(number) for number in numbers]) return input @mobile def standardize(number): return "+91" + " " + number[-10:-5] + " " + number[-5:] print (('\n').join(st...
8047f430c12e696aca77d78a08231dbf3abbc578
austinsonger/CodingChallenges
/Hackerrank/Python/Containers/Word Order/main.py
411
3.65625
4
from collections import defaultdict n = int(raw_input()) words = list() word_counter = defaultdict(int) for i in range(0, n): key = raw_input().strip() word_counter[key] += 1 words.append(key) print len(word_counter) res = list() for word in words: count = word_counter[word] if count > 0: ...
1c80f1e1d064f8ec376945888264e12c3c1a1f1e
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe028.py
558
3.65625
4
''' Number spiral diagonals Problem 28 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 o...
3d2fb1e7e711996f3a6355796351af691d30e72c
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe125.py
1,097
3.515625
4
""" Palindromic sums Problem 125 The palindromic number 595 is interesting because it can be written as the sum of consecutive squares: 6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2. There are exactly eleven palindromes below one-thousand that can be written as consecutive square sums, and the sum of these palindromes is...
4d28bcfd50b1dde0b5e019464f1387e5421203b9
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe038.py
1,022
4.0625
4
''' Pandigital multiples Problem 38 Take the number 192 and multiply it by each of 1, 2, and 3: 192 × 1 = 192 192 × 2 = 384 192 × 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) The same can be achieved by starting with ...
c9eba1490f48f751ff2f86c8a123c70942f6bb92
austinsonger/CodingChallenges
/Hackerrank/Mathematics/easy-sum/easy-sum.py
318
3.515625
4
#!/usr/bin/env python import sys if __name__ == '__main__': T = int(sys.stdin.readline()) triangular_number = lambda n: n * (n + 1) // 2 for _ in range(T): N, m = list(map(int, sys.stdin.readline().split())) print((N // m) * triangular_number(m - 1) + triangular_number(N % m))
129f220d2aaac9e2e0bf18524242ff2a5eb5977c
austinsonger/CodingChallenges
/Hackerrank/Algorithms/string-similarity/string-similarity-v2.py
900
4.1875
4
#!/usr/bin/env python import sys def string_similarity(s): """Computes the string similarity using a simplified Z Algorithm: http://codeforces.com/blog/entry/3107 http://binfalse.de/2010/09/advanced-searching-via-z-algorithm/ """ l, r, n = 0, 0, len(s) z = [0] * n for i in range...
1c444e9347e5cc570a392fdab2a5523704fc8aaa
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe301.py
1,771
3.875
4
''' Nim Problem 301 Nim is a game played with heaps of stones, where two players take it in turn to remove any number of stones from any heap until no stones remain. We'll consider the three-heap normal-play version of Nim, which works as follows: - At the start of the game there are three heaps of stones. - On his tu...
b5a6391af5f4792670f2d95d101371ff455cfc3a
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe265.py
1,272
3.671875
4
''' 2N binary digits can be placed in a circle so that all the N-digit clockwise subsequences are distinct. For N=3, two such circular arrangements are possible, ignoring rotations: For the first arrangement, the 3-digit subsequences, in clockwise order, are: 000, 001, 010, 101, 011, 111, 110 and 100. Each circular...
b0e7d46167ffd3b2738ecfbac964deb578842b1f
austinsonger/CodingChallenges
/Hackerrank/Mathematics/random-number-generator/random-number-generator.py
842
3.640625
4
#!/usr/bin/env python import sys def gcd(a, b): return b and gcd(b, a % b) or a if __name__ == '__main__': T = int(sys.stdin.readline()) for _ in range(T): A, B, C = [int(x) for x in sys.stdin.readline().split()] # Ensure that A <= B A, B = min(A, B), max(A, B) ...
efdbbfca585f858ea2601891bed5ef6644585145
zxwtry/python_study
/aproject/aSwitch.py
799
4.0625
4
#!/usr/bin/python #coding:utf-8 from __future__ import division def add(x,y): return x+y def minus(x,y): return x-y def multi(x,y): return x*y def div(x,y): return x/y operator={'+':add,'-':minus,'*':multi,'/':div} print (lambda x,o,y:operator.get(o)(x,y))(2,'*',3) #print operator['/'](2,3) #print opera...
16da5729d46976824681a4663297d169aabd6a58
awasnikar/Dice-Simulator
/main.py
550
4.1875
4
import random import time roll_again = "yes" while roll_again == "yes" or roll_again == "Y" or roll_again == "y" or roll_again == "Yes" or roll_again == "YES" : print("\nRolling the dice !") time.sleep(2) dice1 = random.randint(1,6) dice2 = random.randint(1,6) print("The values are:"...
b9fffa93dcfb2693bb986734fe262f47aa1d4560
MingfangChang/Blackjack
/french_deck.py
1,780
3.96875
4
import collections import random Card = collections.namedtuple('Card', ['rank', 'suit']) class FrenchDeck: """ This class models a French deck of 52 cards. The dealer managed the player's hands and bets. Player objects implement a specific player's strategy. The player should not modify its ...
a9bf30f332df0b02efbc654f63f5953b9b4b9449
health-data-science-OR/coding-for-ml
/content/01_algorithms/02_oop/text_adventure/basic_game.py
7,616
4.34375
4
''' A text adventure game where a player can move between Rooms. Classes: -------- Room: A location within the game that has a description and exits to other Rooms Game: The main game class. A player can take actions within a game ''' class Room: ''' Encapsulates a location/room within a TextWorld....
13b04ff0c8d6477befb4767e74ff9cedad0f2bff
pbl0rd/Tareas_CC5114
/Tarea_1/neural_network.py
20,124
3.5
4
import numpy as np from neuron_layer import NeuronLayer from tanh import Tanh from sigmoid import Sigmoid # Clase Red Neuronal class NeuralNetwork(object): # Método constructor para la clase Red Neuronal que recibe un entero con el número capas ocultas de la red, una # lista de enteros que se corresponden co...
b16b5043e79f269c71d16e9f0c79cf38cadde127
pbl0rd/Tareas_CC5114
/Tarea_1/tanh.py
521
3.671875
4
import numpy as np # Clase para la función de activación # tangente hiperbólica class Tanh(object): # Método para aplicar la función def apply(self, x): if x > 20: return (1-np.exp(-2*x)) / (1+np.exp(-2*x)) elif x < -20: return (np.exp(2*x)-1)/(np.exp(2*x)+1) e...
cf397c384fdea2c634f0b240c07d56a91fb307a4
quickemailverification/quickemailverification-python
/quickemailverification/http_client/auth_handler.py
1,011
3.5625
4
class AuthHandler(object): """AuthHandler takes care of devising the auth type and using it""" HTTP_HEADER = 1 def __init__(self, auth): self.auth = auth def get_auth_type(self): """Calculating the Authentication Type""" if 'http_header' in self.auth: return self...
c6c5d71e207bd4b297828423e11e4014bc2a792e
DaltonWemer/bankers-algorithm
/banker.py
8,591
4.03125
4
# Dalton Wemer # CSC 360 Operating Systems # Bankers Algorithm Implementation # March 10 2021 # Instructor: Dr. Siming Liu # Get access to CLI parameters import sys # Grabs the first command line argument and sets it # as a variable that we can access in our read function filePath = sys.argv[1] # Loops through the d...
dab42418bad808ae2d3f51f75407d224542c31b0
Maruf001/ElectronPhononCoupling
/ElectronPhononCoupling/util/symmetrize.py
1,151
3.90625
4
""" Generic symmetrization procedures on arrays. """ import numpy as np def symmetrize_array(arr, indices_groups, axis=0): """ Symmetrize an array by taking the average over each subset of indices. For example, given a list of indices_groups [[a1,a2,a3], [b1,b2,b3]], the arrays (arr[a1], arr[a2], arr[...
977d78b3313b463cf12fc1609abd8403515153f8
gng0101/foundations
/foundations_hw_4_2_census.py
5,447
3.8125
4
# We will utilize census data in the following problems: # In[1]: # Importing census and state libraries from census import Census from us import states key = "some key I entered earlier" # Initializing the object named Census to utilize its methods c = Census(key) # ###1. What's the code for people born in Slova...
a9ec28f0df36409d99b5b65782a92b0bb6bc9ca8
arunkumar8489/guvi
/python/19.py
65
3.5625
4
n=int(input()) m=1 for i in range(1,n+1): m=m*i print(m)
5f2ef9621ce1759fca5b5083b607dd56b4c54625
arunkumar8489/guvi
/python/code4.py
282
4.125
4
jk = float(input("Enter first number: ")) kl = float(input("Enter second number: ")) lp = float(input("Enter third number: ")) if (jk > kl) and (jk > lp): largest = jk elif (kl > lp) and (kl > lp): largest = kl else: largest = lp print("The largest number is",largest)
c060d084a34ebc514880c7067e0ad89f4decab4e
davehh1211/holberton-system_engineering-devops
/0x16-api_advanced/0-subs.py
696
3.6875
4
#!/usr/bin/python3 """Write a function that queries the Reddit API and returns the number of subscribers (not active users, total subscribers) for a given subreddit. If an invalid subreddit is given, the function should return 0. """ import requests def number_of_subscribers(subreddit): """ Args: subr...
261b09f521f08fd7228e0edf4c1b0c648905101b
Thedhwanishah/Python_learning
/missing_no.py
558
4.15625
4
""" Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1: Input: [3,0,1] Output: 2 """ def missingElement(nums): # max_element = max(nums) max_element = -1 sum_of_nums = 0 for i in nums: sum_of_nums = sum_o...
b70b3b8141f71fc342a4e3c0bddbf6335f93b3b7
mydios/Dollar-Cost-Averaging
/graphs.py
559
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Module containing graphing functions """ __author__ = 'Dylan Van Parys' __copyright__ = 'Copyright 2020' __license__ = 'MIT' import pandas as pd import seaborn import matplotlib.pyplot as plt def graph_lineplot(df, xn=None, yn=None): seaborn.lineplot(data = df, x...
e44abdcc984674f79877ede9ecbc78cc41ea1f37
SheikhFahimFayasalSowrav/100days
/days001-010/day010/steps/ste03.py
731
4.03125
4
def add(n1, n2): return n1 + n2 def sub(n1, n2): return n1 - n2 def mul(n1, n2): return n1 * n2 def div(n1, n2): return n1 / n2 operations = { '+': add, '-': sub, '*': mul, '/': div } num1 = int(input("What's the first number? ")) print(" ".join(operations)) keep_calculating ...
dbddee33c2e3dad0c8f9955deb3e40d75449a052
SheikhFahimFayasalSowrav/100days
/days081-090/day083/project/tic_tac_toe.py
4,504
4.03125
4
import random EMPTY = '_' CROSS = 'X️' DOT = 'O' class TicTacToe: POS_DICT = { 1: (0, 0), 2: (0, 1), 3: (0, 2), 4: (1, 0), 5: (1, 1), 6: (1, 2), 7: (2, 0), 8: (2, 1), 9: (2, 2), } def __init__(self, players): self.board = [[...
f77c3e3fa6bd04704076cf37f6eeae71c4db3815
SheikhFahimFayasalSowrav/100days
/days001-010/day010/steps/ste01.py
596
4.125
4
def add(n1, n2): return n1 + n2 def sub(n1, n2): return n1 - n2 def mul(n1, n2): return n1 * n2 def div(n1, n2): return n1 / n2 operations = { '+': add, '-': sub, '*': mul, '/': div } num1 = int(input("What's the first number? ")) for symbol in operations: print(symbol, end...
5990d88e1983ebc684621732a0357654d891b178
SheikhFahimFayasalSowrav/100days
/days021-030/day027/project/unit_converter.py
831
4
4
from tkinter import * FONT = ("Make Wonderful Moments Script", 30) def to_km(num_miles): return 1.60934 * num_miles def display_km(): num_miles = float(entry.get()) km_label['text'] = f'{to_km(num_miles):.2f}' window = Tk() window.title("️⛽️ Mile to Km Converter ⛽️") window.config(padx=20, pady=20) ...
2a939abe599cabc03cffdd9a9db25c3759c9407b
SheikhFahimFayasalSowrav/100days
/days081-090/day086/project/scoreboard.py
765
3.703125
4
from turtle import Turtle FONT = 'Atari Classic Chunky' class Scoreboard(Turtle): def __init__(self): super().__init__(visible=False) self.score = 0 self.lives = 5 self.color("white") self.pu() self.goto(200, -250) self.write_score() def write_score(se...
2ffacb28ca77e1525041bc5678810f666da3ffec
SheikhFahimFayasalSowrav/100days
/days021-030/day026/lectures/lec01.py
469
3.953125
4
numbers = [1, 2, 3] new_numbers = [n + 1 for n in numbers] print(new_numbers) name = "Angela" letters = [letter for letter in name] print(letters) # ['A', 'n', 'g', 'e', 'l', 'a'] range_list = [n * 2 for n in range(1, 5)] print(range_list) names = ["Alex", "Beth", "Caroline", "Dave", "Eleanor", "Freddie"] short_nam...
2048701f9dd2c3ec455efd59a8860946831dc1dd
SheikhFahimFayasalSowrav/100days
/days021-030/day027/lectures/lec07.py
463
3.640625
4
class Car: def __init__(self, **kw): self.make = kw.get('make') self.model = kw.get('model') self.colour = kw.get('colour') self.seats = kw.get('seats') car1 = Car(make='Nissan', model='GT-R') print(f'Make: {car1.make}, Model: {car1.model}, Colour: {car1.colour}, Seats: {car1.seats...
67dc336b59e586505de7a16c2e5704318d6477d3
SheikhFahimFayasalSowrav/100days
/days021-030/day027/lectures/lec12.py
503
4
4
from tkinter import * def button_clicked(): label.config(text=user_input.get()) window = Tk() window.title("🖱️ My first GUI program 🖱️") window.minsize(width=500, height=300) label = Label(text='I am a Label', font=("Atari Classic Extrasmooth", 12)) label.pack() label['text'] = "I am still a Label" label....
16b1831f3279f8aab5824755e664061d799e30e2
SheikhFahimFayasalSowrav/100days
/days001-010/day002/lectures/lec02.py
406
4.0625
4
# TypeError # print(len(4837)) num_char = len(input("What is your name? ")) # TypeError # print("Your name has " + num_char + " characters.") print(type(num_char)) new_num_char = str(num_char) print("Your name has " + new_num_char + " characters.") print() a = 123 print(type(a)) a = str(123) print(type(a)) a = fl...
8cb34fd7f246b9381716ce24047a3a2beafe00e2
SheikhFahimFayasalSowrav/100days
/days011-020/day018/challenges/cha03.py
438
3.53125
4
from random import shuffle from turtle import Turtle, Screen tim = Turtle() screen = Screen() colors = ['chartreuse', 'blue', 'dark green', 'dark orange', 'purple', 'salmon', 'red', 'crimson'] shuffle(colors) tim.pu() tim.goto(0, 100) tim.pd() for num_sides, color in enumerate(colors, 3): angle = 360 / num_side...
97da169e02f3338527f93382e8b3d5dba1444815
hsawaji/bitap_search
/bitap_search.py
1,393
3.5625
4
class BitapSearch: ''' fuzzy search by bitap algorithm usage: sentence = 'abcdefghijklmn' search_word = 'fghi' search = BitapSearch(sentence) search.find(search_word); ''' def __init__(self, sentence): self.sentence = sentence self.sentence_chars = ...
f78316792eea0da24cca312209b2ecf87ab1cd60
Namakanova/NamakanovaHW
/Python/HW7.py
2,362
3.5
4
def words(): d = {} with open ("words.csv", 'r', encoding='utf-8') as f: for word in f.readlines(): word = word.replace('\n', '').split(",") d[word[0]] = word[1] return d def playing(d): q = len(d) for key, val in d.items(): i = 3 print("Это должно п...
3b5a8762c73530e6d6a7e99920b4e1927638e6d5
Namakanova/NamakanovaHW
/Python/С большой буквы. 5.12.16.py
331
3.578125
4
with open('text.txt', "r", encoding = "utf-8") as f: s = f.read() s = s.replace("\n"," ") words = s.split() count_cap = 0 count_total = len (words) for words in words: if words[0].isupper(): count_cap +=1 print ("Процент слов с большой буквы" , ( count_cap / count_total) * 100)
667ffcdaba887a82183cabf9ed2a36c33a53677e
jaygauvin/python-hw
/hw5/searcher.py
2,313
3.609375
4
#Jay Gauvin #homework5 from datetime import datetime import shelve import os import pickle from weather import getWeather def search(shelve_name, pickle_name): print("Reading shelved data...") sh = shelve.open(shelve_name) dic = sh["dic"] sh.close() query=input("\nSearch Query: ") query = query.strip().lower(...
de1c1315a81f5ba3fb34274bc9f2e7e6f9a1e986
druplall/Python_BootCamp_CE
/Python_BootCamp_CE/Lists.py
753
4.28125
4
# Testing List my_list = [1,2,3,4] my_name = ['Deodat', 'Ruplall'] test = my_list + my_name # Append will add new item to the back of the list my_list.append('New') print(my_list) # Pop will remove the last element from the list my_list.pop() print(my_list) # You can save the popped item to a variable popvalue = m...
251ea1ec16ecaa8ca1ae2c934d1f5a4a2bf2a913
druplall/Python_BootCamp_CE
/Python_BootCamp_CE/Error_Exception.py
893
4.21875
4
# The following are the 3 keywords for the exception handling # try: This is the block of code to be attempted # except: Block of code will execute in case there is an error in try block # finally: A final block of code to be exected, regardless of an error (ALWAYS Executed) def add(n1,n2): print(n1+n2) add(10,2...
0096295129f6e585b0ec66518ea1dea0ed9509ac
druplall/Python_BootCamp_CE
/Python_BootCamp_CE/Function.py
945
4.25
4
# How to define functions ## def name_of_function(): ## Docsting explain function. ## print('Hello') ### Call function by name, example name_of_function def name_function(): ''' DOCSTRING: Information about the function INPUT: no input.. OUTPUT: Hello.. :return: ''' print('Hello') name_fun...
59ca98e35251ecafcc57e7e3314987f1f26ab65e
jessepiza/Tarea1_Diseno
/sandwich.py
1,126
3.890625
4
class Sandwich: """ Clase Sandwich que genera un Sandwich con nombre y costo de este. """ def __init__(self, name): """ name:param: nombre del sandwich cost:param: costo del sandwich """ self.name = name if self.name == 'JyQ': self.cost = 7000 ...
41f31ea16d580cc829d912ee835b56db490addc2
akgarg89/tiny_python_projects
/08_apples_and_bananas/apples.py
1,417
4.09375
4
#!/usr/bin/env python3 """ Name: Achal Kumar Garg <achalkumargarg89@gmail.com> Date: 2020-01-30 Purpose: Apples and Banana """ import argparse import os import sys # -------------------------------------------------------------- def get_args(): parser = argparse.ArgumentParser( description='Appl...
a38b906850ae381465f0ad7d5837384ea1759c6b
kelraf/my-app
/registration.py
5,191
3.671875
4
''' The module defines user details and methods related to it ''' import re, uuid class UserDetails(object): def __init__(self): #A list to store users self.user_list = [] #A method to register the users def validate_data(self, username, email, password, confirm_password): if not r...
1217a3b034d5ebd9da6f39173172e3f9bd7e4c7f
BUAAtao/LeetCode_Python3
/148.py
516
3.671875
4
#将链表的数值存到列表里排序,再重新构造链表 23题思路一致 # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def sortList(self, head: ListNode) -> ListNode: s = [] temp = re = ListNode(0) while(head): s.append(head.val) head = head.n...
e94c703fbf122f6a927b68e2b032d59577ba443a
yoshix3/HackerRank
/Practice/Algorithms/Warmup/Time_conversion.py
465
3.65625
4
#!/bin/python3 import os import sys # # Complete the timeConversion function below. # def timeConversion(s): h = s[0:2] ap = s[8:10] if("PM"==ap): if(int(h)<12): h = int(h)+12 else: if(h == '12'): h = '00' return "{}{}".format(h, s[2:8]) if __name__ == '__m...
0b286ad433dc6a4fadb94fe06a076f7ab427f3db
FoFabien/lzw-py
/lzw.py
5,466
3.5
4
from functools import partial import math """ WIP - study material attempting to implement LZW to understand how it works """ def compress(uncompressed): # take a bytearray, output an integer list dictionary = {chr(i): i for i in range(256)} # self explanatory w = "" result = [] ...
ad3f12724162e2dca46a32c0ac9cf554ec2ea58d
Susheet/python_assignmentquestions
/pascal.py
279
3.78125
4
def pascalSpot(row,col): if(col == 1): return 1 if(col==row):return 1 upleft = pascalSpot(row-1,col-1) upright = pascalSpot(row-1,col) return upleft+upright for r in range(1,10): for c in range(1,r+1): print(pascalSpot(r,c),end=" ") print("")
aa14eaa5f010a5b955a5bf4edacb3fb296a5a5fe
mmnithin/ict_Full_stack
/python/add.py
356
3.984375
4
def add(x,y): z=x+y; return z def sub(x,y): z=x-y; return z def mul(x,y): z=x*y; return z def div(x,y): z=x/y; return z a=int(input("Enter the first number")) b=int(input("Enter the second number")); result = add(a,b) print(z) result = sub(a,b) print(z) result = mul(a,b) ...
b56d9e135373fea3d24d5ef3ea02bb67a2dec099
mmnithin/ict_Full_stack
/python/sum.py
100
3.96875
4
i=1 num1=int(input("Enter the number :")) sum=0 while(i<=num1): sum=sum+i i+=1; print(sum)
cbaffd3c3ab7df6bddcb2e4148fe68cf8aeba361
MidoriAi/atom-simulator
/atom_simulator/playground.py
279
3.59375
4
symbols = {} with open('ex.txt') as file: output = [] file = file.readlines() for lines in file: output.append(lines.split('\n ')) for i, elem in enumerate(output): symbols[i] = (elem[0].replace('\n', '').split(' - ')) print(symbols)
18d599ebb7f765712ffc5199a9796d3ec08a5d7e
ffatihsen/Asistan
/udemy/ders.py
842
3.890625
4
#Bu fonksiyon dosyadaki tekrar eden isimleri siler.Temiz bir dosyaya tekrarsız şekilde yazar. def kontrol(): file = open("deneme2", "r") fileControl = open("deneme3", "w") deneme3 = [] for line in file: if line not in deneme3: fileControl.write(line) deneme3.append(line) ...
6388d28a490442f7caeb9c6531dc5912faaf91d6
jgadelugo/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/100-weight_average.py
239
3.640625
4
#!/usr/bin/python3 def weight_average(my_list=[]): if not my_list or my_list is None: return 0 totalV = 0 weight = 0 for i in my_list: totalV += i[0] * i[1] weight += i[1] return totalV / weight
fbbad90e99761d93ab5add3dfe09de9d8e608020
jgadelugo/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/4-only_diff_elements.py
232
3.640625
4
#!/usr/bin/python3 def only_diff_elements(set_1, set_2): diff = set() for x in set_1: if x not in set_2: diff.add(x) for y in set_2: if y not in set_1: diff.add(y) return diff
718e7e701ed556c33c37e297edbcd49f7011b9d7
jgadelugo/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/base.py
2,771
3.53125
4
#!/usr/bin/python3 """ Base class """ import json import turtle class Base: """ Base class """ __nb_objects = 0 def __init__(self, id=None): if id is None: type(self).__nb_objects += 1 self.id = self.__nb_objects else: self.id = id @staticmethod ...
2e78b1c0ff073e45d1eb7d95170276e60f689ba2
NizarAlsaeed/pythonic-garage-band
/pythonic_garage_band/pythonic_garage_band.py
777
3.5625
4
Musician.members=[] class Musician: def __init__(self,name:str): self.name = name members.append(self) def get_instrument(self): return '' def play_solo(self): return '' def __repr__(self): return 'Musician('+ self.name + ')' def __str__(self,role...
a210108c6cfb9490abbaed68cf3fbd924435864a
tizzle-b-rizzle/python_learning
/blackjack_complete_no_outside_testing.py
5,027
3.6875
4
# usualy 6 decks (no jokers) # face cards are all 10, ace can be 1 or 11 (give option to decide at beginning?) # dealer will hit if their cards are >17, 17 and above, they'll stand # this has no betting, splitting, double-down etc, I might add that in the future import random import sys deck = [ # one full d...
7a3c5d6ca5cafbea09cb74940b3939c1982e42f9
tizzle-b-rizzle/python_learning
/while_loops.py
157
3.9375
4
cat = 0 while cat < 10: #the below code will repeat as long as the value of cat is less than 10 cat=cat + 1 print("less then 10 cats bby")
fd08b100d34371d76a2f0daadc5b909b398e48c2
wjones907/python-tutorial
/variables.py
2,298
4.25
4
""" Variables in Python """ # Variables demonstrated def variables_demonstrated(): print ("This program is a demo of variables.") v = 1 print("The value of v is now", v) v = v + 1 print("v now equals itself plus one, making it worth", v) v = 51 print("v can store any numerical value, ...
6a3d58965736c4a3b2cf0161c36f9614ad08197e
ACubero/pythonEdx
/ex_32.py
614
4.09375
4
#3.3 Escriba un programa para solicitar una puntuación entre 0.0 y 1.0. Si el puntaje está fuera de rango, imprima un error. # Si el puntaje está entre 0.0 y 1.0, imprima un grado usando la siguiente tabla: #Score Grado #>= 0.9 A #>= 0.8 B #>= 0.7 C #>= 0.6 D #< 0.6 F #Si el usuario ingresa un valor fuera de rango, im...
62b453ae38f03cd61759d293a1b5f649f2e9e03c
seymurabbasov/pythonwithiman
/Repeat.py
853
3.6875
4
"GITHUBNAN ELE" """1)input 2)+,-,* 3)modul 4)min 5)max 6)sqrt 7)inputnan kalkyatornan 8)if 9)while 10)for 11)copy 12)index 13)upper , lower 14)append 15)for""""" a=input("name") b=input("surname") c=input("age") print(" name " + a + " surname " + b + " age " + c) a=2 b=4 c=6 print(a+b+c) print(a-b-c) ...
32a7d4ec0a7896e0a0561d5e30c2c6be89433c3b
roastbeeef/python_learning
/udacity_refract.py
2,410
3.859375
4
def check_answers(my_answers,answers): """ Checks the five answers provided to a multiple choice quiz and returns the results. """ results= [None, None, None, None, None] for item in my_answers: if my_answers[item-1] == answers[item-1]: results[item-1] = True else: ...
0e675316e9cbe6971668d2b120841f953dac97ca
EnasAbdallahAwd/python
/lab1/assignment1/cal.py
370
3.90625
4
def calcarea(shape,num1,num2=1): if shape == "r": return num1*num2*0.5 elif shape == "t": return num1*num2 elif shape == "s": return num1*num1 elif shape == "c": return 3.14*num1*num1 if __name__=='__main__': shape=input("enter shape:") num1=float(input("Enter length:")) num2=float(input("...
e4398464a1fc3da1a0dd95cf91a8ee85c8c03825
AkashSinghChouhan/Machine-Learning-projects
/work on titanic dataset(kaggle challenge)/titanic_with knn and logistic_regression.py
4,812
3.5625
4
import pandas as pd import matplotlib.pyplot as plt from matplotlib import style import numpy as np from sklearn import preprocessing,model_selection import seaborn as sns from sklearn.model_selection import cross_val_score from sklearn.neighbors import KNeighborsClassifier #Variable Definition Key #survival Survival ...
138b20739b0efa47822634d0e30da7cc314b3121
AnuMonachan/Python
/bankaccountclass.py
801
4.03125
4
#To create bank account with attributes owner name & balance class Account: def __init__(self,owner,balance): self.owner = owner self.balance = balance #method to take deposit def deposit(self,amount): na = amount + acc.balance acc.balance = na print("new balance:" + st...
efe525089a646cc43c23ca5445cbf005b4c314f5
sandrastokka/phython
/10.01.18/sumofnumbers.py
268
4
4
myNumber = int ((input ("Enter a number"))) sumOfdigits = 0 while myNumber > 0: sumOfdigits = sumOfdigits + myNumber % 10 myNumber = int (myNumber/ 10) print ("sumOfDigits =", sumOfdigits, "myNumber = ", myNumber) print ("sum of Digis is", sumOfdigits)