blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
2d10bd979abf18fb3a0a3225b73b9b04a10ce67f
dinoelT/CNN_numpy
/SoftmaxLayer.py
4,035
3.796875
4
# -*- coding: utf-8 -*- """ Implementation of Softmax layer """ import numpy as np class Softmax: def forward(self, inputArray): ''' This function calculates the exponential of all inputs and the sum of the exponentials. Finally, it returns the ratio of the exponential ...
a2714878f4318d08e168e21f9a47da18fc909aee
NagarajSMurthy/Data-Structures
/queues.py
943
3.96875
4
class Queue(): def __init__(self): self.queue = [] def isEmpty(self): return self.queue == [] def Enq(self, item): # Enqueue operation self.queue.append(item) def Deq(self): # Dequeue operation data = self.queue[0] # 0 ...
e9d7e19a53797bf3030f95ceb6ca741d7d7c8209
mjakop/mairm
/python/mairm-client/parsers.py
521
3.828125
4
# -*- coding: utf-8 -*- def parse_string(text): output = u'' for char in text: modifiers = u'' if char == u'@': char = u'AT' elif char == u'"': char = u'DOUBLE QUOTE' elif char == u"'": char = u'QUOTE' elif char == u",": char = u'COMMA' elif char == u'.': char ...
7fc82f57b562384c5d2d3b6e36fda35f496f9233
bbarrows89/CSC110_Projects
/myFirstPythonProgram.py
334
3.796875
4
# Bryan Barrows # CSC 110 - 9830 # January 13th, 2017 # File: myFirstPythonProgram.py # A simple program illustrating chaotic behavior. def main(): print("This program illustrates a chaotic function") x = eval(input("Enter a number between 0 and 1: ")) for i in range(10): x = 3.9 * x * (1 - x) ...
d45df8bc1090aee92d3b02bb4e1d42fc93c402a0
dheerajkjha/PythonBasics_Udemy
/programmingchallenge_addition_whileloop.py
285
4.25
4
number = int(input("Please enter an Integer number.")) number_sum = 0 print("Entered number by the user is: " + str(number)) while number > 0: number_sum = number_sum + number number = number - 1 print("Sum of the numbers from the entered number and 1 is: " + str(number_sum))
94d29dc2fd7d77b742305d234fbf6c21912a97ea
dheerajkjha/PythonBasics_Udemy
/basicprograms_simpleinterestcalculator.py
510
3.90625
4
amount = float(input("Please enter the Principal Amount.")) rate = float(input("Please enter the Rate of Interest.")) time = float(input("Please enter the Time Period in Years.")) def simple_interest_cal(para_amo, para_rate, para_time): simple_interest = (para_amo * para_rate * para_time) / 100 print("The Sim...
e96f81fc4967ca2dbb9993097f2653632b08a613
dheerajkjha/PythonBasics_Udemy
/programmingchallenge_numberofcharacters_forloop.py
258
4.34375
4
user_string = input("Please enter a String.") number_of_characters = 0 for letter in user_string: number_of_characters = number_of_characters + 1 print(user_string) print("The number of characters in the input string is: " + str(number_of_characters))
3d4b75966d8a585365e8297c3d2dcce6e7da1f16
reedless/dailyinterviewpro_answers
/2019_08/daily_question_20190814.py
703
3.921875
4
''' Given an undirected graph, determine if a cycle exists in the graph. Can you solve this in linear time, linear space? ''' def find_cycle_helper(graph, reached): if (graph == {}): return False result = False for key in graph.keys(): if (key in reached): return True...
5e865b5a2ac4f087c4fe118e0423ef05908a4a09
reedless/dailyinterviewpro_answers
/2019_08/daily_question_20190827.py
528
4.5
4
''' You are given an array of integers. Return the largest product that can be made by multiplying any 3 integers in the array. Example: [-4, -4, 2, 8] should return 128 as the largest product can be made by multiplying -4 * -4 * 8 = 128. ''' def maximum_product_of_three(lst): lst.sort() cand1 =...
240a6ee8ff27fb5e1958f60ec39e3f4cf2f0b9da
reedless/dailyinterviewpro_answers
/2019_08/daily_question_20190808.py
966
3.84375
4
''' Implement a class for a stack that supports all the regular functions (push, pop), and an additional function of max() which returns the maximum element in the stack (return None if the stack is empty). Each method should run in constant time. ''' class MaxStack: def __init__(self): self.stack ...
5e9bb62185611666f43897fd2033bae28d91ee18
reedless/dailyinterviewpro_answers
/2019_08/daily_question_20190830.py
806
4.21875
4
''' Implement a queue class using two stacks. A queue is a data structure that supports the FIFO protocol (First in = first out). Your class should support the enqueue and dequeue methods like a standard queue. ''' class Queue: def __init__(self): self.head = [] self.stack = [] def ...
f1d328556b13e5d99c75d43cd750585184d9d9fa
deltahedge1/decorators
/decorators2.py
1,008
4.28125
4
import functools #decorator with no arguments def my_decorator(func): @functools.wraps(func) def function_that_runs_func(*args, **kwargs): #need to add args and kwargs print("in the decorator") func(*args, **kwargs) #this is the original function, dont forget to add args and kwargs pri...
0ac3a65fea58acea5bc8ae4b1bbf9a4fb45b9f87
Hilamatu/cse210-student-nim
/nim/game/board.py
1,548
4.25
4
import random class Board: """A board is defined as a designated playing surface. The responsibility of Board is to keep track of the pieces in play. Stereotype: Information Holder Attributes: """ def __init__(self): self._piles_list = [] self._prepare() ...
7cfaddbb9b210cc65003edbee249e6497274bc22
AyhamZaid/Python
/project3.py
4,138
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 7 18:18:24 2019 @author: Ayham """ import sqlite3 from tkinter import * from tkinter import scrolledtext from time import strftime # ============================================================================= # root = Tk() root.title('Project3') ...
acfa0ceb9467b435ecfa2172585f5bbb135e4e80
ckl95/Fluitschema
/to_html.py
6,731
3.609375
4
""" Converts excel table to html table. Excel table should have a particular order: Date, Referee 1, Referee 2, Table 1, Table 2, Table 3, Court manager, Time, Home team, Away team """ import pandas as pd import datetime import numpy as np def to_html_file_writer(df, f): """ Writes the html file out of t...
04ffcddcd2381d78175037628a5af187eedce9d5
fjucs/1082-numerical
/hw1/bisection.py
483
3.5
4
from utils import print_result def bisection(eq, a, b, eps=10e-10): solve = lambda x: eq.s(x) cnt = 1 print('Bisection method: {}'.format(eq.get_name())) if solve(a) * solve(b) > 0: raise RuntimeError('Cannot solve in bisection method') while abs(b - a) >= eps: c = (a + b) / 2 ...
8ec6a15c8700ef338ae3f9977390bae81abb9eb3
fjucs/1082-numerical
/hw1/func.py
1,982
3.71875
4
from math import e, sin, cos, log class Equation: def __init__(self): self.term = [] # Solve def s(self, x): raise NotImplementedError # Solve in derivative def sd(self, x): raise NotImplementedError # Solve in fixed point method def fp(self, x): raise NotImp...
2304142645c7b447340b160e21e79384e67a4942
kunalagg04/Machine-Learning
/01 Linear Regression/lr.py
1,401
3.625
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 31 02:42:19 2019 @author: Kunal Aggarwal """ import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.model_selection import train_test_split dataset = pd.read_csv('Salary_Data.csv') X = dataset.iloc[:,:-1].values Y = dataset.iloc[:,-1].value...
4fef8e1e4342b6d6dc1a3eb72251d71c03f47ce1
linzechao/python
/demo/computed.py
1,195
3.828125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 条件判断 age = input('your age is:') # 转换类型 age = int(age) if age >= 18: print('adult') elif age >= 6: print('teenager') else: print('kid') # 循环 # for in names = ['Michael', 'Bob', 'Tracy'] for name in names: print(name) # 0~3 print(list(range(4))) # wh...
a5ddf29bba8915a2b2eb33354c54ab79fff46541
ayindriladutta/python_practice
/email_slice.py
348
3.96875
4
#get user email address email = input("what is your email address? ").strip() #slice out user name user = email[:email.index("@")] #slice domain name domain = email[email.index("@") + 1:] #format message string = '''your username is "{}" and your domain name is "{}"''' output = string.format(user,domain) #display o...
5d6bac38189e8ccebbdf9fc3f7b1cb363a57079d
ayindriladutta/python_practice
/cinema_booking.py
721
3.984375
4
flims ={ "Sanju":[20,5], "Padmabati":[18,7], "Antman":[3,6], "Tarzan":[10,5] } while True: choice= input("which movie u want to watch?").strip().title() if choice in flims: #pass age = int(input("how old are you?:").strip()) #check user age if age >...
686e53872c553c6dedc03dac6cf19806cc10b19e
NenadPantelic/Cracking-the-coding-Interview
/LinkedList/Partition.py
1,985
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Mar 3 16:45:16 2020 @author: nenad """ """ Partition: Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x. If x is contained within the list, the values of x only nee...
2eff83a38959b26cc87073c2b9352869194149b7
NenadPantelic/Cracking-the-coding-Interview
/Arrays and Strings/1.3.URLify.py
893
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Feb 29 19:40:20 2020 @author: nenad """ #1.3. ''' URLify: Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end to hold the additional characters, and that you are given the "true" ...
581cf34e9289cbdd3839512ad2c3c570b98f307f
KidusAM/SAM
/sam-back/db_utils.py
2,309
3.5
4
""" Group of functions for handling the communication with the database """ import sqlite3 DB = "db/data.db" def conn_db(func): def tmp(*args, **kwargs): conn = sqlite3.connect(DB) cursor = conn.cursor() func(cursor, *args, **kwargs) conn.commit() conn.close() return tm...
94a7a2c8ae1bdfaee064537067dd5d84ecc7bd13
Albert-Richards/Python
/QA_community/challenges/factorial.py
174
4.03125
4
number = input() def factorial(n): if n == 0: return 1 fact = 1 for i in range(1,n+1): fact=fact*i return fact print(factorial(int(number)))
2ee4c2984301844b5bf789fb8ff7f0cb98fc76ff
Fahimeh1983/Python-MIT-course
/longest-alphabet-order.py
634
4
4
s = 'rstuwyabcdefghkl' # s is an example sort = '' guessord = 0 # all the alphabetical orders are above 90 longest = 0 # the longest one has a length of zero for i in s : if ord(i) >= guessord: sort = sort + i # if the order of the next char is more than the previous one, it will be added to our string...
3195f130821f55b37736f5e68a25f3d592fd0ee3
albert405/Python
/Count_occurance.py
134
3.9375
4
string1 = "Hello I hope you are having a nice day!".count(' ') print('count of spaces in string1 is {}'.format(string1.count(' ')))
abe418a09ace7f18412020aaab21402f580835d4
surya-de/leet-JP-Morgan-practice
/reverse_integer.py
1,154
3.5
4
class Solution: def reverse(self, x): # Initiate a max value because # the answer expects to return # 0 if the value is more than # max size of integers. MAX_VAL = 2147483647 form_rev = rev_x = 0 # If the value is a negative # integer the reverse logic # can be done for ...
3c24f4b4cef2aaec2bb4f24e2d2bf3382b791da4
JaviMiot/EstructuraDatosLinealesPy
/listBaseQueue.py
534
3.9375
4
class ListQueue: def __init__(self): self.items = [] self.size = len(self.items) def enqueue(self, data): self.items.insert(0, data) def dequeue(self): data = self.items.pop() return data def traverse(self): for item in self.items: print(i...
c0dbe1cc5afc124e1685189d681b37ac188d6cfe
JadsyHB/holbertonschool-python
/0x0B-python-inheritance/100-my_int.py
424
3.71875
4
#!/usr/bin/python3 """ My Int class """ class MyInt(int): """ rebel class """ def __init__(self, number): """ initialize """ self.number = number def __eq__(self, other): """ returns not equal """ return self.number != other def...
886195fb51ac965a88f3ad3c3d505548638cc6bd
JadsyHB/holbertonschool-python
/0x06-python-classes/102-square.py
2,010
4.59375
5
#!/usr/bin/python3 """ Module 102-square Defines Square class with private attribute, size validation and area accessible with setters and getters comparison with other squares """ class Square: """ class Square definition Args: size: size of side of square, default size is 0 Functions: ...
3190c0f45cd1b3237e0f5076159951b121d8ac32
JadsyHB/holbertonschool-python
/0x04-python-more_data_structures/9-multiply_by_2.py
241
3.96875
4
#!/usr/bin/python3 def multiply_by_2(a_dictionary): if a_dictionary is None: return None else: new_dict = {} for key, value in a_dictionary.items(): new_dict[key] = value*2 return new_dict
afe5095ef83c2d6d455d6862276563da0b7239d9
JadsyHB/holbertonschool-python
/0x11-utf8_validation/0-validate_utf8.py
606
3.734375
4
#!/usr/bin/python3 """ validate utf-8 """ def validUTF8(data): """ returns boolean """ bytes = 0 for num in data: if num < 128: bytes += 1 else: binary = format(num, '08b') if bytes == 0: for bit in binary: if ...
9788f7a5bac4d9b4f5e025c9547bcf4dd5380235
JadsyHB/holbertonschool-python
/0x07-python-test_driven_development/tests/6-max_integer_test.py
1,263
3.703125
4
#!/usr/bin/python3 """Unittest for max_integer([..]) """ import unittest max_integer = __import__('6-max_integer').max_integer class TestMaxInteger(unittest.TestCase): def test_success_ints_floats_signed_unsigned(self): self.assertEqual(max_integer([0]), 0) self.assertEqual(max_integer([1, 2, 3, 4...
55ffa8c32622c42f6d3a314018a0adaf0e1c0d18
JadsyHB/holbertonschool-python
/0x06-python-classes/1-square.py
373
4.125
4
#!/usr/bin/python3 """ Module 1-square class Square defined with private attribute size """ class Square: """ class Square Args: size: size of a side in a square """ def __init__(self, size): """ Initialization of square Attributes: size: size of a sid...
0ebcb35494fa412ff737dce8b0d67974e4352aef
koradiyakaushal/python_projects
/39_product_inventory.py
738
3.78125
4
class Product: def __init__(self, identification, price, quantity): self.identification = identification self.price = price self.quantity = quantity class Inventory: def __init__(self, products): self.products = products @property def value(self): return sum(pr...
d4a65cfb4167ad3d4b07f2be65c6734531eab1b9
koradiyakaushal/python_projects
/5_iter_prime_number.py
674
3.640625
4
import sys # print(sys.maxsize) def chk_prime(x): for i in range(2, x): if x % i == 0: return False else: return True # def want_more(y): # if y == 'y': # return True # else: # return False j = 'y' for i in range(2, sys.maxsize): # print("i",i) if j ...
d7e92c10f1b83ab5a25a6146dddfef70ec9cd620
koradiyakaushal/python_projects
/22_fast_exponentiation.py
272
3.8125
4
i1 = int(input("Enter first digit: ")) i2 = int(input("Enter second digit: ")) e = 1 print(i1**i2) # ans = 0 while i2 > 2: if i2 % 2 != 0: i2 -= 1 e *= i1 # print(e) else: i1 = i1**2 i2 = i2/2 # print(i1) print((i1**2)*(e))
606e0c44b259743290db0b7379c8af1d019a3bf4
koradiyakaushal/python_projects
/16_factorial.py
230
4.03125
4
n = int(input("enter number: ")) # using loop ans = 1 for i in range(1, n + 1): ans *= i print(ans) # using recursion def fact(n): if n == 1: return 1 else: return n * fact(n - 1) print(fact(n))
77a8561cb47757ce31df7dbcbce0ce4dff3c04c4
koradiyakaushal/python_projects
/8_change_calculater.py
257
3.890625
4
n = int(input("enter value: ")) if n >= 10: print('10 rupee: ', n//10) n = n % 10 if n >= 5: print('5 rupee: ', n//5) n = n % 5 if n >= 2: print('2 rupee : ', n//2) n = n % 2 if n >= 1: print('1 rupee: ', n//1) n = n % 1
5bb64dbd9bc7a8f6a5156396d0e58a09129eac38
singhj22/String-Slicing-HW
/String_Slicing_Homework.py
711
4.03125
4
''' Created on Oct 22, 2018 @author: Jugat Singh Python Period 5 even String Slicing HW ''' #input from user string= input("Please enter a String: ") start = int(input("Please enter the index where you would like to start slicing: ")) stop = int(input("Please enter the index where you would like to sto...
c7c01b4b9448fbfe6eb0fa1d414240dfabe19550
xudunyuan/count-automorphism
/github.py
2,821
3.953125
4
from graph import * from graph_io import * import os import copy def init_colors(graph): """ This function colors each vertex in "graph" based on the amount of neighbours. The colours are then saved in the first list inside the colors variable. The colors variable is a list of list of which each li...
4db4720f452b2db358234f9ce50735430fb6a938
Rouzip/Leetcode
/Search Insert Position.py
354
4.125
4
def searchInsert(nums, target): """ :type nums: List[int] :type target: int :rtype: int """ if target <= nums[0]: return 0 for i in range(1, len(nums)): if nums[i - 1] <= target <= nums[i]: return i return len(nu...
acabe80d8e1424e309c5350f0e853e3a921ea3fc
Rouzip/Leetcode
/Simplify Path.py
420
3.765625
4
import collections def simplifyPath(path): """ :type path: str :rtype: str """ pathList = path.split('/') result = collections.deque() for p in pathList: if p == '..': if result: result.pop() if p and p != '.': result.append(p) ret...
1f4f75fed1d1827da36633209c0cbc108289013f
TecProg-20181/03--stebezs
/hang.py
6,576
3.8125
4
import random import string import logging import sys WORDLIST_FILENAME = "palavras.txt" class WordWorld(object): def __init__(self, guesses): self.secret_word = self.load_words().lower() self.letters_guessed = [] self.guessed = guesses def is_word_guessed(self): for letter i...
4415ba37e475c1650da0d81b32f85b4a4ae7d45c
23o847519/Python-Crash-Course-2nd-edition
/chapter_02/full_name.py
492
4.125
4
first_name = "ada" last_name = "lovelace" # sử dụng f-string format để đổi các biến bên trong {} thành giá trị # f-string có từ Python 3.6 full_name = f"{first_name} {last_name}" print(full_name) # thêm "Hello!," ở phía trước print(f"Hello, {full_name.title()}!") # gom lại cho gọn message = f"Hello, {full_name.title...
7bb73b9cd6ca812395b93b17f116abd8e7033311
23o847519/Python-Crash-Course-2nd-edition
/chapter_09/tryityourself913.py
796
4.1875
4
# Import randit function from random library from random import randint # Make a class named Die class Die: def __init__(self, sides=6): # default value of 6 self.sides = sides def describe_die(self): print(f"\nYour die has: {self.sides} sides") # Write a method called roll_die() that prints # a random n...
96384a26d49430e18697d080c49f3341e7b13834
23o847519/Python-Crash-Course-2nd-edition
/chapter_08/tryityourself814.py
874
4.4375
4
# 8-14. Cars: Write a function that stores information about # a car in a dictionary. The function should always receive # a manufacturer and a model name. It should then accept an # arbitrary number of keyword arguments. Call the function # with the required information and two other name-value # pairs, such as a colo...
25799661f3266b1c0e07730d61101949f6f2dbfc
23o847519/Python-Crash-Course-2nd-edition
/chapter_11/try it yourself 11.2/city_functions.py
580
4.09375
4
# 11-2. Population: Modify your function so it requires a third # parameter, population. It should now return a single string of the # form City, Country – population xxx, such as # Santiago, Chile – population 5000000 def format_city_country(city_name, country_name, population=''): # format_name = f"{city_name.ti...
13f6752d21ba7de36c8940fb009ab8fa1957ad6c
23o847519/Python-Crash-Course-2nd-edition
/chapter_10/tryityourself1012.py
890
3.84375
4
# 10-12. Favorite Number Remembered import json filename = "favorite number.json" def read_number(): try: with open(filename, 'r') as f: number = json.load(f) except FileNotFoundError: return None else: return number def get_new_number(): while True: try: ...
c3eb60155abfab7e108fd92cbb519d7c4f5b32f5
23o847519/Python-Crash-Course-2nd-edition
/chapter_08/tryityourself89.py
589
3.96875
4
# 8-9. Messages: Make a list containing a series of short # text messages. Pass the list to a function called # show_messages(), which prints each text message. print("\nEx 8.9 Messages\n" + "-"*70) def show_messages(text_list): message_list = text_list[:] message_list.reverse() while message_list: current_message...
e0f7b4c472500360a03266df6e35031cd4534dc4
23o847519/Python-Crash-Course-2nd-edition
/chapter_07/tryityourself7.1.py
334
4.15625
4
# Ex 7.1 Rental Car # Write a program that asks the user what kind of rental car they # would like. Print a message about that car, such as # “Let me see if I can find you a Subaru.” print("\nEx 7.1") rental_car = input("What kind of rental car would you like?\n") print(f"\nLet me see if I can find you a {rental_car.t...
9cca96cb78e6ae2772c76f81ccf6a2106ee0ac99
23o847519/Python-Crash-Course-2nd-edition
/chapter_03/cars.py
604
4.28125
4
#Sorting print("\nSorting") cars = ['bmw', 'audi', 'toyota', 'subaru'] print(cars) cars.sort() print(cars) #Reverse sorting print("\nReverse sorting") cars.sort(reverse=True) print(cars) #Sort tạm thời print("\n Sorted()") cars = ['bmw', 'audi', 'toyota', 'subaru'] print("Original list:") print(cars) print("\nSorted...
44f55bae68ae6fa0fddd6628dea0c92e1f0d81fe
23o847519/Python-Crash-Course-2nd-edition
/chapter_10/tryityourself106.py
726
4.3125
4
# 10-6. Addition: One common problem when prompting for numerical input # occurs when people provide text instead of numbers. When you try to # convert the input to an int, you’ll get a ValueError. Write a program # that prompts for two numbers. Add them together and print the result. # Catch the ValueError if either i...
5e49bec1f72659b4199f281b4eba01df5b5dcd35
fumingivy/inf1340_2015_asst2
/exercise3.py
4,102
3.75
4
#!/usr/bin/env python """ Assignment 2, Exercise 3, INF1340, Fall, 2015. DBMS This module performs table operations on database tables implemented as lists of lists. """ __author__ = 'Eden Rusnell & Ming Fu' """ Assumptions: 1. that when rows are indentical they do not have spelling errors or typos 2. that all tab...
20b4eb019a5e0cf8ebd2c981d5acea6ec6cddc6e
sweekrithishetty/LeetCode-Algorithms
/Easy: Maximum Depth of Binary Tree.py
978
3.9375
4
#Given the root of a binary tree, return its maximum depth. #A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Input: root = [3,9,20,null,null,15,7] Output: 3 class Solution(object): def maxDepth(self, root): if not root: ...
7b6276a047e48360a75ccfc27fe9be9d98c55d78
e3krisztian/fzf-context-grep
/hgrep.py
1,794
3.671875
4
#!/usr/bin/env python from __future__ import print_function """ hgrep.py regexp file-name (poor man's breadcrumb context) Output matching lines with paths to root in outline hierarcy. Displaying one line for each immediate parent (less indent than current) The lines are displayed in the format right-indented-line-nu...
05a4880ee937140d51d6887cc4a34ff5d672d990
StuartDaniells/Blackjack
/BlackJack.py
10,257
3.90625
4
import random suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs') ranks = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace') values = {'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'Seven':7, 'Eight':8, 'Nine':9, 'Ten':10, 'Jack':10, 'Queen':10, 'King'...
935ad6820b4d63a6ed3684c5a18019e244d30a49
radishmouse/06-2017-cohort-python
/objects-classes-example/phonebook/contact.py
313
3.515625
4
class Contact(object): def __init__(self, first_name, last_name, email, phone): self.first = first_name self.last = last_name self.email = email self.phone = phone def show(self): return "%s, %s - %s (%s)" % (self.last, self.first, self.email, self.phone)
ceeb79b03e897d2b822fe5165803316cae5853b5
radishmouse/06-2017-cohort-python
/104/coins.py
169
3.875
4
another = 'yes' count = -1 while another == 'yes': count = count + 1 print 'You have %d coins.' % count another = raw_input('Do you want another? ') print 'Bye'
6ba1d02a2025378d11c0cfbf8a11055e0593e3ca
radishmouse/06-2017-cohort-python
/104/n_to_m.py
629
4.375
4
n = int(raw_input("Start from: ")) m = int(raw_input("End on: ")) # Let's use a while loop. # Every while loop requires three parts: # - the while keyword # - the condition that stops the loop # - a body of code that moves closer to the "stop condition" # our loop counts up to a value. # let's declare a counter vari...
50cbb178c40d42e83aed3f936feef223eca8a865
radishmouse/06-2017-cohort-python
/dictionaries/dictionary1.py
534
4.21875
4
phonebook_dict = { 'Alice': '703-493-1834', 'Bob': '857-384-1234', 'Elizabeth': '484-584-2923' } #Print Elizabeth's phone number. print phonebook_dict['Elizabeth'] #Add a entry to the dictionary: Kareem's number is 938-489-1234. phonebook_dict['Kareem'] = '938-489-1234' #Delete Alice's phone entry. del phoneb...
a5e45fe0e767a4cdabefca870d2f29ac0ea025ee
BhushanTayade88/Core-Python
/Feb/day 21 duck typing/flywithlist.py
300
3.5625
4
class Bird: def fly(self): print("Bird fly with their wings") class Airplane: def fly(self): print("Airplane fly fuel") class Baloon: def fly(self): print("Baloon can fly in air with the help air") l=[Bird(),Airplane(),Baloon()] for i in l: i.fly()
8be24010aba075dc1e704d8d37cdebfd4a9ceaf0
BhushanTayade88/Core-Python
/Feb/day 19 const,oper/constowerloading.py
268
3.671875
4
class A: def __init__(self,a=None,b=None): if a!=None and b!=None : print(" u enter two parameter") elif a!=None: print("u enter single parameter") else: print(" no argument pass") a=A() a=A(2,3) a=A(5)
1c56bab43e885700d704f90397d3c409d9abb68f
BhushanTayade88/Core-Python
/March/day 11 decorator/task2/class deco/noofdigits.py
229
3.875
4
#no of digits num=int(input("Enter a no:")) sum1=0 totaldig = 0 while num>0: rem = num % 10 sum1 += rem num //= 10 totaldig += 1 print("Som of the total digits are :",sum1) print("Total Digits are :",totaldig)
9858f021c037399c27be321b80a5111b8825e2db
BhushanTayade88/Core-Python
/Feb/day 12/Dynamic/oddeve.py
756
4.3125
4
#1.Program to create odd-even elements list from given list. l=[] eve=[] odd=[] n=int(input("How many no u wants add in list :")) for i in range(n): a=int(input("Enter Numbers :")) l.append(a) for i in l: if i%2==0: eve.append(i) else: odd.append(i) print("----Statements----\n" \ ...
4a21f8dddf880e5ba43cf84435a8c7dd583060bc
BhushanTayade88/Core-Python
/Feb/day 12/total1.py
172
3.953125
4
#3.Program to count elements in a list without using built in function. l=[-1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,2] n=0 for i in l: n=n+1 print("total no in list :",n)
c5a4f945453bd3a0a68596c88a893122e36abafc
BhushanTayade88/Core-Python
/Feb/day 7 constructor/emp.py
359
3.65625
4
class employee: def __init__(self,empid,empname,sal,city): self.empid=empid self.empname=empname self.sal=sal self.city=city emp=employee(101,"bhushan",600000,"yavatmal") emp1=employee(102,"xyz",500000,"pune") print(emp.empid) print(emp.empname) print(emp.sal) print(emp.city) print(emp1.empid) print(emp1.empn...
0861deae63a40b023662127b37b8545851de955c
BhushanTayade88/Core-Python
/March/day 8 lambda func/task/firstupper7.py
272
3.921875
4
''' 7.Given a list, l = ['cat','dog','dow','sheep'] Make the first character of words into capital. ''' l = ['cat','dog','dow','sheep','cjc'] l2=list(map(lambda a:a.title() ,l)) print(l2) result3 = list(filter(lambda x: (x == "".join(reversed(x))), l)) print(result3)
e0984838269b85d4a21bad04df736b98a3cd758e
BhushanTayade88/Core-Python
/Feb/day 12/tup.py
322
3.921875
4
class Student: def __init__(self,rollno,name): self.rollno=rollno self.name=name l=[] n=int(input("enter no. do u want to add")) for i in range(n): s=Student(int(input("Enter rollno :")),input("Enter name :")) l.append(s) li=tuple(l) for stud in li: print(stud.rollno) print(stud.name) print(type(li)...
3c04d676e0bdfdd5c17b81c62a26985e1b034b07
BhushanTayade88/Core-Python
/March/day 5 raise/without propgtn.py
218
3.546875
4
def m1(age): print("m1---") if age<0: raise ArithmeticError("age Problem") print("m1----end") try: m1(-6) except ArithmeticError as e : print("except block",e) print("program end")
5eb7558e0294ace79dd53e50168d4c43ab13288c
BhushanTayade88/Core-Python
/March/day 10 filefand/taskfilehand/4replace.py
261
4
4
''' 4.Replace a word by another word in a file. ''' f=open("testfile.txt","r") a=f.read() #print(a) replace_word=a.replace("word","hello") f.close() f=open("testfile.txt","w") f.write(replace_word) f.close() f=open("testfile.txt","r") print(f.read()) f.close()
b081dab1bd11ed6c1e0c434e6978ed23c72dec78
BhushanTayade88/Core-Python
/Feb/day 11/table.py
104
3.703125
4
n=int(input("Enter any no :")) print("Table of Numer ",n) for i in range(1,11): print(n,"x",i,"=",n*i)
a10c31fc5c15b63e5fd895e1457282eafab1f10f
BhushanTayade88/Core-Python
/March/day 10 filefand/taskfilehand/2perticularline.py
419
4.125
4
''' 2.Program to display particular line taken by user. ''' f=open("bhushan.txt","r") ##print(f.tell()) ##print(f.readline()) ##print(f.tell()) ##print(f.readline()) ##print(f.tell()) ##print(f.readline()) ##print(f.tell()) ##print(f.readline()) b=f.readlines() print(b) a=int(input("which line no u want see :")) pri...
b93e25797317a0a165d3bd691e5665f7d937038e
BhushanTayade88/Core-Python
/Feb/day 15 oops/comprehention/first.py
308
3.78125
4
''' 1.Below are the two lists convert it into the dictionary keys = ['Ten', 'Twenty', 'Thirty'] values = [10, 20, 30] Expected output: {'Ten': 10, 'Twenty': 20, 'Thirty': 30} ''' k = ['Ten', 'Twenty', 'Thirty'] v= [10, 20, 30] d={} d=dict(zip(k,v)) print(d) d2={k[i]:v[i] for i in range(len(k))} print(d2)
b753081724b799bbac3b4b445fe034121a071671
BhushanTayade88/Core-Python
/Feb/day 15 oops/comprehention/five.py
180
4.0625
4
''' 5.Given a dictionary, swap the key-value d = {0:'a',1:'b',2:'c'} Expected output: {'a':0,'b':1,'c':2} ''' d = {0:'a',1:'b',2:'c'} d2={v:k for k,v in d.items()} print(d2)
902d8a2abab4fd46337a7c006df801cadd69771f
BhushanTayade88/Core-Python
/Feb/day 15 oops/hirarch.py
264
3.734375
4
class A: a=10 def m1(self): print("m1.......A") class B(A): def m1(self): print("m1.......B") super().m1 class C(A): def m1(self): print("m1.......C") super().m1() a=C() a.m1() b=B() b.m1() print(C.__mro__)
7774522fb7b118a54da9591bdb8454ddc823831b
BhushanTayade88/Core-Python
/Feb/day 17 abstract/multipleabtra.py
644
4.0625
4
from abc import ABC,abstractmethod class A(ABC): @abstractmethod def m1(self): pass @abstractmethod def m2(self): pass def m3(self): print("m3----A") class B(ABC): #not necesary for class B to inherit ABC class @abstractmethod def m3(self): pr...
dab9bbef0138c21e2b505e762f5a763b01bbb2c3
BhushanTayade88/Core-Python
/Feb/day 2/calculator.py
102
3.59375
4
a=10 b=20 def add(): print(a+b) def sub(): print(a-b) def mul(): print(a*b) add() sub() mul()
ff01b3080817a8469c3aee2376c6c3abc76ebe8e
BhushanTayade88/Core-Python
/Feb/day 19 const,oper/task/callstudent.py
2,432
4.15625
4
from student import * print("----Statements----\n" \ "1.Enter details--\n" \ "2.display--\n" \ "3.Exit--\n") while True: ch=int(input("Enter Your choice----:")) if ch<=2: pass if ch==1: l=[] n=int(input("How many student details u want to insert ...
5f89409e8a841c49fae215a887346ae3f4f364c4
BhushanTayade88/Core-Python
/March/day 11 decorator/task2/mulsqrdecorator.py
465
3.953125
4
def squre(func): def inner(args): x = func(args) ## y = x * x ## func(y) ## print("squre is :",x*x) return x*x return inner def multiply(func): def inner(args): x = func(args) ## y = x * 2 ## print("multiplication is :",x*2) ## f...
44fa278ca112e15ae078553fc3466f223b1e2b9a
BhushanTayade88/Core-Python
/Feb/day 7 constructor/emp2.py
787
3.953125
4
class employee: def __init__(self,empid,empname,sal,city): self.empid=empid self.empname=empname self.sal=sal self.city=city def showemp(self): print("Employee ID :",self.empid) print("Employee Name :",self.empname) print("Salary :",self.sal) print("city :",self.city) if __name...
13349b1e4cf78533840f4128fc9cd68ad82e6943
BhushanTayade88/Core-Python
/Feb/day 5 while,for/test1.py
492
3.796875
4
from cal2 import * print("----Statements----\n" \ "1.Addition--\n" \ "2.Subtraction--\n" \ "3.Multiplication--\n" \ "4.Exit--\n") while True: ch=int(input("Enter your Choice")) if ch<=3: x=int(input("Enter First no")) y=int(input("Enter Second no")) if ch==1: s=add(x,y) print("Addi...
4f1a2cbef3e2b5d3b3f6cb4978cb481722eeb8e3
BhushanTayade88/Core-Python
/Feb/day 1/calculator.py
399
3.75
4
a=30 b=20 def add(): c=a+b print(c) def sub(): c=a-b print(c) def mul(): c=a*b print(c) def div(): c=a/b print(c) def expo(): c=a**2 print(c) def mod(): c=a%b print(c) def floor(): c=a//b pr...
a14253b6695c8ebbe913a05525d001fe46ddb66c
BhushanTayade88/Core-Python
/March/day 11 decorator/task2/class deco/factorial.py
271
4.21875
4
##num=int(input("Enter no :")) ##for i in range(num,0,-1): ## fact = 1 ## if i==0: ## print("Factorial of 0 is :",'1') ## else: ## for j in range(i,0,-1): ## fact = fact * j ## ## print("Factorial of", i ,"is :",fact) ##
6b3db5752495bd7cbfed2d6f88a60dd689dba7c3
BhushanTayade88/Core-Python
/March/day 16 multhreaing with class/classmulthred.py
396
3.59375
4
from threading import Thread import time class Testing(Thread): def __init__(self,st,end): super().__init__() self.st=st self.end=end def run(self): for i in range(self.st,self.end,2): time.sleep(0.5) print(i) time.sleep(0.5) odd = Tes...
5a84bbf62487275b279b0070e4bda6d56b793437
BhushanTayade88/Core-Python
/March/day 3 Exceptionfinaly/mulexcept2.py
229
3.625
4
''' multiple except block ''' try: print("start try block") a=int(input("Enter a Value")) print(10/a) print("end try block ") except (ValueError,ZeroDivisionError)as msg: print("plz Enter valid value",msg)
fb0de79cec36b50e2e2dd8e480e6c7d21a584af3
BhushanTayade88/Core-Python
/March/day 5 raise/task/recurssioncall.py
4,845
3.875
4
from student import * class InvalidSrudDetails(Exception): def __init__(self,msg): self.msg=msg print("----Statements-----\n" \ "1.Enter Student Details--\n" \ "2.Dispaly all Student Record--\n" \ "3.Exit--\n") def rollno(rn): if rn<0: raise InvalidSrudDetails("Rollno s...
3017c84b6efaf65bcf8afc789e0c28e31bce9b7b
BhushanTayade88/Core-Python
/Feb/day 8/temp2.py
524
4
4
from emp import * print("----Statements----\n" \ "1.Enter details--\n" \ "2.display--\n" \ "3.Exit--\n") while True: ch=int(input("Enter Your choice----:")) if ch<=2: pass if ch==1: a=int(input("Enter Employee ID:")) b=input("Enter EMP Name :") c=int(input("Enter salary :")) d=input...
2b7153be02fe67b95c0df9e630b2bc62210e78c6
BhushanTayade88/Core-Python
/Feb/day 13 set/student1.py
650
3.78125
4
class Student: def __init__(self,rollno,name): self.rollno=rollno self.name=name def __str__(self): return "Student Roll no :{} and Student Name :{}".format(self.rollno,self.name) eng=set() comp=set() mech=set() n=int(input("How many student u want add for comp :")) for i in range(n): s1=Student(int(input("E...
27db6bf5041df100a0206c30c92f717585f9e247
olemb/tetris
/tetris.py
8,604
3.578125
4
#!/usr/bin/env python3 """ Tetris for Python / Tkinter Ole Martin Bjorndalen https://github.com/olemb/tetris/ http://tetris.wikia.com/wiki/Tetris_Guideline """ import random from dataclasses import dataclass, replace import tkinter shapes = { # See README.md for format. 'O': ['56a9', '6a95', 'a956', '956a']...
ff9707fbeac61cd1e9c9723756fb7eaf64d1eed8
jacobhanshaw/ProjectEuler
/euler19.py
1,111
3.953125
4
class Month: January = 0 February = 1 March = 2 April = 3 May = 4 June = 5 July = 6 August = 7 September = 8 October = 9 November = 10 December = 11 class Day: Sunday = 0 Monday = 1 Tuesday = 2 Wednesday = 3 T...
f57f45fd217d5f590b074f2bfbda2d1d532a97bb
jacobhanshaw/ProjectEuler
/euler16.py
175
3.6875
4
number = 2**1000 print "Number: ",number numberString=str(number) result=0 for i in range(0,len(numberString),1): result+=int(numberString[i]) print "Result: ",result
0679b2292870e7281e296e380b6f22feb18e240a
jacobhanshaw/ProjectEuler
/euler6.py
238
3.515625
4
number=100 power=2 def GaussianSum(n): return (n * (n+1))/2 SquareOfSums=pow(GaussianSum(number),power) SumOfSquares=0 for i in range(1,(number+1),1): SumOfSquares+=pow(i,power) print "Result: ",(SquareOfSums-SumOfSquares)
6346a58689d00732b2eef5efdd7fd744d1dc6d1d
jacobhanshaw/ProjectEuler
/euler15.py
790
3.703125
4
import time def factorial(top,limit): result=1 for i in range(top,limit,-1): result*=i return result def binomialCoefficient(n,k): return factorial(n,k)/factorial(k,1) """ 0111111 1234 136 14 15 16 """ squareSize=20 print "Array: " t0 = time.time() array2D=[[0 for x in range(squareSize+1)] ...
b5f7eea126334db914c65616dab9a1f9eb07f29e
jacobhanshaw/ProjectEuler
/euler2.py
810
3.765625
4
import timeit def method0(maxVal): result = 0 term0 = 1 term1 = 1 while term1 <= maxVal: if term1 % 2 == 0: result += term1 term1 += term0 term0 = term1 - term0 return result def method1(maxVal): a = 2 b = 8 c = 34 result = a+b w...
5e5753f299e488f8cbbb4f0a6f38746b3e3a6fbe
jacobhanshaw/ProjectEuler
/euler7.py
430
3.96875
4
goalPrime=10001 currentNum=15 currentPrime=6 def isPrime(num): if num % 2 == 0: return False i=3 maxPos=num while i < maxPos: if num % i == 0: return False else: maxPos=num/i i+=2 return True while currentPrime<goa...
6db0867c8184d63a3e0af81ad883b1b64900805c
jacobhanshaw/ProjectEuler
/euler102.py
4,016
3.53125
4
""" Define several layers of elimination: 1. Checks based on quadrants: Cannot contain the origin if: -All points are in the same quadrant -All x values or all y values have the same sign (2 in set, diff <> 2) (& one of the points is not the origin) Can contain the origin if one or more points are on the boundary:...
552b19e397af2bdd27a1e272857f5ec16daee05f
jacobhanshaw/ProjectEuler
/euler44.py
468
3.578125
4
import math def isPentagonal(x): value=math.sqrt(float(24*x+1)) return value.is_integer() and value % 6 == 5 pentagons=[] n=1 found=False while not found: current=n*(3*n-1)/2 pentagons.append(current) for i in range(len(pentagons)-2,-1,-1): diff=current-pentagons[i] aSum=current+pe...
8f585c240a5433159261a01c17fe09a092b16b9f
jacobhanshaw/ProjectEuler
/Algorithms/BetterIsPrime.py
512
3.9375
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: r=math.floor(math.sqrt(n)) # n rounded to the greatest integer r so that r*r<=n f...