blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
717cf6f2d2015fc7cb0e88bd72becb3ee2f0855f
DZH777/Python
/Scripts/input/input.py
2,482
4.09375
4
#input message = input("Tell me something, and I will repeat it back to you: ") print(message) #prompt prompt = "If you tell us who you are, we can personalize the messages you see." prompt += "\nWhat is your first name? " name = input(prompt) print("\nHello, " + name + "!") #int age = input("How old are you? ") age = ...
82d5456ca5fdb122c32e47f2cde86740ef426f69
DZH777/Python
/Scripts/files/file_reader.py
1,122
3.8125
4
with open('pi_digits.txt') as file_object: contents = file_object.read() print(contents) print('----------------') filename = 'pi_digits.txt' with open(filename) as file_object: for line in file_object: print(line.rstrip()) print('----------------') with open(filename) as file_object: lines = file_o...
024343f773389f8691f7fa029142d1ab3b9ebd6b
nhungtlu/nguyenthihongnhung-fundamentals-c4e01
/BTN/Doi.py
91
3.578125
4
a = int(input('Enter the temperature in Celsius?: ')) S = a*5.0 print(a,'(C) = ', S, '(F)')
1a7efe4aff7dc3947fe20750a19ded25b1f196c9
nhungtlu/nguyenthihongnhung-fundamentals-c4e01
/BTN/giaithua.py
212
3.515625
4
def giaithua(n): if (n == 1): return 1 else: return (n * giaithua(n-1)) num = int(input("Nhập số cần tính giai thừa: ")) print("Giai thừa của", num, "là", giaithua(num))
2de55c442d2bd6f9d83d01a8a3cb01d0c63a972d
MFurkan41/pythonAll
/Console/Blindfolded Cube Solving/blindfolded_cube.py
476
3.609375
4
liste = [["A","Q"],["B","M"],["C","I"],["D","E"],["F","L"],["G","X"],["H","R"],["J","P"],["K","U"],["N","T"],["O","V"],["S","W"]] write = input("") write = write.upper() write = write.split(",") for i in range(0,len(write)): for j in range(0,len(liste)): try: if(write[i] == liste[j][0]): ...
d8730777a1d2c3beedb81b085b71f3c1f9acf246
isurucuma/xtreme
/Stack/Stack without size limit/Stack.py
1,224
4.03125
4
class Node: def __init__(self, value=None): self.value = value self.next = next class LinkedList: def __init__(self): self.head = None def __iter__(self): curNode = self.head while curNode: yield curNode curNode = curNode.next class Stack:...
6ee684d3ec3c4fdba85fa3165177068dcd4b3407
gerrylwk/Efficient-Matrix-Algorithms
/augGauss.py
753
3.5
4
import numpy as np def augGauss(mat): #Gaussian for general matrix n = len(mat) for i in range(0,n-1): for j in range(i+1,n): m = mat[j][i]/mat[i][i] for k in range(i+1,n+1): mat[j][k] -= m*mat[i][k] x = np.zeros(n) ...
04944ef0b264ac84038ae9e11ba9a45f82592742
charleygrossman/algorithms
/sort/comparator.py
883
3.75
4
from typing import * from collections import defaultdict from functools import cmp_to_key def main(): s = "ccbbbaad" want = "b3,a2,c2,d1" got = freqsort(s) assert want == got, f"freqsort: want={want} got={got}" def freqsort(s: str) -> str: """ Map the characters of s to their frequencies (oc...
94415ac7f8301896f33ee3c117785d79008ef299
akshar-raaj/hack
/priority_queue.py
322
3.859375
4
import heapq class PriorityQueue(object): def __init__(self): self._list = [] def append(self, element, priority): """ Keep the priority queue always sorted """ heapq.heappush(self._list, (-priority, element)) def pop(self): return heapq.heappop(self._list)[...
2e9bc39142d2e4d528b1e69c71eb01855fdf9025
akshar-raaj/hack
/prime.py
333
4
4
def is_prime(num): assert num > 1 if num == 2: return True else: for divisor in range(2, num): if num % divisor == 0: return False return True def primes_greater_than_equal_num(num): while True: if is_prime(num): yield num ...
71b0a92901b185227ca6e52bb6807a6514d24498
akshar-raaj/hack
/hack.py
996
3.828125
4
class A(object): NAME = 'akshar' def search(search_term, strings): for term in strings: if search_term in term: yield term #strings = ['abc is good', 'bad', 'sad is bad', 'cde is after abc'] #results = search("abc", strings) #for result in results: #print result def dedup(input): s...
41ec52083a881c604f2d6de7ea3d785de5d4d1ce
lufias69/reduksi_huruf
/reduksi_kata.py
322
3.546875
4
def reduksi_huruf(kata): #kata = 'siiiiiiapaaaa' nkata = list() for i,k in enumerate(kata): if i>2: if kata[i]== kata[i-1] and kata[i] == kata[i-2]: continue else: nkata.append(k) else: nkata.append(k) return "".join(nkata...
db5fbd53ae39f5c6db44c0aba98b3ae0659abb41
ratuljain/report
/BellmanFord.py
653
3.546875
4
d = {} def addStuff(d, k, v): if k in d: d[k].append(v) else: d[k] = [] d[k].append(v) addStuff(d, "ravi travels", "arv-10:30,dep-10:40") addStuff(d, "ravi travels", "arv-09:30,dep-09:40") addStuff(d, "ravi travels", "arv-11:30,dep-12:40") addStuff(d, "kishore travels", "arv-09:30,de...
cd850f2488d51f8f854faf8e0acbf25633311950
hcape/SATsudoku
/sud2sat.py
4,693
3.609375
4
#!/usr/bin/python import sys, logging import string N = 9 # logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) def base9(i, j, k): """Convert a number to base 9""" return 81 * (i - 1) + 9 * (j - 1) + (k - 1) + 1 # one number per cell rule def main(input_fname, output_fname): row_pos = 1 co...
1ec23cf5561ad8015fc495c26650e06e92e788aa
khiner/notebooks
/python_crash_course/chapter_9_code/restaurant.py
801
4.125
4
"""A class that can be used to represent restaurants.""" class Restaurant(): """A simple model of a restaurant.""" def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaur...
fe59da80b29e77a6ef2e7d3eb52f67bb7425456a
skysunsun/-
/lpthw/ex15.py
299
3.875
4
from sys import argv script, filename = argv txt = open(filename)#打开文件 print(f"Here's your file {filename}:") print(txt.read())#读文件 print("Type the filename again:") file_again = input(">")#手动输入 txt_again = open(file_again)#打开文件 print(txt_again.read())#读文件
59afa78306819d40783f42a86247fe30255d65bb
wangzexin/ProblemEuler
/Largest palindrome product.py
365
3.609375
4
# Initialization a = 999 f = False nums = [] # Loop from the largest 3-digit numbers while a > 99: b = a while b > 99: st = str(a*b) if st[0] == st[-1] and st[1] == st[-2] and st[2] == st[-3]: nums.append(a*b) b -= 1 a -= 1 # Find the max m = -1 for num in nums: if...
aa683e7eb0966f12da282a0b52f3da43402bc54e
sandycamilo/CS1.1-madlibs
/madlibs.py
1,020
3.6875
4
import os as os bashCmd = "clear" os.system(bashCmd) print('Hi! So happy you are here!') name = input("Enter a name") verb = input('Enter an -ing verb') adjective = input('Enter an adjective') noun = input('Enter a noun') place = input('Enter a place') color = input('Enter a color') feeling = input('Enter a feeling...
70dfbc76a13b6a9332ac1b2cddce900f9779325f
h4rm41n/Python-Basic-Weekend
/latihan_3.py
368
3.765625
4
x = 2 y = 2 pangkat = x**y print pangkat # result = x + y # print (" x + y ", result) # result = x - y # print (" x - y ", result) # result = x * y # print (" x * y ", result) # result = x / y # print (" x / y ", result) # result = x % y # print (" x % y ", result) # result = x ** y # print (" x ** y ", result) ...
aee867bbdcc4c25cc347bb7061168acd8728cb54
camillebrsn/MoocGit
/functions.py
784
3.546875
4
def list_sum(liste): if isinstance(liste[0], int): out = 0 elif isinstance(liste[0], str): out = '' for elem in liste: out += elem return out def facto(n): out = 1 for elem in range(2, n+1): out = out*elem return out def diff_list(liste1, list...
84abad9398b45e2d64f38942e403992040a20c22
theignaciocode/ProjectEuler
/10001st prime/problem.py
349
3.53125
4
primeNumberFound = 10001 primeNumberCount = 0 number = 1 while primeNumberCount < primeNumberFound: number += 1 contador = 0 for numberTemp in range(2, int(number**(1/2))+1): if number % numberTemp == 0: contador += 1 break if contador == 0: primeNumberCount += 1 pri...
a657b2e3053aecd9eb2f9950a58c84f3b8b123c7
ankitprakash89/Python-Case-Studies
/Case Study 2.py
3,521
3.625
4
# coding: utf-8 # In[42]: import pandas as pd import numpy as np store = pd.read_csv("C:/Users/Administrator/Desktop/Jupiter notebooks/Store.csv", header = 0, encoding="latin") store.head(n=5) # In[16]: #1.How many unique cities are the orders being delivered to cities = store.City.unique() print(len(cities)) ...
406ebf860e68bdcec718eb1b1b6a8e118d43e4b8
mohitrobo/Project-Euler
/Largest prime factor.py
802
4.03125
4
#program to find the largest prime factor of a number import time start = time.time() #Enter the number for which prime factor needs to be found num = 600851475143 #variable for storing prime factors prime_factor = 0 x = 2 #for finding and incrementing the prime factors while x>1: for i in xrange(2,x): #for fi...
4aa4100dce1f44eb91a8fc79c241586933dbcb7d
mohitrobo/Project-Euler
/40_Champernowne's constant.py
1,501
3.8125
4
#Champernowne's constant #1.) I need the fractional part with numbers starting from 1 to 1000000 number #2.) Since we need to retrieve the digit locations and multiply them, so we do not need to iterate till 1000000 number #3.) So we need to find the number to iterate through so that the number of digits reaches 10000...
96c300222f1a29dcc4fe68592e65087db6761656
mohitrobo/Project-Euler
/Digit fifth power.py
398
3.59375
4
#Digit fifth power #let's assume the upper bound number be n = k*(9^5) #so the possible upper bound number could be in the range # 10^(k-1) <= k*(9^5) <= 10^(k) #so we find that k = 6 import time start = time.time() add = 0 #for adding the numbers for i in range(10,6*(9**5)): if sum([int(j)**5 for j in str(i)]) ...
a81016b9ef05cf841615f43cb5844777653c8571
mohitrobo/Project-Euler
/power digit sum.py
348
3.90625
4
#sum of the digits obtained from 2^value import math import time start = time.time() #function to calculate sum of digits def power_sum(n): add = 0 #variable to store the addition x = str(int(math.pow(2,n))) for i in range(0,len(x)): add += int(x[i]) return add print(power_sum(1000)) end = t...
d0593f601285844e42a189c53396649839552f49
mohitrobo/Project-Euler
/Prime pair sets.py
2,587
3.84375
4
#Prime pair sets #Go to this site for more information #https://blog.dreamshire.com/project-euler-60-solution/ #1.) create a list of prime number upto 10000, except 2 becoz concatenating 2 will always be divisible #2.) Find pairs of concatenable primes and then use each set to find intersections with other sets. #So, ...
8457f47632e90351e6728f59b7bbdac77106c7de
mohitrobo/Project-Euler
/Consecutive prime sum.py
983
3.921875
4
#Consecutive prime sum #list to store prime number prime = [2] #dictionary to store the number of prime sum for a given prime prime_sum = {} num=2 #check for the length of prime list y = 0 #function to find prime number def prime_number(p): for i in range(2,p): if (p%i) == 0: break else...
fd26400d5d0460375ba2fe6c13cf38730820c8f5
mohitrobo/Project-Euler
/Coin sums.py
767
3.59375
4
#Coin sums #solving using mathematical equation import time start = time.time() counter = 0 for a in xrange(0,3): #for 100p denomination for b in xrange(0,1+(200-100*a)/50): #for 50p denomination for c in xrange(0,1+(200-100*a-50*b)/20): #for 20p denomination for d in xrange(0,1+(200-100*a-...
75adfa85b4446c9231ea6f5fff6e4e75b36f9881
mohitrobo/Project-Euler
/Pandigital prime.py
1,017
3.609375
4
#Pandigital prime #the digits 1st from 1-9 #then 1-8 if not found in 9 digit, then reduce it further #variable to store max prime prime = 1 ################################### #This is one way fo doing it ################################### #for num in xrange(2,10000): # for i in xrange(2,num): # if (num%...
d02ec7005f488682e78bb38a3f558a9a786bbee2
mohitrobo/Project-Euler
/Coded triangle numbers.py
2,179
3.5625
4
#Coded triangle numbers import math import urllib import time start = time.time() opener = urllib.FancyURLopener({}) f = opener.open("https://projecteuler.net/project/resources/p042_words.txt") lines = f.read() new = lines.split('","') #make a dictionary of alphabets alpha = {'A':1,'B':2,'C':3,'D':4,'E':5,'F':6...
f61c2f93b24e74a34f58620f3f5c1518ffcd2984
vafokpa/python-challenge
/PyPoll/main.py
1,671
3.65625
4
import csv import os candidate_list =[] candidict = {} #adding the path of the budget_data csvpath = os.path.join("election_data.csv") with open(csvpath, newline="") as csvfile: csvreader = csv.reader(csvfile, delimiter=",") #read the header row first (to make sure I'm in) csv_header = next(csvreader) ...
78b83bc2bc8f646db826203ada7ad25525ccaac3
jfuini/Data-Structures
/Stack.py
994
3.953125
4
# -*- coding: utf-8 -*- """ Created on Sun May 08 14:08:26 2016 @author: John Fuini """ class Stack: def __init__(self): self.items = [] def is_empty(self): if len(self.items) == 0: return True else: return False def push(self, item): ...
f9ae307ed132c75a4946de98e2345d05351e0504
matt-oconnell/gwc-python
/python-exercises/4-lives.py
174
3.65625
4
lives = 10 while True: print(lives) ## PUT CODE HERE ## check if lives are less than 1. If so, break out of the loop lives = lives - 1 print('Done with the loop!')
607d15dece9117271105a4221120085dec8e5495
JamesEaton1001/first-commit
/Exercise_3.1.py
2,154
4.15625
4
#This is a program that does a sequential search of an ordered set and stops when your target is less than the position in the list. #Exercise 3.1 #By James Eaton #Big-O for best case is O(1) #Big-O for average is O(n) #Big-O for worst is O(n) def seqSearch(target, lyst): position = 0 ...
d31bada227cb114186c1cef35ca0b1b5ed130312
bquirin/Python
/LearnPython3TheHardWay/ex33.py
588
4.09375
4
def printNumbers(stop, increment): i = 0 #initialize i numbers = [] #declare empty list while i < stop: print(f"At the top i is {i}") numbers.append(i) i += increment print("Numbers now: ", numbers) print(f"At the bottom i is {i}") #print("The numbers: ") #for ...
4d2765a3ec53f55ef1979f1deac00d44f4b425ea
JLandstrom/TrafficPrediction
/FileHandler.py
3,222
3.59375
4
import os import pandas as pd import traceback class CsvTrafficDataHandler(): """ Class for reading, extracting, and writing data from file instance variables: inputFilePath: Full path of file to be read outputFilePath: Full path where to write file allColumns: List of column names in file ...
d21c1d9b1d4beb2b4a8412d12ce666015ebefc9d
PudgyElderGod/MadLibs
/Madlibs.py
716
3.515625
4
Adjective1 = input("Enter an adjective: ") PropNoun1 = input("Enter a proper noun: ") Noun1 = input("Enter an animal(plural) : ") Verb1 = input("Enter a verb: ") PlurNoun1 = input("Enter a plural noun: ") PropNoun2 = input("Enter a proper noun: ") Num1 = input("Enter a number: ") Adjective2 = input("Enter an adjective...
b6cbde4f6fe7e6bf4c6fb5307af7dbf52afcd108
gibson-kelsey/SMU-Homework
/Python_Challenge/PyPoll/main.py
1,619
3.90625
4
import csv csvpath = r"Resources\02-Homework_03-Python_Instructions_PyPoll_Resources_election_data.csv" print(csvpath) #inital Total Votes total_Votes = 0 candidateDict = {} #read in the file with open(csvpath, "r") as csvfile: csvreader = csv.reader(csvfile, delimiter=',') # Read the header row first (sk...
660fbe303f8402307ff636fcd776918c2ab54fe9
CodeProgress/Minesweeper
/Minesweeper.py
17,127
3.640625
4
import sys import random import itertools class Game(object): def __init__(self, test_mode_parameters=None): self.test_mode_parameters = test_mode_parameters self.ascii_art = AsciiArt() if not self.test_mode_parameters: self.print_title_screen() self.max_side_length_of_...
8ad477c2436381aa797811b01fd359e6f89c3f1f
Nogueira-Candido/CursoPython---Modulo_01
/ex035.py
580
4.34375
4
''' Para construir um triângulo é necessário que a medida de qualquer um dos lados seja menor que a soma das medidas dos outros dois e maior que o valor absoluto da diferença entre essas medidas. ''' a = float(input('Digite a medida A do triângulo: ')) b = float(input('Digite a medida B do triângulo: ')) c = float(inp...
d0ffddb7e45200027e97a10b29b8978f1eb318ab
Nogueira-Candido/CursoPython---Modulo_01
/ex037.py
731
3.921875
4
cores = {'limpa':'\033[m', 'amarelo ':'\033[33m', 'margenta':'\033[34m', 'roxo':'\033[35m'} num = int(input('Digite um número: ')) opcao = int(input('''Escolha a opção de conversão: [1] - Binário [2] - Octal [3] - Hexadecimal: ''')) if opcao == 1: print('O número {} em binário é igual a...
cf19c9bd766934f442b32229ed0d9bf93f936d2c
Nogueira-Candido/CursoPython---Modulo_01
/ex049.py
697
3.609375
4
n = int(input('Digite um número que você deseja saber a tabuada: ')) op = int(input( ''' ESCOLHA A OPERAÇÃO DESEJADA: [ 0 ] - ADIÇÃO [ 1 ] - SUBTRAÇÃO [ 2 ] - MULTIPLICAÇÃO [ 3 ] - DIVISÃO ''' )) print('\nTABUADA DE {}\n'.format(n)) for c in range(1,11): if op == 0: t = n+c ...
7d62d8c4b463239859d11b2e64f5d17c0b07f9e9
raficci/infosatc-lp-avaliativo-01
/exercicio28.py
243
3.953125
4
n1 = float(input("digite um valor ")) n2 = float(input("digite outro valor ")) n3 = float(input("digite mais um valor")) q1 = n1*n1 q2 = n2*n2 q3 = n3*n3 R = q1+q2+q3 print(r)("está foi a soma dos quadrados dos tres numeros digitados")
8f6a3fb8a1b16f28cb8c45cafacc2e93980ff430
CaJiFan/PF-coding-exercises
/pytest - ejercicios/Ejercicio 2 -L1.py
1,449
4.15625
4
#Terminado #En su programa se tiene los datos de restaurantes y valoraciones de los mismos en listas paralelas #Se necesita de las siguientes funciones: #1) Defina una funcion en la que ingrese el nombre de un restaurante y retorne su valoracion. De argumentos va a tener: el restaurante al cual se quiere saber su valo...
a4d3d027d58e1cecb6443abac12893666e04d8c0
CaJiFan/PF-coding-exercises
/U2) Variables y tipos de datos/Ejercicio 1-L0.py
1,554
4.3125
4
#Terminado #Revise e imprima los tipos de datos que se encuentran en cada variable #Nota: Diferencie los tipos de datos que puede encontrar en python #Use la funcion type(var) var1 = "Hola Mundo" var2 = 12341 var3 = 3.14 var4 = [1,2,3,4] print(type(var1)) print(type(var2)) print(type(var3)) #Realice un programa en ...
c1860e31c77249b5cc7af6d6370dccc47be57ba2
CaJiFan/PF-coding-exercises
/U7). Archivos entrada y salida/Ejercicio4.py
438
3.6875
4
# Dado el archivo compras.txt leer el archivo y mostrar en pantalla la lista de tuplas con objetos y cantidades de # la siguiente forma #OUTPUT #[('rosas', 15), ('manzanas', 5), ('peras', 10), ....] #Solucion file = open ("compras.txt","r") lista = [] linea = file.readline() while linea!= "": datos = linea.split...
b30c0de8acfff44b4ca99be5f531181bce8e01a9
CaJiFan/PF-coding-exercises
/U7). Archivos entrada y salida/Ejercicio3.py
810
3.65625
4
#Realice un programa que imprima en pantalla el nombre del estudiante y si su promedio es mayor a 60 mostrar, # "Aprobado", caso contrario mostrar "Reprobado" #seguir formato, nombre, apellido, Estado:, aprobado/reprobado #archivo grades.csv # OUTPUT #Aloysius Alfalfa Estado: Aprobado #University Alfred Estado...
ad24971ea30370d494fc8fde0464c65fecfcd7cb
CaJiFan/PF-coding-exercises
/U4) Funciones/Ejercicio 4 - L2/main.py
808
3.9375
4
#Terminado #Usted trabaja en una tienda y le piden definir las funciones que se encuentran en el archivo "funciones.py" los datos de la tienda que le son proporcionados son una lista con los precios de los productos, lista de los nombres de los productos y una lista con los codigos de cada uno de los productos from f...
195030f20477f03e9ba93419e7762da19fb51cbc
CaJiFan/PF-coding-exercises
/U4) Funciones/Ejercicio2.py
1,507
3.609375
4
#Dadas las siguitentes listas defina 2 funciones que calculen lo siguiente: #funcion edad(nombres,edades) devuelve una lista con el nombre de la persona de mayor edad y de menor edad #funcion indiceMasa(nombres, peso, estatura) devuelve una lista con el nombre de la persona de mayor indice de masa # corporal y el de m...
0d4f3cd11edbcfbbc54119a07446c3f8cc99ce2e
CaJiFan/PF-coding-exercises
/U5) Arreglos n-dimensionales/Ejercicio 3 - L1.py
909
3.796875
4
#Terminado #En una empresa le piden a usted crear un programa que nos ayude a determinar los nombres de los empleados que ganan mas de 300 dolares #dentro de la empresa, para ello nos dan una lista de nombre de los empleados y los sueldos de cada uno de ellos #Defina una funcion que con el uso de numpy nos ayude a sab...
d7ad55d84d2de35038b771a4103fc22c6af1862c
asya-bergal/abercal
/parse.py
1,098
3.609375
4
import parsedatetime from datetime import * from tzlocal import get_localzone from pytimeparse.timeparse import timeparse from util import * # If you explicitly pass in a timezone, it will assume that, # Otherwise it will use your local timezone. def parse_datetime(datetime_str, relative_base): cal = parsedatetim...
5e3b16ae6f634888f57816810b0fd3de40d4fb65
shawnxgan/Mini-Project-1
/Shopper/Customer.py
3,372
3.53125
4
from tkinter import * class Customer: def __init__(self, master, conn, cursor): self.__conn = conn self.__cursor = cursor self.__root = master #Customer's login page frame self.__Customer_Login_frame = Frame(self.__root, height=720, width=960) self.__Custome...
6beb7932763fd5135e39ae36983fbf6daf728373
AaronLi/Blackjack-Server
/blackjack/blackjackgamestate/gamestate.py
1,070
3.609375
4
from abc import ABC from typing import Tuple import db.game class GameState(ABC): @staticmethod def enter(game: "db.game.Game") -> "db.game.Game": """ Called when you enter the state :type game: blackjack.db.game.Game """ return game @staticmethod def poll(ga...
b65b48e619af26533103c6e9d8e52d21b5f8010c
lauren-moore/Project_Bird_Adventure
/obstacles/first.py
2,414
4
4
from replit import clear import time import random from replit import audio from colorama import Fore, Back, Style from enter_to_continue import * def first_obstacle(): '''User will need to guess a number between 0 and 5. Correct number will be randomly generated''' print("Welcome to your life as a birb!\n\...
d46d00c9409bbf29f9c9a8a377dfbc5245d6b99a
angolubev/AI_Lab_2
/challenge_dataset.py
887
3.625
4
import pandas import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn import linear_model # считываем данные из файла data = pandas.read_csv('challenge_dataset.txt', names = ['x', 'y']) x = data['x'] y = data['y'] # строим точки plt.scatter(x, y, color='red', alpha = 0.5) #...
61ef6fb971dac49c948a3c0a7d437d8816e050dd
NithishRaja/natural-selection-simulator
/ecosystem/getRandomCoordinates.py
431
3.5
4
# # File containing code to generate random coordinates # # # Dependencies import random # Function to get random coordinates def getRandomCoordinates(gridSize): """Generate random coordinates within grid. Keyword arguments: gridSize -- integer """ # Generate random coordinates coordinates = ...
91ee87ae8b1da63c107fe19a5afa9fd820862abd
lagagain/lagpy
/lagpy/functools/Callable.py
3,163
3.78125
4
from .Proxy import Proxy class CallableMeta(type): """ A MetaClass, and implement the method __call__ of Callable Class """ def __call__(defineclz, *args, **kargs): """ # Callable Class Accept a function and arguments(include keyword arguments) which will pass args to t...
2e8ea1eeede4babb43798710bc9f78e123ea33ec
acruis/sandbox
/ArrayOps/np_2d_delete.py
122
3.5625
4
import numpy as np a = [np.array([1,2,3]), np.array([5,6])] a[0] = a[0][a[0] != 2] print a[0] # [1 3] print a[1] # [5 6]
1ffe6e1126618ccfb2f0727405521ab5d8aa48e7
Vango82/PhD-Thesis-Code
/eB.py
1,262
3.65625
4
# Author: Vango # Edit Time: 6/11/2021 11:25 AM import numpy as np import math def erlangB(A, k): # 'A' is the total offered traffic (Erlang), k is the number of circuit if A <= 0: # if offered load is less than or equal to zero, then blocking probability is zero return 0 k = math.flo...
f7d486f00cb28119ed797693c2412e2f362824ee
BiswasAnanya/PyNativeProblemSolving
/PythonBasicExerciseBeginners/Qstn7.py
229
4.125
4
# Return the total count of sub-string “Emma” appears in the given string given_string = "Emma is good developer. Emma is a writer" substring="Emma" count = given_string.count(substring) print("Emma appeared",count,"times")
b034ed97c9fd4214559f69aafb7ec1b9c5080fa8
BiswasAnanya/PyNativeProblemSolving
/PythonBasicExerciseBeginners/Qstn4.py
317
4.125
4
# Given a string and an integer number n, # remove characters from a string starting # from zero up to n and return a new string given_string= "WelcometoPYnative" n=5 length=len(given_string) new_string="" for item in range(n, length): char=given_string[item] new_string=new_string+ char print(new_string)
09d9ba0ebb7bdbe3b6917ce63e1402c029d72b58
BiswasAnanya/PyNativeProblemSolving
/PythonBasicExerciseBeginners/Qstn12.py
413
3.6875
4
# Calculate income tax for the given income by adhering to the below rules # Taxable Income Rate (%) # First $10,000 0 # Next $10,000 10 # The remaining 20 income =45000 if income >= 20000: first_taxpayable = 10000*(0/100) second_taxpayable = 10000*(10/100) remain_taxpayable = (income-20000)*(20/100) total_t...
c1c3116af9eea7fa37b59ba4e7a809874fb6b8d9
BiswasAnanya/PyNativeProblemSolving
/PythonBasicExerciseBeginners/Qstn2.py
384
4.0625
4
# Given a range of first 10 numbers, Iterate from start number to the end number and # print the sum of the current number and previous number n=10 prev_num=0 for item in range(0,n): current_num = item sum = current_num+prev_num print("Current Number:",current_num,end=" ") print("Previous Number:",pre...
f1087ab1e61ae549f0f2548027bb30b2cecd0357
BiswasAnanya/PyNativeProblemSolving
/inputoutputexercise/Extra1.py
1,215
4.25
4
# Digit extraction: Print the digits of a given number # input 341 # output 3 4 1 # given_number = str(input("Enter the number: ")) # for item in given_number: # print(item) ############################################################################# # Print the sum of digits of a given number # input 341 # o...
3ec1354f545417e22135233846264df36be1b977
GiftWind/pythonhomeworks
/hw05/hw5.py
1,250
4.03125
4
# 1. После запуска предлагает пользователю ввести неотрицательные целые числа, # разделенные через пробел и ожидает ввода от пользователя. # 2. Находит наименьшее положительное число, не входящее в данный пользователем # список чисел и печатает его. print("Введите набор целых неотрицательных чисел, разделенных пробела...
03d5af87b42cb2af5006b5d1c25d194cb93e0a0e
GiftWind/pythonhomeworks
/hw06/hw6.py
635
3.890625
4
# The decimal number, 585 = 1001001001 in binary, is palindromic in both bases. # Find the sum of all numbers, less than one million, which are palindromic in # base 10 and base 2. (Please note that the palindromic number, # in either base, may not include leading zeros.) def ispalindrome(number): string = str(numb...
046fcddd3c35e89a06e02ff9a27e0ad23067b5b6
mahimaarora/notitia
/Visualising Data/vd_3.py
560
3.796875
4
# implementting histogram from matplotlib import pyplot as plt from collections import Counter if __name__ == '__main__': grades = [83, 95, 91, 87, 70, 0, 82, 85, 100, 67, 73, 77, 0] # print(grades) decile = lambda grade: grade histogram = Counter(decile(grade) for grade in grades) plt.bar([x -...
ce7d7672c64871c4e1225d3260eb52576c745b82
mahimaarora/notitia
/Statistics/centralTendencies.py
877
3.609375
4
import random import collections if __name__ == '__main__': def mean(x): return sum(x)/len(x) def median(v): n = len(v) sorted_v = sorted(v) midpoint = n // 2 if n % 2 == 1: return sorted_v[midpoint] else: return (sorted_v[midpoint - 1...
2c1cdbe21fcdf7c9fa728d5c7b65cad560eb244e
zzg330/PythonLearning
/learn.py
893
4.0625
4
#!/usr/bin/env python import math def move(x,y,step,angle): nx = x + step * math.cos(angle) ny = y - step * math.sin(angle) return nx, ny x, y = move(100, 100, 60, math.pi/6) aTuple = move(100, 100, 60, math.pi/6) print(x) print("######") print(y) print("$$$$$$$$$$") print(aTuple) print(aTuple[0]) def power(x,...
c9b53dd54653129fd11678235d58279ed46ffde6
badamczyk1995/4G_Clinical_Task
/main.py
3,560
3.75
4
class Phone: def __init__(self): self.keypad = self.generate_phone_keypad() self.phone_number = None self.word = None self.used_index_tracker = None @staticmethod # Generates a dictionary mapping letters to a number key def generate_phone_keypad(): mappings = {...
1c27b62fb787c425443ca89302eed4c4f3499f99
EthanGe77/leetcode
/035/v1.py
287
3.703125
4
class Solution: def searchInsert(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ ret = len([num for num in nums if target > num]) return ret a = Solution() print(a.searchInsert([1,3,5,6],0))
3d38064ddb24b65efb7cf9c8987d68d6d2821c09
EthanGe77/leetcode
/002/v1.py
783
3.84375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: carry = 0 def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ ...
6062ff8f026fde69cc26b448212903391f4a6789
yuexiwu/ml_study
/机器学习/logistic_regression/normal.py
1,475
3.5
4
from logistic_regression.core import * data = pd.read_csv('ex2data1.txt', names=['exam1', 'exam2', 'admitted']) data.head() # 看前五行 data.describe() sns.set(context="notebook", style="darkgrid", palette=sns.color_palette("RdBu", 2)) sns.lmplot('exam1', 'exam2', hue='admitted', data=data, size=6, ...
3c4d2a433393c3673fcd189763c8d105298cd761
suramakr/play-zone
/MPNeuron/mpneuron.py
7,097
3.71875
4
from sklearn.model_selection import train_test_split import sklearn.datasets import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.metrics import accuracy_score # real world data # https://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_breast_cancer.html breast_cancer = s...
94e664c6bce2b260fe7ab1dc02905f8bf148f511
adageran2418/Programacion20182
/Clase 14 de Agosto.py
824
4
4
print("Bienvenido, vamos a calcular su ingreso neto del salario \n") salario1 = float(input("Ingrese por favor el valor de su salario numero 1: \n")) retefuente1 = float(input("Ingrese el valor de la tasa de retencion en la fuente: \n")) salario_neto_1 = salario1 * (100 - retefuente1) / 100 salario2 = int(input("I...
89b19814b2db146910b4e89b9318605dc2c5dff4
Tahooft/ytdl
/archief/timeit.py
341
3.546875
4
import time from functools import wraps def timeit(method): @wraps(method) def wrapper(*args, **kwargs): start_time = time.time() result = method(*args, **kwargs) end_time = time.time() print(f"Timed: {method.__name__} => {(end_time-start_time)*1000} ms") return result...
028a15cfa68bd7dff979c996999b2c8e0ae2bedf
AdrianoW/FlyingCarND
/2 - Motion-Planning/prunning.py
1,086
3.65625
4
import numpy as np def point(p): return np.array([p[0], p[1], 1.]).reshape(1, -1) def collinearity_check(p1, p2, p3, epsilon=1e-6): m = np.concatenate((p1, p2, p3), 0) det = np.linalg.det(m) return abs(det) < epsilon # We're using collinearity here, but you could use Bresenham as well! def prune_p...
ce24b5642c2d12730ad42cfc79fec40934fdbf67
ian-vu/grande-project
/back-end/randomNumberGenerator.py
527
3.859375
4
#make a script that loads random in future and other python libraries import random import sys def randomNumberGenerator(min_number,max_number): #min_number = int(input('Min: ')) #max_number = int(input('Max: ')) min_number = int(float(min_number)) max_number = int(float(max_number)) if min_number > max_...
1df184acbd5bd53422065c6fc4bde86eb3d58184
tasnuvaleeya/hackerRank
/contest/recursive_number.py
437
3.703125
4
def sum_digit(list_of_num): if len(list_of_num)==1: return list_of_num[0] else: sum_num = sum(list_of_num) return sum_digit([int(x) for x in str(sum_num)]) if __name__ == "__main__": n, k = input().strip().split(' ') n, k = [str(n), int(k)] num_string = [int(i) for i in str(...
475f2229a9e3854b0193dc249aa14596ae7c89af
tasnuvaleeya/hackerRank
/30_days_of+code_challenge/day8.py
300
3.796875
4
N=int(input()) my_input = [input().split() for _ in range(N)] phonebook = {k:v for k,v in my_input} while True: try: name=input() if name in phonebook: print("%s = %s" %(name, phonebook[name])) else: print("Not found") except: break
380ea598a97bd1d99e894500681061f817e89397
sourav-coder/GeeksForGeeks-Solutions
/Uncommon characters.py
325
3.734375
4
# coded by sourav sarkar for _ in range(int(input())): s=list(input()) s1=list(input()) print(s,s1) a=[] for i in s: if i not in s1 and i not in a: a.append(i) for i in s1: if i not in a and i not in s: a.append(i) a=sorted(a) print(''.join...
ae6e8f79be3adb674d78ff97e44a9862a1a76e52
sourav-coder/GeeksForGeeks-Solutions
/Find Number of Numbers.py
246
3.671875
4
# Your task is to complete this function # Function should return an integer #--coded by sourav sarkar---# def num(a, n, k): # Code here s=0 for i in a: c=list(str(i)) #print(c) s+=c.count(str(k)) return s
5fcff3266111e287e5eae33ad27327743d5139d0
gidj/pyLinkedList
/test.py
1,358
3.796875
4
import unittest from pylist import LinkedList, LinkedListItem class SingleCases(unittest.TestCase): """ Test edge cases """ def setUp(self): self.l = LinkedList() self.l.append('test_item') def test_one_item_head(self): self.l.pop() self.assertEqual(self.l.head, None) ...
57b385a15506303fe0f6cd38be52f867dfa9f558
adenhaus/Collection-of-Small-Python-Programs
/password_generator.py
472
3.859375
4
import random # Define acceptable characters chars = "abcdefghijklmnopqrstuvwxyzAVCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()+=-<>,.[]{}?/" chars_list = [] # Fill a list with these characters for i in chars: chars_list.append(i) password = "" length = int(input("How long would you like the password to be? ")) ...
ca708453dc1fb85531ca0357e9dfbffc11611b8a
ArrogantNobody/leetcode
/algorithms/mapping/138_Copy List with Random Pointer.py
687
3.609375
4
""" # Definition for a Node. class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random = random """ class Solution: def copyRandomList(self, head: 'Node') -> 'Node': if not head: return ...
ab45ab4cc6e6ed85c10e73b6dacaf24d4bad983a
ArrogantNobody/leetcode
/algorithms/two_pointer/88_Merge Sorted Array.py
962
3.84375
4
class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. """ nums1[m:m+n] = nums2[:] nums1.sort() return nums1 #two pointer class Solution: def merge(self, nums1: List[...
4ef0991d679fba11cd8031cc55edafaa60782a81
ArrogantNobody/leetcode
/algorithms/trees/100_Same Tree.py
1,625
4.03125
4
#dfs # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isSameTree(self, p: TreeNode, q: TreeNode) -> bool: i = self.ite(p) j = self.ite(q)...
c4c6ad92b024e0ed69865a5edaf50750d275742b
ArrogantNobody/leetcode
/algorithms/link_list/148_Sort List.py
663
3.90625
4
#there are several ways to solve this question, due to the limited time, I will only introduce one function class Solution(object): def sortList(self, head): """ :type head: ListNode :rtype: ListNode """ #main idea of this function is to store val in a list and return them to...
8851e24228d72e8ba82ac0266bb5ca33ab4decfe
xKuroiUsagix/python-online-marathon
/sprint07/question03.py
1,134
4.5
4
class MotorCycle: """Class for MotorCycle""" def __init__(self): self.name = 'MotorCycle' def TwoWheeler(self): return 'TwoWheeler' class Truck: """Class for Truck""" def __init__(self): self.name = 'Truck' def EightWheeler(self): return 'Eigh...
453277774c37eebf417fb41ebcdc88e4f0951d3f
xKuroiUsagix/python-online-marathon
/sprint07/question01.py
1,225
3.875
4
from abc import abstractmethod class Product: @abstractmethod def cook(self): pass class FettuccineAlfredo(Product): name = 'Fettuccine Alfredo' def cook(self): print(f'Italian main course prepared: {self.name}') class Tiramisu(Product): name = 'Tiramisu' def cook(self): ...
267461f54a33db961e7c2c84c62f8ef73efa83e8
llewellyndm/MIT-Python-6.0001
/PS4/ps4a.py
2,337
4.25
4
# Problem Set 4A # Name: llewellyndm # Collaborators: # Time Spent: x:xx def get_permutations(sequence): ''' Enumerate all permutations of a given string sequence (string): an arbitrary string to permute. Assume that it is a non-empty string. You MUST use recursion for this part. No...
fe47ae1643e0e74866a908bd97d19694cbc11a5e
kevinrhine/qbb2017-answers
/day3-afternoon/average.py
271
3.609375
4
#!/usr/bin/env python import sys fh = open( sys.argv[1] ) sum = 0 count = 0 for line in fh: line = line.rstrip() sum = int(line) + sum count = count + 1 average = sum / count print "There are %s genes with an average gene length of %s" % (count, average)
676814b9ea415d1f1d9d935043a06039fae9635d
babycommando/tiki-ai
/app.py
2,734
3.515625
4
import streamlit as st import time import requests from PIL import Image def main(): st.set_page_config( # Alternate names: setup_page, page, layout layout="centered", # Can be "centered" or "wide". In the future also "dashboard", etc. initial_sidebar_state="auto", # Can be "auto", "expanded", ...
07dc4b0f0b454014a9bb88f5aa73bb2c063bbd7e
owlfox/misc
/q2.py
480
3.6875
4
def f(i): rtn = [] for i in range(1,i+1): isDby3 = i % 3 == 0 isDby5 = i % 5 == 0 if isDby3 and isDby5: rtn.append(i) elif isDby3: pass elif isDby5: pass else: rtn.append(i) return len(rtn) if __name__ == '_...
59d6762ba103cdc132258965b45be61c19443d92
victorbaulier/project
/main.py
4,965
3.53125
4
# Créé par victor, le 20/05/2016 en Python 3.2 from tkinter import * import pygame from pygame.locals import * from classs import * from constant import * import time pygame.init() LV=Choose_level() #principale loop continu=1 while continu: continu_home=1 while LV.choice==0: ...
7ac7d39cd3d094fcc7a58c343d4c032b4971b4b5
DejaVuMan/data_visualization
/classwork+homework/03-13-2020 Intro2/Class/2_Cond_Statements examples/ex4_absoluteVal.py
405
4.53125
5
# This program writes the absolute value out of whatever entered number you have. number=input("Please enter a number. This program will give you its absolute value: ") number = int(number) if number < 0: print("The absolute value of " + str(number)) number = number*-1 print(" is: " + str(number)) elif n...
2f8fa8495f48b2b3c605b0cc2b070af27e5c8e45
DejaVuMan/data_visualization
/classwork+homework/03-06-2020 Intro1/pythontest.py
2,202
4.1875
4
print('Good evening gamers!!!') print('Very Epic!!!?!') def main(): pass #Comments start with Hashtags! name = "Doge Charger" print(name) print(type(name)) print(type(5)) print(type(5.7)) print(type(True)) print(type(None)) print(name[2]) #name[2] = "G" #You are unable to mutate this type to a different type! nam...
93d8dd6032b3bf51bbe506ace75de6b7714e36d9
DejaVuMan/data_visualization
/classwork+homework/04-06-2020 Lab4/1_File_Operations/Ex1_DivBy4_WriteToFile/Ex1_DivBy4_WriteTF.py
405
3.609375
4
# This program will list out all numbers divisible by 4 and list them to a document. ListDivis = open("C:\\GitRepo\\data_visualization\\classwork+homework\\04-06-2020 Lab4\\1_File_Operations\\Ex1_DivBy4_WriteToFile\\NumsDivisibleBy4.txt","w+") a = 1 b = 21 listDiv = [] for x in range (a,b): #From a1 to b21 if x % ...
388f16cb4cf5663a319a183709946b25f9e55b90
DejaVuMan/data_visualization
/classwork+homework/03-20-2020 Ex3/2_Python_SD_Functions.py
3,355
4.28125
4
# In Python, we can define our own functions. We can treat them as subprograms, or functions within MATLab. # # NOTE: Example Structure. # # def funtion_name(position_arg, arg_default=value, *arg_4, ** arg_5): # instructions # return value ###################### # Function Definition: # # d...