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
194a7d2d1d862cfda300d7e94bc7b8398af7be5b
icydee/python-examples
/fibonacci.py
1,151
4.1875
4
#!/usr/local/bin/python3 # Python 2.6 script to calculate fibonacci number # Raises exception if invalid input is given class fib_exception(Exception): pass def fib_recursive(input): n = int(input) if n <= 0 or n != input : raise fib_exception() elif n==1 : # first in series r...
b55217fc43e05bf17591023bd7bbcfb70392a16e
JHU-PacBot/pacbot_simulation
/pac_man/graphics.py
3,893
3.5
4
from gameState import * import pygame red_hue = (255, 0, 0) pink_hue = (255, 192, 203) blue_hue = (0, 255, 255) frightened_hue = (0, 0, 255) orange_hue = (255, 165, 0) black_hue = (0, 0, 0) yellow_hue = (255, 255, 153) pac_man_hue = (204, 204, 0) unit_size = 20 def print_maze(game_display, game_state): grid = g...
27690183c2b5a25c3fcad6297d7d34786a3db944
EricMFischer/svm-political-election
/P2_1.py
8,510
3.640625
4
''' Part 2: Election Outcome Prediction 2:1: Prediction by Rich Features (classify election outcome w/ rich features) Using the same features from section 1.2, train a classifier to classify the election outcome. Report: Average accuracies on training and testing data. The chosen model parameters. Perform k-fold cross-...
b0a0213a26d2521ad246620da74a68dfa43eec57
BenjellounHamza/dimensionality_reduction
/Lab_1/Pca.py
1,055
3.5
4
from processing_data import processing_data, plot import pandas as pd from sklearn.decomposition import PCA import matplotlib.pyplot as plt import numpy as np from sklearn.preprocessing import StandardScaler from numpy.linalg import svd data, type = processing_data() data_centred = pd.DataFrame(StandardScaler().fit_tr...
bfd7c4fddd8aeea39c9bb52a3ad5df91f294efa0
ArunBaskaran/border-crossing-analysis
/src/auxfuncs.py
5,752
4.21875
4
#--------------------Definitions of classes, containers, and functions used in the program----------------# # Class whose objects are the columns required in the output file. Defined in order to make the sorting process more efficient class Entry: def __init__(self, border, date, measure, value, average): ...
a826dd67a43ac2cb6bf4afb4dfcdf82eac09805d
ifireball/python-satellite-dsl
/satellite_dsl/type_handler.py
2,343
3.609375
4
#!/usr/bin/env python """This module provides a decorator that can be used to create type handler singleton classes Type handlers are classes that can be called with a type and always return a specific instance meant to handle that type. Different classes can be registered into the same class to handle different types...
a9c3fad9f05dfb0c6235a8e95ed0cbc6fe1b98d4
kristinlin/SCARY
/data/calculations.py
5,007
3.734375
4
import sqlite3 import csv import csvToDict import dbBuilder #c is the cursor #returns a list where each index is the name of the state with that id def getStates(c): stateIDs = csvToDict.csvToDictStates('./data/states') ans = [''] * 50 for entry in stateIDs: ans[stateIDs[entry]] = entry return ...
99fe277f70a1d0c2bc0877b2f1c6fb0270b3a5f1
andyschultz/Scripts
/Python/textbooks/myflowers.py
955
4.0625
4
from swampy.TurtleWorld import * import math world = TurtleWorld() bob = Turtle() bob.delay = 0.01 def polyline(t, n, length, angle): '''Draws n line segments with the given length and angle (in degrees) between them. t is a turtle. ''' for i in range(n): fd(t, length) lt(t, angle) ...
b6cd8ec976de432264e9908fba4a3b75b7a94049
DFrankTech/csc221
/hw7/ch11/examples/coinFlip.py
441
3.984375
4
# Simulates flipping a coin 1,000 times. Without debugger import random heads = 0 for i in range(1, 1001): if random.randint(0, 1) == 1: heads = heads + 1 if i == 500: print('Halfway done!') print('Heads came up ' + str(heads) + ' times.') # The random.randint(0, 1) call ➊ will return 0 half of...
2ba08848ca096fa03b729d8389de0ca06730c66c
vaschuck/Coffee_Machine
/Problems/Half-life/task.py
213
3.828125
4
HALF_LIFE = 12 initial_quantity = int(input()) final_quantity = int(input()) half_lives = 0 while initial_quantity > final_quantity: initial_quantity //= 2 half_lives += 1 print(half_lives * HALF_LIFE)
86b19e0932f9ab11924be4e63132aca072c8d46e
vaschuck/Coffee_Machine
/Coffee Machine/On a coffee loop/stage_5.py
3,232
4
4
cash = 550 water = 400 milk = 540 beans = 120 cups = 9 def display_status(): print('The coffee machine has:') print(water, 'of water') print(milk, 'of milk') print(beans, 'of coffee beans') print(cups, 'of disposable cups') print('$', cash, ' of money', sep='') def take_money(): global c...
d23953d971597b91c681be07a1518b2fd9b6de88
vaschuck/Coffee_Machine
/Problems/Good rest on vacation/task.py
191
3.6875
4
days = int(input()) food_cost = int(input()) flight_cost = int(input()) night_cost = int(input()) total_cost = food_cost * days + night_cost * (days - 1) + flight_cost * 2 print(total_cost)
319aff1e104b857443e553774e4ed3509148bb65
vaschuck/Coffee_Machine
/Problems/A mean of n/task.py
138
3.71875
4
lines = int(input()) sum_ = 0 for _ in range(lines): number = int(input()) sum_ += number average = sum_ / lines print(average)
63a2861d05caec7cb8f9cc447258bd921eefb25e
vaschuck/Coffee_Machine
/Problems/Favor/task.py
111
3.578125
4
limit = int(input()) number = 1 sum_ = 0 while number <= limit: sum_ += number number += 1 print(sum_)
91a965e2e256e748c345e2d38bd3a1dac5abcdbe
cdjobe/WordReader
/wordreader.py
1,123
3.59375
4
import glob import string import re # contains list of words word_list = [] # dictionary containing words and word count word_count = {} # common words that might not be worth counting banned_words = ["a", "an", "and", "are", "as", "at", "be", "but", "by", "can", "for", "if", "in", "is", "it", "its", "like",...
57cee468c3ff7772b6b797e07c8bd2707c931ad4
stas-grgv/leetcode-challenges
/palindrome.py
1,380
3.78125
4
import math from decimal import Decimal # Log10(x) def number_of_digits(x: int): if x == 0: return 1 else: return (int(math.log10(x))) def checkPalindrome(x: int) -> bool: is_palindrome = False if x < 10 and x > 0: is_palindrome = True elif x < 0: is_palindrome = ...
ac094a2d8aee409b98e7cf45a833d849f977a376
allenmqcymp/mini-python-projects
/Blackjack/blackjack.py
7,380
3.921875
4
from random import shuffle import sys ''' Extensions: Use 6 decks of card instead of 1 Ace cards can act both as a 1 and a 11 ''' ''' ''' class Card(object): def __init__(self, value): self.value = value def getValue(self): return self.value def __eq__(self, other): if is...
2b4d77f0fe256fe6fa6d04096e158fb8e121aabd
abrahamanderson19972020/Coffee-Machine-Project
/functional_test.py
3,230
4.09375
4
from functional_menu import MENU, resources def choice(want): try: drink = MENU[want] return drink except: print("Enter a valid input!(espresso/latte/cappuccino)") def total_money(): print("Please insert coin...") quarter_count = int(input("How many quarters >>>")) dime_c...
1ac7a9e8d9ee10eeb8e571d3dd6e5698356a1a47
NitinSingh2020/Computational-Data-Science
/week3/fingerExc3.py
1,503
4.28125
4
def stdDevOfLengths(L): """ L: a list of strings returns: float, the standard deviation of the lengths of the strings, or NaN if L is empty. """ if len(L) == 0: return float('NaN') stdDev = 0 avgL = 0 lenList = [len(string) for string in L] for a in lenList: av...
3238969a22a8f6b8ce3c3b4e304a6437a23ad467
AutumnColeman/python_basics
/python-loops/box.py
234
4.03125
4
width = int(raw_input("Width?" )) height = int(raw_input("Height?" )) print "*" * width for i in range(height - 2): num_spaces = width - 2 spaces = " " * num_spaces row = "*" + spaces + "*" print row print "*" * width
80d674fa13606ccecb4943feb34ea9878cf45cca
AutumnColeman/python_basics
/python-strings/caesar_cipher.py
688
4.5625
5
#Given a string, print the Caesar Cipher (or ROT13) of that string. Convert ! to ? and visa versa. string = raw_input("Please give a string to convert: ").lower() cipher_list = "nopqrstuvwxyzabcdefghijklm" alpha_list = "abcdefghijklmnopqrstuvwxyz" new_string = "" for letter in string: if letter == "m": ne...
3bac6dcded9f050f8c3d8aff2e2f9f5083310d00
nishesh19/CTCI
/educative/rotateLinkedList.py
1,146
4.1875
4
from __future__ import print_function class Node: def __init__(self, value, next=None): self.value = value self.next = next def print_list(self): temp = self while temp is not None: print(temp.value, end=" ") temp = temp.next print() def rotate(head, rotations): # TODO: Write ...
4984a0fc54b4fb94ce00d4e4078d12afcc2387d9
nishesh19/CTCI
/educative/rearrangeString.py
619
3.734375
4
from heapq import heappush from collections import defaultdict def rearrange_string(str): char_freq = defaultdict(int) for char in str: char_freq[char] += 1 char_count = [] distinct_chars = 0 for key in char_freq: if char_freq[key] == 1: distinct_chars += 1 el...
d4d6493193ad2c011f902096eb65401a62f2a222
nishesh19/CTCI
/educative/medianOfNumberStream.py
1,475
4.03125
4
from heapq import heappush, heappop, heappushpop class MedianOfAStream: def __init__(self): self.first_half = [] self.second_half = [] def insert_num(self, num): if not self.second_half: heappush(self.second_half, num) return if num < self.second_half...
2b057da37d9188606a1be543d5bae1ca6b4b2617
nishesh19/CTCI
/leetCode/binarySearchRange.py
1,864
3.578125
4
class Solution: def searchRange(self, nums, target) : index = self.binarySearch(nums,0,len(nums)-1,target) if index == -1: return [-1,-1] lindex = self.searchLeft(nums,0,index,target) rindex = self.searchRight(nums,index,len(nums)-1,target) ...
76fa2b8accc88b315988324d74dff48d39cefdd6
nishesh19/CTCI
/Tries/trie.py
1,374
3.796875
4
from collections import defaultdict class Trie(): def __init__(self): self.trie = self._trie() def _trie(self): return defaultdict(self._trie) def addWord(self, word): curr = self.trie for w in word: curr = curr[w] curr['word'] = word curr.set...
35de7c5e5a3d1d8bdd96d52da7af595bf352edc5
nishesh19/CTCI
/LinkedList/sumListsReverseOrder.py
2,172
3.828125
4
''' 2.S Sum Lists: You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1 's digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list. EXAMPLE Input: (7-) 1 -) 6) + (5 -)...
9c091e4e3c4090e276eaad3b8ae15ea5e8fb6654
nishesh19/CTCI
/Arrays and Strings/Urlify.py
721
4.28125
4
# 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" # length of the string. (Note: If implementing in Java, please use a character array so that you can # perform this operatio...
060cd08e52fdd9c7344605a4386c05f09b92a93d
nishesh19/CTCI
/Trees/topologicalSort.py
1,187
3.609375
4
''' 4.7 Build Order: You are given a list of projects and a list of dependencies (which is a list of pairs of projects, where the second project is dependent on the first project). All of a project's dependencies must be built before the project is. Find a build order that will allow the projects to be built. If there ...
6e58c3d2c52524ae138b55a4d4dbaf57512d363b
nishesh19/CTCI
/LinkedList/deletemiddlenode.py
1,892
4.125
4
''' 2.3 Delete Middle Node: Implement an algorithm to delete a node in the middle (i.e., any node but the first and last node, not necessarily the exact middle) of a singly linked list, given only access to that node. EXAMPLE Input: the node c from the linked list a->b->c->d->e->f Result: nothing is returned, but the n...
9b53f05eee24088e2b44b0b950e80cabbdd58108
nishesh19/CTCI
/Stacks and Queues/stackOfPlates.py
2,169
4.0625
4
''' 3.3 Stack of Plates: Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the previous stack exceeds some threshold. Implement a data structure SetOfStacks that mimics this. SetOfStacks should be composed of several stacks ...
233363bd154d6809621a2b465f0417798ca9820b
nishesh19/CTCI
/Dynamic Programming/knapsack.py
1,484
3.8125
4
''' Given the weights and profits of ‘N’ items, we are asked to put these items in a knapsack which has a capacity ‘C’. The goal is to get the maximum profit from the items in the knapsack. Each item can only be selected once, as we don’t have multiple quantities of any item. Given two integer arrays to represent weigh...
92249616ea76c67eece181441e181512b7493404
nishesh19/CTCI
/Random/radixSort.py
865
3.875
4
import math def countingSort(A, power): size = 10 auxiliary = [0 for i in range(size)] ordered = [None for i in range(len(A))] for i in range(len(A)): index = int((A[i] // power) % 10) auxiliary[index] += 1 for i in range(1, size): auxiliary[i] += auxiliary[i-1] for ...
cc69acb866ed926fe66d4c015c515e09144a2cc5
nishesh19/CTCI
/educative/findAllMissingNumbers.py
461
3.953125
4
def find_missing_numbers(nums): missingNumbers = [] i = 0 while i<len(nums): j = nums[i] - 1 if j<len(nums) and nums[i]!= i + 1 and nums[i] != nums[j]: nums[i],nums[j] = nums[j],nums[i] else: i += 1 for i in range(len(nums)): if nums[i] != i + 1: missingNumbers.append(i+1) ...
40f532290ddcc06177d9ff37c710136b755c1e3d
Zygarde1105/AE401-Python
/score.py
214
3.875
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 11 19:37:39 2020 @author: Richard_Surface1 """ score = int(input("What is your score?")) if score < 60: print("so bad") else: print("so good")
dc3c2e010483741d2b228afbddce842699d69b8f
underlmao/ML-Fall-2019
/hw1/hw1_newton.py
3,084
3.53125
4
import numpy as np import matplotlib.pyplot as plt bases = 3 with open("testfile.txt") as file: data = file.readlines() X = [] Y = [] for line in data: array = line.strip().split(',') for i in range(len(array)): array[i] = float(array[i]) X.append(array[0]) ...
1b0f4e16c9dc7df6f1bbd083fb0fdb3952b808da
ryuku04/ProjectEuler
/problem7.py
764
3.828125
4
# usr/bin/python # -*- coding:utf-8 -*- #******************************************************************************* #* Problem 7 : 10001st prime #* By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. #* What is the 10001st prime number? #***************************...
2d5762606a912354777ebba78b3dc87351a4ff5c
ryuku04/ProjectEuler
/problem4.py
1,035
3.875
4
# usr/bin/python # -*- coding:utf-8 -*- #******************************************************************************* #* Problem 4 : Largest palindrome product #* 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 larg...
0e96602ee53daed9c79ddbcc07d54f885038e08b
redperiabras/CS34grp1CI_TempController
/fuzzify_error_dot_Neg.py
1,643
3.515625
4
#*************************************************************************# # @BeginVerbatim # Title: Fuzzy Controller for Thermal Control System by implementing FL # Description: Given the target temperature, we need to control and balance # it by determining the degree of error and error dot of a # ...
7a4676dc734faacf3b4c6638ef6fd34297291af4
L0GI0/Python
/Codes/building_a_multiple_choice_quiz.py
757
3.671875
4
#!/usr/bin/python3 from Question import Question question_prompts = [ "What color are apples? \n (a) Read/Green\n(b) Purple\n(c) Orange \n\n", "What color are Bananas?\n(a) Teal\n (b) Magenta\n (c) Yellow \n\n", "What color are strawberries? \n (a) Yellow \n (b) Red \n (c) Blue \n\n" ] questions = [ Question(qu...
0ae230c0779ec2e5c66984da69bf768c1082635a
L0GI0/Python
/Codes/translator.py
514
4.03125
4
#!/usr/bin/python3 #basic translator #Giraffe Language #vowels -> g (any vowel becomes g) #------ #dog -> dgg #cat -> cgt def translate(phrase): translation = "" for letter in phrase: if letter.lower() in "aeiou": if letter.isupper(): translation = translation + "G" else: translation = translation ...
e94f1f07150945766804cb28a1e831429bc880de
L0GI0/Python
/Codes/functions_with_lists.py
919
4.25
4
#!/usr/bin/python3 lucky_numbers = [32, 8, 15, 16, 23, 42] friends = ["Kevin", "Karen", "Jim", "Oscar", "Tom"] print(friends) #append another lists at the end of a list friends.extend(lucky_numbers) print(friends) #adding indivitual elements at the end of given list friends.append("Creed") #adding individual elements...
7255e858a67f1640b7f82972435b916b1dc4f301
L0GI0/Python
/Codes/if_statement_and_comparistion.py
245
4.3125
4
#!/usr/bin/python3 #comparison operators eg. >=, <. <=, ==, != def max_num(num1, num2, num3): if num1 >= num2 and num1 >= num3: return num1 elif num2 >= num1 and num2 >= num3: return num2 else: return num3 print (max_num(3, 4, 5))
9dd82d3e14c52770683ad8a568567c571aa81ff1
MRpopo13/ml_bett
/bett_utils.py
502
3.5
4
def find_avg_odd_for_prec(prec): """ :param prec: precision of prediction method :return: print the avg odd needed to have a positive roi gain = unit * (odd - 1) odd = gain / unit - 1 Gw - Gl Gw = prec * unit * (odd - 1) Pw = (1-prec) * unit Gw - PW > 0 => pre...
65d501c73e5391bcc5ca2fae8c0fbdcca967a9df
bhavika/stats_DataScience
/standard_math.py
666
3.65625
4
import math import collections as c def mean(x): return sum(x) / len(x) def median(v): n = len(v) sorted_v = sorted(v) midpoint = n // 2 if n%2 == 1: return sorted_v[midpoint] else: lo = midpoint - 1 hi = midpoint return (sorted_v[lo] + sorted_v[hi]) / 2 def ...
90895322cefb2b18049ca9b43a3a80d801ef160e
tetutetu214/lesson_python
/0903.py
318
3.671875
4
n = int(input()) for i in range(n): st = input() print(st[0]) #joinの利用の仕方 #””(空白なしで).joinする(以降の内容を) #"+"にすれば、文字間に+がはいって表示される n = int(input()) st = [input() for i in range(n)] result = "".join(i[0] for i in st) print(result)
935dfbc90dc1e5af94e573ef3a6cac9e603e11be
tetutetu214/lesson_python
/0808.py
686
4.0625
4
def helloWorld(): return "Hello World!" def add(num1, num2): add = num1 + num2 return add #Pythonの配列[](){}をつかうよ #リスト:なかの値を変えることが出来る list = ["a","b","c"] print(list) print(list[0]) #タプル:なかの値を変えることが出来ない #基本形 tuple = ("a", 5 , 3.14) print(tuple) print(tuple[0]) #応用 def third(tuple): return (tuple[2]) #ディクショナリ...
b0257a63c480f43bead0a93b78c4631efb24d55b
Allegheny-Computer-Science-102-F2020/cs102-F2020-lab4-starter
/datasummarizer/tests/test_summarize.py
1,015
3.796875
4
"""Ensure that the data summarization works correctly.""" import math from datasummarizer import summarize def test_summarize_empty_number_list(): """Ensure that an empty list of numbers summarizes correctly.""" data_list_numbers = [] mean = summarize.compute_mean(data_list_numbers) assert math.isna...
6b0d723353d2c54e6455bd6da9ddeee092fcbed6
phrdang/booklist
/booklist.py
32,096
3.65625
4
""" Welcome to the Book List project. Title: booklist.py Author: Rebecca Dang Date: September 27, 2018 """ from time import sleep from re import findall from os.path import isfile from datetime import datetime from os import listdir # Troubleshooting instructions for user for inputting book titles book_title_troubles...
527f4681f7ef1d96bb6b703c193584e362bcc409
RUC-CompThinking18/exploratory-programming-1-jtf73
/Exploratory project.py
568
3.796875
4
def double(t): #defined x as a list x = [] f = [] d = [] #Made new list in order to organize other list and return all of them at once Azcr = [] #t = [30, 18, 24, 76] for element in t: if element in t != int print "Numbers only." return if element in ...
87d50c7cfbf20cfe348e20b309d336d84003072c
saychakra/PublicKey_Cryptography
/welcomeScreen.py
1,919
3.5
4
from os import system import platform import digitalSignature as dsig import CryptoSys as crypt from time import sleep def checkPlatform(): # detecting platform os to write the proper clear screen if (platform.system() == 'Windows'): return "cls" elif (platform.system() == 'Linux'): ...
36a8d113b34f0d2ac148567ce9f3ef286039a67d
Susik86/Python_Homework
/Practical 3.py
2,702
3.84375
4
# Task 1 # def mult(a, b): # return a * b # # print(mult(5, 5)) # assert(mult) # # # def minus(a, b): # return a - b # # print(minus(10, 5)) # assert(minus) # # # def div(a, b): # if a == 0: # print("Error raises") # else: # a / b # # # print(div(25, 5)) # assert div # # # def sum_number...
5bf2d5474848af1699dec3a83bc5891e404c8cac
Angel-Znoker/IA-2019-1
/IA3_codificador.py
3,139
4.0625
4
"""Versión de Python utilizada 3.6.X Integrantes: - Aco Guerrero Iván Rogelio - Hernández Arrieta Carlos Alberto - Hernández García Luis Angel - Hernández Gómez Ricardo Este programa realiza el cifrado y descifrado de mensajes por columna (cifrado por transposición columnar simple https://goo.gl/...
e4434cfa2ff0b2b53664dd678bb0d6c9490e8e67
ibnahmadCoded/how_to_think_like_a_computer_scientist_Chapter_5
/palindrom_checker.py
248
4.21875
4
def is_palindrome(word): """Reverses word given as argument""" new_word = "" step = len(word) + 1 count = 1 while step - count != 0: new_word += word[count * -1] count += 1 return new_word == word
0ac61d0536dc899344a149ca3a86ac17a29e3f12
danodic/pianopad
/src/mode.py
12,249
3.53125
4
import pdb import os.path import translator as t import map_manager as maps class Mode: """ A 'Mode' is pretty much a note mapping. You can have modes for different note mappings, like scales or anything fancy that comes to your mind. A mode is made from 3 files: . A file containing all the notes...
891527cdc87bf184092588d237b830176edcecfd
HALOFRAS/Laboratory-work1
/5.py
98
3.75
4
a=input("Строка: ") print( "".join( [e for e in a if e not in "уеыаоэяиюeyuioa"] ))
a36b6bb70dcb82d5c43d2cf0061048584c05ded0
pieteradejong/python
/distance_metric.py
568
4.0625
4
from abc import ABC, abstractmethod class DistanceMetric(ABC): @abstractmethod def calc_distance(self, a, b): pass class Euclidean1D(DistanceMetric): def calc_distance(self, a: float, b: float) -> float: return abs(a - b) # class EuclideanNDimensions(DistanceMetric): # def calc_dist...
1c93b3cc18e5fdea86e84540ef2d5a8c8add5445
kshitijyadav1/Python_Programming_Stuff
/mathCalc/printN_fibanocci_Number.py
659
4.0625
4
#! python3 # find fibanocci number from the series init and to where the series end. import sys from_ = 0 to_ = 0 try: to_ = sys.argv[2] except: to_ = int(input("Enter the fibanocci series range: ")) def n_Fibanocci_series(end): numberA = 0 numberB = 1 fib = 0 for val in range(end): if val == ...
33bd2189e0336df8f3a2241f40805e26fee613be
kshitijyadav1/Python_Programming_Stuff
/mathCalc/area_of_Regular_polygon.py
686
3.71875
4
#! python3 # -v python 3.7 import sys import math import time numberOfSide = 0 side = 0 INITtime = time.time() try: numberOfSide = sys.argv[1] side = sys.argv[2] except: numberOfSide = float(int(input("Enter the number of sides: "))) side = float(input("Enter the side: ")) area = (numberOfSide *...
237325a28a76546c12bd704313703bda937ebdcb
kshitijyadav1/Python_Programming_Stuff
/mathCalc/simpleInterest.py
553
3.984375
4
#! python3 import sys # Simple interest = (Principal * rate * time) / 100 principal, rate, time = 0, 0, 0 try: principal = float(sys.argv[1]) rate = float(sys.argv[2]) time = float(sys.argv[3]) except: principal = float(input("Enter principal: ")) rate = float(input("Enter rate of interest: ")) time = float(int(...
0ff0a238da2e48a751d66401f303090375a03ed1
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/14. ALGEBRA/ALGEBRA/StringManipulation.py
733
4.125
4
# https://www.youtube.com/watch?v=k9TUPpGqYTo&list=PL-osiE80TeTt2d9bfVyTiXJA-UTHn6WwU&index=2 # MATH FUNCTIONS in Python: https://docs.python.org/3.2/library/math.html #all key methods related to string manipulation message = "Hello World" print(message[0:3]) #including lower limit, but not including upper li...
6765f11257a114c4d2ae7e3368a20dda30c237e6
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/5. STRINGS/reverseString.py
292
4
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 17 20:06:03 2017 @author: Sandbox999 """ #this is Sandbox's Python Code #reverse a string without using a library method print("enter your string") myS = input() i = len(myS) while i > 0: print(myS[i-1]) i = i-1
141636cbc5e8148f6f6a0f7046d45bb486c5a784
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/11. PROJECTS_MonthlyReview/check_perfectSquare.py
269
3.703125
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 3 09:56:18 2017 @author: Sandbox999 """ #this is Sandbox's Python Code #check if a number is a perfect square n = int(input("enter the number you want to check if it is perfect square")) # assign as homework
dca7845b0b0f952709f1477f24b1049bd1a87991
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/11. PROJECTS_MonthlyReview/Print_Alphabets.py
246
3.828125
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 2 21:14:32 2017 @author: Sandbox999 """ #this is Sandbox's Python Code alphabet = "abcdefghijklmnopqrstuvwxyz" for i, letter in enumerate(alphabet): print(letter.upper(), alphabet[i:])
58dede4b8f03da38f12c3d3b64e4bae1f54de9a9
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/6. LISTS/tuples.py
477
4
4
tuple1 = ("banana", 3.2, 7) print(tuple1) print(type(tuple1)) #tuple1.reverse() #reverse(), pop(), remove(), clear() etc. are not allowed #tuple is NOT mutable print(tuple1) list1 = ["orange", 2.7, 3] print(list1) list1.reverse() #list is revered in place i.e. it is mutable print(list1) list1.clear() print...
04f8e66d3978ea6782bbb18dd88669666ced840d
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/11. Recursion/towerOfHanoi.py
1,426
4.03125
4
# towers of Hanoi # The number of moves necessary to move a tower with n disks can be calculated as: 2n - 1 # The legend and the game "towers of Hanoi" had been conceived by the French mathematician Edouard Lucas in 1883. # There is a general rule for moving a tower of size n (n > 1) from the peg S to the peg T:...
25b120ae9c73fdaf7402288f487fb73d89dded77
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/GUI-GAMES/TkinterImages.py
1,180
3.765625
4
# http://www.c-sharpcorner.com/blogs/basics-for-displaying-image-in-tkinter-python #To display image in Python is as simple as that. #But, the problem is PhotoImage class only supports GIF and PGM/PPM formats. #The more generalized formats are JPEG/JPG and PNG. #To open and display with those formats, we nee...
560b217619a868f4d23d65dc7c2c9b59f6aa465c
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/6. LISTS/Insults_ByBoris.py
955
4
4
import random #import library to generate random numbers import time #import library to wait before action list_one = ["sniggering", "limping", "gibbering", "ham-fisted", "boasting", "gib-faced", "snooty", "snooty", "bouncing", "creeping"] list_two = ["manakin", "snotbinder", "blizzard-fish", "mugawump", "blunder-...
f7a065c1803dadf574ebdd488f5b7d950af833b7
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/5. STRINGS/checkForCharacter.py
340
3.734375
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 17 20:00:41 2017 @author: Sandbox999 """ #this is Sandbox's Python Code print("enter a string") myS=input() print("enter a character you want to check") myC = input() i = 0 while i < len(myS): if myC[0] == myS[i]: print("character exists in str...
5d3f85e1ddda1176b055ba4fc9ff53e886710be0
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/10. GUI_Tkinter/GUI_BindingButtons2_nb.py
386
4.09375
4
from tkinter import * root = Tk() def printName(event): #event is the parameter for printName function print("hello, my name is Bucky") button_1 = Button(root, text="Print my name", bg="red", fg="white") button_1.bind("<Button-1>", printName) #Buton-1 means Left Button #bind function takes 2 parameters...
484e9f1b1f6c24fc75ac60f98909fdeb01a9111e
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/BlackJack/BlackJackMain.py
1,678
3.625
4
# code for BlackJack Game #version1: single player against dealer, 1 deck of cards, A is always 1, full deck at the beginning of each round import random #data #deck >> List or Dictionary deck = ['CA', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'CJ', 'CQ', 'CK'] dictVal = { 'CA':1, 'C2':2, 'C3':3,...
8f5855cd8a478602fe7a81fd565689abc324a265
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/6. LISTS/Hangman_Simple.py
786
4.09375
4
#hangman simple game built ground up import time name = input("what's your name?") print("Hello, " + name + " let's play Hangman") print("") time.sleep(1) print("start guessing...") time.sleep(1) word = "secret" guesses = '' turns = 10 while turns > 0: failed = 0 for char in word: ...
2f94b7b041d82b01c60f42d51c139a729cf057df
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/6. LISTS/Insults_IF.py
512
3.921875
4
#random insults generator using IF-ELIF Statements and Function import random def insultMe(): insult = random.randint(1,3) if insult == 1: print("gogo") elif insult == 2: print("bobo") elif insult == 3: print("nono...
3189a9bddb5e0869d4c2a3fd33df5916788f3680
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/13. PYGAME/Pygames/pygame1.py
1,079
3.578125
4
#sentdex YouTube Video Tutorial Series #first pygame with basic window import pygame #import pygame module pygame.init() #start pygame #pygame is an instance, hence need to instantiate it gameDisplay = pygame.display.set_mode((800, 600)) #resolution of the game window #set_mode() expects a tuple, not 2 parameter...
5b9ede1eebb86b07dee88f1b6638f0b4f0a71fa0
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/14. ALGEBRA/ALGEBRA/quadraticSIMPLE.py
572
4.03125
4
# solving a quadratic equation simply import math quad = input("enter a standard quadratic equation, enter 1 if coefficient is 1: 1x^2 - 5x + 6 = 0\n") print(quad) terms = quad.split(" ") print(terms) a, rhs = terms[0].split("x^2") a = int(a) print("a is", a) b, rhs = terms[2].split("x") b = int(b) i...
0ffa34a5a216c15da574f44ecda653e777c226b3
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/5. STRINGS/vowelsWord.py
615
4.09375
4
# user enters the word myWord = input("what's the word you want to check #vowels for?") # calculate the vowels by looping through each character in the word print(len(myWord)) print("") #print each letter in the word i = 0 while i < len(myWord): print(myWord[i]) i = i + 1 print('') count = 0 #n...
81edf9cc854f26a78de715e94cca7836ed808605
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/python_shapes.py
3,092
3.9375
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 19 13:52:33 2018 @author: Mitch Labrenz """ import turtle import math import time turtle.speed(0) def drawPolygon(size, sides): for i in range(0,sides): turtle.forward(size) turtle.left(360/sides) def drawCircleInPolygon(siz...
5e9f216b3fc99e2b7a1f63ccf7c6ee63bd2614d6
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/myFunctions/randomAddMult.py
336
3.953125
4
# randomly adds or multiplies import random def addT(x,y): d = x+y return(d) def mulT(x,y): return(x*y) a = int(input("enter first num: ")) b = int(input("enter second num: ")) c = 0 r = random.randint(0,1) #toss on a coin if r == 0: c = addT(a,b) #function call else: c = mulT(...
32a6ed96ae21fb312961325d9eb0cff5791b5493
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/3. LOOPS/ComputerGuessesYourNumber.py
1,057
3.96875
4
# This is a guess the number game. import random guessesTaken = 0 print('Hello! What is your name?') myName = input() lowerLimit = 1 upperLimit = 20 print('Well, ' + myName + ', you think of a number between 1 and 20.') while guessesTaken < 6: computerGuess = random.randint(lowerLimit, upperLimi...
7f2d5b3d5f97f93a1c410a32a621e95e8e76bd2c
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/9. DATA STRUCTURES/Lesson9_Collections_dataStructures.py
395
3.53125
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 3 21:03:45 2017 @author: Sandbox999 """ filelist=list(range(2000,2020, 2)) """2 indicates range here""" print(filelist) print(filelist[2]) print(filelist[2:5]) """note: upperbound is NOT included i.e. upperbound-excluded""" print(filelist[0:3]) pr...
31ce24dd88d2ce6137b740cb969c259fe26aec31
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/ErrorHandling/SyntaxErrors2.py
399
3.8125
4
#errors in loops # Syntax errors are also called parsing errors apple = 1 while apple < 10: #missing colon print(uggh) # NameError: name 'uggh' is not defined apple = apple + 1 #indentation error #print("How are you?) # SyntaxError: EOL while scanning string literal #print('I am fine")...
9a3ed1b0b1dcbcbaa544b3421f175e53e0cd0bc0
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/ErrorHandling/ExceptionHandling1.py
289
4
4
while True: try: age = int(input("enter your age: ")) if age < 18: print("welcome, Kiddo!!") break else: print("Howdy, Sir!") break except ValueError: print("please enter numeric age")
83343b5857d5c2661981b89052a7ea35b6d603de
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/CreateFilesPython.py
686
3.5625
4
# -*- coding: utf-8 -*- """ Created on Sat Nov 11 07:49:48 2017 @author: Sandbox999 """ # create a file called testing.txt in the folder C:\in file=open("C:\\in\\testing.txt", 'w') #w is for write file.write("such a nice file that I am") file.close() file=open("C:\\in\\testing.txt", 'r') content=file.re...
dff855b8ce3437c2f62c3f07a68b40f83efafbf3
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/5. STRINGS/Palindrome.py
680
3.78125
4
# -*- coding: utf-8 -*- """ Created on Sat Nov 18 07:24:19 2017 @author: Sandbox999 """ #this is Sandbox's Python Code # this checks if a string is a palindrome i.e. reads same forwards & backwards myS = input("please enter your string:") newS="" i = len(myS) j = 0 while (i > 0): newS=newS+myS[i...
d000f23556519377afda30e6eb6fa5af6789795b
Nithishphoenix/AirlineReservations
/Airlines.py
3,054
3.65625
4
# Airline Reservation System import pickle print ("====================================") print ("====================================") print ("====================================") print ("==== AIRLINE MANAGEMENT SYSTEM =====") print ("====================================") print ("===============================...
c3e0b6bd4763bf17a5c6f7452b253d97686a4a00
SherMM/programming-interview-questions
/hackerrank/linked_lists/insert_at_tail.py
602
3.75
4
import sys import random from linked_list import LinkedList, Node from print_nodes import print_nodes def insert_at_tail(ll, node): """ docstring """ curr = ll.head if curr is None: ll.head = node else: while curr.next is not None: curr = curr.next curr.next...
111a4db76992a35f4590e21b69684d8f7d057b94
SherMM/programming-interview-questions
/epi/sorting/selection_sort.py
812
4.21875
4
import sys import random def selection_sort(array): """ docstring """ def swap(arr, i, j): arr[i], arr[j] = arr[j], arr[i] for i in range(len(array)): min_value = array[i] min_index = i for j in range(i+1, len(array)): value = array[j] if va...
36e21fdb5962f666b7d032c5a688638624dfb391
antritt/comp110-21f-workspace
/exercises/ex01/numeric_operators.py
443
3.75
4
"""Numeric Operators Program!!""" __author__ = "730228132" x: str = input("Left-hand side : ") y: str = input("Right-hand side : ") t1_new = int(x) ** int(y) ro = str(t1_new) print(x + " ** " + y + " is " + ro) t2_new = int(x) / int(y) r1 = str(t2_new) print(x + " / " + y + " is " + r1) t3_new = int(x) // int(y) r2 = s...
73ce9d6642e50f9018c698952e7f4479b32c927d
KwonChanSoon/autotrader
/robot/trades.py
19,872
4.125
4
from datetime import datetime from typing import List, Dict, Union, Optional class Trades: """ Object represents stock trades. This is used to create new trade, add customisation trades, and modify excisting content. """ def __init__(self): self.order = {} self.trade_id = "" ...
83885908263d8eaac803c7df15caab3e3ac81e6d
AlegreVentura/Mazes
/Maze.py
3,177
3.9375
4
# Cell class. from Cell import * # Miner class. from Miner import * # Traveler class. from Traveler import * # Random functions import random class Maze: """ Class for a maze. """ # The board that represents the maze. board = None # The board that will be traversed using BFS and DFS. b...
5308f4c50780e2425f00709946a2e03f992fdce6
nogifeet/Raspberry_Pi_Introduction
/Traffic Signal Led/traffic-singal_using_led.py
875
3.8125
4
#led example for traffic Signal #each signal will be lit for 10 seconds then turn off(except Yellow) #the signal will run for 5 interations #order Red-10 seconds, Yellow - 5 Seconds, Green - 10 Seconds similar to Real Life Traffic Signal #Pin Structure #GPIO-18 for Green #GPIO-17 for Yellow #GPIO-23 for Red import RP...
ad61416d954e0ca825e53efa655ab32c6b37028a
franiakpiotr8/python
/zad13_mnozenie_macierzy.py
599
3.765625
4
# !python import random print("==========zadanie13==========") matrix1 = [[random.randrange(10) for i in range(8)] for i in range(8)] matrix2 = [[random.randrange(10) for i in range(8)] for i in range(8)] result_matrix = [[0 for i in range(8)] for i in range(8)] for i in range(8): for j in range(8): ...
b0f053266a9182899e2e15fa6706ccb862c64b85
franiakpiotr8/python
/zad9_usun_slowa.py
393
3.6875
4
# !python import re print("==========zadanie6==========") file = open('example.txt') try: text = file.read() finally: file.close() words_to_remove = ["się", "i", "oraz", "nigdy", "dlaczego"] print(text) for word in words_to_remove: pattern = r'( ' + word + r'\W?)' print(pattern) ...
685329a6da0619e610aa67442b8454864d8175af
franiakpiotr8/python
/zad11_iloczyn_wektorow.py
184
3.59375
4
# !python print("==========zadanie11==========") a = [1, 2, 12, 4] b = [2, 4, 2, 8] result = 0 for x in range(0, len(a)): result = result + a[x]*b[x] print(result)
fa987c3d6e2c2e1dba192beee4cb430cb9d265ce
DZGoldman/Google-Foo-Bar
/problem22.py
2,284
4.40625
4
# things that are true: """ Peculiar balance ================ Can we save them? Beta Rabbit is trying to break into a lab that contains the only known zombie cure - but there's an obstacle. The door will only open if a challenge is solved correctly. The future of the zombified rabbit population is at stake, so Beta ...
7c6a7b8edf67d8debd02e1f9f0c3d4a13f9e5592
mleverge/Computational-Science
/_homework3/_exercise1/hmwk3_ex_1.py
3,181
3.59375
4
import numpy as np import matplotlib.pyplot as plt from numpy.random import random, seed import time seed=(1234) def Distribution(n_item) : # Generate a random discrete distribution of n_item r = random(size=(n_item)) # elements # i. Gene...
31dd9b9277891103e5b4610515587ef16f17fe71
AnatSanzh/KPISem4Lab1
/cui.py
4,522
3.796875
4
from abstract_storage import RecordStorage from fake_storage import MemoryRecordStorage import io_helper _choices = "\n1. Show records" \ "\n2. Add record " \ "\n3. Update record" \ "\n4. Remove records by phone number" \ "\n5. Erase all records " \ "\nEnter...
d00872698878c7cfb2243c8842e7f66cc033f41f
brycealderete/CodingDojo
/Python/For_loops_basic2.py
1,649
3.953125
4
def biggie(list): for i in range(0,len(list),1): if list[i]>0: list[i]='Big' return list print(biggie([-1, 3, 5, -5])) def count(list): sum =0 for i in range(len(list)): if list[i]>0: sum = sum +1 list[len(list)-1]=sum return list print(count([1,6,-4,-2,-...
03b0d0365a8aefba2e3f14f2f909f2bb67adc00a
JustDoItGit/algo_practice
/15-二分查找/bsearch.py
364
3.828125
4
def bsearch(nums, target): low, high = 0, len(nums) - 1 while low <= high: mid = low + (high - low >> 1) if nums[mid] == target: return mid elif nums[mid] < target: low = mid + 1 else: high = mid - 1 return -1 test_nums, tar = [1, 2, 3, 4...
47991fc01a29ae8cc8224837bb9d609df68147dd
halokid/MyLeetCodeBox
/test/reverse_string_recursion.py
549
3.796875
4
# coding=utf-8 class Solution: def reverseString(self, s): def helper(left, right): if left < right: s[left], s[right] = s[right], s[left] # helper(left + 1, right - 1) helper(0, len(s) - 1) class Solution2: def reverseString(self, s): left, right = 0, len(s) - 1 while lef...