blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4345de77649c88b69f2c04d351523d570d357445
BorisVV/cellphonesUnittest_Capstone
/phone_manager.py
3,911
3.8125
4
# Manage a list of phones # And a list of employees # Each employee gets 0 or 1 phones class Phone(): def __init__(self, id, make, model): self.id = id self.make = make self.model = model self.employee_id = None def assign(self, employee_id): self.employee_id = emplo...
c1a5abd50bb7fbf23720bd0be4d6dea5950cd43c
jfuerst92/RL_Bascinet
/policy_iteration.py
8,597
3.6875
4
import gym from gym import envs import numpy as np import pandas as pd import random import time import matplotlib.pyplot as plt def policy_evaluation(policy, env, discount_factor=1.0, theta=0.00001): """ Implement the policy evluation algorithm here given a policy and a complete model of the environment. ...
a6b27dea7cdac1143ff10e2f3475d304f0ef13b0
CoderKn1ght/Algorithm-Implementations
/Concepts/Trie/autocomplete.py
2,844
4.25
4
class Trie(object): def __init__(self): self.childrens = {} self.end_of_word = False def insert_words(list, root): current_trie_node = root for word in list: for letter in word: if letter not in current_trie_node.childrens: temp_trie_node = Trie() ...
1e9ab118dba52d05b6abb2ba3661b3957aee2949
LuminesenseComputing/SensorTesting
/ultrasonic/ultrasonic.py
3,049
3.53125
4
## RPi (Raspberry Pi) interface with ultrasonic sensor # Method: # In RPi terminal, run the following command: python3 ultrasonic.py # Output: Real-time distance measured by ultrasonic sensor # Last edit: Jordan Hong, 14:00 June 19, 2020 # Import Libraries import RPi.GPIO as GPIO import time def main...
271d17d58e704d98467d0cb6a3906a44d19e6bdf
stat88/textbook
/_build/jupyter_execute/content/Chapter_08/03_Normal_Approximation.py
9,956
4.34375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: # NO CODE from datascience import * from prob140 import * get_ipython().run_line_magic('matplotlib', 'inline') import matplotlib.pyplot as plt plt.style.use('fivethirtyeight') import numpy as np from scipy import stats # ## Normal Approximation ## # In this section ...
a39f285a5b16758f5b54e28b0b945150d228e680
ramonvaleriano/python-
/Livros/Introdução à Programação - 500 Algoritmos resolvidos/Capitulo 2/Exercicios 2a/Algoritmo81_leia54.py
529
3.6875
4
# Program: Algoritmo81_leia54.py # Author: Ramon R. Valeriano # Description: # Developed: 16/03/2020 - 19:17 # Updated: number = int(input("Enter with number: ")) centesimal = int(number/100) decimal = int((number%100)/10) unitary = int(number%10) reverse = (unitary*100)+(decimal*10)+centesimal print(reverse) sum_ = ...
7baf4a647c5cfc8ad9d01148cc9fa963d5323ea9
bhainesva/Projects
/Text/reverseString.py
305
3.75
4
import sys import time def reverseRecursive(istr): if len(istr) <= 1: return istr return reverseRecursive(istr[1:]) + istr[0] def reverseSlice(istr): return istr[::-1] if __name__ == "__main__": print "Recursive: " + reverseRecursive(sys.argv[1]) print "Slice: " + reverseSlice(sys.argv[1])
ced424c8bb8b254df85bf2450075adb555363cef
nebomusic/qbot
/CameraTest.py
660
3.546875
4
# Camera Sample in Python # Save as a .py file # Mr. Michaud # www.nebomusic.net import cv2 as cv2 import numpy as np import scipy as sc # Setup Camera Object: 0 is the index of the installed camera # 1 is the index of a USB camera (webcam) cap = cv2.VideoCapture(0) # Camera Loop - Read image from camera and display...
bf3aac481e1176fe5cf38a5e73169ce216ba2333
davidbarton/mexbtcapi
/mexbtcapi/concepts/currency.py
4,888
3.703125
4
from decimal import Decimal import logging logger = logging.getLogger(__name__) def check_number_for_decimal_conversion(number): a = type(number) in (int, long) b = isinstance(number, (str, unicode, Decimal)) if not (a or b): logger.warning("You are using a number (" + str(number) + ...
9c01b78b8a033a3424645a147118f8730d461c5b
s-arnus/python
/adventofcode/2018/day4.py
7,608
3.546875
4
#!/usr/bin/python3 # #For example, consider the following records, which have already been organized into chronological order: # #[1518-11-01 00:00] Guard #10 begins shift #[1518-11-01 00:05] falls asleep #[1518-11-01 00:25] wakes up #[1518-11-01 00:30] falls asleep #[1518-11-01 00:55] wakes up #[1518-11-01 23:58] Guar...
0a7c4006480b3e37d2e3952f5082e4ff36d8e24f
babiswas/Practise2
/test66.py
1,755
3.9375
4
class Node: def __init__(self,value): self.value=value self.left=None self.right=None def max(self,node): test=node while test.right: test=test.right return test def min(self,node): test=node while test.left: test=test.lef...
004f8836e603745c64da0e760904c237944c99c8
lmmx/pyx-sys
/src/pyxsys/wm/window.py
2,656
3.59375
4
class Window(object): def __init__(self, win_id, d_num, client_hostname, win_title): self.desktop_number = d_num self.win_id = win_id self.title = win_title self.client_hostname = client_hostname return def __repr__(self): """ Prints the window desktop nu...
7646a4209611573db1e1b52b487de1157307a81b
YuanyuanQiu/LeetCode
/0326 Power of Three.py
168
3.953125
4
def isPowerOfThree(n): while n>1: if n%3 != 0: return False else: n /= 3 return n == 1 print(isPowerOfThree(9))
3b959be97c572d51265f10520e2867a175084ea6
csatyajith/algos_final_project
/maze.py
4,020
3.765625
4
import random import numpy as np from utils import Utils class Cell: def __init__(self, row, col): self.row = row self.col = col self.blocked = False self.visited = False self.parent = None self.children = [] def get_co_ordinates(self): return self.ro...
4e0cac2364effa622341b16bb2f06602f545ca67
izzyevermore/python-sick-class
/main.py
3,066
3.546875
4
from tkinter import * window = Tk() window.title("Student No: 789456123") window.geometry("600x500") #Labels l1 = Label(window, text="SicknessCode: ") l1.place(x=25, y=150, anchor="w") l2 = Label(window, text="DurationofTreatment: ") l2.place(x=25, y=200, anchor="w") l3 = Label(window, text="Weeks/Months") l3.plac...
713f535248448ae76fe902da8e4b512ae8ba80fb
106mahsamoghaddami/Mahsa-Moghaddami-HW6-maktab65
/hw1/hw1_2.py
1,046
4.15625
4
def display_time(dict1,dict2): s_counter=0 m_counter=0 second=dict1["second"]+dict2["second"] while second>=60: second=second-60 s_counter+=1 minute=dict1["minute"] +dict2["minute"]+ s_counter while minute>=60: minute=minute-60 m_counter +=1 hours=dict1["hour...
30408b5e988a8d738cec80af6524c37a53572fb9
debopriyobhowmick/Algorithms
/Algorithms using Python/Insertion Sort/insertion_sort.py
392
4.15625
4
# Sort a list of numerical array in ascending order # Algorithm used = Insertion Sort def insertion_sort(a): for j in range(1, len(a)): key = a[j] i = j-1 while i >= 0 and a[i] > key: a[i+1] = a[i] i = i-1 a[i+1] = key return a old = [32, ...
b9caf5edf976335076783f05475a8382949d1114
kenzzuli/hm_15
/01-04_python基础/11_模块/hm_08_模块的搜索顺序.py
442
3.640625
4
# 模块的搜索顺序,先搜索当前目录,再搜索Python的系统目录 # 如果当前目录有random.py 就不会搜索系统目录 此时再调用randint方法会提示模块中没有这个方法 # 所以 我们在开发中,模块的名字千万不要和系统模块的名字相同 import random # rand = random.randint(0, 10) # print(rand) print(random.__file__) # 此时输出 # /Users/ken/PycharmProjects/11_模块/random.py
e61c1e75533c8a96558f06886f0cca1e242bae26
2324593236/MyPython
/练习项目/打印九九乘法表.py
496
3.59375
4
# _*_ coding utf-8 _*_ # 开发团队:HS黄舍 # 开发人员:Administrator # 开发项目:Python Study # 开发时间:日期:2020/11/27 时间:19:20 # 文件名称:打印九九乘法表.py # 开发工具:PyCharm for x in range(1,10):#循环次数 for y in range(1,x+1):#输出列数 if x == y:#当行数等于列数时 print(x,"X",y,"=",x * y,"\n")#结尾换行 else:#否则 print(...
0722552ae18b2b69ef340b7abb55848492386d41
Tusho-zica/Tusho
/Lets_code/Lógica_de_programação_orientada_a_objetos/Aula_03/Lista 1 - While/ex07.py
694
4.125
4
# 7. Faça um programa que sorteia um número N e peça para o usuário # adivinhar o número sorteado. A cada resposta errada, o seu programa # deve imprimir um aviso dizendo que a resposta está errada e pedir # novamente uma resposta ao usuário. import random # random.randint(a, b)¶ # Return a random integer N s...
ed26d4227ab9d245a08f86a0a957e6265241077a
Devieswaran/pyth.pgm
/printgreaterstring.py
156
4.125
4
a=str(input("Enter the string:" )) b=str(input("Enter the string:" )) if(len(a)>len(b)): print(a) elif(len(a)<len(b)): print(b) else: print(a or b)
65ebcd1ac7b51d076108122202f8d119c3a9a472
manish1822510059/Python-1000-Programs
/Pattern/23_pattern.py
97
3.53125
4
for i in range(0,5): for j in range(4,i-1,-1): print(chr(j+65),end="") print()
77fb46bcecf4470d57b15f0bb9740089cdd74f14
xiaozhi5448/python-linux
/grammer/calcu.py
563
3.59375
4
mZ!/usr/bin/env python # coding=utf-8 from operator import add,sub from random import choice,randint ops={'+':add,'-':sub} MAX_TRIES=2 def doprop(): op=choice('+-') nums=[randint(1,10) for i in range(2)] nums.sort(reverse=True) ans=ops[op](*nums) pr='%d %s %d = ' % (nums[0],op,nums[1]) oops=0 ...
8222a371f48a56085f9a4151dff445b3f312d108
MACHEIKH/Datacamp_Machine_Learning_For_Everyone
/12_Dimensionality_Reduction_in_Python/4_Feature_extraction/calculatingPrincipalComponents.py
1,850
3.5625
4
# Calculating Principal Components # You'll visually inspect a 4 feature sample of the ANSUR dataset before and after PCA using Seaborn's pairplot(). This will allow you to inspect the pairwise correlations between the features. # The data has been pre-loaded for you as ansur_df. # Instructions 1/4 # 25 XP # Create a...
78569df3e69a22e4c1fd263e899dfdfc941e5ea7
Marcoss28/Simple-Python-Calculcator
/calculator_MarcosH.py
4,146
4.21875
4
#import library from tkinter import * #refers to all modules I think #create an instance of TK() (initializes everything) root = Tk() # add a title for window root.title("Simple Calculator") #create an Entry instance for user input e = Entry(root, width = 35, borderwidth = 5) #e manipulates input e.grid(row = 0 , co...
ae72f7c8856ff0a0d81b35177e78fb4bcc3e00a0
gpallavi9790/PythonPrograms
/Python Basic Programs/3.ArithmeticOperations.py
356
3.96875
4
a = input('Enter a number'); b = input('Enter another number'); a=int(a) b=int(b) c = 0 c = a + b print ('Addition is ', c) c = a - b print ('Subtraction is ', c ) c = a * b print ('Multiplication is ', c) c = a / b print ('Division is ', c ) c = a % b print ('Remainder is ', c) c = a**b print ('Power is ', c) c = a...
f69464dcfe5645d749b16b9daa8e0838e24b5149
nanites2000/AdventOfCode
/2022/day6/day6_part2.py
752
3.734375
4
with open("input.txt") as input: lines = input.readlines() test_list = [] for index, letter in enumerate(lines[0]): if index in range(13): test_list.append(letter) print(test_list) else: if letter in test_list: test_list.append(letter) print(test_list) ...
aeae73a356a8c3e44d1d1f3ed76160236ca5c8e7
LucasVanni/Curso_Python
/Exercícios/ex015.py
251
3.546875
4
dias = int(input('Informe a quantia de dias que o carro foi alugado: ')) kmR = float(input('Informe quantos Kilometros foram percorridos pelo carro: ')) pago = (dias * 60) + (kmR * 0.15) print('O total a pagar é de R$ {:.2f}'.format(pago))
cca79ababf7524e89791fdee4f4f29dd858cf1cb
ETERNASMI/CursoPython
/exercicio50pythom.py
215
3.9375
4
s = 0 for c in range(1, 7): n = int(input('Digite um numero:')) #print(n) if n % 2 == 0: s += n print('a soma dos numeros par é {}'.format(s)) if s == 0: print('Todos os numeros sao impares')
36b460d88321224bd25a7f503b354d548464d2e7
LucimarLial/AssistantPP
/utils/markdown.py
5,511
3.53125
4
#Any possible outlier obtained by this method should be examined in the context of the purpose of the dataset. #Now we can identify which points are outside this range, that is, they can be considered outliers. markdown_outliers = ''' The method of removing outilers used in this project is the Amplitude Interquartile...
23b61ae48c604ca2060a655184383c27b4897f5e
clivejj/blimpo
/blimpo.py
1,185
3.65625
4
import random #read csv file reader = open("occupations.csv", "r") data = reader.read() #print data reader.close() #split csv file by line dataList = data.split('\r\n') dataList = dataList[:-1] #print dataList dict = {} for x in dataList[1:]: #deal with case of commas within quotations if x[0] == '"': ...
643d0277936f9f1e876e1efa6583e7c008b6cf1b
woskoboy/aio
/decor/decorator_functools.py
530
3.625
4
import time # import functools def clock(func): # @functools.wraps(func) def clocked(*args): name = func.__name__ + ', '.join(repr(arg) for arg in args) start = time.time() result = func(*args) stop = time.time() - start msg = ' function: {} time: {:.10f} result: {}'.fo...
7a6660ea731d27c2bf2be01cc13dc3db17bdf532
Suru996/SRM-e_lab-Python-Level-1
/Replace me if you can.py
124
3.640625
4
a = input() b = input() c = len(a) d = '' for x in range(0,c): if(a[x] == b): d += '#' else: d += a[x] print(d)
1fb64664c6ce8ee9d0812d2a753e164a14fa8375
parambole/LeetCode
/Trees/quad-tree.py
1,331
3.734375
4
""" # Definition for a QuadTree node. class Node: def __init__(self, val, isLeaf, topLeft, topRight, bottomLeft, bottomRight): self.val = val self.isLeaf = isLeaf self.topLeft = topLeft self.topRight = topRight self.bottomLeft = bottomLeft self.bottomRight = bottomRig...
c80eeba85f319356bb1dcc5a1f4b72f9bdddc32f
maciejratajski1999/Algorytmy-i-struktury-danych-python
/Lista 7/search_algorithms_kasztan.py
2,903
3.765625
4
from FIFOQueue import FrontFIFOQueue as Queue class SearchAlgorithms: def __init__(self, graph): self.graph = graph def depth_first_search(self, key): def recursive_search(current_vertex): current_vertex.setColor("black") if current_vertex.key == key: ...
2edbdef644722cd983cfb78e881d588cb3a99d36
HarshitaMBharadwaj/HarshitaMBharadwaj
/assignment2prob1.py
546
4.34375
4
#Given an integer,n, perform the following conditional actions: #If n is odd, print Weird #If n is even and in the inclusive range of 2 to 5, print Not Weird #If n is even and in the inclusive range of 6 to 20, print Weird #If n is even and greater than 20, print Not Weird n=int(input("enter the intrger numbe...
1a96de3a95414726a747ef9de2b06617242b51f9
KhachKara/Python_Tutor
/Basic/Happy_Birthday.py
444
4.03125
4
""" Example 1-2 =========== Says Happy Birthday to me [Adnan Umer] using functions """ def say_happy_birthday(): """ Prints "Happy Birthday to you!" in console """ print("Happy Birthday to you!") def sing(person_name): """ Sings Happy Birthday song for given person name """ say_happy_bir...
e7e51cc0ef10d37ea5a609eb178cfde4059792f7
huangyu687468/python_ML
/src/RVM/RVM/fit_rvc.py
4,211
3.671875
4
# Input: X->a (D+1)xI data matrix, where D is the data dimensionality # and I is the number of training examples. # w - a Ix1 vector containing the corresponding world states for each training example, # nu - degrees of freedom, # X_test - a data matrix containing training examples for which we need to make prediction ...
89185c392d3071e625da4b7ae6e6124022385330
ryuji-jp/janken
/janken.py
1,553
3.71875
4
# !/usr/bin/env python # -*- coding: utf-8 -*- import random dic = {"a": "グー", "b": "チョキ", "c": "パー"} count = 1 while True: try: print("じゃーんけーん") print("a=グー b=チョキ c=パー aかbかcを入力") user = input('>>> ') user = user.lower() user_choice = dic[user] choice_list = ["a"...
e7dea5342879c3a7eeabd648013da430cc090aaf
prakashatul1/interview_prep
/Ex_Files_Python_Data_Structures/Exercise Files/GUI Code/maze_gui_game.py
13,012
3.9375
4
""" Python Data Structures - A Game-Based Approach Robin Andrews - https://compucademy.net/ """ import config import turtle import random try: import playsound # Not part of standard Library. Install with `pip install playsound`. SOUND = config.SOUND except ImportError: SOUND = False impo...
bbc5bde0007630a42f21cb07589d5aff639a4d27
HuronComputerClub/hom_event
/test.py
894
4.21875
4
#This program is a sample which shows off the functions of my Tkinter wrapper #It makes it extremely easy to draw on a Tkinter canvas from wrapper import * #import the library my_window = create_window() #create the window and run __init__ #draw stuff! Things are drawn in a standard xy coordinate plane my_window.wri...
eff5bd308e006b6bb266eb158c24fe668a860c3d
longjiazhen/automate-the-boring-stuff-with-python
/3_8.py
478
3.984375
4
import random print('I am thinking of a number between 1 and 20.') my_num = random.randint(1, 20) times = 0 your_num = -1 while your_num != my_num: print('Take a guest.') your_num = input('> ') times += 1 if int(your_num) < my_num: print('Your guess is too low.') elif int(your_num) > my_num:...
a01e9e1d697861ad6f90ce57e619b7abb89595f2
Aasthaengg/IBMdataset
/Python_codes/p02690/s856370666.py
191
3.796875
4
x = int(input()) def factorization(x): for a in range(-118,120): for b in range(-119, 119): if a**5 - b**5 == x: return print(a,b) factorization(x)
e8fc55578411331389a01a99be05633a34e1db27
andrenanninga/advent-of-code
/2015/day-05/solve.py
1,008
3.8125
4
# http://adventofcode.com/day/5 import re input = open('input.txt').read() words = input.split('\n') def part1(words): # pattern to match all strings that contain: # at least one instance where the same letter repeats twice # at least 3 vowels (aeiou) # none of the substrings ab, cd, pq or xy pat...
77fd4d7773c59b05e26d7bd27a32072e47e3e9d1
dwade-main/Git-Test
/Git_Test_Code.py
218
3.875
4
import random repeat = True while repeat: print("You rolled", random.randint(1,6)) print("Do you want to roll again? Y/N") repeat = ("y" or "yes") in input().lower() else: print('Thank you for playing')
45a3b71c71d33a26e98daed7eb2b86eb4c0927a5
gammaseeker/DSA_Python
/mergesort.py
628
4
4
import math def merge(list1, list2): result = [] left = 0 right = 0 while left < len(list1) and right < len(list2): if list1[left] < list2[right]: result.append(list1[left]) left += 1 else: result.append(list2[right]) right += 1 return...
50124266474adf8fbfba002a194882a20f8cd0b8
mf4lsb/Algorithms
/hackerrank/python/Piling Up.py
631
3.875
4
# https://www.hackerrank.com/challenges/piling-up from collections import deque for i in range(int(input())): n = int(input()) sideLengths = deque(map(int, input().split())) top = max(sideLengths) while len(sideLengths) > 0: if sideLengths[0] >= sideLengths[-1] and sideLengths[0] <= top: ...
e6f01c081010356dd67c960520f37ee9eb2a4218
gnanadeepika/Data-Structures
/BinaryTree/Sie_dept_of_tree.py
479
3.609375
4
class Node: def __init__(self,data,left=None,right=None): self.data=data self.right=right self.left=left def get_size(root): if not root: return 0 return (1+get_size(root.left)+get_size(root.right)) root = Node(10,Node(8,Node(3),Node(5)),Node(2,Node(22,Node(32)),None)) def...
b43ec51bb2e31f67967ada8486e6b728d4617bb4
PierreRoyer/plato-personal
/src/pers/functions/numeric.py
4,249
4.0625
4
""" Generic numeric utility functions. """ import numpy as np def is_power_of_2(n) -> bool: """ Checks whether the given number is a power of two. Args: n: Number for which to check whether it is a power of two. Returns: True if the given number is a power of two; False otherwise. ...
c69622702273283d1847d28e09cf08ee1ef66d76
Dinamo0809/Programas-en-Python
/Python/Verificar Contraseñas/Verificador de Contraseñas.py
1,057
3.703125
4
#Verificar contrasenas import user import user2 import time def validar(): correct = False while correct == False: print ("Por favor, ingrese su nombre de usuario.") ch2 = input (": ") if user.nickname(ch2) == True: print ("El nombre de usuario " + ch2 + " a sido verficado con exito. Cargando sig...
9dc560a501d6f6acc7f1a2635187399f1ba1f3ca
Vl-tb/Ticket_Agents
/agent.py
1,203
3.65625
4
""" Used to store and manage information related to an airline ticket agent. """ class TicketAgent: """ Creates a ticket agent object. """ def __init__( self, idNum ): self._idNum = idNum self._passenger = None self._stopTime = -1 def idNum( self ): """ Gets...
a5e7a67645b1d352cf3bf5b36e36fb8322ab26e0
jamarrhill/Assignment-7.a
/square_list.py
443
3.8125
4
# Name: Jamar Hill # Date: 11/8/2020 # Description: Assignment 7a """Define square_list and it's contents as "nums." """ def square_list(nums): """Each item in the contents (nums) of square_list will be represented by variable "x" """ for x in range(len(nums)): """Provide formula to square each variabl...
e872f8768aefced6140d2aa148676e94ee558528
abhinai96/Python_conceptual_based_programs
/class/class/class4.py
632
4.0625
4
print("1=square star") print("2=triangle star") class Loops: def square(): a=5 for i in range(1,a+1): for j in range(1,a+1): print("*",end=" ") print() def triangle(): ...
15b69889f7b26b8da3bf58e9e91a2c52ec523721
ARNoor/Number-Theory-Python
/2. GCD_LCM.py
1,256
3.578125
4
#Stein's is computationally effective, as multiplying by 2 or divison by 2 is much favorable by our computers #than doing modular operation import time def GCD_Euclid(u, v): if u == 0: return v elif v == 0: return u else: return GCD_Euclid(v % u, u) def GCD_Steins(u, v)...
0cef80e492440b79f77f4d7c0a3d245bc0d6c97f
A01377958/Mision-02
/cuenta.py
436
3.9375
4
# Autor: María Fenanda Vela Calderón, A01377958 # Descripcion: Calcular el costo total, la propina y el IVA de la comida. # Escribe tu programa después de esta línea. costo = int( input( "Escribe el costo de la comida: ")) propina = costo*0.13 iva = costo*0.15 total = costo + propina + iva print( "Costo de su com...
b240c5aed5e7f88aa143100882bbe9bd24a0b297
evinpinar/competitive_python
/leetcode/621.py
1,193
3.59375
4
from heapq import heappush, heappop from collections import Counter def leastInterval(tasks, n): c = Counter(tasks).most_common() spaces = n * (c[0][1]-1) for i, el in enumerate(c): if i == 0: continue spaces -= min(el[1], c[0][1]-1) return len(tasks)+spaces def leastInterv...
fff1dd250ab8236bcb5e2766c8f7f2f811f67ba7
projeto-de-algoritmos/Grafos2_GeraLabirintos
/GeraLabirintos/Board.py
3,699
4.125
4
from pygame import draw, Surface from colors import BLACK, WALL from random import randint class Board(): def __init__(self, width: int, height: int, horizontal: int, vertical: int, margin: int, standard_color: tuple) -> None: self.width = width self.height = height self.vertical = vertical...
11e853e29cce4b836885d9c2c9474ec0a5840016
h3llopy/web-dev-learning
/Euler Problems/prob0007.py
567
3.96875
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? Answer: 104743 """ import math def is_prime(number): x = 2 while x < int(math.sqrt(number))+1: if number % x == 0: return Fa...
e1f719ff257638d11b407bfa3c3fb69e2259270c
yk4r2/Pizza
/main/pizza.py
2,127
3.765625
4
from collections import defaultdict from enum import Enum class Size(Enum): """This is done for sizes checkup using the EAFP-paradigm.""" M = 0 L = 1 XL = 2 class PizzaBase: """A basic class for pizza creating Has a returnable dict of basic ingredients, their amount and size. """ ...
65c845c348a068aaad672e06722fddf0d21170b1
jjnorris31/metodosNumericos
/positive_negative_sum.py
592
4.125
4
""" Create a function that takes a list of positive and negative numbers. Return a list where the first element is the count of positive numbers and the second element is the sum of negative numbers. Examples [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15] ➞ [10, -65] [92, 6, 73, -77, 81, -90, 99, 8, -85, 34]...
a6884177fc30abcc40c47bc677cfb058b729274d
Nikita6599/first
/date-util.py
708
3.9375
4
import datetime from datetime import date import calendar # a function that will return only the current date def date_func(): return (str(datetime.datetime.today().day)) # a function that will return the current year def year_func(): return (str(datetime.datetime.today().year)) # a function that will return th...
ff0c256e6b14f66e5ae6c138f4335e79f84be8dc
iahn75/training_python
/san_antonio.py
1,423
4.0625
4
# -*- coding: utf8 -*- import random import json '''quotes = [ "Ecoutez-moi, Monsieur Shakespeare, nous avons beau être ou ne pas être, nous sommes !", "On doit pouvoir choisir entre s'écouter parler et se faire entendre." ]''' '''characters = [ "alvin et les Chipmunks", "Babar", "betty boop",...
3d0c1589f90a2fdd8227905dd319b3d745b3d006
wfriedland/hack-oregon-trail
/players.py
354
4.09375
4
def player_name(): print('Five players are required to play The Oregon Trail.') trail_dict = {} players = list(range(1, 6)) for item in players: player = input("What is the name of player #{}?: ".format(item)) trail_dict['player{}'.format(item)] = ({'name': player, 'health': 10, 's...
2179f3000d9fcda8cc21e23b9d25f692ceb13cc5
jhb86253817/nltk-practice
/NLTK/ch04/basics_of_python.py
764
3.53125
4
import nltk import pprint #split data into two parts text = nltk.corpus.nps_chat.words() cut = int(0.9 * len(text)) training_data, test_data = text[:cut], text[cut:] #sort the words based on their length words = "I turned off the spectroroute".split() wordlens = [(len(word), word) for word in words] wordlens.sort() '...
5b2548c237931b762a4f206217ae06cb992dc060
jordan-dinwiddy/python-play
/basics/lamda1.py
696
4.09375
4
#!/usr/bin/python # Lambda's are restricted to a single expression in python. # The lambda keyword is really just syntactic sugar for a # normal function definition. def make_incrementor(n): # return lambda x: x + n the same as below return lambda(x): x + n # This also works so I think a 'lambda' in python is i...
5f611ee44ec178f0916a0bc41d0e1772f319c666
AkhilGandhi1999/Bulk-File-Renamer-Python-
/bulk_re.py
920
3.90625
4
import os import glob def main(): #print(os.getcwd()) ct = 0 ct1 = 0 print("1)Rename all files in same pattern\n2)Rename specific files") choice = int(input()) if choice==1: print("List of files before renaming are ") for filename in os.listdir(os.getcwd()): print(filename) print("Choose the type of re...
cb5d4082b7e5bce929108a2f57791941f9ab9c5f
SPatel29/Back-Tracing-Soduoko-Game
/Soduko_Board_Algorithim.py
4,604
3.953125
4
from copy import deepcopy def pprint(board): for i in range(len(board)): if i % 3 == 0 and i != 0: print("- - - - - - - - - - - - - ") for j in range(len(board[0])): if j % 3 == 0 and j != 0: print(" | ", end="") if j == 8: ...
5e773fa208f7cb7dd5bbcdbceedb00e1b7bde423
anmonzi/petting_zoo_python
/animals/blue_ringed_octopus.py
703
3.828125
4
from animals import Animal from datetime import date from movements import Swimming # Designate Goat as a child class by adding (Animal) after the class name class BlueRingedOctopus(Animal, Swimming): # Remove redundant properties from Goat's initialization, and set their values via Animal def __init__(self, n...
a7a596746449e88b5f26465c523193f2540547d1
nju-websoft/SPARQA
/code/common_structs/graph.py
6,884
3.53125
4
import copy from collections import defaultdict from common_structs.bag import Bag class Graph(object): '''Undirected graph implementation. The cost of space is proportional to O(V + E) (V is the number of vertices and E is the number of edges). Adding an edge only takes constant time. The running...
96bd2f559aa3e5a8771e1b02b102f3ba4f207ca3
Nikunj-Gupta/Python
/practice/Level3/transpose.py
243
4
4
length = input("Enter length: ") i=1 a=[] final =[] while(i<=length): n=input("Enter list: ") a.append(n) i = i + 1 for x in range(0,len(a)): for y in range(len(a[0])): final.insert(a[y][x]) for f in final: print f
c2d3f6c5040cc8b19d74f6cc93d53398963fcca0
SeanLuTW/codingwonderland
/lc/lc1247.py.py
1,660
4
4
""" 1247. Minimum Swaps to Make Strings Equal You are given two strings s1 and s2 of equal length consisting of letters "x" and "y" only. Your task is to make these two strings equal to each other. You can swap any two characters that belong to different strings, which means: swap s1[i] and s2[j]. Return the minimum ...
40ec35faf719f204915ec89ee40c30c04cc90fc1
usgs/ps2ff
/ps2ff/constants.py
1,146
3.734375
4
from enum import Enum class AutoName(Enum): def __init__(this): this._value_ = this.name """ These enum members hold their name (as a string) as their value. For example: DistType.Rjb.value == 'Rjb' """ class DistType(AutoName): """ Type of distance measure to compute. - 'Rjb' is for th...
9c6c8f28010242664ad0f399cffb0f8ea0712d22
ehabarman/Hackerrank-Solution-python_proficiency
/Solutions/sets/Check Strict Superset.py
420
3.734375
4
''' Date 29-8-2018 ''' def check_if_superset(superset,n): for i in range(n): subset = set(raw_input().split()) if len(subset) == len(superset): return False elif subset.intersection(superset) != subset: return False return True if __name__ == '__main__': s...
319c18d595e2be916eaba061d3944b342bf8e8fb
SidSoft/rosalind
/prtm/prtm.py
1,300
3.890625
4
""" Calculating Protein Mass In a weighted alphabet, every symbol is assigned a positive real number called a weight. A string formed from a weighted alphabet is called a weighted string, and its weight is equal to the sum of the weights of its symbols. The standard weight assigned to each member of the 20-symbol ami...
8d101aa905cc6c3f33ffcfc2fc401415464bb3b5
adkhune/aditya-codes
/pythonscripts/programs/1string.py
145
3.734375
4
def main(): print("Hare Krishna") str1 = [] for i in range(3): str1.append(i) print(str1) if __name__=="__main__": main()
759160332c3f74b958f665cbcb8a2b37df886274
AndreeaParlica/Codewars-Python-Fundamentals-Kata-Solutions
/unique in oreder.py
959
4.03125
4
# Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of elements. # # For example: # # unique_in_order('AAAABBBCCDAABBB') == ['A', 'B', 'C', 'D', 'A', 'B'] # unique_in_order('...
35899d68e41a6f8574fb97db54b2bd3ec48da83b
MatheusEwen/Exercicios_Do_CursoDePython
/ExPython/CursoemVideo/ex072.py
353
4
4
r = int(input('Digite um número de 0 a 20:')) while r > 20 or r < 0: r = int(input('Tente novamente.Digite um número de 0 a 20:')) n = 'zero','um','dois','três','quatro','cinco','seis','sete','oito','nove','dez','onze','doze','treze','catorze','quinze','dezesseis','dezessete','dezoito','dezenove','vinte' print(f'v...
fdbdc912c51277477d39c5d47849216e509847d1
ebaek/Data-Structures-Algorithms
/LeetCode/swap_pairs.py
836
3.828125
4
# 24: Swap Nodes in Pairs # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None # Iterative approach class Solution: def swapPairs(self, head: ListNode) -> ListNode: dummy = prev = ListNode(0) dummy.next = head ...
1ba5c2f74a72bd4218d6347460480dce84cf9d3b
Nickname1748/DroneTrafficAnalysis
/visual.py
3,299
3.59375
4
import tkinter import time def init_window(): ''' Initialize main window. ''' window = tkinter.Tk() window.title('DroneTrafficAnalysis') window.resizable(False, False) return window def init_canvas(window): ''' Initialize main canvas and roads. ''' canvas = tkinter.Canvas...
d22c2d95e7bce4181cf716e26f83ae6648705a32
Alberts1995/Example
/Checkio.com/Home/back_each_word.py
237
4.25
4
def backward_string_by_word(Sentence: str) -> str: words = Sentence.split(" ") newWords = [word[::-1] for word in words] newSentence = " ".join(newWords) print(newSentence) backward_string_by_word("Hello word")
a0e8c8f2d60fd3fb47e30fe0cf7cc4c6fb49ed8d
edutomazini/courseraPython1
/semana8/removeelemento.py
460
3.875
4
def remove_repetidos(lista): listaret = [] for elemento in lista: if elementoinlista(elemento, listaret) == False: listaret.append(elemento) listaret.sort() return listaret def elementoinlista(item, lista): for elemento in lista: if elemento == item: return True return False lista = [2...
339a25b0fe1bcf36a62c28af5fc68bc45f655d16
610yilingliu/leetcode
/Python3/993.cousins-in-binary-tree.py
1,190
3.609375
4
# # @lc app=leetcode id=993 lang=python3 # # [993] Cousins in Binary Tree # # @lc code=start # 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 isCousins(self, root...
c97b9c91cc2d25eb77cb580341f83c14dc16bb1f
Branch321/CharGen
/main.py
3,860
3.609375
4
''' CharGen is a character creator for a custom ruleset ''' import random def choose_skills_unit_test(test_number): ''' Checking to make sure Power option works in choose_skills function :param test_number: Parameter that determines how many tests to run :return: Dictionary full of chosen skills and t...
aa549a18bab5c0eff7e1c230eb4494198a634fd5
sinha-p/Text-Compression
/nodes.py
1,794
3.75
4
class Node: right = None left = None def __init__(self, key='', value=0, prev=None, next=None, right=None, left=None): self.key=key self.value=value self.prev=prev self.next=next def setnext(self, n): self.next = n def setprev(self, p): self.prev =...
b27c6c151520589ac1cc67049f8eb57b1bfd1d09
rahulr0801/Awesome-Python-Games
/Code/2- Guess the Number.py
2,537
4.0625
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import random import math import simplegui #------------------------------------------ # declaring global variables secret_number = 0 num_range = 100 remaining_gue...
ef03e71d9aa0d4c5acc0a0d543bfb1e4bea7c330
Ritatachen/qlearning-vs-sarsa-in-gridworld
/enviroment.py
4,500
3.5
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 2 19:43:27 2019 @author: Rita """ # Adapted from: https://github.com/lazyprogrammer/machine_learning_examples/tree/master/rl # create an grid enviroment for our agent import numpy as np #read the file data = np.genfromtxt('iceWorld.txt',dtype='str') wid...
ec3b04f562cf209b74cd3c005519fefa50b8e522
luke-demas/reddit-daily-programmer-solutions
/solutions/challenge3_easy/challenge3_easy.py
991
4.0625
4
# r/dailyprogrammer # challenge 3, easy # https://www.reddit.com/r/dailyprogrammer/comments/pkw2m/2112012_challenge_3_easy/ # solution by Luke Demas # ord('A') == 65 # ord('a') == 97 option = input("(e)nocde or (d)ecode?\n") if option == "e": text = input("Enter text to encode:\n") shift = int(input("Enter sh...
b451728b1c44b7b3cc41301ff629e51a7402cfbe
kashamcrash/capstone
/Pima Indians Diabetes ML Modeling.py
8,108
3.703125
4
#!/usr/bin/env python # coding: utf-8 # In[49]: # Agenda # Predict the possibility of diabetes based on multiple diagnostic measurements # Dataset has been sourced from NIDDK (National Institute of Diabetes and Digestive and Kidney Diseases) # Credentials - kasham1991@gmail.com | Karan Sharma # In[50]: import ...
d8533c27db5a813696d625eefa2b0205c2f24e12
AmberKramer/Programming1
/Les 9/2. While-loop & strings.py
286
3.78125
4
woord="" lengte=0 while True: lengte=0 woord=input("Geef een string van 4 letters:") for i in woord: lengte+=1 if lengte==4: print("Inlezen van correcte string:",woord,"is geslaagd") break else: print(woord,"heeft",lengte,"letters")
55472dcf9c17e3cece67d4793fce9c8b219b1f75
dymfangxing/leetcodelintcode
/leetcode_py/Advanced_daily_training/5-18-题目/226_Invert_Binary_Tree.py
1,234
4
4
#coding=utf-8 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Solution(object): """ BFS """ def invertTree(self, root): """ :type root: Tre...
1538615ac69eb9c06a5ad94aecd8cea9b9a5815f
azhar-azad/Python-Practice
/16. password_generator.py
3,369
4.375
4
# Author: Azad # Date: 4/12/18 # Desc: Write a password generator in Python. Be creative with how you generate passwords # - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. # The passwords should be random, generating a new password every time the user asks fo...
335fe4ceba9d9d406c40e66233690bea89ac075e
Francosantander/Tercer_Parcial
/franco-santander-58105/tateti.py
1,921
3.65625
4
class TaTeTi(): def __init__(self, board=None): if not board: board = [' ' for _ in range(9)] self.board = board def full(self): for i in range(9): if self.board[i] == " ": return False return True def win(self): for i in rang...
1c1df24747268da1a2f6c70b7c335d22a2d0af34
XinZhaoFu/leetcode_moyu
/543二叉树的直径.py
1,009
3.890625
4
""" 给定一棵二叉树,你需要计算它的直径长度。一棵二叉树的直径长度是任意两个结点路径长度中的最大值。这条路径可能穿过也可能不穿过根结点。 示例 : 给定二叉树 1 / \ 2 3 / \ 4 5 返回 3, 它的长度是路径 [4,2,1,3] 或者 [5,2,1,3]。 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.le...
a8445c86f79d8082b781374b3e94b6a7b0a39921
MarkNOakden/AdventOfCode
/15/21/s21.py
3,466
3.59375
4
#!/usr/bin/env python2 import unittest from itertools import combinations # class TestIt(unittest.TestCase): # # Part 1 tests # def test_1(self): # self.assertEqual(dist('London', 'Dublin'), 464) # def test_2(self): # self.assertEqual(dist('Dublin', 'London'), 464) # def tes...
80106cec5f31513eafcc70dbcf938bfcd1a99695
Manish211997/Programs
/diwali lights problem - Solution.py
1,108
4.375
4
# Approach # find the Lcm of number from left to right # If the number is 1 2 3 Then finding the LCM of 1 2 which is 2 # Then output of LCM of 1 2 that is 2 # now taking LCM of 2 3 then we get 6 which is the final answer # down is the program to calculate the lcm of 2 numbers def lcm_func(a,b): n=max(a,b) in...
427484b811ab282f67aacb692700d475a25a2e16
Vansh054/Project-105
/Project 105/stdDerive.py
553
3.53125
4
import pandas as pd import plotly.express as pe import csv import math f = open("data.csv") csvObject = csv.reader(f) fileData = list(csvObject) number = [] add = 0 mean = 0 for i in fileData[0]: h = float(i) number.append(h) add = add + h mean = add/len(number) addition = 0 for i i...
0ee4f7a2f298c8ee4a033d3e0022bad0b0165d64
luozhancheng/leetcode_python
/venv/leedcode/trie.py
999
4
4
class Trie: def __init__(self): self.root = {} self.endWord = "#" def insert(self, word: str) -> None: node = self.root for c in word: node = node.setdefault(c, {}) node[self.endWord] = self.endWord def search(self, word: str) -> bool: node...
4cf528e24f93616d9d9adfa51a33e9abb83e7132
Omega094/lc_practice
/flatten_nested_list_iterator/Flatten_efficient_ii.py
440
3.859375
4
class NestedIterator(object): def __init__(self, nestedList): self.queue = nestedList[:] def next(self): if not self.hasNext(): return return self.queue.pop(0).getInteger() def hasNext(self): while self.queue and not self.queue[0].isInteger(): self.queue = se...
21f2cd46c59ed4438b763f1399ae7a6b32990e9a
FancyYan123/LeetcodeExercises
/24_SwapPairs.py
1,060
4.0625
4
""" 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。   示例: 给定 1->2->3->4, 你应该返回 2->1->4->3. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/swap-nodes-in-pairs 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ from typing import * class ListNode: def __init__(self, x): self.val = x sel...
0ec31448c41bf75040d7ad883310c3173d4918a7
kokot300/python-core-and-advanced
/arthmetic.py
417
3.765625
4
a=10 b=5 print(a+b) print(a-b) print(a*b) print(a/b) print(a**b) print(a//b) print(a%b) c=d=e=10 print(c,d,e) x,y=10,5 print(x,y) x+=y print(x) x-=y print(x) x*=y print(x) x/=y print(x) x**=y print(x) x//=y print(x) x%=y print(x) print(c==d) print(c!=d) print(c<d) print(c>d) print(c<=d) print(c>=d) print(c==d or c!...