blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9d63cf177af6b55f6f5b2fdffc5905c65503a42d
gabriellaec/desoft-analise-exercicios
/backup/user_313/ch139_2020_04_01_19_26_57_289131.py
383
3.59375
4
import math import sys sys.float_info.dig def arcotangente(x,n): resultado = 0 contador = 1 while contador != n: numerador = x**contador divisão = (numerador/contador) format(float(divisão), '6g') resultado = resultado + divisão contador = contador + 2 ...
7768d0785e09df5f5d1b2126f01f267e4996e741
HeyStenson/python_practice
/candy_problem.py
306
3.671875
4
def candies(s): if len(s) <= 1: return -1 else: s.sort() base = s[-1] total = 0 for x in s: if x < base: diff = base - x total += diff print total return total candies([5,8,6,4])
9d5615093ad3825d295ff44a5a40770f93fc55b4
cfcodefans/study-python3
/src/study/machine_learning/example/NaiveBayesExample.py
3,194
3.5625
4
import os import csv from typing import Iterable, List, Tuple import random import math Row = List[float] Rows = List[Row] path: str = os.path.dirname(__file__) print(path) data_path = path + "/pima-indians-diabetes.data" def loadCsv(file_path: str) -> Rows: rows: Iterable = csv.reader(open(data_path)) ret...
a37b070da7fc4969e9ac3eca2a36e99f501bcb14
SuveenMekala/Web_scraping
/scrapetest.py
1,118
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 22 20:10:01 2018 @author: Suveen """ from urllib.request import urlopen from bs4 import BeautifulSoup import ssl import re # Ignore SSL certificate errors ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NON...
02694416079de92aaa625ef6ca805251a75be11b
FouedDadi/holbertonschool-web_back_end
/0x00-python_variable_annotations/8-make_multiplier.py
425
3.71875
4
#!/usr/bin/env python3 """[float as arg and returns a function (multiplies a float by multiplier)]""" from typing import Callable def make_multiplier(multiplier: float) -> Callable[[float], float]: """[type-annotated function] Args: multiplier (float): [argument float] Returns: callable[...
a471e57b2dcf09ea428fae78886076ce47636ac1
AnubhavMadhav/Learn-Python
/08 Functions/listfun.py
159
3.53125
4
'''We can pass any type of sequence type in the functions like list, set, tuple, maps etc.''' def display(lst): for i in lst: print(i) display([1,2,3,4])
cd35aed5eed721f2e8a25cbae9933a68b811e943
deejaygraham/makers-n-creators
/code/hello-python.py
197
3.96875
4
print('hello, world') print("hello " + "world") print("hello world " * 3) # hard way to draw a border print("##############################") # the easy way to draw a border print("#" * 30)
4864c967ce0f99414f31193346503cfa7189f92a
Bl00drav3n/AdventOfCode
/2021/06/code.py
895
3.5
4
test_input = '3,4,3,1,2' def breed_feesh(input, days): # We only have to keep track of the total number of feesh corresponding to their internal timer counts = [0] * 9 for feesh in [int(v) for v in input.split(',')]: counts[feesh] += 1 for i in range(0, days): zero = counts[0] c...
2d1de2771212f5147172e34b38f4ab1cba77e1c5
EatingLeo/ProjectEuler
/problem3.py
555
4.0625
4
for x in range(2,600851475143): if x % x == 0: print ("This is not a prime number") else: print ("This is a prime number") print ("This is the largest prime number" + str(max(x))) # why the code can't print out the result? # A: because the number you are trying to output is too big. You have to wait for a long...
fb6dd6c9ec3a2268a239bad33019287227431b95
JackKoLing/python_study_notes
/chapter10/chapter10.py
4,456
3.6875
4
# coding: utf-8 """ 第10章:文件和异常 """ # 10.1 从文件中读取数据 import os print(os.getcwd()) # vscode的主目录是以.vscode文件的所在目录为主目录 # 读取整个文件,使用with不用手动close() with open(r'chapter10\pi_digits.txt') as file_object: contents = file_object.read() print(contents.rstrip()) # 逐行读取 filename = r'D:\learnCode\pythonBook\chapter10\pi_d...
630383eb703d6c561fee0d6fd9d8226eb12d189f
k23040198/270201041
/lab8/example3.py
281
3.5625
4
import random def get_rand_list(b,e,N): same=[] list1=(random.sample(range(b,e),N)) list2=(random.sample(range(b,e),N)) for i in list1: if i in list2: same.append(i) print(list1) print(list2) return same print(get_rand_list(0,10,5))
eed166dcf986b8c804f2fab7ca7f45702971f6a1
cheinks/symmetrical-sniffle
/Fortnite Location Generator.py
2,624
3.9375
4
import random import string named_locations = ["Anarchy Acres", "Dusty Divot", "Fatal Fields", "Flush Factory", "Greasy Grove", "Haunted Hills", "Junk Junction", "Lonely Lodge", "Loot Lake", "Lucky Landing", "Moisty Mire", "Pleasant Park", "Retail Row", "Risky Reels", "Salty Sprin...
0bbe6a695d70a9ec0e6c566d5691b3d4aafda194
rsreevishal/A-December-of-Algorithms-2019
/December-11/d11.py
949
4.125
4
def check(email): if('@' not in email): print('@ is required') return elif(email.count('@') > 1): print('@ is used more than once') return else: alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" number = "1234567890" chars = "._-" ...
5dc8e61e3ecc54c5421296a34e4301f9914d9112
danganhvu1998/myINIAD
/code/PythonINIAD/test.py
334
4.40625
4
import math while True: try: # Let's user input radius of a circle, allowing decimals r = float(input('radius=')) # Shows the area of the circle print('The area of circle is', r * r * math.pi) except: # Shows an error message when radius is not inputted correctly print('Please input a radi...
715a107bf5cf39fc12a118eb71cab712d40dce7a
dewanshrawat15/Algorithmic-Toolbox
/week3_greedy_algorithms/3_car_fueling/car_fueling.py
797
3.8125
4
# python3 def compute_min_refills(distance, tank, stops): # write your code here if distance <= tank: return 0 i, numStops, curr_stop, dist_covered = 0, 0, 0, 0 flag = False stops.append(distance) while dist_covered < distance: while i < len(stops) and stops[i] - curr_stop <= t...
195c9bddd8f3e556bdb53edec0ddc5fc371fd529
supriadi-yusuf/python-unit-test
/example 1/activity/test_2.py
563
3.671875
4
"""========================================================== this test is created based on tutorial at https://www.youtube.com/watch?v=_OyuFg9pGQg ==========================================================""" import unittest from unittest import mock,TestCase from .morning import refreshing, refreshing2 ...
a47be00d607d1b5faf1552e40f8624129fb1d05f
parihar1302/python
/python_stringVariable.py
478
3.9375
4
str = "AvengerAssemble" num = 55 print (str) print ("str") print (str[1]) ##indexing :- number start from 0 print (str[4:10]) ##range :- including from given number : excluding only last value print (str[2:]) ##giving value to last value print (str[:4]) ##from first value to second last value print (str, ...
c218f018d9a92e586d00efad277c980c0376b9c7
Michael-Z/poker-analysis-tools
/src/main/python/replayer/replayer.py
717
3.65625
4
''' Given a game replay each hand for review. This class contains all the logic related to interpreting the hands and actions, it is intended to be decoupled from any GUI code. ''' class Table(object): ''' Represents a table state from a game. ''' def __init__(self): self.numPlayers = 0 self.h...
0bc2f5f53847fe0963e1f5587c70aad1cb53b6c9
vamsikrishna6668/python-core
/7-8(am)/all folders/core,python/collections types/List/listed.py
152
3.953125
4
list1=[10,20,30,40,50,60] list2=[1,2,3,4,5,6,7,8] list3 =list1+list2 print(list3) print('--------------------------------') list4= list1*3 print(list4)
e72dd95a46b18c844159089fe9d52928abcb39f2
wartrax13/exerciciospython
/Livro Nilo Ney - Programação Python/Exercicios/Exercicio_5.17.py
1,271
3.90625
4
valor = float(input("Digite o valor a pagar:")) cédulas = 0 atual = 100 apagar = valor print('NOTAS:') while True: if atual <= apagar: apagar -= atual cédulas += 1 else: if atual >=1: print("{} notas(s) de R${}".format(cédulas, atual)) else: print("{} nota...
f15039f8b4998cd384a24966d9282c8ba74dc9b5
GetPython2020/MyfirstRepository
/Leetcode_3_Length_of_longest_string.py
396
3.5
4
def lengthOfLongestSubstring(s): last_appear = {} start=0 longest=0 for index,letter in enumerate(s): if letter in last_appear and last_appear[letter] >=start: start = last_appear[letter]+1 else: longest = max(longest, ...
8081b872b8f22f45be5a9e2d39bdb3becc1622c4
jm824/RiverLevelsANN
/scripts/Gauge/river_readings_archive_file_downloader.py
2,060
3.578125
4
import urllib3 import shutil import datetime import os """ Script to download all 15min archived river level readings from the EA online archive (API). Simply specify the start and end date of the files to download. A directory to download to can be specified. """ class DownloadArchiveFiles: def __init__(self, st...
7a74289e77c0dcc15a2991564643346d57872fe3
sagar437/python_learning
/count_hi.py
198
3.796875
4
def count_hi(str): count = 0 for i in range(len(str) - 1): print(str[i:i+2]) if str[i:i+2] == 'hi': print(str[i:i+1]) count += 1 return count str = 'iamhisa' count_hi(str)
667073ba3bf4301b3013b7fb99603118ca508e71
alexandrepoulin/ProjectEulerInPython
/problems/problem 20.py
320
3.734375
4
print("Starting...") def fact(x): answer = 1 for i in range(1,x+1): answer *= i return answer def sumOfTerms(x): sumSoFar = 0 for i in range(0, len(str(x))): sumSoFar += int(str(x)[i]) return sumSoFar print(sumOfTerms(fact(100))) input("Press enter to exit")
4009abbffc189061949ad2875c24e37c3e4a9482
jlsmirandela/Curso_Python
/Exercicios/ex040.py
333
4.0625
4
nota1 = float(input('Insira a primeira nota - ')) nota2 = float(input('Insira a segunda nota - ')) med = (nota1 + nota2) / 2 if med < 5: print('Média - {:.1f} - REPROVADO'.format(med)) elif 5 <= med < 7: print("Média - {:.1f} - PARA RECUPERAÇÂO.".format(med)) else: print ('Média - {:.1f} - APROVADO!'.form...
9e95aab5f73264b5fd7de1c1f3394e20b3b062b1
DianaZabala02/Ejerciciosphyton
/punto5.py
247
3.953125
4
numM= int(input("Digite el numero de Mujeres: ")) numH= int(input("Digite el numero de Hombres: ")) ta= numM + numH promM= numM * 100/ta promH= numH * 100/ta print(f"El promedio de Mujeres es: {promM}") print(f"El promedio de Hombres es: {promH}")
a361527f96146840a6727040d3e7de13ef3d49d7
pissall20/algorithmic-toolbox
/week2/fib_last_digit_sum.py
470
3.90625
4
def pisano_period(n): prev, curr = 0, 1 for i in range(n*n): prev, curr = curr, (prev+curr) % n if prev == 0 and curr == 1: return i + 1 return 1 def fibonacci_last_digit_sum(n): new_n = (n+2) % pisano_period(10) a, b = 0, 1 for i in range(new_n-1): a, b =...
76c226172594e39c4571a644f4b7da93966bbacc
ashutosh-9211/add
/getting started/missing value deal.py
2,309
3.9375
4
# -*- coding: utf-8 -*- ''' OM SHRI GANESHAY NAMAH''' ''' Dealing with missing value : there are two major methods 1. The Simple One: dropping the missing value containing column 2. Simple Imputer: filling missing values with the mean value ''' ' Dropping the missing value column and calculating MAE' def drop...
fd82fc86f81f5d24f8c4c2656145ff6543b8270e
crobertz/python-algorithms
/lists/heap.py
1,166
3.828125
4
def parent(i): """given index i returns parent index""" return int((i-1)/2) def left_child(i): """given index i returns left child index""" return 2 * i + 1 def right_child(i): """given index i returns right child index""" return 2 * (i + 1) def max_heapify(A, i): """ given array A su...
11ed517ddb811f08e73445786f9d1be833054bff
AP-MI-2021/lab-4-RaresSabau
/main.py
2,855
3.6875
4
def prim(n): ''' Returneaza True daca numarul este prim, iar Flase in caz contrar :return: ''' for i in range(2, n // 2): if n % i == 0: return False return True def test_prim(): assert prim(7) == True assert prim(82) == False def minim_ultima_cifra(lst, n): ''...
db162d658883a24a69358f5221d785b99cd05806
Micromegass/Python
/primrRange.py
418
3.84375
4
import random def prime_range(): #create random number between 2 an 10.000.000 and save to variable random_num = random.randint(2, 10000000) prime_list = [] # find all prime numbers in that list for item in range(2, random_num): is_prime = True for num in range(2, item): if (item % num == 0): is_prime ...
dfc8fb0188709e970706e48183dbbd75b3ba9c63
tdbui1209/thinkcspy3
/Chapter 2/ex2.4.py
188
3.734375
4
# the following line will raise an error # print(bruce + 4) # because bruce is is not defined # Assign a value to bruce so that bruce + 4 evaluates to 10 bruce = 6 print(bruce + 4) # 10
14318482d19eeda5f78d87284f6a5f1f52606acb
LordCatello/ProjectAADS
/Problem4/vertex_cover_tree.py
2,547
4.03125
4
# 27/12/2019 from tree import Tree def vertex_cover_tree(tree: Tree) -> int: """ It evaluates the minimum vertex cover of a tree. It evaluates the minimum vertex cover of the tree passed as parameter :param tree: the tree on wich the vertex cover is performed. :return the number of nodes ...
8992d583a131c07d3800e09cb02f3a50f464f15f
Yang-Ding/leetcode_Python
/35_Search_Insert_Position.py
367
3.609375
4
class Solution: # @param {integer[]} nums # @param {integer} target # @return {integer} def searchInsert(self, nums, target): if nums[0]>=target: return 0 if nums[-1]<target: return (len(nums)) for i in range(len(nums)-1): if nums[i+1]>=target ...
0fae3d7773010b94f87746497e6d49f0fcf9c628
vicamu/countries
/opp/gba.py
1,034
3.6875
4
from pokemons import * import random print("POKEMON".center(50, "-")) print("Oak: Select your first pokemon...") [print(f"{i+1}. {pokemon.name}") for i, pokemon in enumerate(pokemons)] user = int(input("Choose: ")) - 1 pokemon_a = pokemons[user] pokemons.remove(pokemon_a) pokemon_d = random.choice(pokemons) print(f"Yo...
639d77f8476ecc0baafca1c13d8f419f2b604838
Randle9000/pythonCheatSheet
/pythonCourseEu/3_NumericalPython/python_course_eu/15_legends_and_annotations/Ex3.py
412
3.59375
4
from polynomials.polynomials import Polynomial import numpy as np import matplotlib.pyplot as plt p = Polynomial(2, 3, -4, 6) p_der = p.derivative() fig, ax = plt.subplots() X = np.linspace(-2, 3, 50, endpoint=True) F = p(X) F_derivative = p_der(X) print(p) ax.plot(X, F, label="$" + str(p) + "$") ax.plot...
e17716a001abe1debd7cf07b09589d78167f7fb8
hoshinotsuki/DataStructures_Algorithms
/geeksforgeeks/find-distance-between-two-nodes-of-a-binary-tree.py
1,301
3.765625
4
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def distance(root, t1, t2): d1, d2, dp = postorder_search(root, t1, t2, 0) return (d1 - dp) + (d2 - dp) # O(n) def postorder_search(root, t1, t2, d): if root is None: return Non...
9b95e6345920543d56f1c84585bc1f4de9b582be
jesuruban/First_github_pjt
/learnpythonhardway exercises/ex5.py
780
3.875
4
#files from sys import argv script=argv print (argv) file1=input("filename pls... ") #opening the file in read mode and printing file1_txt=open(file1) print (file1_txt.read()) file1_txt.close() #opening the file in write mode,truncating and adding again file1_txt=open(file1,"w+") new_lin1=input("enter the word u wi...
23036af9f08f82479cc3f26a6e1e20081cfc2eed
lulock/cs231a
/ps3_code/p3/problem3/data.py
3,141
3.53125
4
import matplotlib.pyplot as plt import random import torch import torchvision from torch.utils.data import Dataset class MNISTDataset(Dataset): """ A Dataset for learning with subsets of the MNIST dataset for either the original labels or labels that describe how the image has been rotated. Rotations ...
245b7129a2febc2c951c4863372d1321599c1be4
tianyupu/comp3608ass1
/C.py
4,733
3.921875
4
# Master Search # This does a mini-max algorithm, but stores the best 3 options, it then chooses one of these solutions at random with the following probabilities: # 80% chance of the optimal # 15% chance of the second best # 5% chance of the last one import random import A won = 10000 lost = -10000 from Queue import ...
421c762fa7f0490bef1d872d1cc4939c5918c5fb
ltzp/LeetCode
/排序/LeetCode977_有序数组的平方.py
912
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/10/16 0016 21:17 # @Author : Letao # @Site : # @File : LeetCode977_有序数组的平方.py # @Software: PyCharm # @desc : class Solution(object): def sortedSquares(self, A): """ :type A: List[int] :rtype: List[int] """ ...
78f24742f588ae68bab86cd8f46d0eedf48d7424
wasif-balol/saylani-python
/Practise/practise/1.py
101
4.03125
4
print(2**2) print(3**3) print(2**8) print(5/2) list=[1,2,3,4,5] for i in list: print(i)
d83584c590e6411fe026111a314b311b7f0962c1
vishal-B-52/Documentation_of_Python
/OOPExercise5.py
4,645
4.78125
5
# Using class method for alternative constructor :- """ Suppose a user wants to create an object by giving class as input and then passing a string which will get break down to "name", "Salary" and "post". The object must gain it's value from just a string statement and should cover all the 3 arguments of __ini...
d85c9c73c97776bbe3f1141257136f6004eb77df
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4163/codes/1709_3063.py
346
3.90625
4
po=int(input("quantidades de pecas de ouro: ")) y=input("nome da armadura escolhida: ").upper() #lower d= int(input("fator de destreza: ")) if(y == "INTEIRA") and (po>=200): r=(30*d-20) print(r) elif(y=="MALHA") and (po>=50): r=(15*d-1) print(r) elif(y=="PLACA") and (po>=100): r=(20*d-18) print(r) else: r=("PO...
8c9baf8ca5d92dff2274fc30645fd0c077c6299a
Ming-Qin-tech/MIT-6.0001
/MIT 6.0001 python/pytest/trytest.py
206
3.640625
4
try: a = int(input("input a number")) b = int(input("input a number")) print(a/b) except: print("bug in user input") else: print("none mistake") finally: print("whatever")
6dd9d88c35481a14f849b661c387abc99e690236
czbijian/python
/day05/06引用传递.py
422
3.71875
4
def test1(x,y): x.replace("c","C")#关键在这里,该结果x和a指向同一个地址。 #如果改为x=x.replace("c","C"),则x与a指向不同的地址 y.append(10) print("x变量指向的内存地址为:%s"%id(x)) print("y变量指向的内存地址为:%s"%id(y)) a = "abcdefg" b = [1,2,3] print("a变量指向的内存地址为:%s"%id(a)) print("b变量指向的内存地址为:%s"%id(b)) test1(a,b)
f0a9a9c053dc3ba56dc4c6419a99b7dad5597249
MichaelReiter/CSC361
/Assignment 1/http/cookies.py
884
3.578125
4
import re from typing import List class Cookie: """ Cookie parsed from HTTP response header has name, key and domain. """ def __init__(self, name: str, key: str, domain_name: str) -> None: self.name: str = name self.key: str = key self.domain_name: str = domain_name def __s...
75e8a68094b4752056880313e79dd0be1eb4739f
inwk6312winter2019/openbookfinal-Vijaisriraam
/task1A_2.py
642
3.796875
4
import string def count_the_article(book): count=0 book_list=[] for line in book.split(): word=line.strip(string.punctuation) myword=word.lower() book_list.append(myword) # print(book_list) count=count+1 print('The total no of words in the word_list is:',count) fp1=open('Book1.txt') file1=fp1.read() fp2=...
67aba3b508389b92ed3219a55d90004e463065f0
ZackAkil/random-scripts
/infinity-string.py
196
3.6875
4
import operator def infstr(s): """Tests for an infinity string.""" a=map(ord,s) m=lambda x,y:x-y t=lambda i,j:i*j return reduce(t,map(m,a[:3:2],a[1::2]))<0 print infstr('alpha')
c50314dd8806b408b4ef0bf88cd781610b2b344f
G00398275/PandS
/Week 09/myFunctions.py
1,021
3.640625
4
# Lab 9 Errors, Testing and Logging; myfunctions.py # This program contains the tests for checking useFib.py # Author: Ross Downey import logging #logging.basicConfig (level = logging.DEBUG) def fibonacci (number): a = 0 b = 1 fibonacciSequence = [0] # one in list already, number -1 times for i ...
f0936be764c00e31810ef824a2a604fd8fc0d7e9
paperboi/ICG-Lab
/3.5-Bcircle.py
2,983
4.09375
4
# ####################################### # BRESENHAM'S CIRCLE DRAWING ALGORITHM # by Jeffrey Jacob, CED15I036 # ####################################### import sys, pygame from pygame import gfxdraw BGColor = (4, 15, 15) TextColor1 = (46, 233, 131) TextColor2 = (242, 226, 186) TextColor3 = (252, 255, 252) TextColor4 ...
c7e9d95eef63900be0aa3e9f873d041b68350be9
Givrecoeur/Behind_The_Stars
/modules/MathClassFunctions/Lines.py
6,157
3.71875
4
# -*- coding: utf-8 -*- """ Created on Sun May 29 17:11:27 2016 @author: Benoît """ import math import numpy import matplotlib.pylab as py import Points class Line(): def __init__(self, point1, point2): self.dir, self.ori = self.create_line_2p(point1, point2) self...
dbbceaab06f3df6a05bbc4abab0ff07670ccb8ab
mariacamila0712/Taller_ciclos_para
/ejercicio4.py
1,105
3.796875
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 20 21:24:40 2021 @author: Maria Camila """ # Calcular el promedio de edades de hombres, mujeres y de todo un grupo # de alumnos. cantidad_alumnos = int(input('Digite la cantidad de alumnos: ')) total_mujeres = 0 contador_mujeres = 0 total_hombres = 0 contador_hombres =...
31874271f5c1baf5e1df0a17e8dceddea62a41ec
KaioViana/pense-python
/listas/middle.py
340
3.984375
4
def middle(t): """Recebe uma lista e retorna uma cópia dela contendo apenas os valores do meio :param t: lista de valores numéricos :return: cópia da lista t apenas com os valores do meio """ return t[1:-1] def main(): t = [1,2,3,4] t2 = middle(t) print(t2) if __name__ == '__mai...
224c879d62b32ef745d6952f9bd5db61cb8fbe3c
abmurli/my_codes
/python_code/Self-test/sorting/max_value_in_the_list.py
215
3.875
4
def max_value(arr): max_value = arr[0] for i in arr: if i > max_value: max_value = i print(max_value) if __name__ == '__main__': arr = [5, 3, 4, 2, 3, 5, 5] max_value(arr)
b2b38e5223842cd136b2634af69109a97de317b3
jaruserickson/project-euler-solutions
/python/004.py
1,132
4.15625
4
def largest_palindrome_bruteforce(): lst = [] for number in range(100,1000): for num in range(100,1000): #cast as string to make it easier to check if its a palindrome if is_palindrome(str(number * num)): lst.append(number * num) return max(lst) #checks if n...
df07b12dc9ab0b4c342b2d983da25c4e07c4315d
ayaz98/demo_project
/first.py
95
3.59375
4
print("Ayaz") for i in range(10): print("Hello World") if True: print("THis is new World")
a993c3e359392754bd4d1cf46d00bf840da03c73
byAbaddon/OOP-Course-PYTHON-May-2020
/5.1 Inheritance - Exercise/06. Mix it/project/vehicle/car.py
1,000
3.625
4
from project.vehicle.vehicle import Vehicle class Car(Vehicle): def __init__(self, available_seats, fuel_tank, fuel_consumption, fuel ): super().__init__(available_seats) self.fuel_tank = fuel_tank self.fuel_consumption = fuel_consumption self.__fuel = fuel @property ...
6f2f68c740a3552848f9213383a8c4ebd830dfac
nischalshrestha/automatic_wat_discovery
/Notebooks/py/honeygupta/titanic-survival-predictor/titanic-survival-predictor.py
7,419
3.546875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns get_ipython().magic(u'matplotlib inline') # In[ ]: #import train and test CSV files train = pd.read_csv("../input/train.csv") test = pd.read_csv("../input/test.csv") #ta...
c52f31e9b635524788e823c06d85b2bc07f9223d
Notinfrequently/python-hw
/hw_6/funcs.py
1,766
3.53125
4
from typing import Iterable def ilen(iterable: Iterable): """ >>> foo = (x for x in range(10)) >>> ilen(foo) 10 """ return sum([1 for i in iterable]) def flatten(iterable: Iterable): """ >>> list(flatten([0, [1, [2, 3]]])) [0, 1, 2, 3] """ ls = list(iterable) if not ls...
9fe3954740b24b62bcb4428da0890ea6fba00cd3
oliverlee0/cryptography
/crypt.py
3,329
3.640625
4
import random import math # Caesar Cipher # Arguments: string, integer # Returns: string def encrypt_caesar(plaintext, offset): ciphertext = "" for char in plaintext: ciphertext += chr(ord(char) + offset) return ciphertext # Arguments: string, integer # Returns: string def decrypt_caesar(ciphertext, offset): p...
36c8078c357d6b2e8cf948753ab2e97cb7cb7781
AdrianVasquez1/FirstTurtleProject
/Star.py
587
3.9375
4
import turtle turtle.shape("turtle") turtle.left(80) turtle.speed(100) def star(turtle, size): for i in range(5): turtle.forward(size) turtle.right(144) def starSpiral(): size = 1 for i in range(60): star(turtle, size) size = size + 5 turtle.forward(10) tu...
12dafbc9f347e7cb589da23abdaa1a871dcc5826
vivek-nagre/LU2Nd
/LUB2.py
503
3.921875
4
name="vivek" print(name.upper()) print(name.capitalize()) print(name.index('i')) print(name[3]) print(name.count("v")) # list assignmant lst=["my","name","is","vivek",] print(type(lst)) lst.append("nagre") print(lst.index("my")) lst.reverse() lst.remove("is") lst.insert(0,"so what") # del lst print(l...
bb7153fc2d623e3420a855fa0f89d1034b447d00
shaunc44/Python-Exercises
/string_replace.py
184
3.546875
4
def string_replace(*phrase): phrase = ",".join(phrase) phrase = phrase.replace("right", "left") return phrase print string_replace("right now I would like to do the right thing!")
26e54ed2a1c9a9c28c1470989655816f0eaef995
pzy636588/wodedaima
/遍历字典.py
590
4
4
#dictionary.item(),其中dictionary为字典对象,返回值即可遍历的(键--值)的元素列表,想要获取到具体的“键--值对”,可以通过for循环 #遍历该元素列表 dictionary={'阿里巴巴':'码云','腾讯控股':'马化腾','字节跳动':'张一鸣'} for item in dictionary.items(): print(item) #获取字典的各个元素 dictionary = {'阿里巴巴': '码云', '腾讯控股': '马化腾', '字节跳动': '张一鸣'} for key,value in dictionary.items()...
1270e17a6c5222a6e0f5c404f583f33cc6c065fb
vinceajcs/all-things-python
/algorithms/string/sliding window/minimum_window_substring.py
3,999
4.03125
4
"""Given a string s and a string t, find the minimum window in s which will contain all the characters in t. Example: Input: s = "ADOBECODEBANC", t = "ABC" Output: "BANC" Note: If there is no such window in s that covers all characters in t, return the empty string. If there is such window, you are guaranteed that th...
faf4baf8385e48c371c6d6852ad8ac72add1d3e5
AndCotOli/Zipper
/main.py
1,837
4.375
4
from Zipper import Zipper from pathlib import Path def main(): print("Welcome to Zipper, the tool for compressing files into multiple formats!\n") print("Let's get started. First, select a type of compression. Accepted types are: zip, tar, gtar and btar.") extensions = ("zip", "tar", "gtar", "b...
af4e32f52418f9faa7318ee4e741746df246c54d
SheikhFahimFayasalSowrav/100days
/days021-030/day023/capstone/car_manager.py
1,265
3.59375
4
from random import choice, randint from turtle import Turtle COLORS = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"] STARTING_MOVE_DISTANCE = 5 MOVE_INCREMENT = 10 class Car(Turtle): def __init__(self): super().__init__('square') self.color(choice(COLORS)) self.pu() ...
ad512d31962937703b0cf1ddf0f17cd6d0c15ec5
eperich/project_euler
/problem9.py
571
3.765625
4
def check_sum(num1, num2, num3): num_sum = num1 + num2 + num3 check = False if num_sum == 1000: check = True return check b = 1 c = 2 check1000 = False while b < 999: while c < 999: a2 = c ** 2 - b ** 2 a = a2 ** (1 / 2) if a.is_integer(): check1000 = c...
1e3b80a977b45cd4377b363b2fdca7f20624a781
ozan-git/Fibonacci-and-BinarySearch
/main.py
5,290
4.09375
4
# Performs find n-th fibonacci number and binary search. # It was created on October 17, 2021. # Written by Orhan Ozan Yildiz. import numpy as np def Fibonacci(order): # The fibonacci sequence begins from the first term so it can't be 0. if order <= 0: print("Please enter a valid number.") # The first fibonacci...
166661dec76def217ce3e3c8288b89d3f7ef87d8
ManushApyan/python_lessons
/leap_year.py
170
4.0625
4
my_year = input("Please enter the year: ") my_year = int(my_year) print(my_year) x = 4 y = my_year%4 y = bool( not y) print("That fact than your inputted year leap is",y)
d009b0020e7baa417ca6a0dffda3e4859b97501e
milanpopovic/PyUchim
/projects/Milan.Popović/fibonacci.py
708
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Nov 11 14:38:42 2018 @author: milan """ # Fibonacci numbers # Iterative algorithm def IterFib(n): if n <= 1: return 1 f1,f2 = 1,1 for i in range(n-1): f1,f2 = f2,f1+f2 return f2 # Recursive algorithma def RecFib(n):...
47acb867a532156d90b13e92132115f232256c05
jatin69/mca101-OOPS
/Recursive List sorting/insertion_sort/mysort-del-index-tracking-ins.py
1,353
4.03125
4
mylist=[1,7,8,5,2] def mysort(mylist,sort_index=0,unsort_index=1): ''' Objective : Sort the List ''' #print(" called with : sort_index = ",sort_index," and unsort index = ",unsort_index) #print(mylist) if((len(mylist)== unsort_index)): # print("returning") return # ch...
61cfb882855fb017da5a8cb214ac31ded6bf59f5
kunalghosh/BECS-114.1100-Computational-Science
/exercise2/problem3.py
2,632
3.765625
4
from __future__ import division import doctest import pylab as pl import numpy as np # a) use newton's method to calculate roots # equation = x^3 - x - 5 # x_initial = 0.57735 # max_iter = 50 # print the results and explain them ## TODO : Write tests # x^3 - 1 , re-written to get rid of powers def f(x_r,x_i): ...
1799b1f40d4e27be6a4337d708861f40be2e9593
nub8p/2020-Summer-Jookgorithm
/최민우/[20.07.24] 10874.py
106
3.78125
4
ans = '1 2 3 4 5 1 2 3 4 5' for i in range(1, int(input()) + 1): if ans == input(): print(i)
5dce3a5dff916440fa08284e574b757fcc67a50c
gsbhardwaj27/datastructure-algorithms-related-problems-python
/coursera_algorithms_part1/week1/union_find_with_specific_canonical_element.py
2,118
3.734375
4
''' Interview Questions: Union–Find (ungraded) Union-find with specific canonical element. Add a method 𝚏𝚒𝚗𝚍() to the union-find data type so that 𝚏𝚒𝚗𝚍(𝚒) returns the largest element in the connected component containing ii. The operations, 𝚞𝚗𝚒𝚘𝚗(), 𝚌𝚘𝚗𝚗𝚎𝚌𝚝𝚎𝚍(), and 𝚏𝚒𝚗𝚍() should all take l...
eb75850b921220f8c5c3acc9c5d921dd0bff30d8
tontonchin/hulistics_kai1028
/model/zikkou_zissen.py
3,233
3.625
4
"""このプログラムは実行部です""" import numpy as np import random import math from moussaif import fa_dasu, hulistics_1, cal_fij, cal_fiw , dasu_v_1d, dvdt import matplotlib.pyplot as plt import matplotlib.animation as animation import pandas as pd #関数部の関数を全ぶmoussaif.pyからインポートしてから実行する #n = 10 pi = math.pi df1 = pd.read_excel('...
cf262c948a908a7c9337bc7739b72fb95a276cc8
li2ui2/Python_Personal_DEMO
/DATA_STRUCTURE/leetcode/滑动窗口/无重复字符的最长子串.py
693
3.796875
4
""" leetcode 3 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 """ import collections def lengthOfLongestSubstring(s): n = len(s) if s is None or n == 0: return 0 count = collections.Counter() left = 0 result = 1 for right in range(n): co...
13bf572e0e1a91966211f43f502b36c54b835e38
songjiyang/Mypython
/myPractice/combination.py
483
3.796875
4
import copy def combine(array,comb_num): length = len(array) result = [] item = [0]*comb_num def next_item_item(loop_num=0,num=0): if num == comb_num: result.append(copy.copy(item)) return for i in range(loop_num,length): item[num]=array[i] ...
1ec0713a165935027d24c1d5b2f0185ded62b99a
qaz8586248/Study
/01/p10.py
561
3.953125
4
# 关于self的案例 class A(): name = " liuying" age = 18 def __init__(self): self.name = "aaaa" self.age = 200 def say(self): print(self.name) print(self.age) class B(): name = "bbbb" age = 90 #a = A() # 此时,系统会默认把a作为第一个参数传入函数 #a.say() # 此时,self被a替换 #A.say(a) # 同样...
1153efff69d0b3bfd1bf809c9751f2f45b42ceb1
ydf0509/distributed_framework
/function_scheduling_distributed_framework/concurrent_pool/custom_threadpool_executor.py
11,562
3.84375
4
""" 史上最强的python线程池。 最智能的可自动实时调节线程数量的线程池。此线程池和官方concurrent.futures的线程池 是鸭子类关系,所以可以一键替换类名 或者 import as来替换类名。 对比官方线程池,有4个创新功能或改进。 1、主要是不仅能扩大,还可自动缩小(官方内置的ThreadpoolExecutor不具备此功能,此概念是什么意思和目的,可以百度java ThreadpoolExecutor的KeepAliveTime参数的介绍), 例如实例化一个1000线程的线程池,上一分钟疯狂高频率的对线程池submit任务,线程池会扩张到最大线程数量火力全开运行, 但之后的七八个小时平均每分钟...
0ce32f5f0d21848c642a6849050d09d23c0dd254
ReggieCarey/ExactMatching
/NaiveApproach/Match.py
1,007
3.671875
4
class Match: def __init__(self): pass @staticmethod def match(t: str, p: str) -> list: c = 0 n = len(t) m = len(p) results = list() for i in range(n - m + 1): NOMATCH = False for j in range(m): c += 1 i...
57dcb878c5aae85876973db2aa42353fd54a58a8
nurgleth/LeetCode_algoritms
/easy/1281 Subtract the Product and Sum of Digits of an Integer/task.py
525
4.125
4
""" Given an integer number n, return the difference between the product of its digits and the sum of its digits. Example 1: Input: n = 234 Output: 15 Explanation: Product of digits = 2 * 3 * 4 = 24 Sum of digits = 2 + 3 + 4 = 9 Result = 24 - 9 = 15 Constraints: 1 <= n <= 10^5 """ def subtractProductAndSum(n): ...
bf6569a3a0e477f14954b250e6e3245950f0fee9
stevenschmatz/cryptography
/RSA.py
764
3.84375
4
from itertools import combinations def euclid(a, b): '''returns the Greatest Common Divisor of a and b''' a = abs(a) b = abs(b) if a < b: a, b = b, a while b != 0: a, b = b, a % b return a def coprime(l): '''returns 'True' if the values in the list L are all co-prime ...
64ad42453e9af732ba9d0cea5199ce635adf696f
madhurimukund97/MSIT
/3. CSPP1/cspp1 final exam/assignment1/assignment1/read_input.py
315
4.28125
4
''' Write a python program to read multiple lines of text input and store the input into a string. ''' def main(): '''main''' input1 = '' num = int(input()) for i in range(num): i += 1 input1 += input() input1 += '\n' print(input1) if __name__ == '__main__': main()
5fb1a70b5720ddf4e0eb9ecfb575aba07b36fbf8
iGetPoints/python-junk
/calculator_example.py
539
4.25
4
# First attempt at making a calculator print('What kind of operation would you like to do? (+ - * /) ?') Opp = input() print('Enter the first number') Num1 = input() print('Enter the second number') Num2 = input() if Opp == '+': Answer = int(Num1) + int(Num2) elif Opp == '-': Answer = int(Num1) - in...
0b08e9043e0320f82adab8db475c27f64e6dc66f
YaJunCui/learn_files
/python/learn_python/test_if.py
83
3.5
4
# coding:utf-8 a = 5 if a==4: print "it is four" else: print "it is not four"
767af55ce24d7ae1813ab402a65967afb902d251
DastLab/AttributedGraphProfiler
/query_rewriter/test/similar_strings_test.py
1,081
3.515625
4
from io import StringIO import editdistance import pandas as pd from query_rewriter.test.relaxer_test import similar_strings def main(): print("Levenshtein similar strings...") data = StringIO("""name;sex;city;age john;male;newyork;20 jack;male;newyork;21 mary;female;losangeles;45 maryanne;f...
ecd5ee2e7afd4eeea31103060348dec7632dbc7b
Jet-son/refactored-memory
/Day2/Day2.py
796
3.609375
4
f = open("Day2Input",'r') passwords = [i for i in f.readlines()] def parser(item): plist = item.split() finallist = [] tmp = plist[0].replace('-',' ') tmp = tmp.split() finallist.append(tmp[0]) finallist.append(tmp[1]) tmp2 = plist[1].replace(':','') finallist.append(tmp2) finallis...
ffa4792a2e4086e71f4a21e01f27a0024ee79b3a
alexaugusto23/The-huxley
/Demais/Multiplos.py
183
3.796875
4
#Multiplos mult = int a,b = input().split(" ") a = int(a) b = int (b) mult = (b/a)*a print(mult) if (mult == b): print("Sao Multiplos") else: print("Nao sao Multiplos")
8070960c76c0e02a329a955370d9a14dda1fea74
LeoHeller/PyDrone
/modules/utils.py
1,700
3.65625
4
"""Helper functions.""" import threading import time import time as t update = "Sun Sep 9 22:08:04 2018" name = "Leo Heller" # filename = os.path.basename(main.__file__) def setupdate(): """Change the last update date.""" global update update = t.ctime() def head(): """Print header.""" prin...
54aa7a8d94030086293256fd1c450987648334aa
andrewyang89/spectrazam2electricboogaloo
/spectrazam2electricboogaloo/Profile.py
1,694
3.609375
4
import numpy as np class Profile: """ Defines a profile for a face, including the respective face label and the mean descriptor vector of all associated descriptor vectors """ def __init__(self, name: str, d_vectors_in): """Creates an instance of the Profile class Parameters ...
dea5d0f37ec9b5d953404f7d3299c2fbb0fcef70
melodist/CodingPractice
/src/HackerRank/Prime XOR.py
775
3.5625
4
""" Using dynamic programming """ #1. My Solution from collections import Counter def is_prime(n): i = 2 if n < i: return False while i*i <= n: if n % i == 0: return False i += 1 return True def primeXor(a): MOD = 10**9 + 7 count = 0 c = Counter(a) M = 8192 ...
a3da205721534ad14436f59edb962e972fb17db6
KalahBranch/spiral
/spiral/homework.py
326
4
4
def spiralize(number): if number == 1: return_value = 1 else: return_value = ( 2 * (number * number * 2) - (2 * number - 2) * 3 + spiralize(number - 2) ) return return_value if __name__ == "__main__": print(spiralize(5)) print(spiralize(21)) print(spiralize...
5e4654299fa14dd80fbb0088fe1e6f6f55b97d28
AbdManian/pythonclass-exercises
/ex7/drawengine_answer.py
2,897
3.65625
4
import turtle # fill_box(x, y, dx, dy, [color=None]) # box((x1,y1), (x2,y2), [color=None], [width=None]) # box(x1,y1,x2,y2, [color=None], [width=None]) # fill_box_array(x, y, dx, dy, cnt, [add_x=0], [add_y=0], [color=None]) # line(x1, y1, x2, y2, [color=None], [width=None]) # multiline((x1,y1), (x2,y2), ...., (xn,yn) ...
39fa3dbb779fe694feae287c3b77c330ad7b31d5
Jzgao04/Year9DesignCS-PythonPM
/RamanujanTaxi.py
195
3.6875
4
digit1 = input() digit2 = input() digit3 = input() digit4 = input() if digit1 == 8 or digit1 == 9 or digit4 == 8 or digit4 == 9 or digit2 == digit3: print("ignore") else: print("answer")
fd96d70a9e83eadb7cec9b059420e71425cd3333
juandarr/ProjectEuler
/25.py
501
3.84375
4
""" Finds the first 1000-digit in the Fibonacci series Author: Juan Rios """ def fibonacci(number_length): a = 1 b = 1 current_index = 2 big_number = 10**(number_length-1) while ((b/big_number)<1): tmp = b b = a + b a = tmp current_index += 1 return current_inde...
aadd887090ee0a13c6b336d6b1e2d1a866c7a964
humachine/AlgoLearning
/leetcode/Done/108_ConvertSortedArrayToBST.py
824
3.90625
4
#https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ '''Given an array where elements are sorted in ascending order, convert it to a height balanced BST. ''' class Solution(object): def arrayToBST(self, nums, start, end): if start == end: return None mid = (start+en...
99db4bfbaa4e033f605aaadbeaaac360401885f3
RonanChance/competitive-programming
/UnlockPattern.py
649
3.71875
4
import fileinput file = fileinput.input("test.txt") line1 = file.readline() line1 = line1.strip() line2 = file.readline() line2 = line2.strip() line3 = file.readline() line3 = line3.strip() print(line1) print(line2) print(line3) def finding(loc): if loc == # finding location of start s = 1 if str(s) in line1...
2ffe9a3e920b7301e79ad39ac4e4008e9920e803
DmOfff/praktika
/1/t93.py
180
3.5625
4
# Найдите сумму квадратов первых n натуральных чисел n = int(input("n: ")) sum = 0 for i in range(1, n+1): sum += i * i print(sum)