blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
63cb2a5b39f87e7c9691f5c28fc0bb37d527377f
Tushar00728/Healthyprogrammer
/healthypro.py
1,736
3.765625
4
#Healthy Programmer # 9am - 5pm # Water - water.mp3 (3.5 litres) - Drank - log - Every 40 min # Eyes - eyes.mp3 - every 30 min - EyDone - log - Every 30 min # Physical activity - physical.mp3 every - 45 min - ExDone - log # Rules # Pygame module to play audio # Put music files in the same directory as the progra...
5ed0b730af0e571c16a53600be8522adbdd13de7
Ali-externe/Epitech-Third-Year
/AIA_gomoku_2019/pbrain-gomoku-ai.py
35,878
3.546875
4
#!/usr/bin/env python3 from random import randint def tab_printer(tab): s = 0 while s < l + 1: print (tab[s]) s = s + 1 def min_fct(tab, s, w): if (w != (len(tab) - 1) and tab[s][w + 1] != 'A' and tab[s][w + 1] != 'H'): tab[s][w + 1] = tab[s][w + 1] + 1 if (w != 0 and tab[s][w ...
3d0aea2c662704c67a7ae5baab4dcc8046f98b73
harshitpoddar09/HackerRank-Solutions
/Problem Solving/Algorithms/Extra Long Factorials.py
413
3.75
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'extraLongFactorials' function below. # # The function accepts INTEGER n as parameter. # def extraLongFactorials(n): # Write your code here ans=1 for i in range(2,n+1): ans*=i print(ans...
294759c38b25b2f7859bb8fe336ea5dc4d57a32a
weinen-j/MIT_6.00.1x_solutions
/miscleaneous/iteration.py
259
3.875
4
# -*- coding: utf-8 -*- """ Created on Sun Feb 28 22:04:49 2021 @author: Jonas """ def iterPower(base, exp): prod = 1 for i in range(1, exp + 1): prod *= base * 1 return prod print(iterPower(2, 4)) # for i in range(1, 3): # print(i)
697668f9c537cf94236b19c1841fff2c14520343
baany/practice
/Leetcode/findNumbersWithEvenNumberOfDigits.py
321
3.609375
4
from typing import List class Solution: def findNumbers(self, nums: List[int]) -> int: count = 0 for item in nums: if len(list(str(item)))%2 == 0: count = count+1 return count objSol = Solution() print(objSol.findNumbers([12,123,12345,1234,1234546,7162537612]))...
09cf2ff5196cbda6e7fbabe8311a1784d3baa736
Ryan-D-mello/MyCaptain-Projects
/count_letters.py
463
4.1875
4
def most_frequent(string): for i in range(len(string)): temp=0 for j in range(len(string)): if string[i] in string[j]: temp=temp+1 mydict[string[i]]=temp print(mydict) mydict={} string=input("Enter a string: ") most_frequent(string) #I couldn't ...
f1c3ccba775a215ec49a4e82c28f3a4223abfadf
clark2668/rust-bootcamp-2021
/homework/day4/bst_python/bst.py
3,338
3.875
4
class BST: """ Binary search tree """ def __init__(self, key=None, value=None): self.key = key self.value = value self.left = None self.right = None def search(self, key): if not self.key: return None if self.key == key: retur...
26cb14c74b015803f29a349ba0f9955dc86d4b82
runzezhang/Code-NoteBook
/lintcode/0491-palindrome-number.py
1,739
4.21875
4
# Description # 中文 # English # Check a positive number is a palindrome or not. # A palindrome number is that if you reverse the whole number you will get exactly the same number. # It's guaranteed the input number is a 32-bit integer, but after reversion, the number may exceed the 32-bit integer. # Have you met this...
0aba22f83ebf47f8034d5716cfe2c563fc163e0e
udayakumaran/programs
/unique char.py
711
3.5
4
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" def unique_english_letters (word) : counter = 0 for i in letters : if i in word : counter += 1 return counter n=int(input()) string=[] string1=[] for i in range(n): k=input() string1.append(k) h=k.lower() st...
bb50238a6dbf191c011b230c20f3f84fac5b3ca7
vedpari/Python_4_everybody
/dictionaries.py
1,581
3.984375
4
#Creating a new dictionary, adding new key-value pairs, comparing if the key is already present, incrementing the counter by 1. #Program to know how many times the name has showed up. counts = dict() names = ['csev','cwen','csev','zqian','cwen'] for name in names: if name not in counts: counts[name] = 1 e...
73317bdcd49546ac8641ef1cf1072b74ba598fbd
adi1991/learn-python-the-hard-way
/ex15.py
901
4.15625
4
#ex15 from sys import argv script, filename = argv txt = open(filename) print "Here is your first file %r" % filename print txt.read() print "Print the file again:" file_again = raw_input(" >") txt_again = open(file_again) print txt_again.read() # #from sys import argv #script, your_name, filename1, filen...
61a2f4b739162acc625e0a3f758c4f84851bb974
mwave1239/Python-Examples
/addevenmore.py
219
4.09375
4
def oddevenmore(x): for num in range(1,2001): if num % 2 == 1: print "The number: {} is odd.".format(num) else: print "The number: " + str(num) + " is even." oddevenmore(1)
89ea5169e8177768f4f73432e153e8cd1497dca7
rsolorza/CPE-Year-1-Projects
/Python Projects/lab-1-rsolorza/lab1.py
5,756
4
4
import unittest #* Section 1 (Git) #persnickety #* Section 2 (Data Definitions) #* 1) #a Celsius variable is a float representing Temperature in Celsius #a Fahrenheit variable is a float representing the converted Celsius temperature #* 2) #a Price variable is an integer representing price in cents of the item #...
b67e632370938199b913fee174d9b38b33cc8436
glennandreph/learnpython
/fourtythree.py
115
3.796875
4
for x in range(5): print(x) for x in range(3, 6): print(x) for x in range(3, 8, 2): print(x)
2ac1b2f606aca5c7603676a577b2fea0f00b09c4
gauriindalkar/while-loop
/interview guessing game.py
506
3.75
4
i=0 f=5 c=10 while c>0: u=int(input("enter number")) d=0 if u==f: print("your guessing is correct") print("congrates") break elif u<f: d=f-u r=c-d if r>0: print("remaining chance",r) else: print("finished") elif f<u: ...
06fe185f61abb382d28d8862c6ec5598e34b693a
tuxinhang1989/leetcode
/happy-number.py
466
3.671875
4
mem = set() class Solution(object): def isHappy(self, n): """ :type n: int :rtype: bool """ if n == 1: return True mem.add(n) res = 0 while n > 0: res += (n % 10) ** 2 n //= 10 print mem, res if res ...
2ddbc91b2e5fcb1baf0f972da22d2539ceea9949
NetanelTz/GoogleProject
/main.py
716
3.59375
4
import initial_function import AutoCompleteModule def main(): print("Loading the files and preparing the system...") initial_function.read_from_zip() print("The system is ready. ") while True: text_to_search = input("Enter your text:\n").strip().lower() print(AutoCompleteModule.get_bes...
ff21572352c24abc214ae660eb78f8409390280f
Beto-Amaral/HalloWelt
/ex030 - Par ou Ímpar.py
348
3.953125
4
#Crie um programa que leia um número inteiro e mostre na tela se ele é PAR ou ÍMPAR. num = int(input('Digite o numero: ')) resultado = num % 2 #qdo se coloca a (%) por dois o resultado de qq numero vai dar 0 para n° pares e 1 para n° impares. if resultado == 0: print('Este é um numero par') else: print('este é...
bef587d51a68ec411528fe8f12abb0a421d9b1df
bcgbr5/CS4320_SWEngineering
/Sprint_3/data_playground.py
2,305
3.953125
4
#Assignment 12 : Basic Data Analysis # Basic demonstration manipulating publicly available datasets # Simply run with your latitude and longitude to get the last day_count # days of weather at the trail_count nearest Mountian Bike trails to your location # within distance miles of your location import requests,time...
237a94a8436cea3ea9747bc036fb2cd98044905e
Stake20/pythonwork
/zipfunction.py
538
3.921875
4
list1 = [1,2,3,4,5] list2 = ['one', 'two', 'three', 'four', 'five'] zipped = list(zip(list1, list2)) print(zipped) unzipped = list(zip(*zipped)) print(unzipped) fruits = ['Guava', 'Naartjie', 'Tomato'] amount_of_fruits = [7, 12, 30] prices = [12.50, 6.80, 88,88] what_i_bought = [] for (fruit, amount, pr...
8d4dbb261c52cf35fb623b0ffb2cb1d939bb0f4c
purduerov/XX-Core
/rov/hardware/servo/Servo.py
1,836
4
4
import wiringpi import time class Servo(object): """ Look here for more of how this works: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor/software """ def __init__(self, pin=12): self.pin = pin # sets up wiring pi gpio wiringpi.wiringPiSetupGpio(...
565c568187b42b39b8384d0df9f249e1def3184c
vishalthakurmca/5thfabpythonsession
/Quetion_13.py
168
4.03125
4
def sum_of_numbers(a): sam=0 for i in range(1,a+1,1): sam=i+sam return sam num=int(input("Enter a Number")) print(sum_of_numbers(num))
23f0c20af7c7852ae00299ef9de9291562c9bf62
goutham-nekkalapu/algo_DS
/ctci_sol/arrays_strings/8.py
1,564
3.984375
4
# In a given MxN matrix, if one of the elements of row or coloumn are '0' populate the entire row and column with zeros def populate_zeros(data): # finding if any first row or first column have zeros row = 0 col = 0 for i in data[0]: if i == 0: row = 1 break ...
b0886c7ea49963d1130bc739b0d5f3ecdf5d7223
yunho0130/140812_Python
/Week1/coinCounter.py
2,300
3.53125
4
__author__ = 'Administrator' # 동전계산 프로그램 함수와 리스트를 사용해서 만들어보기. # 리스트에 1000원권을 추가해도 코드의 수정이 필요 없을 것 # 100원짜리만 있을 때 다른 주화는 물어보지 않는 것. 입금할 주화를 선택. 총계. """ c10=10 c50=50 c100=100 c500=500 """ # calcValue (10) total = 0 coinValue = 0 coinTable = [10, 50, 100, 500,1000] length = len(coinTable) def multipleVal (coinValue, c...
6c8f36fe6f05401c1eba045ced0e239a733448af
Bazgha19/Python-Programs
/Random.py
231
3.578125
4
#Use of random ''' Random used in an array import random a=['Saurav','Meenakshi','Ashok','Ladli'] s=random.choice(a) print(s) ''' ''' Random used for chosing number from 1 to 6 import random a=random.randint(1,6) print(a) '''
c5580ddd473b8c6874af7ef111e9e4ac6c0904e2
ekhossejn/Stack
/Stack.py
2,649
3.640625
4
class MyStack(): def __init__(self): self.__data = [] def is_empty(self) -> bool: return (len(self.__data) == 0) def size(self) -> int: return len(self.__data) def top(self) -> int: if self.is_empty(): raise IndexError return self.__data[-1] def po...
367f4f8cb80cd7df3586476791d45f3ed8cefa68
DennisDondergoor/AlgorithmicToolbox
/26_points_and_segments.py
820
3.546875
4
# Uses python3 import sys def fast_count_segments(starts, ends, points): lst = [] for i in starts: lst.append([i, "u"]) for i in ends: lst.append([i, "w"]) for i in points: lst.append([i, "v"]) lst.sort() cnt = [] d = {} j = 0 for i in range(len(lst)): ...
003b4d24f22c885640b4e2757e785f8fb32daee3
Aasthaengg/IBMdataset
/Python_codes/p02257/s611765441.py
583
3.78125
4
import math def isPrime(n): if n <= 1: return False elif n < 4: return True elif n % 2 == 0: return False elif n < 9: return True elif n % 3 == 0: return False else: i = 5 while i <= math.sqrt(n): if n % i == 0: ...
a091d1f11f9cd8da3cfd4a540854d77ee831b8c1
vanderson-henrique/trybe-exercises
/COMPUTER-SCIENCE/BLOCO_36/36_1/conteudo/user.py
1,137
4.28125
4
class User: def __init__(self, name, email, password): """ Método construtor da classe User. Note que o primeiro parâmetro deve ser o `self`. Isso é uma particularidade de Python, vamos falar mais disso adiante!""" self.name = name self.email = email self.pass...
995dbfae7f9281cb76a46a9a3fba3ec8a66b3121
austin-starks/Data-Structure-Algorithms-Practice
/curriculum_blank.py
1,473
3.625
4
import sys sys.path.insert(1, "LinkedList") import LinkedListTest # Curriculum # Data Structures # • Arrays Description: # - Big-O for insert: # - Big-O for delete: # - Big-O for lookup: # - Example use: # • Linked List Description: # - Big-O for insert: # - Big-O for delete: # - Big-O for lookup: # - Examp...
ea196e30ea02e7dd2a5acc48876b9079d542e451
IonutPopovici1992/Python
/Socratica/filter_1.py
435
4
4
# Map, Filter, and Reduce Functions # Filter # Method 3: Use 'filter' function # Example: Find all data above the average. import statistics data = [1.3, 2.7, 0.8, 4.1, 4.3, -0.1] average = statistics.mean(data) print(average) print() print(filter(lambda x: x > average, data)) print(list(filter(lambda x: x > aver...
690dad9742fe61345ceea499da453eac5f0daa2b
alvinyeonata/CP1404
/workshop 4/calcAreaAndVolume.py
458
4.15625
4
print("area calculator") width =int(input("Enter width")) height =int(input("Enter height")) depth =int(input("Enter depth")) area = width*height volume = width*height*depth print("area" ,area, "volume" ,volume) """ def get_dimentions(): length = int(input("Enter the length: ")) width = int(input("Enter the...
50e303a4159fc8329c752ffdbe3e6175a46f9c79
shailypriya/RollingDiceSimulator
/main.py
1,699
3.515625
4
from tkinter import * from PIL import ImageTk, Image import itertools import random background_color = "#0D865D" # kind of green root = Tk() root.geometry("960x900") first_image_path = "./0.png" second_image_path = "./0.png" first_dice_image = ImageTk.PhotoImage(Image.open(first_image_path)) first_dice_label = Label...
b96538110f98d5fddf4af00636c171dd63f8df1a
iGrushevskiy/python
/battleship_game.py
1,773
4.625
5
#importing random function for further random column and row index generation from random import randint #creating empty parent list board = [] '''populating the parent list with 5 child lists in order to create multidimensial matrix playing desk ''' for x in range(5): board.append(["O"] * 5) def print_board(bo...
a981ecaa3bfa6d6e9bf9fdd921b3277749fdb45e
ChirantanSoni28/Python-Skillup
/Problem 6/solution.py
151
3.515625
4
def bmi(weight, height): bmi = weight / height**2 return ["Obese", "Overweight", "Normal", "Underweight"][(bmi<=30) + (bmi<=25) + (bmi<=18.5)]
339be2a4f6e62bb5acf4cd5710022c909a8aded0
sashakrasnov/datacamp
/23-network-analysis-in-python-2/1-bipartite-graphs-and-product-recommendation-systems/02-the-bipartite-keyword.py
2,257
4.09375
4
''' The bipartite keyword In the video, Eric introduced you to the 'bipartite' keyword. This keyword is part of a node's metadata dictionary, and can be assigned both when you add a node and after the node is added. Remember, though, that by definition, in a bipartite graph, a node cannot be connected to another node ...
225798f2a79f252d9d862d3f5749c6a9074340f5
joseph-p-pasaoa/exercises-codesignal--py
/arcade/25-array-replace.py
878
4.09375
4
""" 25: ARRAY REPLACE Given an array of integers, replace all the occurrences of elemToReplace with substitutionElem. Example For inputArray = [1, 2, 1], elemToReplace = 1, and substitutionElem = 3, the output should be arrayReplace(inputArray, elemToReplace, substitutionElem) = [3, 2, 3]. Input/Output [execution tim...
0bb79eacacdf3e7498577bfb2986dae967d19fbe
featurelle/DesignPatterns
/GoF/behavioral/Strategy.py
1,637
4.09375
4
from __future__ import annotations from abc import ABC, abstractmethod class Router(ABC): def __init__(self, name, movement): self._name = name self._movement = movement @abstractmethod def find_route(self, a, b): pass @property def name(self): return self._name ...
e49ff629d0e0891466fde4546988d1056e3ab1bd
maniCitizen/-100DaysofCode
/Concepts/Lists.py
452
3.96875
4
print(range(0, 10)) even = list(range(0, 10, 2)) odd = list(range(1, 10, 2)) print(even) print(odd) my_string = "abcdefghijklmnopqrstuvwxyz" print(my_string.index("e")) print(my_string[4]) small_decimals = list(range(5, 10)) print(small_decimals) print(small_decimals.index(8)) odd = range(0, 1000000, 2) print(odd[9...
b4922d10ab8b6dd923a2f3422118108aaa9dd926
abhilashshukla/python-coading-questions
/library/lib_csv.py
2,737
3.828125
4
''' Created on Jul 19, 2014 @author: Abhilash Shukla Description: This file will contain all reusable csv processing functionality ''' import csv from collections import OrderedDict, namedtuple from lang import Lang ''' Count number of columns in a CSV file csv_file : Full qualified path of CSV file ''' def GetC...
c889d83eeedec533704bd84a0af59cd2fdf1aee4
ozifirebrand/Packt_and_study_for_python
/Exercises/practice.py
260
4.15625
4
print('What is your name?\n') name = input() print('Hello, {} '.format(name)) print('Hello! Please rate your day on a scale of 1-10.') day = input() print("""Your day is rated {} by you. Thank you for taking part in this questionnaire""" .format(day))
81ebb2252e52b3b52ec1c313be7b252b20ead6d3
dongbo910220/leetcode_
/Tree/965. Univalued Binary Tree Easy.py
884
3.515625
4
''' https://leetcode.com/problems/univalued-binary-tree/submissions/ Success Details Runtime: 24 ms, faster than 32.08% of Python online submissions for Univalued Binary Tree. Memory Usage: 13 MB, less than 7.90% of Python online submissions for Univalued Binary Tree. ''' # Definition for a binary tree node. # class...
acdcba9627800a1c895a6b0ae4fa97447b2d510d
Seeulaterrr/Python_degetal
/Lesson_1/Exercise_Lesson_141.py
464
3.890625
4
#Create a dictionary with 5 names and money, #summ money of the first and last names, print the summ #add a new name with the summ of the money #print the number of entries and check if #"Luba" is inside my_dic={"Alla":30, "Sveta":16, "Alex":48,"Anton":0, "Luba":75} print("The summ is: " + str(my_dic["Alla"]+my_dic["L...
012406635d97114c5109ce5c2338df1ffaca92f6
artdiev/exoclick-test
/task1-3.py
2,795
4.28125
4
# Task 1 - Highest occurrence def highest_occurrence(array): """ Time: O(n) Space: O(n) :param array: strings, int or floats, can be mixed :return: array containing element(s) with the highest occurrences without type coercion. Returns an empty array if given array is empty. """ # h...
6fb82438ee2b5fd2d32741cf6efe4b2c08dc4634
kevin-s/microwaveoptimization
/microwaveoptimization/main.py
152
3.75
4
def main(): print("Hello World!") def thirtySecondIncrements(seconds): if seconds % 30 != 0: return None return seconds / 30
acd9fd167e7def8b06122728fb7afa322de389c5
ThiagoAnd/Python
/ListaExercicios/Exercicio3.py
1,884
3.859375
4
def validarZero(numeros): cont = 0 while len(numeros) > cont: if numeros[cont] != 0: return False else: True cont += 1 return True def validarEntrada(numeros): cont = 0 while len(numeros) > cont: if numeros[cont] >= 1 and numeros[cont] <= 8...
11ea6f291a7f1f80e9e4bfcb9b4793ee3c620a9a
movalex/jupyter_work
/Multiprocessing/mp_lesson.py
521
3.71875
4
import multiprocessing def spawn(num): """simple multiprocessing example :returns: TODO """ return f"spawned {num}!" # if __name__ == "__main__": # for i in range(55): # p = multiprocessing.Process(target=spawn, args=(i,)) # p.start() # p.join() # spawn and wait till co...
b6ffcc8ec4c39f7a08ee798bc0227fd664ca058c
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/222/users/4061/codes/1601_2426.py
137
3.609375
4
tempo = float(input("digite tempo")) vel = float(input("digite velocidade")) dist = vel*tempo litros = dist/12 print(dist) print(litros)
039f4507f6c6af895498d5714195ba8c74432112
Leo10Gama/L30Pi
/fibonacci.py
193
3.859375
4
def get_fib(n): if n < 0: return "Not a valid input" elif n == 1: return 0 elif n == 2: return 1 else: return get_fib(n-1) + get_fib(n-2)
c32fa0e9f9cf95e80564c6341ca5af9ec78bcd13
adityakverma/Interview_Prepration
/Leetcode/Heap/LC-378. Kth Smallest element in Sorted Matrix.py
3,634
3.890625
4
# Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. # # Note that it is the kth smallest element in the sorted order, not the kth distinct element. # # Example: # # matrix = [ # [ 1, 5, 9], # [10, 11, 13], # [12, 13,...
26231eb3162ac1c98ee2e72b5c44284c403f1c57
yfeng75/learntocode
/python/escapechar.py
516
3.734375
4
splitString = "This string has been\nsplit over\nseveral\nlines" print(splitString) tabbedString="1\t2\t3" print(tabbedString) print('The pet shop owner said "No, no, \'e\'s uh,...he\'s resting".') # or print("The pet shop owner said \"No,no, 'e's uh,...he's resting\".") print("""The pet show owner said "No,no,'e's uh,...
e40ef83fd0c58c804074c7d19927ddb921c025a3
Mandhularajitha/dictinary
/meraki error qns.py
633
4.09375
4
a = {(1,2):1,(2,3):2} print(a[1,2]) # out put 1 # ================================================== a = {'a':1,'b':2,'c':3} print(a["c"]) # =================================================== fruit = {} def addone(index): if index in fruit: fruit[index] += 1 else: fruit[index] = 1 addone('A...
1d2902b229b5d2060dedbb9a2050811889367b3a
ianxxiao/Python-for-Data-Science
/HW2_ixx200/get_bus_info.py
5,583
3.828125
4
# PULL BUS DATA FROM METRO API # Return a list of bus information import sys import pandas as pd import sys import json import urllib3 import pprint import csv def setup(api_key, bus_line): ''' This function creates a API URL based on user inputs Args: api_key (str): private API key the use received from MTA A...
e5fbc00450f6e3ae567ae72a8181d964605aac23
Joshuacruzc/CurriculumAlgorithm
/Curriculum.py
865
3.578125
4
class Curriculum: def __init__(self, department, courses=None): self.department = department if courses is None: self.courses = list() else: self.courses = courses def get_concentration_courses(self): return [course for course in self.courses if course....
728690052d2bd69ffc4c38e385278c629c71cea0
Wowfz/CS542_MechineLearning_PS2
/knn/knn.py
4,160
3.65625
4
#!/usr/bin/env python import csv import random import math import operator import pandas #Code to update the data training and testing from sys import argv #Getting the arguments directly from the command to run the script script, k_input, TrainData_Input, TestData_Input = argv TrainingData = pandas.r...
dd1857c2ce06d635a4e5dcc5c1b8870911864a36
akueisara/leetcode
/P36 Valid Sudoku/solution.py
1,009
3.703125
4
class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: for i in range(9): row = set() column = set() box = set() for j in range(9): if board[i][j] != '.': if board[i][j] not in row: ...
ddf787bc4ff0ead43a2d9fc6a21a101615b506be
yuekai146/uyghur
/check.py
230
3.546875
4
def check_num_words(filename): f = open(filename, 'r') lines = f.readlines() lines = [l.strip() for l in lines] lines = list(set(lines)) num = 0 for l in lines: num += len(l.split()) return num
3254d4be5af3f8ec80d07778c53a3488336be81d
moogar0880/CodeEval
/Python/find_writer.py
822
4.15625
4
"""You have a set of rows with names of famous writers encoded inside. Each row is divided into 2 parts by pipe char (|). The first part has a writer's name. The second part is a "key" to generate a name. Your goal is to go through each number in the key (numbers are separated by space) left-to-right. Each number repr...
b1187de8c6984820f073d1ddb1dc59b4ee891a12
kepoc100/alg_datast_ws16_17
/tree (Kopie).py
1,410
3.9375
4
class Node: def __init__(self,data,left=None,right=None): self.data = data self.right = right self.left = left class bst: def create_node(self,data): return Node(data) def binary_insert(self,root,node): if root is None: return self.create_node(node) self.root = root self.node = node if root i...
0ed86ebd5ce7154aeffee8df116705c7ac647574
diwadd/sport
/cf_jumps.py
246
3.53125
4
import math t = int(input()) for _ in range(t): x = int(input()) d = math.sqrt(1+8*x) n = math.ceil((-1.0+d)/2.0) m = n*(n+1)/2 if m == x: print(n) elif m - 1 == x: print(n+1) else: print(n)
fc94c6c4e1109a8ae8eb4ff9d93927d5bf7f6d37
huangel1998/Apartment-List-Internship-Challenge
/SOCIAL NETWORK SIZE (176243).py
5,179
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Mar 13 19:39:08 2018 @author: angelhuang """ import string import sys def load_words(list_file): """ loads file into program """ # inFile: file inFile = open(list_file, 'r') #opens the file in read mode # wordlist: list ...
4a4bd2ac62b10c15f00e702ce6d6c02966575c23
tonyyzhu/cs101
/Lesson_6_How_to_Have_Infinite_Power/12-Bunnies/solutions.py
429
4.1875
4
def fibonacci(n): if n == 0: return 0 else: if n == 1: return 1 else: return fibonacci(n-1) + fibonacci(n-2) # From the README: # We do NOT accept pull requests that have deleted another contributer's hint or solution without a very clear reason # ALL solutions m...
1f3f225e95e6512e06c12c2cbc1b9ad317b46780
MuhammadSaqib-Github/Python
/Loops/5.30.py
1,330
4.03125
4
year = eval(input("enter year ")) #k is year y = year for m in range(1,13): if m == 1: month="january" elif m == 2: month = "February" elif m == 3: month = "March" elif m == 4: month = "April" elif m == 5: month = "May" elif m == 6: m...
292321935dab82466b6cbdf1b231a5bfc0b7dc4d
nbrahman/HackerRank
/03 10 Days of Statistics/Day04-02-Binomial-Distribution-II.py
1,620
4.21875
4
''' Objective In this challenge, we go further with binomial distributions. We recommend reviewing the previous challenge's Tutorial before attempting this problem. Task A manufacturer of metal pistons finds that, on average, 12% of the pistons they manufacture are rejected because they are incorrectly sized. What is ...
465262c24f5fc433f30d7b126fd7debec93049eb
FKistic/Python-Personal
/calci project/calci v3.py
578
3.9375
4
x = int(input("Please Type the 1st number: ")) y = int(input("Please Type the 2nd number: ")) a = x+y b = x-y c = x*y d = x/y opp = input("PRESS ENTER TO CONTINUE: ") print() if opp is opp: print("IF ADDED THEN ANSWER WILL BE") print(a) print() print("IF SUBTRACTED THEN THE ANSWER WILL BE") print(b...
0a78387a8f5347ae19604f3bfe8a4c0c3034d22e
noobcoderr/python_spider
/alien_invasion/ship.py
1,591
3.5
4
import pygame class Ship(): def __init__(self,ai_settings,screen): """init ship and set its start location""" self.screen = screen self.ai_settings = ai_settings #load ship pic and get its bounding rectangle(wai jie juxing) self.image = pygame.image.load('images/shipbmp.bm...
b96219735c72ad8aba4746bc48d931631898f4c0
kwokwill/comp3522-object-oriented-programming
/Midterm/Q1/design.py
1,701
4.28125
4
""" (7 Marks) In this program we are simulating a Landlord taking taking rent from a Tenant. The existing code is designed incorrectly. Your task is to: TODO Examine the code below. After examination, answer which design idiom the code in this file violates? Write your answer in the space...
45318225e91cbfb1b1336b356c165baba0acbdab
v370r/Codes
/TechDose/Sort012.py
364
3.609375
4
def Sort(A): #total n/3 iterations only lo = 0 m =0 hi = len(A)-1 while(m<=hi): if A[m]==0: A[lo],A[m] = A[m],A[lo] lo+=1 m +=1 elif A[m]==1: m+=1 else: A[m],A[hi] =A[hi],A[m] hi -=1 return ...
6f32d1fdb0b14f10c7cd78bbf4516a08dd231e98
stevelp99/htx-immersive-08-2019
/01-week/4-friday/labs/Steven-Dismuke/Steven-Dismuke-Fizz-Buzz.py
350
4.125
4
## Steven Dismuke ### Determine if numbers in a range are divisible by "3" and print "fizz", by "5" and print "buzz", and by "3 and 5" and print "fizzbuzz". list=range(1,100) for num in list: if num%3==0 and num%5==0: print("fizzbuzz") elif num%3==0: print("fizz") elif num%5==0: prin...
3f195ea99cb3652f9c347307b23a7594e3ed8d0c
Endlex-net/practic_on_lintcode
/compare-strings/code.py
428
3.859375
4
# -*- coding: utf-8 -*- class Solution: """ @param A : A string includes Upper Case letters @param B : A string includes Upper Case letters @return : if string A contains all of the characters in B return True else return False """ def compareStrings(self, A, B): a = list(A) for...
7fa7e6879e6b59b705ef69c32ecd58cb7c19aabc
acycliczebra/multiplicative_persistence
/mulper.py
1,460
3.609375
4
import sys from functools import reduce from itertools import product def multiplication_persistence(num, verbose=False): if verbose: print(n) if num < 10: return 0 product = 1 n = num while n > 0: product *= (n % 10) n //= 10 return 1 + multiplication_persis...
379deb2ed86cc86c6dec770c3ba0809c3341df07
zhangli709/algorithm009-class01
/Week_09/049.py
372
3.5625
4
# 049 字母异位词分组 class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: new_strs = [''.join(sorted(i)) for i in strs] from collections import defaultdict my_dict = defaultdict(list) for idx, val in enumerate(new_strs): my_dict[val].append(strs[idx]) ...
3fa362226a5a33dfc89978a0c05e62c719d22dcb
MichalWlodarek/Tic-Tac-Toe
/TTT.py
6,232
4.0625
4
import tkinter.messagebox try: import tkinter except ImportError: import Tkinter as tkinter # Declaring button's functions. Empty button when pressed will display 'X', click will turn to False and the next # button press will produce a 'O' and the click will turn back to True. Count is used to determine...
5ef6680b75f4c3466f6747936e85be29ac2d8206
foxxpy/Exercices-Python
/1. Les fonctions récursives par l'exemple - Partie 1/join.py
895
3.875
4
#Recréer la fonction join() des chaînes de caractères avec un algorithme récursif def recursion_join(c, liste, i=0): final_string = str(liste[i])+c if i < len(liste)-1 else str(liste[i]) if i < len(liste)-1: final_string += recursion_join(c, liste, i+1) return final_string #recursion_join(...
77241748353a615dab718c0b911656976505438d
michlee1337/practice
/control/checkers/Board.py
5,960
3.84375
4
from Piece import * import copy class Board: ''' Attributes: - state <List of Lists>: describes the cells of the board - isAgentTurn <Boolean>: True if it is Agent's turn Methods: - customState: set your own board state using lists of lists of integers. - nextBoards: return...
be717f7f3746419e384d2f6a3aeb2d8c02d2ce7a
mhtehrani/Algorithms
/PlacingParentheses_DynamicProgramming.py
1,399
3.625
4
""" Maximum Value of an Arithmetic Expression (Dynamic Programming) =============================================================== @author: mhtehrani September 17, 2021 https://github.com/mhtehrani """ import numpy def eval(a, op, b): if op == '+': return a + b elif op == '-': return a - b ...
0c424b288373f896fe80b9e79d23162de591d36f
zach-aravind/AI-Nielit
/ML/Day3_Nov12/q1.py
964
4.34375
4
# Question 1 # Develop an ML model for predicting sales for the Advertising data (Advertising.csv file) using Linear Regression. #Import necessary modules from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn import metrics import pandas as pd import numpy ...
cb91654455e0ab7be8aac119ea11c35c4a03c7a7
Gamain/PyCode
/Features/for_else.py
533
3.90625
4
# 要点: 如果for元素被迭代完,则不会执行else子句 否则会执行else子句 l=[1,2,3,4,5] for i in l: print 'Yes',i else: print 'No' print '-------------' for i in l: print 'Yes',i break else: print 'No' print '-------------' for i in l: print 'Yes',i continue else: print 'No' print '-------------' for i in l: ...
6873528cc935b0ce37b927008bdfc1eba37e372b
kathuriaapk/Make-My-Quiz
/MakeMyQuiz.py
584
3.859375
4
import quizGenerator import playQuiz #MAKE MY QUIZ print("\nApp is designed ito create and play quizes .\n") sel = True while(sel is True): selection = input("Select the operation you want to perform ?\n \ (type 1 to create quiz & \ntype 2 to attemp quizes)\n \ or type 'quit' to exit.\nYour choice :- ") if selecti...
04124ee1b630f7f77fb4cb48c1559d3190a2790a
AgileMathew/AnandPython
/Module II/pgm04_prod.py
196
4.09375
4
#Problem 4: Implement a function product, to compute product of a list of numbers. def prod_list(x): prod = 1 for i in x: prod = prod * i return prod print prod_list([3,2,3])
0eb8b5fb2acab4ac59f38bc8f0213a8be61a77a0
Amitnijjar008/CSE150
/Assignment 3/CSE150_Assignment_3/CSE150_Assignment_3/solutions/p5_ordering.py
2,078
3.6875
4
# -*- coding: utf-8 -*- from operator import itemgetter from collections import deque def select_unassigned_variable(csp): """Selects the next unassigned variable, or None if there is no more unassigned variables (i.e. the assignment is complete). This method implements the minimum-remaining-values (MRV)...
40a6813ae7bf9eaf4fb7c944afa4bf7b9ab1677b
a01375610/Mision_02
/extraGalletas.py
511
4.15625
4
#Autor: Patricio León #Descripción: Teclea el número de galletas que quieres para saber la cantidad #de ingredientes que necesitas. galletas = int(input("¿Cuántas galletas quieres preparas?: ")) azucar = (1.5*galletas)//48 mantequilla = (1*galletas)//48 harina = (2.75*galletas)//48 print("Si quieres", galletas, """ga...
3dba613f73952e48df2c6a31a2e39c07b8789ef3
veerapalla/cracking_the_coding_interview
/Algorithms/dijkstra/dijkstra.py
1,802
4.09375
4
# Python Implementation for Dijkstra's Algorithm def readData(adj, dist): print "Loading Data ..." f = open('dijkstraData.txt', 'r') for line in f.readlines(): line = line.split() node = int(line[0]) for i in line[1:]: i = i.split(',') dist[(node, int(i[0]))]...
4d22b7cccce1c210d3fec536cf57a28e3feb8514
XuQiao/codestudy
/python/misan/game.py
658
3.59375
4
import numpy as np # My opponent and I play a game, if I stay he quits, then I get $10 he get nothing. If both stay, we both pay $1. def play(x, y): if x and y: return (-1, -1) if x and (not y): return (10, 0) if (not x) and y: return (0, 10) if (not x) and (not y): retur...
c03b257948f6cac5a603d10d09b987d8b3cc0bd6
S-Downes/CI-Challenges
/Stream-3/01_python_challenges/projects/boggle-solver/boggle.py
3,421
4.15625
4
from string import ascii_uppercase from random import choice # Define our function(s) for testing def make_grid(w, h): """ Our make_grid() function returns a grid of given dimensions width and height """ return {(row, col): choice(ascii_uppercase) for row in range(h) for col in range(w)} def posi...
c0bcacded485835372b990a31fa60c16be032129
gourav-singhal/daily_coding_problem
/problems/30/solution_30.py
1,355
4.28125
4
def coding_problem_30(arr): """ You are given an array of non-negative integers that represents a two-dimensional elevation map where each element is unit-width wall and the integer is the height. Suppose it will rain and all spots between two walls get filled up. Compute how many units of water remain ...
fc3b700d9cce05890ceef02ef855d766a2b7bc60
sruthipraveenkumargeetha/ZKAP_implementation
/feigefiatshamir/sample_serv.py
1,902
3.5
4
# Script file: sample_serv.py import socket import common import random import json # next create a socket object s = socket.socket() print "Socket successfully created" # reserve a port on your computer in our # case it is 12345 but it can be anything port = 12345 # Next bind to the port # we have not ty...
439cd65ba23adf4313fc919b518220fb9019bbed
narayanbinu21/origami-website
/bankatm.py
900
3.71875
4
class Atm: def __init__(self,cardnumber,pin): self.carnumber = cardnumber self.pin = pin def checkbalance(self): print("balance = 50000") def withdrawel(self,amount): new_amount = 50000-amount print("u have withdrawn" + str(amount)+"your remaining balance is"+...
ed83f85c69ed6ecdc4bcdd259c86c9b9c6f98d61
anshulg825/Codecademy-Courses
/Machine Learning/Regression/honey,kaggle,regress,scikit.py
732
3.59375
4
import codecademylib3_seaborn import pandas as pd import matplotlib.pyplot as plt import numpy as np from sklearn import linear_model df = pd.read_csv("https://s3.amazonaws.com/codecademy-content/programs/data-science-path/linear_regression/honeyproduction.csv") prod_per_year= df.groupby('year').totalprod.mean().rese...
531e5f05ad2ce3ec7568bc3045c64e85a9c2c37f
EuricoDNJR/beecrowd-URI
/Em Python/1011.py
98
3.671875
4
raio = float(input()) pi = 3.14159 calc = (4.0/3)*pi*raio**3 print('VOLUME = {:.3f}'.format(calc))
ff3accc7013e6c38f3b4be5d73f6f9c1a38edb0c
AnujBalu/PyQt5_Notes
/Udemy_PyQt5/Ls_1_PyQt5.py
780
3.671875
4
from PyQt5.QtWidgets import QLabel from PyQt5.QtWidgets import QMainWindow from PyQt5.QtWidgets import QApplication class display(QMainWindow): def __init__(self): # we cann't add widgets in main class so that we are creatinf a super(display,self).__init__() #...
03def8342321303d5159a8bd8bed1de5f1f7dd3b
lsteiner9/python-chapters-7-to-9
/chapter9/volleyball.py
2,823
4.15625
4
# volleyball.py from random import random def print_intro(): print("This program simulates a game of volleyball between two teams " "called \"A\" and \"B\". The ability of each team is indicated " "by a probability (a number between 0 and 1) that the team wins " "the point when servi...
8acb7401ac4bca2de5571c4ed7e861018badf582
gherreraa1/PortafolioMetodosNumericos
/Parcial 1/metodoPuntoFijo.py
557
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Aug 14 08:38:13 2018 @author: memoherrera """ import matplotlib.pyplot as plt def xnew(xprev): return (2 * xprev ** 2 + 3)/5 x0 = 0 x1 = 0 x0Array = [] x1Array = [] iteraciones = 0 for i in range(5): x1 = xnew(x0) x0Array.append(x0) x1...
40d0841fa2dcaa1c9edceb5cc8bfc0a527ca2f13
violetaventura001/vv-python-lists-loops-programming-exercises
/exercises/08.1-Merge_list/app.py
364
3.984375
4
chunk_one = [ 'Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell' ] chunk_two = [ 'Lucas' , 'Jake','Scott','Amy', 'Molly','Hannah','Lucas'] def merge_list(list1, list2): new_merge_list =[] #1. Declare an empty list. for x in merge_list #2. Loop the two list. if x in list1 ...
1c1695b6b45227c200c5d5d48bb3a2d7eec07122
AdamTutor/Inventory-rental-program
/inventory.py
6,188
3.671875
4
import csv from Rental_classes import * #IS TESTED# def get_file_contents(filename): """ (file_obj) --> (list) Takes in a csv file as a parameter and reads the file and outputs a cvs.reader object that is converted to a list of lists.""" with open(filename, newline='') as inv: #csv.reader(file to...
31c26aef789d8819aacf55a850ca81d9d097c9eb
dmoitim/pos_ciencia_dados
/01 - Introdução à programação com Python/003_aula02_variavel_nomes.py
788
4.4375
4
''' começar com letras podem conter letras, números e underline não podem conter espaços não podem ser palavras reservadas não são tipadas ''' # Concatenação num1 = 10 print("Valor de num1: " + str(num1)) num2 = 20 print("Valor de num2: " + str(num2)) # String nome = "Python" print(nome) # Métod...
1d15ea8320ade0bd5f78f9506aca687b704fdaf1
hrishitelang/Leetcode-Problem-Solving-and-SQL
/Data Structures/Queue/main.py
1,520
4.09375
4
class Queue: def __init__(self): self.queue = [] def displayoptions(self): while True: a = int(input("1. Enqueue\n2. Dequeue\n3. Peek\n4. Size\n5. Display\n6. Is Queue empty?\n7. Exit\nChoose your option: ")) if a == 1: data = int(input("Enter the...
f3f61e6bc63a43046df56a2c33d2efe59db8efae
FrazerBayley/FB-examples
/Python/BlackJack/blackjack.py
6,332
4.0625
4
""" Frazer Bayley CIS 211 blackjack.py This is a blackjack game simulator with with a dealer and a player. The display begins with 12 blank labels (6 dealer cards, 6 player cards) and 3 buttons (deal, hit, and pass). These relate to functions deal(), hit() and pass_f(). The functions produce tkinter messageboxes wh...
03bf24f6d50ab46181182823f3f65786f0f5e1bc
smttl/faktoriyel
/factorial.py
308
4.375
4
#factorial.py # calculates the factorial of a given number var = 1 while var == 1 : print("This program will calculate the factorial of a given number.") x = input("Enter a number: ") fact = 1 for i in range(x): fact = fact * (i + 1) print(str(x) + "! = " + str(fact))
ed80c5492a72ff00832eadf0a820d6533d7b28ef
Heart-of-Prairie-Fire/ML_algorithm
/utils/features/generate_polynomials.py
2,142
3.734375
4
# -*- coding:utf-8 -*- __author__ = 'Qiushi Huang' """Add polynomial features to the features set 将多项式特征添加到特征集""" import numpy as np from .normalize import normalize def generate_polynomials(dataset, polynomial_degree, normalize_data = False): """变换方法: x1, x2, x1^2, x2^2, x1*x2, x1*x2^2, etc. :param dat...