blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
51604ee8ff67265c7eca3cb50e541d81f8f347db
nagpalchi/MyFirst
/PycharmProjects/webscrapper1/cylinder.py
427
3.640625
4
class Cylinder(): pi=22/7 def __init__(self,height,radius): self.height = height self.radius= radius def volume(self): return self.pi*self.radius*self.radius*self.height def surfaceArea(self): return 2*self.pi*self.radius*self.height cylinder1 = Cylinder(10,20) print("Sur...
ca96973d55c36767151a3b5a21be3d54d9d823fb
nagpalchi/MyFirst
/documents/python/cowsnbulls.py
802
3.609375
4
import random cows=0 bulls = 0 bot=[] user=[] def findit(bot,user): cow = 0 bull=0 for x in bot: if x in user: if bot.index(x)==user.index(x): cow+=1 else: bull+=1 return cow,bull while 0>-1: print("1. New Game \n 2. Exit ") inp = input("Enter your choice\t") if(inp=='1'): bot = str(random.ran...
fae45fd7cfb83e0a1c85236806aa27193a7de6fa
AloysiusAji/minggu-4-71180298
/Soal Buatan sendiri minggu 4 71180298.py
1,434
3.78125
4
#Aloysius Gonzaga Ardhian Krisna Aji #71180298 #Membuat program untuk mencari nilai konversi mata uang asing ke rupiah #Dolar 14500, Yen 134, Ringgit 3534, Euro 17269, Rupee 195. def USD(Dolar): uangUSD = Dolar * 14500 return uangUSD def JPN(Yen): uangJPN = Yen * 134 return uangJPN def Malay(Ringgit):...
f9b312bb62d8f049321e181956394d7c9f99a8b1
LirraSmile/autotest-course
/4_lesson3_step3.py
1,471
3.625
4
from selenium import webdriver from selenium.webdriver.support.ui import Select #Специальный класс из библиотеки WebDriver import math import time #Задача: найти на странице элементы, сложить их, найти в выпадающем списке сумму и нажать кнопку link = "http://suninjuly.github.io/selects1.html" try: browser = web...
7bb2d974b3da67ce4ab03b7178141ffde04e4c6f
ed18s007/Geeksforgeeks_practice
/01_Data_Stuctures/02_Linked_List/12_Check_circular_LL.py
387
3.578125
4
# your task is to complete this function # function should return true/false or 1/0 def isCircular(head): # Code here slw_node, fst_node = head,head while fst_node.next is not None: slw_node = slw_node.next if(fst_node.next.next is None): return False fst_node = fst_node....
eac3ecb2ae2430b97c081418aa3298088e87ab45
ed18s007/Geeksforgeeks_practice
/01_Data_Stuctures/02_Linked_List/37_nth_from_end_LL.py
421
3.78125
4
# Nth node from end of linked list def getNthfromEnd(head,n): #code here idx = 1 curr_node = head while idx < n: if(curr_node.next is None): return -1 idx+=1 curr_node = curr_node.next prev_node = head while curr_node: if curr_node.next is None: ...
abbd46b750f8d56b860636526ebe9cbc3b273614
ed18s007/Geeksforgeeks_practice
/01_Data_Stuctures/02_Linked_List/47_Delete__greater_value_right_LL.py
565
3.578125
4
# Delete nodes having greater value on right def compute(head): #Your code here prev_node = head if head.next is None: return head curr_node = head.next while curr_node: if curr_node.next is None: if prev_node.data < curr_node.data: prev_node.next = Non...
295fd2e05aa5c2ccb7857846bc068496b9c02130
ed18s007/Geeksforgeeks_practice
/01_Data_Stuctures/03_Stacks_And_Queues/08_Remove_repeated_digits_given_number.py
321
3.65625
4
# Remove repeated digits in a given number #code for T in range(int(input())): stack = [] N = input() for char in N: if not stack: stack.append(char) elif stack[-1] == char: continue else: stack.append(char) print(''.join(stack)) ...
4767f065f922abb35cd7e45dd7be7d586cba3daf
ed18s007/Geeksforgeeks_practice
/01_Data_Stuctures/03_Stacks_And_Queues/02_ Rev_First_k_elem_Queue.py
235
3.5625
4
def reverseK(queue,k,n): # code here k_q = queue[:k] return k_q[::-1]+queue[k:] def reverseK(queue,k,n): # code here rev_k = [] for i in range(k): rev_k.append(queue[k-i-1]) return rev_k + queue[k:]
a6121554fdecf392c0ce86910659da3930287edd
ed18s007/Geeksforgeeks_practice
/01_Data_Stuctures/02_Linked_List/17_data_at_k_node_LL.py
236
3.625
4
# Node at a given index in linked list def getNth(head, k): # Code here if(k==1): return head.data else: node = head while k>1: node = node.next k-=1 return node.data
fbc947245de8ab1ba134520baf55b49203839d5b
ed18s007/Geeksforgeeks_practice
/01_Data_Stuctures/03_Stacks_And_Queues/14_Queue_using_two_Stacks.py
486
3.9375
4
# Queue using two Stacks def qPush(x,stack1,stack2): ''' x: value to push stack1: list stack2: list ''' #code here stack1.append(x) def qPop(stack1,stack2): ''' stack1: list stack2: list ''' #code here if len(stack1)==0: return -1 for i i...
87c40f7bbad2bf51205d343089cd7a5386e39909
ed18s007/Geeksforgeeks_practice
/01_Data_Stuctures/03_Stacks_And_Queues/21_Infix_to_Postfix.py
995
4.09375
4
# Infix to Postfix #code def priority(char): if char=="+" or char=="-": return 1 elif char=="*" or char=="/": return 2 elif char=="^": return 3 return 0 for T in range(int(input())): exp = input() stack = [] output = [] for c in exp: if c=="(": ...
02cf9700bc202d837d16f88b67bc3ac1fd621b60
ed18s007/Geeksforgeeks_practice
/01_Data_Stuctures/03_Stacks_And_Queues/01_get_min_at_pop.py
947
3.75
4
#User function Template for python3 def _push(a,n): ''' :param a: given array :param n: given size of array :return: stack ''' # code here stack = [] for i in range(n): stack.append(a[i]) return stack def _getMinAtPop(stack): ''' :param stack: our stack :ret...
2ef9a0f4d9cd21d637a57a6bc30d126bc022448c
aneeshsebastian/python
/py_class.py
334
3.671875
4
class Dog: info = "Some info" def __init__(self, name, age, color): self.name = name self.age = age self.color = color def bark(self,age): print(f"BARK! {age}") mydog = Dog('Ram', 25, "Black") mydog.bark(10) mydog.name = "One name" print(mydog.name) print(mydog.info) print(...
c40119ce76ad55a08ee28a35e120940d643a2b49
DMSstudios/Introduction-to-python
/input.py
726
4.28125
4
#first_name = input('enter your first name: ') #second_name = input('enter your first name: ') #print( f'My name is:' first_name, second_name') #print(f"My name is,{first_name},{second_name}") #print("My name is {} {}" .format(first_name,second_name)) taskList = [23, "Jane", ["Lesson 23", 560, {"currency": "KES"}]...
f2e84b8c181b7e88ca7f6d3fb8f470786d403522
imperial-dev/breathe-ventilator
/arduinocode.py
1,816
4.0625
4
This program drives a unipolar or bipolar stepper motor. The motor should revolve one revolution in one direction, then one revolution in the other direction at varying speeds (controlled by potentiometer) The motor is attached to digital pins 8 - 11 of the Arduino. Potentiometer is connected to analog input 0. ...
fe81a54eaeb4995d63190a324d307220371d7947
CnNjuTdy/Game
/src/model/items.py
601
4
4
# -*- coding: utf-8 -*- # Time : 2019/3/22 19:21 # Author : tangdaye # Description: 一系列数据的集合 class ItemList: def __init__(self, max_size): self._max_size = max_size self._items = [] def get(self, index): if index < len(self._items): return self._items[index] ...
bed0c5ba5bdbb8c84600ebb782bde0ff0841beac
stephqwu/CoderByte-1
/Medium/29.DistinctList/solve.py
363
3.734375
4
def DistinctList(arr): dictionary = { } values = list(set(arr)) for v in values: dictionary[v] = 0 for each in arr: dictionary[each] += 1 result = 0 for value in dictionary.values(): if value == 2: result += 1 elif value > 2: result += (value-1) return result # keep this function ca...
daa976df5dd7ed15e927d65012d6e1420b1cb60a
stephqwu/CoderByte-1
/Medium/10.LetterCount/solve.py
1,350
3.640625
4
import re def get_biggest_occurence(word): chars_occurences = {} for char in word.lower(): if char in chars_occurences: chars_occurences[char] += 1 else: chars_occurences[char] = 1 return max(chars_occurences.values()) def is_word_valid(word): chars_occurences = {} for char in word.lower(): if char in...
f5c46515f18152fb8258906722aaaa8bb4c97f3b
stephqwu/CoderByte-1
/Easy/37.OtherProducts/solve.py
364
3.8125
4
def OtherProducts(arr): result = [] for i in range(0, len(arr)): product = 1 for j in range(0, len(arr)): if j == i: pass else: product *= arr[j] result.append(str(product)) return "-".join(result) # keep this function ca...
7a1ae6018cb2d4f2eba4296c4a1e928de77f9089
Watersilver/cs50
/workspace/pset6/mario/less/mario.py
390
4.125
4
# Draws hash steps from left to right. Last step is double as wide as others from cs50 import get_int # Gets height by user height = -1 while height < 0 or height > 23: height = get_int("Height: ") # Prints half pyramid # Iterate rows for i in range(height): # Iterate collumns for j in range(height + 1):...
fa60c787a1ded9baf0c60cb1835c6c55e89f2497
limafernando/APA
/Ordenacao por Comparacao 1/SelectionSort.py
612
3.765625
4
''' parâmetro -> necessário aprenas a lista de entrada, dela são tirados os elementos e o seu tamanho ''' def SelectionSort(inputList): #for tem limite superior aberto for i in range (0, len(inputList)): i_min = i #i_min = índice do menor valor j = i+1 for j in range(i+1, len(inputList)): if inputLis...
18269d692f3e1fb5ebcc51d895a051daf2c20cd9
AndreiToroplean/new_numbers
/number.py
7,266
3.53125
4
from itertools import zip_longest from digits import Digits class Number: def __init__(self, *digits, is_reversed=True, is_positive=True): if is_reversed: self.digits = list(reversed(digits)) else: self.digits = list(digits) self.is_positive = is_positive @cla...
e67634a82fcd776999526b9bc0cb695a7c351fff
uhrzel/ph-guide-to-prog
/arrays/python/lists.py
399
4.09375
4
# Declare an empty list items = [] items.append(input()) items.append(input()) items.append(input()) items.append(input()) items.append(input()) # Our position, or "index": index = int( input() ) # Print our list: print(items) # Get our item at position: our_item = items[index] # Print our item print(our_item) # No...
50bed1ca0909867bff328a54fee3c97ddea28405
AbhiniveshP/BFS-2
/Cousins.py
6,171
4.0625
4
''' Solution: 1. The problem can be solved using one of the 3 methods (BFS using Queue or DFS using Stack or DFS using Recursion). In each of the solutions, maintain two flags to check whether x is found and y is found or not. 2. In BFS using Queue, check whether both x and y are children of the same parent, als...
1de368236323f5bd5d07787fcef546df9340db06
francescotamburi/numericalODE
/test.py
448
3.578125
4
import sys import math if __name__ == "__main__": if sys.argv[1] == "help" or sys.argv[1] == "h": print('"f(x)", x0, iterations, step-size') else: dydx = sys.argv[1] dydx = "dydx = lambda x: " + dydx exec(dydx) x = float(sys.argv[2]) iterations = int(sys.argv[3]) step = sys.argv[4] prec ...
b2717a54ed348814d5ea422bc5a060ddcade622f
Kuralamudhu/python13
/python13.py
84
3.65625
4
b=int(input()) def hello(a,b): for i in range(0,b): print(a) hello("Hello",b)
2b309efa14c81a1cc50de67dcbc3a2a222a8d5a4
ghacc11/snakeai
/lib/flood_fill.py
632
3.5
4
def count_room(theMap, start_cell): theMap_list = [list(row) for row in theMap] x = start_cell[0] y = start_cell[1] count = 0 theStack = [(x, y)] while len(theStack) > 0: x, y = theStack.pop() if not 0 <= x < len(theMap_list) or not 0 <= y < len(theMap_list[0]): conti...
78cc32c777d2be27d9a280fd1b8478b02d2d78d2
thakopian/100-DAYS-OF-PYTHON-PROJECT
/BEGIN/DAY_03/005.2-pizza-order-nested-conditional.py
1,149
4.25
4
# 🚨 Don't change the code below 👇 print("Welcome to Python Pizza Deliveries!") size = input("What size pizza do you want? S, M, or L ") add_pepperoni = input("Do you want pepperoni? Y or N ") extra_cheese = input("Do you want extra cheese? Y or N ") # 🚨 Don't change the code above 👆 # Write your code below this li...
70c1be0fa061a29d265589d2fc8390769d219330
thakopian/100-DAYS-OF-PYTHON-PROJECT
/BEGIN/DAY_03/001.flow-if-else-conditional.py
277
4.28125
4
print("Can you the rollercoaster!?") height = int(input("What is your height in cm? ")) ''' #pseudo code if condition: do this else: do this ''' if height >= 125: print("Get on board and ridet he rollercoaster!!!") else: print("sorry not good enough kid!")
b81038bcea2aa8ea6741cecb21d87745cf9e70d1
thakopian/100-DAYS-OF-PYTHON-PROJECT
/BEGIN/DAY_04/03.1-list-index.py
458
4.0625
4
# create separate lists of values fruits = fruits = ["Strawberries", "Nectarines", "Apples", "Grapes", "Peaches", "Cherries", "Pears"] vegetables = ["Spinach", "Kale", "Tomatoes", "Celery", "Potatoes"] # set both lists to one value dirty_dozen = [fruits, vegetables] # print from the value an index...
a8d94cc1c75e67f5f965b11f2ae74973f4147c6a
thakopian/100-DAYS-OF-PYTHON-PROJECT
/BEGIN/DAY_04/04.1-day-4-2-exercise-solution.py
1,817
4.3125
4
# https://repl.it/@thakopian/day-4-2-exercise#main.py # write a program which will select a random name from a list of names # name selected will pay for everyone's bill # cannot use choice() function # inputs for the names - Angela, Ben, Jenny, Michael, Chloe # import modules import random # set varialbles for in...
3c77f361ce4c9e5622fce0236a73fff1cfedd73b
thakopian/100-DAYS-OF-PYTHON-PROJECT
/BEGIN/DAY_04/03-lists.py
1,199
4.25
4
# list exercise replit https://repl.it/@thakopian/day-4-list-practice#main.py states_of_america = ["Delaware", "Pennsylvania", "New Jersey", "Georgia", "Connecticut", "Massachusetts", "Maryland", "South Carolina", "New Hampshire", "Virginia", "New York", "North Carolina", "Rhode Island", "Vermont", "Kentucky", "Tennes...
2537e102c1274d4e47dfef1410b06c264eec4917
silvaDominic/Tic-Tac-Toe
/TicTacToe.py
5,821
3.953125
4
""" ------------------- Monte Carlo Tic-Tac-Toe ------------------- How to start and stop the game: Click the 'play' button at the top left corner of CodeSkulptor to start the game. A popout window will appear with a menu. Simply click the menu to begin. To stop, exit the popout window and click the 'reset'...
39662b58ba0ae702a29888986e08623bf45c8859
Imran-Gasanov/python-algorithms
/subarray.py
573
3.53125
4
def subarraysDivByK(nums, k): """ >>> subarraysDivByK([4,5,0,-2,-3,1], 5) == 7 True ([4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3]) """ sums = [] result = 0 for i in range(len(nums)): sums.append(sum(nums[:i + 1])) for index, summ in enumerate(...
7007575d6e01edf3b2196f94bbd07a543bbac103
Imran-Gasanov/python-algorithms
/nth_prime_number.py
637
3.8125
4
def nth_prime_numbers(n): """ >>> nth_prime_numbers(1) == 2 True >>> nth_prime_numbers(6) == 13 True >>> nth_prime_numbers(10001) == 104743 True """ list_of_prime_number = [] curr = 2 count = 0 while count < n: curr_is_prime = 'yes' for elem in list_of_pri...
f34f7f6372892b3f187399d5570f1e5de0425066
zhangmin1995/demo
/main04.py
1,277
4.09375
4
#利用面向对象的继承机制定义椭圆(ellipse),正方形(square),矩形(rectangle),圆形(Circle)等类 # 设计一个函数compute-area(shapes);输入一个图形列表,输出这些图形的面积之和 class Shape(object): @property def area(self): pass class Ellipse(Shape): def __init__(self, long=0, short=0): super().__init__() self.long = long ...
71ed0dcfdfe584e915b41a7bbbc197c3609d97e6
chupin10/KodeKonnectPyClass
/rockpaperscissors.py
812
4.125
4
import random computerchoice = random.randint(0, 2) if computerchoice == 0: computerchoice = 'rock' if computerchoice == 1: computerchoice = 'paper' if computerchoice == 2: computerchoice = 'scissors' print(computerchoice) yourchoice = input('Enter rock, paper, or scissors: ') if yourchoice == computerch...
f67997192327a592dde05fcf110cb48ebd6cbddd
chupin10/KodeKonnectPyClass
/looptest.py
179
4.40625
4
print('Before loop') count = 0 while count < 3: print(count) count = count + 1 print('While loop is over') for count in range(3): print(count) print('After loop')
b2517936d6fb0065c65149ef498e718d7184a2f5
wukunze/Algorithm-python
/wkzlab/class_0/Permutation.py
1,088
3.765625
4
class Permutation(): ''' 组合排列 A n m -> ''' def __init__(self, total:int, choose: int): # eliteCount: int self.__total = total self.__choose = choose self.__choosed_list = [] ''' 0 1 2 3 4 __choosed_list : 012 013 014 023 024 034 123 124 134 234...
ae31c6cde30707ffccaf9bc0ed9eb70756f11514
xc13AK/python_sample
/week_v2.0.py
655
4.46875
4
#!/usr/bin/python3.4 #-*- coding:UTF-8 -*- import datetime #get the feature day from input year=int(input("enter the year:")) month=int(input("enter the month:")) day=int(input("enter the day:")) new=datetime.date(year,month,day) print("the day is %s-%s-%s"%(new.year,new.month,new.day)) weekday=int(new.weekday()) ...
ac47ed7bb94bb497e48579befaf876bf698ae004
RandomStudentA/cp1404_prac
/prac_01/broken_score.py
554
4.0625
4
""" CP1404/CP5632 - Practical Broken program to determine score status """ score = float(input("Enter score: ")) # When score is smaller than 0 or greater than 100 it prompts you an error if score < 0 or score > 100: print("Invalid score") else: # When score is 90 or greater it will print "Excellent" if sc...
aa76b47446b755e24ecf51d3fcdb84df3d5862df
RandomStudentA/cp1404_prac
/prac_08/unreliable_car_test.py
385
3.640625
4
from prac_08.unreliable_car import UnreliableCar unreliable_car = UnreliableCar("Old Faithful", 100, 10) reliable_car = UnreliableCar("Modern Machine", 100, 90) for i in range(1, 10): print("{} drove {}km".format(unreliable_car.name, unreliable_car.drive(i))) print("{} drove {}km".format(reliable_car.name, re...
586b29249cd0af8bad4d2622fca3846faa5626d1
RandomStudentA/cp1404_prac
/prac_05/hex_colours.py
446
4.34375
4
COLOR_TO_NAME = {"AliceBlue": "#f0f8ff", "AntiqueWhite": "#faebd7", "aquamarine1": "#7fffd4", "azure1": "#f0ffff", "beige": "#f5f5dc", "bisque1": " #ffe4c4", "black": "#000000"} color_name = input("Enter color name: ") while color_name != "": if color_name in COLOR_TO_NAME: print(color_nam...
3b105b43f202b9ca5f35fe8a65a3e5ce7ca4815c
RandomStudentA/cp1404_prac
/prac_04/lists_warmup.py
984
4.34375
4
numbers = [3, 1, 4, 1, 5, 9, 2] # What I thought it would print: 3 # What it printed: 3 print(numbers[0]) # What I thought it would print: 2 # What it printed: 2 print(numbers[-1]) # What I thought it would print: 1 # What it printed: 1 print(numbers[3]) # What I thought it would print: 2 # What it printed: [3, 1, ...
914d46811bf18373326554fba4d2e50b546d666d
j0shward/Euler-Project
/Problem 4.py
394
3.953125
4
import numpy as np import pandas as pd #problem 4 #A palindromic number reads the same both ways. #The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. #Find the largest palindrome made from the product of two 3-digit numbers. z = [] for i in range(1,1000): for j in range(1,1000)...
1e8beaa6353b5111f8bf8917bd88e6bf7dd01ef9
j0shward/Euler-Project
/Problem 17.py
2,079
3.640625
4
# Euler Project - Problem 17 # If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. # If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? # Do not count spaces or hyp...
6d21fe0aca960abcca8a5db228ffd4cc0431b453
Glistening1/FRHS-Python-Programming-Assignments
/PRG9/Num A.py
229
3.875
4
numlist = [] for i in range(1,6): numlist.append(int(input("Enter in a number: "))) numlist.sort(reverse=True) print("") for j in numlist: print("(%s)".center(40) % j) print("") input("Press enter to close")
997d8fe177a2458adeb6d55727f088833488c40c
akhileshsantosh/TrafficFine
/src/PoliceNode.py
8,008
3.59375
4
from Utils import readFile, getPoliceRecord, writeToFile, writeToLogFile # PoliceTree: This is a Binary Tree of entries of the form <police ID, total fine amount> class PoliceNode: def __init__(self, policeId, fineAmt,bonusThreshold): self.policeId = policeId self.fineAmt = fineAmt self.le...
c67eee77631f9ef0d3a325eadeaab4039f3d8b1b
Systematiik/Python-The-Hard-Way
/ex15_1.py
429
4.21875
4
# reading textfiles by user input # open() opens file when in same directory # read() reads file from sys import argv # takes argument and puts under variable txt and function open, opens filename filename = input("Give me a text file to read (.txt): ") txt = open(filename) print(f"Here's your file {filenam...
ad8927d675907b661391b785026adaae2f33d3bd
Systematiik/Python-The-Hard-Way
/ex15.py
702
4.15625
4
#reading textfiles by passing args and user input #open() opens file when in same directory #read() reads file from sys import argv script, filename = argv #takes argument and puts under variable txt and function open, opens filename txt = open(filename) print(f"Here's your file {filename}: ") print(txt....
ea77221764e592bae48f42e9a6b5d512744f505c
Systematiik/Python-The-Hard-Way
/ex29.py
654
4.1875
4
people = 20 cats = 30 dogs = 15 #20 < 30 #print if people < cats: print("Too many cats! The world is doomed!") #20 !> 30 #no print if people > cats: print("Not many cats! The world is saved!") #20 !< 15 #no print if people < dogs: print("The world is drooled on!") #20 > 15 #print i...
1d48cbd702fd755552d129e6ddbc38c1812a7495
ITguyRy/Python3_Programs
/finished/reverseWords.py
337
3.90625
4
def sentence(): user_input = str(input("Provide a sentence to reverse: ").capitalize()) return user_input def reverse(user_input): user = user_input.split() user2 = user[::-1] print(', '.join(user2).capitalize()) def main(): user_input = sentence() reverse(user_input) return ...
6b8fc6ea7af6576ee3f92ba5a312cf4709a27d77
ITguyRy/Python3_Programs
/finished/list_remove_dupes.py
457
3.96875
4
def dupeList(): a = [] MAX_LIST = int(input("How long do you want your list to be? ")) count = 0 while MAX_LIST > count: num = MAX_LIST - count count+= 1 num_input = int(input("Provide {} numbers for the list(add dupes): ".format(num))) a.append(num_input) ...
0d9492bd4f60643e0e96c86fdb385385c971ad28
ITguyRy/Python3_Programs
/fileOverlap/fileOverlap23.py
850
3.671875
4
def list_one(): with open('happynumbers.txt','r') as happy: happylist = [] output = happy.read().split('\n') happylist.append(output) for i in happylist: happylists = list(map(int,i)) return happylists def list_two(): with open('primenumbers.txt','r') as pr...
851d341f3c111b4deb0dd10d10c325fe91e22ef2
ITguyRy/Python3_Programs
/finished/cowAndbulls.py
1,435
3.859375
4
import random def user_guess(): while True: try: guess = int(input("Guess the four digit number: " )) if guess < 9999 and guess > 999: guess = list(str(guess)) return guess break else: print("Guess 4 d...
5c309301d456d8fabc22fa0ee9bb2a2325dc59ae
Derek132435/Code-Examples
/Question_Answer_python/source/answer.py
6,829
3.734375
4
""" Derek Edwards Source code for job stories """ import datetime import getpass import socket import random def get_date_and_time(): """ Return current date and time in a string. :return: current date and time """ now = datetime.datetime.now() return "Current date and time: " + now.strftime("...
1744e5b999103af8dadaf7edc1a5a134e60a0e85
avataylor11/CS104-02
/Python Guessing Game.py
976
3.84375
4
import random theComputerNumber = (random.randint(1,1000000)) gameOver = False numberOfGuesses = 0 lowGuessRange = 0 highGuessRange = 1000000 guess = int (input ("Enter a guess: ")) #This is a game loop while gameOver != True: numberOfGuesses + 1 if guess < theComputerNumber: print ("guess is to...
1f7339d4e3fa7e1121187a43b829f73ae17a356c
andyhu4023/EulerProject
/002.py
545
3.828125
4
''' Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. ''' ...
b571d027eb58929ac37a6f457a5da8ecd251af3a
Varunram/AlgoStuff
/python/2dpeakfinder.py
1,548
3.53125
4
# BUG: arr1 view top to bottom. tilt head to udnerstand def find_max(arr1): max1 = max(arr1) return max1, arr1.index(max1) def peakfinder(arr, start, end): print arr if end - start <= 1: return max(arr) mid = (start + end) / 2 max1, index = find_max(arr[mid]) if index - 1 > 0: ...
f47067e8862899605b4ff514501fd45f953c517e
Varunram/AlgoStuff
/spoj/scraper.py
733
3.734375
4
def find(i): if parent[i]!=i: parent[i] = find(parent[i]) return parent[i] def union(i,j): while(parent[i]!=i): i = parent[i] while(parent[j]!=j): j = parent[j] if(rank[i]<rank[j]): parent[i] = j else: parent[j] = i if rank[i] == rank[j]: ...
ac735e2e6678f8406a97c2952126379806774bcf
Varunram/AlgoStuff
/dp/abbreviation.py
553
3.734375
4
def comp(arr, g): i =0 while arr and g: if str(arr[0]).upper() == g[0]: g = g[1:] arr = arr[1:] elif ord(arr[i]) >97: arr = arr[1:] else: return False if g: return False else: for i in range(len(arr)): if...
e9fa693b041e90f78c34d47edb4b147a72daeaac
djfkahn/MemberHubDirectoryTools
/hub_map_tools.py
5,770
4.09375
4
#!/usr/bin/env python """This program inputs the map of elementary school teachers to hub names. It assumes the presence of a file called 'hub_map.csv' in the directory from which the program is executed. """ import csv # import os def ConvertHubStringListToIDList(hub_name_list, map_d): """hub_map_tools.ConvertHub...
811a46823d4473d3edca3d0ef7aeda7655d4512c
djfkahn/MemberHubDirectoryTools
/actions.py
12,840
3.671875
4
"""Defines the main menu module for a program that inputs a MemberHub directory dump, a school roster, and a hub map to perform analyses on the MemberHub directory. """ import roster_tools import hub_map_tools import family # import person import roster def FindMissingEmail(arg_list): """menu.FindMissingEmail ...
20cfcd5b474da4b8ad30c2972fc7cdff0294dc80
masci/playground
/cstutoring/002.py
182
4.0625
4
"""" As an example, the sum of the digits of 2 to the 10th power is: 2^10 = 1024 => 1+0+2+4 => 7 What is the sum of the digits of 2^50? """ print sum(int(x) for x in str(2**50))
2f73dc172ad2614d81a3ead9deff5a2ea8bfb944
masci/playground
/cstutoring/040.py
1,302
3.90625
4
""" By the famous binomial theorem, we can develop Pascal's Triangle. Here is the first 5 rows of the famous triangle: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 ...... A few things to observe; the first and last numbers of each row is 1. To calculate the other numbers, it is simply the sum of the a...
b970828b8afbaccb7f88a38961f76498c714ab9d
masci/playground
/cstutoring/050.py
479
3.84375
4
""" In honor of our 50th problem, what is the sum of the first 50 terms in the sequence given below? 50 100 5000 100 150 ...... Note that you are seeing the first 5 terms. +50*50/50+50... """ def fiftyseq(limit): i=50 count=0 yield i while count < limit: if count%3 == 0: i+=50 ...
2d6fbe5aae4566ffe14ffcc26f95fe2ef6f6d1cb
masci/playground
/cstutoring/012.py
314
3.796875
4
""" Given the following functions: f(x) = 50x^3 - 46x^2 + 25x - 14 g(x) = 49x^3 + 45x^2 - 20x^3 + 195x - 4 What are the first 5 digits of f(105) * g(105)? """ def f(x): return 50*(x**3) - 46*(x**2) + 25*x -14 def g(x): return 49*(x**3) + 45*(x**2) - 20*(x**3) +195*x - 4 print str(f(105) * g(105))[:5]
9c7e75c5b7453bb054870f5caa61063747ca5a3a
masci/playground
/cstutoring/004.py
784
4
4
""" Given the following information about a US telephone touchtone keypad: 1: (NONE) 2: A,B,C 3: D,E,F 4: G,H,I 5: J,K,L 6: M,N,O 7: P,R,S 8: T,U,V 9: W,X,Y calculate the product of each characters value. As an example, say the user enters: "Practice", the product would be: 7 * 7 * 2 * 2 * 8 * 4 * ...
ee1ac59c388681ec8d70c4ebae1da17b72743ee4
masci/playground
/cstutoring/031.py
278
3.796875
4
""" Given the first few factorials below: 1! = 1 2! = 2 x 1 = 2 3! = 3 x 2 x 1 = 6 4! = 4 x 3 x 2 x 1 = 24 etc... How many zeros appear in total in 100!? """ def fact(n): ret = 1 while n: ret *= n n -= 1 return ret print str(fact(100)).count('0')
0564cebd0dc15ba1065fc1788c803fda21675c3e
masci/playground
/cstutoring/022.py
745
3.578125
4
""" In math, a midpoint is a point lying between two (x, y) coordinates on a graph. As an example, say we have the points: (2, 5) (4, 10) The midpoint is found by adding the two x coordinates, the two y coordinates and dividing by 2. The result is another (x, y) pair: ((2+4)/2 , (5+10)/2) The answer is: (3, 7.5) ...
a5a8b8022dbe7aea6f32b41c7753c795241a4c75
masci/playground
/cstutoring/054.py
1,143
3.953125
4
""" A simple exponent may be 210 which evaluates to 1024. It is an easy one to find by any standards and it is easy to see that the sum of the digits is 7. However, something like the expression 74719 is much more difficult to find and is out of range for most calculators. It evaluates to the 55 digits answer below...
11b85c24adef83dc68a657b524ad16faa85ff267
santiagbv/AlgorithmicToolbox
/Week1-Prgramming-challenges/a_plus_b.py
118
3.84375
4
#Sum of two digits #Compute the sum of two single digit numbers. a, b = map(int, input().split(" ")) print(str(a+b))
dcceaf5065975d7bda400e95f207dd15eab8257b
georgeszhao/LC-practice1
/45. Jump Game II.py
876
3.546875
4
class Solution(object): def jump(self, nums): """ :type nums: List[int] :rtype: int """ ans, end, max_pos = 0, 0, 0 for index, value in enumerate(nums[:-1]): max_pos = max(max_pos, index + value) if index == end: end =...
bbcd8ebe2a0a04fc1eeb104f6a2f34965c84ef91
georgeszhao/LC-practice1
/46. Permutations.py
986
3.578125
4
class Solution: def permute(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ self.ans = [] self.dfs(nums, []) return self.ans def dfs(self, nums, path): if not nums: self.ans.append(path) for ...
f571434e741440cad41bb9273721a5bf4d05a1ee
georgeszhao/LC-practice1
/7. Reverse Integer.py
532
3.609375
4
class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ if x == 0: return 0 ans, sign = 0, 1 if x > 0 else -1 x = abs(x) while x: ans = ans * 10 + x % 10 x //= 10 ans *= si...
618e8ff68d27980af951781b41ab3b2a7a2d953e
ProtikAcharjay/python-beginner
/14.Programofstarex3.py
376
3.78125
4
print("how many rows you want to take?") row=int(input()) print("Type 1 for soja type 2 for ulta") num=int(input()) bol= bool(num) if bol==True: for i in range(1,row+1) : # for j in range(1,i+1): # print("*", end=" ") # print() print("*"*int(i)) if bol==False: for...
b1b0fd328e32f91128f09b3440530fe335a065fc
ProtikAcharjay/python-beginner
/6.dictionaryexcercise.py
277
3.703125
4
print("Welcome the student database") std={"Protik":"AIUB","Niloy":"Deffodil","Amartya":"Kazi Nazrul Islam University", "Bondhon":"Barend Medical","Jion":"Admission"} print("Write down student name to know Institute") find=input() print(std[find]) print("Thank You")
662351e7dfcadc5f8f912c6cd56849d8e377ecd3
trndnd/NeuralNetworks
/ModelReworked/BackPropagation.py
5,181
3.609375
4
''' I need to learn sql for this part as we initialize the weights here and also call on it when we do initialize it the weight array should look something like this [[[1,2],[1,2],[1,2]],[[1,2,3],[1,2,3],[1,2,3],[1,2,3]]] The Arrays inside of the array are the weights [[1,2],[1,2],[1,2]] Thi...
85a7405c3c806341dd7228b68d8a1514e3da4a9f
navyTensor/ToricCode
/Simulation/Lattice.py
2,122
3.53125
4
""" Lattice.py This program has a function stringBitHailtonian(L) which takes in the side legnth of a square toric lattice and outputs the Hamiltonian of the lattice in a binary string bit 2n by n matrix representation of the form [ 0 A ] [ B 0 ] where A represents the block matrix due to the vertices, B repres...
107b0bb56f9a83d4f3ef6bb8c0d218b85757c96f
tranxuanduc1501/Homework-16-7-2019
/Bài 4 ngày 16-7-2019.py
704
4.25
4
a= float(input("Input a to solve equation: ax^2+bx+c=0 ")) b= float(input("Input b to solve equation: ax^2+bx+c=0 ")) c= float(input("Input c to solve equation: ax^2+bx+c=0 ")) if a==0 and b==0 and c==0: print('This equation has infinity solution') elif a==0 and b==0 and c!=0: print('This equation has no ...
0fcef73ca0d185913699931571bf59abb7bcc813
ArthurAkopyan/Miscellaneous
/Mathlab Dyncamical Systems Code Python/reducere.py
5,815
3.890625
4
import sys import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D #import matplotlib.pyplot as plt #Starter Stuff print 'Put the matrix in reduced row echelon form(\'rref\') or graph a dynamical system(\'dyn\')?' SystemType = input() def swap(a,b): increment = int(0) temp =...
4cbe6b226a254873187563c39f987d7d62f871f6
sansiddhjain/ML-assgn-3
/Q2.py
8,372
3.96875
4
from __future__ import division import numpy as np import math import matplotlib.pyplot as plt import timeit from visualization import plot_decision_boundary #-------------GENERAL NEURAL NETWORK IMPLEMENTATION--------------- #Functions for the same def sigmoid(z): return (1/(1+np.exp(-z))) def grad_sigmoid(z): r...
eb701c2f4a5c53937673fe2efbcf64355212d9dd
Aniket2124/Python-Insight
/fibonacci_no.py
1,683
4.0625
4
def fun_fibonacci_series(fibonacci_num_limit): if fibonacci_num_limit < 0: print("Incorrect no") elif fibonacci_num_limit == 0: print(0) elif fibonacci_num_limit == 1: print("0,1") else: fibonacci_series_str = "0, 1" fibonacci_num = 0 fibonacci_num_last =...
9a4e78a39688db864ee8004bc9195a2cd49d9c81
Aniket2124/Python-Insight
/tic_tac_toe_game.py
1,221
3.65625
4
# Tic Tac Toe Game def drawfield(field): for row in range(5): # 0 1 2 3 4 if row % 2 == 0: # print lines practicalRow = int(row / 2) for column in range(5): if column % 2 == 0: # 0 2 4 practicalColumn = int(column / 2) # 0 1 2 ...
5f7f81fad1524581433b57586027ddde1a57285a
lootic/StringComparison
/comparison_set.py
1,532
3.84375
4
class ComparisonSet: ''' Allows you to quickly compare one sequence to many others. Effectively making comparison run in O(m) time instead of O(n), where m is the length of the sequence you are comparing with the set and n is the number of sequences you compare it with. ''' def __init__(sel...
bcb1218614f57973e93446b4d5a3917fc45159f6
jose-brenis-lanegra/Brenis.Lanegra.T07
/range_nro02.py
270
3.921875
4
#hallar la suma de las areas de un circulo que su radio comprende de 1 a 8 import os pi=float(os.sys.argv[1]) area=0 #iterar el radio for radio in range(1,9): print(radio) area=area+pi*(radio**2) #fin_iterar print("la suma de las areas del circulo es:", area)
2e97b8c744507acc0fad36f485ff6df6b41ca8c7
jose-brenis-lanegra/Brenis.Lanegra.T07
/para_nro02.py
273
3.921875
4
#hallar la suma de las areas de un circulo que su radio comprende de 1 a 8 import os pi=float(os.sys.argv[1]) radio=1 #iterar el radio while (radio<9): print(radio) radio+=1 area=pi*(radio**2) #fin_iterar print("la suma de las areas de un circulo es:", area)
958c819df9860aafc7e0c5bc2ab27706b72e807f
MilanaKazaryan/algortihms
/mergesort.py
1,448
3.765625
4
def swap(lst, i, j): n = len(lst) assert(i >= 0 and i < n) assert(j >= 0 and j < n) (lst[i], lst[j]) = (lst[j], lst[i]) return def copy_back(output_lst, lst, left, right): assert(len(output_lst) == right - left + 1) for i in range(left, right+1): lst[i] = output_lst[i - left] r...
949ccfb0964d8365e02f0ba62a33ca17c8601463
aceDwill/PAT
/pat1042.py
857
3.5625
4
""" 思路:用两个数组,一个数组存储初始牌序,另一个存储洗牌一次后的牌序,然后迭代 """ K = int(input()) # 洗牌次数 order = [int(x) for x in input().split()] # 洗牌顺序 cards = [x for x in range(1, 55)] # 初始牌序 cards_result = [0] * 54 # 最后牌序 cards_color = ["S", "H", "C", "D", "J"] # 牌的花色 for i in range(K): for j in range(54): cards_result[orde...
9a6361186c4191ecba4c140e2af42f0860d260ff
aceDwill/PAT
/pat1070.py
872
3.796875
4
""" 思路:按月饼单价从高到低依次卖月饼,数量不够市场数量的卖下一种,直到满足市场数量 """ class MoonCake: def __init__(self, amount, price, unit_price): self.amount = amount self.price = price self.unit_price = unit_price # 月饼单价 my_input = input().split() N = int(my_input[0]) D = float(my_input[1]) amounts = [float(x) f...
4b453d701c8ab2977e1a3ae6c0fa4e783cd93c56
aceDwill/PAT
/pat1038.py
486
3.90625
4
""" solution: 1.repeat every string until the length is 8 2.save original string and repeated string in a dic 3.sort the dic according to its value 4.join the strings of keys as the final result """ segments = input().split()[1:] segments_dic = {} for s in ...
957599a053a0ce2565fe4058bb5f0953c1954901
caiizilaz/python-tut
/if_statement.py
291
4
4
# age = int(input('Enter you age : ')) # if age < 10: # print('young') # elif age < 40: # print('the fire') # else: # print('old') meaty = input('Do you eat meat? (y/n) : ') if meaty == 'y': print('here is the meaty menu...') else: print('here is the veggie menu...')
8b81b33f35fe6d5f4d72029f38a7675e145eb56b
mszsorondo/Pr-cticas-y-programas-viejos
/primeras_funciones.py
396
3.671875
4
#def mensaje(): #print ("Estamos aprendiendo Python") #print ("Estamos aprendiendo instrucciones básicas") #print ("Poco a poco iremos avanzando") #mensaje() #mensaje() #mensaje() #def suma(num1, num2): #print (num1+num2) #suma(5,7) #suma(9,8) #suma(11,10) #def suma (num1,num2): # r...
0526e460066ef5be4763d3ae388f6f6e95c34821
mszsorondo/Pr-cticas-y-programas-viejos
/Ejerciciospythonvideo17.py
572
4.03125
4
#A... #numinicial=int(input("Introduce el número inicial: ")) #numsiguiente=int(input("Introduce un número mayor que el anterior: ")) #while numinicial<numsiguiente: # numinicial=numsiguiente # numsiguiente=int(input("Introduce un número mayor que el anterior: ")) #print ("El programa ha terminado") ...
0a0bc6766054e85c22dffec461f78fb5b3c797a8
mszsorondo/Pr-cticas-y-programas-viejos
/POOPráctica1.py
1,681
3.9375
4
class personaje(): def __init__(self): self.__vida=400 self.__mana=1500 self.__energía=1000 self.velocidad=0 self.nombre=input("Introduce el nombre del personaje: ") self.velocidad=int(input("Introduce la velocidad en que camina el personaje: ")) def caminar(self): if self.v...
ca1dc219ac692e632eeae09ddd2f03410d7c2014
hanwool26/this_is_code_test
/python_basic_for_codetest.py
1,953
3.859375
4
a = [3,5,4,2,1] print(a) # slicing a = [1,2,3,4,5,6,7] print(a[1:3]) # List comprehension array = [i for i in range(10) if i % 2 == 0] print(array) # 2차원 리스트 초기화 n = 4 m = 3 array = [[0] * m for _ in range(n)] # 내부적으로 parameter를 쓰지 않을 때 _ 를 씀 print(array) # 자주쓰는 method # append() / sort() / reverse() / insert() / ...
aaf37718720536db7b09ab2d72efeb95a5571c9d
kkudumu/Python
/Car.py
836
3.8125
4
class Car(object): def __init__(self, price, speed, fuel, mileage): self.price = price self.speed = speed self.fuel = fuel self.mileage = mileage self.tax self.tax() self.display_all() def tax(self): if self.price >= 10000: self.tax = .15 else: sel...
b97ded9481ff3b1607a8269d6a43c8ee36398637
kkudumu/Python
/Fun_With_Functions.py
337
3.953125
4
def odd_even(): for i in range(2001): if i % 2 == 0: print "Number is {}. This is an even number".format(i) else: print "Number is {}. This is an odd number".format(i) odd_even() a = [2,4,10,16] def multiply(a): for i in xrange(len(a)): print a[i]*5 pr...
978c5b7d928003ea45686ad3b9c0b74c0da5774d
R-ISWARYA/python
/display even number15.py
82
3.765625
4
s=int(input("s=")) e=int(input("e=")) for x in range(s+1,e): if(x%2==0): print(x)