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
d56b20f007aeb77803a1c56a52068427685ad080
prasannabe2004/MITx
/6.00.1.x/Week3/Lecture5/lectureCode_Lec5-Problem5-gcdRecur.py
162
3.625
4
def gcdRecur(a,b): if b == 0: return a else: return gcdRecur(b,a%b) result = gcdRecur(9,12) print "GCD of a and b is: " , str(result)
fc7b850e0dd7661541dd52832b870f56a1541653
prasannabe2004/MITx
/6.00.2.x/scratchpad.py
658
3.78125
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 31 16:27:46 2014 @author: pmohanasundaram """ import random def dist1(): return random.random() * 2 - 1 def dist2(): if random.random() > 0.5: return random.random() else: return random.random() - 1 def dist3(): return int(random.rand...
daaf1572ef7bf3971cd3a1e27c3397622aa0a172
schoentr/data-structures-and-algorithms
/code-challanges/401_code_challenges/linked_list/linked_list.py
2,852
4.25
4
from copy import copy, deepcopy class LinkedList(): head = None def __init__(self, iterable=None): """This initalizes the list """ self.head = None if iterable: for value in iterable: self.insert(value) def __iter__(self): """This makes...
fcb4418e821cc4c6d813b7c414cc415ccccc7dba
schoentr/data-structures-and-algorithms
/code-challanges/401/stacks_and_queues/test_stacks_and_queues.py
2,697
3.890625
4
from stacks_and_queues.stacks_and_queues import Stack, Queue def test_stack_exists(): assert Stack def test_instantion_stack(): assert Stack() def test_insert_one_stack(): fruits = Stack() fruits.push('Apples') expected = 'Apples' actual = fruits.top.value assert actual == expected def ...
78a6e7972a8960932922e1aad5982183086a8670
schoentr/data-structures-and-algorithms
/code-challanges/401/trees/fizzbuzz.py
809
4.15625
4
from tree import BinaryTree def fizzbuzz (self, node = None): """ This Method traverses across the tree in Order. Replacing the value if divisable by 3 to Fizz, if divisibale by 5 to buzz and if divisiable by both 3 and 5 to fizzbuzz """ rtn = [] if node is None: ...
8e3a079278d9a5c59df34cbbe77c2b10a47449f6
schoentr/data-structures-and-algorithms
/code-challanges/401_code_challenges/sorts/radix_sort/fooradix_sort.py
2,103
4.125
4
def radix_sort(inpt_list, base=10): """This sort takes in a list of positive numbers and returns the list sorted in place. Arguments: inpt_list {[list]} -- [Unsorted List] Keyword Arguments: base {int} -- [description] (default: {10}) Returns: [list] -- [Sorted List] """...
b03d4c98d35e0bb4572ec203fb6ca188ccb32f88
Ewalddav/LeetCode
/Solutions/002.AddTwoNumbers/solution.py
1,286
3.890625
4
''' David Ewald 8/29/21 002 Add Two Numbers: Medium You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume...
4f7f9444af2567cc217adbdee2476e095667cb6a
madhavms/OOP_CODE
/Account.py
2,803
3.765625
4
class Account: def __init__(self,CustomerID): self.ID = CustomerID #creates id for each object self.total=1000 #object.total=1000 ;deposits 1000 into each account def deposit(self, amount): self.total +=amount return "BALANCE AFTER DEPOSIT RS:"+" "+str(self.total)+"\n" ...
0f00d94dfd5b21ef42b9f83516dfc9cca6c1780b
serkanhoca/Python64
/SORULAR(1..HAFTA).py
4,469
4.09375
4
''' #1.soru sayi=input("Bir sayı giriniz =") print(sayi) #----------------------------------------------------------- #2.soru isim=input("Adınızı yazınız =") print(isim) #----------------------------------------------------------- #3.soru say1=int(input("1. sayıyı giriniz =")) say2=int(input("2. sayıyı giri...
96f92216445cfc2f365822eec83dcada080c6357
NickCalderone/assembler
/replace_symbols.py
318
3.515625
4
def replace_symbols(lines, dictionary): replaced = [] for l in lines: if l[0] == '@': if l[1:] in dictionary: replaced.append('@' + str(dictionary[l[1:]])) else: replaced.append(l) else: replaced.append(l) return replaced
51375b5fa9bc0114769265acd0e3fd12b747fa59
MrNexon/LP_Labs
/lab1/z1v3.py
269
3.71875
4
import math a = int(input('a: ')) b = int(input('b: ')) c = int(input('c: ')) try: d = 1 - a * (b ** c) - a * ((b ** 2) - (c ** 2)) + (b - c + a) * (12 + b) / (c - a) print(math.fabs(d)) except ArithmeticError: print('Деление на 0')
4affad70ba72ef8c280491afdc81b8528a7d3a10
tharpta/data_structs_and_algos
/recursion/fibonacci.py
408
4.03125
4
#Fibonacci sequence is a sequence of numbers in # which each number is the sum of the two preceding ones # and the seqience starts from 0 and 1 def fibonacci(n): #constraint assert n>=0 and int(n) == n, 'the number can only be positive and must be int' #base case if n in [0,1]: return n #...
c0a814a1761bd9b11510500386eee4044f4f3d75
abhinab1927/Data-structures-through-Python
/ll.py
1,631
4.21875
4
class Node: def __init__(self,val): self.next=None self.value=val def insert(self,val): if self.value: if self.next is None: self.next=Node(val) else: self.next.insert(val) else: self.v...
39affc2ea1f6a886b2cf30828091390c768a701e
RobACollins/Portfolio
/model.py
5,885
3.59375
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 9 12:17:48 2017 @author: gy17rac """ #The following code is the model created within the practicals. #This can be ran within a python simulator or within command line with "python ./model.py" import matplotlib matplotlib.use('TkAgg') import matplotlib.pyp...
bf83277c8da437c3983ba4f1342abc9cc85d0fab
luckycontrol/Algorithm_with_python
/sorting/CellSort.py
754
3.78125
4
def run(): arr = [2, 1, 5, 6, 4, 3, 9, 8, 10] size = 9 newArr = cellSort(arr, size) print(newArr) def cellSort(arr, size): _arr = arr gap = size // 2 if gap != 0 and gap % 2 == 0: gap += 1 while gap > 0: for i in range(gap): _arr = insertionSort(_arr, i, size-1, ...
21bf0c41c6d281be496bfe8ef838b3e54819ab42
luckycontrol/Algorithm_with_python
/Graph/Floyd.py
901
3.671875
4
class Graph: def __init__(self, vertices): self.V = vertices self.weights = [ [0 for _ in range(vertices)] for _ in range(vertices) ] def shortest_path(self): A = self.weights for k in range(self.V): for i in range(self.V): for j ...
882e3be3601729364193437c89166ecad0b948f0
luckycontrol/Algorithm_with_python
/BubbleSort.py
342
4.03125
4
def bubble(list): sorted = False length = len(list) - 1 while not sorted: sorted = True for i in range(length): if list[i] > list[i+1]: sorted = False list[i], list[i+1] = list[i+1], list[i] return list lst = list(map(int, input().split(...
ed3f3e6455cebc467992bb30f66245f18219cc25
moemaair/Problems
/searching/python/binary_search.py
1,670
3.953125
4
""" Binary Search Write method to return True if integer is in array """ def binary_search(arr, val): low = 0 high = len(arr)-1 while low <= high: mid = low + (high-low)/2 #alternatively (high+low)/2 if arr[mid] == val: return True elif arr[mid] < val: low = mid+1 else: high = mid-1 return Fals...
3bd447494cb080d62752b0c9d22c6e30bb6d3e47
moemaair/Problems
/heaps/python/median.py
2,065
3.890625
4
from Heap import MinHeap, MaxHeap """ Approaches for Median: 1) Buckets from MIN to MAX value increment count in each bucket store total count of elements loop through until you reach total/2 2) Sort array and return middle value 3) Balanced Binary Tree (in order traversal produces a sorted list in O(n) time you can...
6ee37e4138f6cf1ac448f785e6d94b29736dc4e2
moemaair/Problems
/lists/python/nth_node_from_tail.py
938
4.0625
4
from LinkedList import LinkedList from LinkedList import build_ll_from_lst from Node import Node """ Return data in Nth node from the end head could be None as well for empty list # Approaches 1) Use a queue to keek track of last pos_from_tail values, then dequeue at end 2) Use list, then return list[len(list)-pos_fr...
d1b23699007c2cbfd4b0ea3f2121b8adb4cfda6f
moemaair/Problems
/lists/python/remove_duplicates.py
1,853
3.75
4
from LinkedList import LinkedList from LinkedList import build_ll_from_lst from Node import Node def remove_duplicates_sorted(head): start = head while head is not None: while head.next is not None and \ head.value == head.next.value: head.next = head.next.next head = head.next return LinkedList(start) ...
3006661cf576429fdefb8ce6b6346eddd763a347
moemaair/Problems
/graphs/python/Graph.py
1,931
3.75
4
from Vertex import Vertex class Graph(object): def __init__(self, vertices={}): self.vertices = vertices self.num_vertices = len(vertices) def add_vertex(self, key): vertex = Vertex(key) self.vertices[vertex.key] = vertex self.num_vertices+=1 return vertex ...
ff7a0cdc59ffb167129ec7beb448ce3499ea8c14
moemaair/Problems
/lists/python/delete_kth_node.py
1,660
3.953125
4
from LinkedList import LinkedList from LinkedList import build_ll_from_lst from LinkedList import get_test_linked_list from Node import Node """ Delete Kth Node in LinkedList You're given the pointer to the head node of a linked list and the position of a node to delete. Delete the node at the given position and ret...
22b4965a4bf888af0b134cd42d550a6622957b30
moemaair/Problems
/powerset/powerset_recursive.py
892
3.5
4
'''powerset for any symbol''' def subsets_m(set, m, pos): p = [] while m > 0 and pos <= len(set)-m: subs = subsets_m(set, m-1, pos+1) for s in subs: p.append([set[pos]] + s) pos += 1 if p == []: return [[]] return p def pset(set): p = [[]] m = 1 ...
e556737d693fb598ee89751696aa05ff4b791e9a
moemaair/Problems
/stacks/python/sort_stack.py
2,680
4.1875
4
from Stack import Stack from Stack import build_stack_from_list """ Sort Stack Write a method to sort a stack in ascending order Approaches: 1) 3 stacks - Small, Large, Current 2) Recursive - Sort and Insertion Sort """ def sort_stack_recursive(stack): if len(stack) == 0: return ele...
63fd26db1c118c2d91c4fa801e077a7d642c2834
moemaair/Problems
/math/python/grid_unique_paths.py
1,346
3.578125
4
import math class Solution: # @param A : integer # @param B : integer # @return an integer def uniquePathsRecurse(self, A, B): if A == 1 or B == 1: return 1 paths = 0 if B-1 > 0: paths += self.uniquePathsRecurse(A,B-1) if A-1 > 0: path...
176d58d5bd2b5c3148c3882d9010a9be36568071
moemaair/Problems
/strings/python/is_rotation.py
2,181
4.375
4
#Cases """ 1) Empty string 2) Normal is rotation 1-step 3) Normal is rotation multistep 4) Normal no rotation same chars 5) 1,2,3+ length 6) Strings not same length == False """ #Approaches """ 1) Submethod called "rotate" which rotates string one-place, main method rotates str2 len(str1) times, checks if strings are ...
e37c22e6e03c1a576b264ae00769edbf084fcc4b
moemaair/Problems
/graphs/python/pretty_print.py
1,411
4.125
4
from Graph import Graph from Graph import build_test_graph from Vertex import Vertex """ Pretty Print Starting with a single Vertex, implement a method that prints out a string representation of a Graph that resembles a visual web Approach: 1) Using BFS, extract all unique vertices from the graph into set 2) Loop ...
469a59d991f878a9a668df228b310a9d633a60f4
moemaair/Problems
/stacks/python/stacks_w_array.py
1,569
4.125
4
from Stack import Stack from Node import Node """ Stacks with Array Implement 3 stacks using a single array Approaches 1) Index 0, 3, 6.. first stack. 1, 4, 7.. second stack. 2, 5, 8.. third stack. """ class StacksWithArray(object): def __init__(self): self.array = [None for x in range(99)] # Represent next av...
7327941fe409b50b117919a4d28e5dc310f540be
moemaair/Problems
/recursion/python/binary_strings.py
1,240
4
4
#3 def generate_binary_str(n, curstr): if len(curstr) > n: return [] if len(curstr) > 1 and curstr[0] == "0": return [] strings = [] if curstr != "": strings.append(curstr) return strings + generate_binary_str(n, curstr + "1") + \ generate_binary_str(n, curstr + "0")...
1043391288e9b6b26e2feeff248cee4ebefcc085
moemaair/Problems
/stacks/python/evaluate_expression.py
2,374
4.3125
4
from Stack import Stack """ Evaluate Expression Evaluate a space delimited mathematical that includes parentheses expression. e.g. "( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )" == 101 Approaches: 1) Use two stacks, one for operators, one for operands. If you get to close paren?, then pop last two operands off and combine u...
8313743ae59cfa60cc537d9d475478571b061ebc
shuforov/CheckiO
/feed_pigeons/feed_pigeons.py
1,191
3.515625
4
#http://www.checkio.org/mission/feed-pigeons/ def checkio(number): feeds = number feed_to_need = [] number_of_pigens_feed = 0 g = 0 s = '' if number > 1: s = range(1,number) elif number <= 1: s = range(1,11) for z in s: g += z if g <= feeds: ...
1f64ac3bcf160e7bb1b87c9d16582313826578ed
madhavpalshikar/python
/dp.py
246
3.671875
4
def steps(N): if N == 0: return [()] elif N == 1: return [(1,)] else: l1 = [(1,) + items for items in steps(N - 1)] l2 = [(2,) + items for items in steps(N - 2)] return l1 + l2 print(steps(50))
805ef7bc4b3d3407dba02308264a78eacb661547
CTEC-121-Spring-2020/mod-4-programming-assignment-FDvorak1979
/Prob-1/Prob-1.py
1,184
4.09375
4
# Module 5 # Programming Assignment 6 # Prob-1.py # Frank Dvorak # INSTRUCTIONS: # Insert a comment above each line of code in the program below to describe # what the code does from graphics import * def main(): # Creates the graphic window win = GraphWin("title", 1000, 1000) # Draws a ci...
6fee11aba435fbce0c6793dd12f9bdd51bcb11ba
dmcg89/herdimmunity
/person.py
2,924
3.84375
4
from virus import Virus import random random.seed(42) class Person(object): def __init__(self, _id, is_vaccinated=None, is_infected=None, infection=None): self._id = _id # int self.is_alive = True # boolean self.is_vaccinated = is_vaccinated # boolean self.infection = infectio...
de7ecdf07ef4a14be0786a17bd8e905f9e0ae5f0
ratuljain/dp
/HackerRank/lad.py
1,454
3.6875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT def shortDist(graph, start, goal): visited = [] queue = deque([(start, 0)]) while queue: node, dist = queue.popleft() if node == goal: return dist visited.append(node) for vertex in [i for i in...
2e3830e20050670f394e57619cc2271c16447365
hz2119/poly
/poly/poly.py
536
3.640625
4
class Polynomial: def __init__(self,coefs): self.coefficients = coefs def degree(self): return len(self.coefficients)-1 def __str__(self): coefs=self.coefficients terms=[] if coefs[0]: terms.append(str(coefs[0])) if self.degree() > 0 and coef...
77ef7665013d1fc7ddde118c360588b4561824a6
nivethithanm/Data-Structures-and-Algorithms
/linear_search.py
985
3.640625
4
''' Creatnx now wants to decorate his house by flower pots. He plans to buy exactly ones. He can only buy them from Triracle's shop. There are only two kind of flower pots available in that shop. The shop is very strange. If you buy flower pots of kind 1 then you must pay and if you buy flower pots of kind 2. Plea...
c4435995d9e502bb633c0b2223fd4e15326f5300
ash6898/Python-Class
/class6.py
424
3.84375
4
print("Hey enter some number to add") try: a = int(input("Enter a")) b = int(input("Enter b")) f = open("asdasdsad.txt") c = a+b print(c) except ValueError: print("value thappu da") except FileNotFoundError: print("File eh ila da") finally: print("Nan mixture thinmban da") print("Ok I'...
d767c40204bce77d67f55fdf71abab546ae1fa98
DanielQFK/Python-Exercise
/Python-Exercise-11.py
804
3.953125
4
# Tuple exercises... # 1. Tuple1 = ("daniel" , "Max" , "EMMA") print(Tuple1) # Output = ('daniel', 'Max', 'EMMA') print(Tuple1.title()) # Output = Traceback (most recent call last): # File "Python-Exercise-11.py", line 7, in <module> # print(Tuple1.title()) # AttributeError: 'tuple' object has no attribute 'tit...
5e5e52fa26a36e9cd942e65e152a3afe6298fb0f
DanielQFK/Python-Exercise
/Python-Exercise-17.py
1,753
3.984375
4
# set Exercise # Part 1... Integer_set = {1.2 , 19827 , 52435 , 234 , 21 , 47756.0938774} print(Integer_set) """" output: {1.2, 234, 47756.0938774, 19827, 52435, 21} """ # Tip:set doesn't accept .title or .upper and ... String_set = {"Kim" , "Tom" , "luara" , "John" , "BOB"} # print(String_set.title()) """ output:Tra...
c926b8418cca8f14e4a4d7863d59e277e4d712da
artopping/nyu-python
/brunch/brunch.py
1,076
4.09375
4
#!/usr/bin/env python3 import sys import math def usr_input(): print ("Lets Brunch!") while True: try: number= int(input("How many people are coming?: ")) break except ValueError: print ("Woops! Please enter a number only, no letters") while True: try: booze= int(input("Perfect, what level of...
f19d6e9e46c6a3265b4625ef98f952e14861a862
artopping/nyu-python
/course1/assignment_5/exercises_test.py
404
4.125
4
x = (raw_input("would you like to convert fahrenheit(f) or celsius(c)? ")) if x == "f": y = (raw_input("what is the fahrenheit?")) f = (int(y) - 32) * 5.0 / 9 print ("and in celsius, that is: "), print (f) elif x == "c": y = (raw_input("what is the celsius?")) f = (int(y) *9) / 5.0 + 32 prin...
d3c1a39d1a4f9e21ea569ae1bc0720314ae856e2
artopping/nyu-python
/course1/assignment_5/test.py
284
4.28125
4
#!/usr/bin/env python import sys def convert_f2c(S): """(str): float Converts a Fahrenheit temperature represented as a string to a Celsius temperature. """ fahrenheit = float(S) celsius = (fahrenheit - 32) * 5 / 9 return celsius print (celsius)
8ba5229b9bf24c36eec6fc113b1b020064b8ed87
artopping/nyu-python
/course2/session2/classses_session2.py
710
4.4375
4
#!/usr/bin/env python3 #Classes: storage of data and set of functions that define the class # class has a function and data (local to itself) # when you want to use it< instance= MyClass()> class MyClass: pass #obect my_circle as instance of Class circle # think of class as bucket...lot of room, for data storage a...
b028fa7970f89f34c73a25c612ba05854b7a1783
onedreamxmm/dynamic-programming
/maximal product when cutting rope.py
1,224
3.515625
4
''' Given a rope with integer-length n, how to cut the rope into m integer-length parts with length p[0], p[1], ..., p[m-1], in order to get the maximal product of p[0] * p[1] *...* p[m-1]? m is determined by you and must be greater than 0(at least one cut must be made). ''' from functools import lru_cache class Solu...
cb484afa51e1d0aecd8de61de9b398c38d7d92ed
dongwoooo/lesson
/140712/practice_1.py
166
3.546875
4
import random u = 45 a = random.randint(1,45) list = [a] for index in range(1,6): while a in list: a = random.randint(1,45) list.append(a) list.sort() print list
5f754845fdae552a765e15ffb88d3a1dc548fc9a
nagesh2708/Calculator
/cal.py
3,192
3.71875
4
from tkinter import * root = Tk() root.title("Calculator") a = None b = None c = None flag = None def placing(x): text1.insert(END,x) def sum(): global a,b,flag a = text1.get() text1.delete(0,END) flag = 1 def dif(): global a,b,flag a = text1.get() text1.delete(0,E...
bd3985e9f05a86b9b944007f46dd5f35890d6d78
vivekgupta8983/python3
/table.py
123
3.703125
4
#!/usr/bin/python3 for i in range(0,21): for j in range(0,21): print(f'{j} X {i} = {i*j}') print('x'*20)
89db7f6519f2542bec43ceecaa3be231b1e429af
vivekgupta8983/python3
/range.py
269
4.21875
4
#!/usr/bin/python3 #range functions returns a sequence for number start from o and ends ta specific number #range(start, stop, step) # for i in range(100): # print(i) # for i in range(2, 10, 2): # print(i) my_range = range(1, 10) print(my_range.index(3))
5997c5f1c3d2d0a70cd576527a24ca18825b08d7
alifmhmmd/multithread
/thread.py
759
4.03125
4
#!/usr/bin/python import threading import time # Define a function for the thread def print_time( threadName, delay): count = 0 while count < 5: time.sleep(delay) count += 1 print "%s: %s" % ( threadName, time.ctime(time.time()) ) if __name__ == "__main__": # creating thread t1 = t...
d8da6eadca20c0709eb1105ecbe430e8329ab08e
sean-ashley/data-visualization
/Math grades data analysis/average_grades_analysis.py
746
3.765625
4
from matplotlib import pyplot as plt #data tables past_years_averages = [82, 84, 83, 86, 74, 84, 90] years = [2000, 2001, 2002, 2003, 2004, 2005, 2006] error = [1.5, 2.1, 1.2, 3.2, 2.3, 1.7, 2.4] # Make your chart here #create a 10x8 figure fig= plt.figure(figsize = (10,8)) #create bar graph with error lines plt.bar...
064cb46b734706c23c60ce872fb16fccecee22a4
nikileeyx/learning_python
/2. Dictionary and List/2002_codeReusing.py
842
4.34375
4
#The Code Reusing 1.0 by @codingLYNX ''' Note: In this question, 0 is considered to be neither a positive number nor negative number. You are to implement the following three functions with the following specifications: is_odd(x) returns True if the input parameter x is odd, False otherwise. is_negative(x) returns Tru...
3025d4771b4374a5b63b59838f72843dbbabbfea
carlos-paezf/Metodos_Numericos_Python
/Series_Taylor_Seno.py
833
3.78125
4
import math # Convertir argumento a radianes x_deg = float(input('Valor del argumento en grados: ')) x = math.radians(x_deg) n = int(input('Número de terminos a sumar: ')) # Error verdadadero/total porcentual err_verd = 100.0 # Valor verdadero de sen(x) sen_verd = math.sin(x) # Inicializar el acumulador en 0 sen_x...
a5ba1a5bc1b8e08626f2605fa3a323ace396857e
OneEyeHealer/code
/assets/source/chaos.py
1,341
3.671875
4
def swap(queue, num1, num2): queue[num1], queue[num2] = queue[num2], queue[num1] return queue def minimumBribes(queue): bribeCount = 0 for index in range(len(queue)-1, -1, -1): # going backward like orginal queue sticker, person_pos = queue[index], index + 1 # case 1: when we don't br...
9d96c1c335b19dedef6586f0c196d2ef88f7b1c0
SoyamDarshan/system_design
/SOLID Principles/Interface Segregation Principle/isp.py
1,311
3.75
4
# The idea is we dont want too many methods in a interface, instead keep it granular and keep them separated from abc import abstractmethod class Machine: def print(self, document): raise NotImplementedError def fax(self, document): raise NotImplementedError def scan(self, document): ...
5ae9194c43c27e73fef80b97a2739e82fcc01be9
frankkreutzer/CSC-241
/homework2.py
2,487
3.890625
4
# # NOTE: # # A function must have a code block otherwise # Python will complain. For that reason I put # a pass Python statement where the code block # should be. The pass statement does absolutely # nothing. You should replace the pass statement # with your function implementation def forLoop(): ''' printing nu...
dfe7efe681c5d117bbe0b3a15f2e50cf52e29a08
frankkreutzer/CSC-241
/Practice/midtermPractice.py
864
3.78125
4
def postal(first, last, address, city, state, zipcode): 'print postal mailing address' print("{} {}\n{}\n{}, {} {}".format((frist), (last), (address), (city), (state), (zipcode))) def evens(n): 'return the list of the first n positive even numbers' res = [] for i in range(2, 2 * n + 1, 2): ...
dde624c870e01e1aed62379d5d2a732479c56e03
frankkreutzer/CSC-241
/homework7.py
3,737
3.90625
4
# Exercise 6.12 def letter2number(lgrade): 'returns the number grade corresponding to the letter grade lgrade' grades = {'A+': 4.3, 'A': 4, 'A-': 3.7, 'B+': 3.3, 'B': 3, 'B-': 2.7, 'C+': 2.3, 'C': 2, 'C-': 1.7, 'D+': 1.3, 'D': 1, 'D-': 0.7, 'F+': 0.3, 'F': 0} return grades[lgrad...
d3aa639dedd916dbf54b6eeba26ec11927d3e79c
frankkreutzer/CSC-241
/Example Files/2Dlists.py
233
3.578125
4
def print2D(table): for row in table: for i in row: print(i, end = ' ') print() def incr2D(table): for i in range(len(table)): for j in range(len(table[0])): table[i][j] += 1
200bba7dceaf9a0fbea7d49cad8ee514bdb47b2a
vvkr13/Fun-games
/guess the number.py
858
4.09375
4
import random print("-----WELCOME TO ' GUESS THE NUMBER GAME ' ---------------") while True: n = int(input("ENTER CHANCES")) if n < 6: break else: print("you cannot more than 5 chances ") x = random.randint(1, 20) print("GUESS THE NUMBER IN BETWEEN 1 TO 20") print(f"YOU'VE GOT {n} ...
976d3303d888d16029e18023d95c68ee3b32e686
FranciscoMeloJr/VM
/python_codes/wave2.py
797
3.5
4
import numpy as np from scipy.io import wavfile def show_info(aname, a): print "Array", aname print "shape:", a.shape print "dtype:", a.dtype print "min, max:", a.min(), a.max() print rate, data = wavfile.read('test.wav') show_info("data", data) # Take the sine of each element in `data`. # The n...
f082714935b82debac328becd44f2f5cf64a2344
apollo81/choinka
/Dzien4/choinka.py
163
3.8125
4
# wysokość choinki height = int(input('podaj wysokość choinki: ' )) for i in range(1, height + 1): print(((height-1) * " ") + ((i-1) * "#") + (i * "#"))
2f16b05d5a9347e8f1ca905a5003e1332e8dfb0b
lixingyangok/learn-python-01
/01-practice-2022-0220/数据类型/01 字符串.py
740
3.65625
4
''' Author: 李星阳 Date: 2022-02-20 19:42:44 LastEditors: 李星阳 LastEditTime: 2022-03-01 20:22:32 Description: ''' str01 = 'let\'s go' # 转义符号 \ print('str01:', str01) print('type:', isinstance(str01, str)) # True print('type:', type(str01)) # <class 'str'> print('type:', type(type(str01))) # <class 'type'> print( '...
d435a461753efffcbe9bea81405d580c2ef87881
lixingyangok/learn-python-01
/demo/11-class.py
397
3.84375
4
class Car: def __init__(self, color, address): self.color = color self.address = address def go(self, distance): self.address += distance def show_self(self): print(f'Hi, I\'m a {self.color} car, I\'m at {self.address}') car01 = Car( color='red', address=0, ) car...
9f7add9f682dce3268cf8aff601f7a89b62f0fc0
cheejiayuan512/ictproj
/venv/csvreader.py
1,714
3.625
4
import datetime import csv #get operating time and returns opening and closing timing in a tuple of len 4 def get_operating_time (stall_name): with open('stall_info\\operating_hours.csv') as csvfile: readCSV = csv.reader(csvfile, delimiter=",") for row in readCSV: if stall_name in row: open_hou...
7a5ba69844282b430bffddd8bc59f62b0ece7729
MarcoSampaio/Python-Fatec
/aula02/zip2.py
99
3.90625
4
z=zip("fatec ","santos") for (x,y) in z: print 'Primeira letra '+x print 'Segunda letra '+y
e2e1e193853ad91ddb02faa75c441e451e0b069e
MarcoSampaio/Python-Fatec
/aula02/funcao1.py
447
3.546875
4
def contar(pal): #esse dicionario possuira como indice as letras da palavra pal e como valor a quantidade de frequencia d={} for letra in pal: if letra in d: d[letra]=d[letra]+1 else: d[letra]=1 print d contar("araraquara") #para casa #faca uma funcao toDic...
dffa406f4b6f6f5d0ee226b49991d5b9f625a711
zeydustaoglu/8.hafta_odevler-Fonksiyonlar
/11. OzgunListe.py
507
4.21875
4
# Verilen bir listenin içindeki özgün elemanları ayırıp yeni bir liste olarak veren bir fonksiyon yazınız. # Örnek Liste : [1,2,3,3,3,3,4,5,5] Özgün Liste : [1, 2, 3, 4, 5] try: newListe = [] def ozgunListe(list): for i in list: if i not in newListe: newListe.append(i) ...
e061add5e37ec90668c5b99677252862a7ece79c
zeydustaoglu/8.hafta_odevler-Fonksiyonlar
/7. PisagorUcgeni.py
1,860
3.84375
4
# 1'den 100'e kadar olan sayılardan pisagor üçgeni oluşturanları # ekrana yazdıran bir fonksiyon yazın.(a <= 100,b <= 100) print('''' |\ | \ c b | \ pisagor ucgeni => c^2 = a^2 + b^2 (uzun kenarin karesi kisa kenarlarin karesinin |___\ ...
26d80fb183c8fecb280b97e607c770bd42764c75
EddyAtPessac/Roboc_Python
/robot.py
5,357
3.625
4
# -*-coding:Utf-8 -* # Module de la classe Robot class Robot: """ Classe Robot gere la position et le deplacement du robot l'attribut cmd contient la commande a executer, qui a ete mise en forme et qui est re-actualisée a chaque tour ('s3' devient 's2' au tour d'apres) """ def __init__(sel...
44ffce558430c32a5e1ace6972639e10b2abd701
Luciferochka/Colokvium
/4.py
426
3.71875
4
#Створіть масив з п'яти прізвищ і виведіть на екран ті з них, які починаються з певної букви, яка вводиться з клавіатури. a = [] k = input('Enter your letter') for i in range (5): a.append(input(f'Enter {i+1} surname')) print(f'New array with letter {k}') for i in a: for j in i: if j[0] == k: ...
cf3d5dcebcdcf7c7fbadc60b1a8fc406450ce838
Luciferochka/Colokvium
/11.py
526
3.796875
4
#Дані про температуру води на Чорноморському узбережжі за декаду вересня зберігаються в масиві. Визначити, скільки за цей час було днів, придатних для купання. import numpy as np import random n = 30 a = np.zeros((n),dtype=int) count = 0 for i in range(n): a[i] = random.randint(5,25) if a[i] > 15: coun...
b9d3bd85b2e817b2793d2e832515fd8a3cf2e26f
Luciferochka/Colokvium
/30.py
632
3.5
4
#Обчислити середнє арифметичне значення тих елементів одновимірного масиву, які розташовані за першим по порядку мінімальним елементом. import numpy as np import random n = int(input('Enter your count of els:')) a = np.zeros((n), dtype=int) mid = 0 min = 0 minn = 0 for i in range(n): a[i] = random.randint(-100,100...
92d5355b7f835dd8ab2496217b312a54bf5ccd2f
SaumoPal97/ResumeReviewer
/name_extract.py
224
3.578125
4
mylines = [] with open('resume.txt', 'rt') as myfile: for myline in myfile: mylines.append(myline) print("Name: ", end="") for c in mylines[0]: if c == "|": break; else: print(c, end="")
14e63734422e2d4de024ead0a5b278ffd4c89a63
vo-borodin/StepicAlgorithmTasks
/Calculator.py
1,056
3.5
4
# Калькулятор # https://stepik.org/lesson/13262/step/5?unit=3447 def solution(number): if number == 1: return [1] D = [0] + [i - 1 for i in range(1, number + 1)] prev = [0] * (number + 1) prev[2] = 1 i = 1 while i <= number: indeces = (i + 1, 2 * i, 3 * i) ...
cdfe9e975cf0eed5f60b1514c6a74962ec06086c
armgolf/smartbin2
/smartbinoriginal.py
2,389
3.578125
4
import time #required for pausing the script #open and close plate specified in the argument def openplate(): import openplate #add complete variable for the plate and return it #rotate the top bin compartment def rotate(): import rotate #proximity sensor to identify presence of an object in bin entry co...
ddadcdf3353feb3f8edf9470ddd4c36ac1be6b30
Sksingh97/DSA
/linkedlist.py
1,156
3.984375
4
class Node: def __init__(self, data): self.data = data self.next = Node ten = Node(10) twenty = Node(20) thirty = Node(30) fourty = Node(40) head = ten ten.next = twenty twenty.next = thirty thirty.next = fourty fourty.next = None def print_list(): current = head while(current is not No...
690f4504114a972a0c3aa1b2021b820880eff724
kmurphy13/algorithms-hw
/dac_search.py
736
4.1875
4
# Kira Murphy # CS362 HW2 def dac_search(lst: list, key) -> bool: """ Function that searches for an item in an unsorted array by splitting the array into halves and recursively searching for the item in each half :param lst: The unsorted array :param key: The item being searched for :return: Tr...
65451202d563297d22cc7d546180aea819a9b241
mmtmn/lightsout
/bruteForce.py
7,255
3.921875
4
# made by Thiago M Nóbrega # to run this project: python main.py import numpy as np from game3x3 import play from translator3x3 import translate from random import randrange import os print("") print("We will be solving a 5 by 5 lights out puzzle") print("") print("Instructions:") print("") print("1.) First open the ...
165b7bacbaaeb105c6692b2c36782f5ea567b020
jpherrenknecht/Sciences
/test vectorize.py
190
3.625
4
import numpy as np A=np.array([2,1,7]) def fonction(val): if val<3: val=0 else: val=2*val + 5 return val fonc= np.vectorize(fonction) a= print(fonc(A))
4e309fae20b3d3b79bd3de795600f7aa9f57b000
JInsalaco/SSW555_S20
/gedcom_parser.py
63,257
3.546875
4
'''The purpose of this file is to read and analyze a GEDCOM file. This program will save information about individuals and families in lists (or collections) so that they can be examined later. It can be assumed that the number of individuals in any file is always less than 5000, and the number of families is always ...
467ec5ea3082f911bc83d16fc3490cfa801ec010
jeyansaran620/DSA_python
/Algorithmic toolbox/Week 3/change.py
429
3.890625
4
# Uses python3 def get_change(m): total = 0 count=0 while total < m: while total + 10 <= m: total += 10 count += 1 while total + 5 <= m: total += 5 count += 1 while total + 1 <= m: total += 1 ...
6be51467c7a8ca0dfc96eacf2e19aa24ed765d41
jeyansaran620/DSA_python
/Data Structures/Week 1/tree-height.py
973
3.671875
4
# python3 import sys, threading sys.setrecursionlimit(10**7) # max depth of recursion threading.stack_size(2**27) # new thread will get stack of such size class Node: def __init__(self): self.children = [] def addChild(self, child): self.children.append(child) def ...
6adf6563ccdb58cd2d68707580ec78dbf1cead52
cheung1/python
/4.py
164
3.75
4
#-*-encoding=utf-8 a = 18 print('--------A------') if a<=18: print('我已经成年啦,哈哈 .....') print('--------a------') print('--------B------')
de85cac04313c5572a0cf4953f6e6e7ea620194a
cheung1/python
/system.py
951
3.84375
4
#the function has parameter not has a return value def menu(): print '-'*30 print ' card mangement system V8.8' print '1.add card' print '2.delete card' print '3.change card' print '4.search card' print '5.read each card' print '6.quit the system' print '-'*30 #get users' information #this function does ...
5ceff881fad153efd3b9ce95dfd6b77c7b9f55fa
cheung1/python
/help.py
441
4.15625
4
#1.write the triangle print code # notice: when you just define, it cannot execute #2.define a function def printTriangle(): 'this is the help document ' print ' * ' print ' * * ' print '* * *' #3.invoke the function #notice:only can via the invoke to use the function # invoke the function: write the functio...
aa7ed7d0d5a46b1cc111924eb718ea6d55ee0804
mahewi/TKO2096
/sourceCodes/KNNCrossValidation.py
4,431
3.953125
4
''' Authors: Marco Willgren, 502606 Jarno Vuorenmaa, 503618 Exercise 1: Application of data analysis K-nearest neighbors and cross-validation - Program your own implementation of kNN. Preferably with python. - Select a data set of your choice from the UCI machine learning repository: \url{http://archive.ics...
5c842446ee666fb6adc0d7a163d48243965e1a97
joskid/python-rdf2tensor
/test/sqlite_read_test.py
267
3.578125
4
import sqlite3 conn = sqlite3.connect('dictionaries.db') c = conn.cursor() print "ENTITIES" for row in c.execute('SELECT * FROM entities ORDER BY id'): print(row) print "\nPROPERTIES" for row in c.execute('SELECT * FROM properties ORDER BY id'): print(row)
53f8016596756d44b8e46cc3aa53dbc24b8fc342
SmileAnage/redis
/redis/day02/03_hash+redis+mysql.py
1,256
3.65625
4
""" hash + redis + mysql 联合查询数据 """ import redis import pymysql # 连接redis r = redis.Redis() # 连接mysql p = pymysql.connect( host='127.0.0.1', user='root', password='123456', database='mysite', ) # mysql创建游标 cursor = p.cursor() # 1.输入要查询的用户名 # 2.先到redis查询 # 3.redis如果没有查找到,再到MySQL查询 # hash: key field ...
27fb0ce96666f9df063b1fd66b0eb8b77f0aeb75
vtminhvt/Python-Code
/paddlePong (copy).py
2,406
3.65625
4
from Tkinter import * master = Tk() import time frame = Canvas(master, width=1000, height=600, bg="black") frame.pack() frame.create_rectangle(50, 50, 950, 500, outline="white") frame.create_line(500, 50, 500, 500, fill="white", dash=(2,4)) paddle1positionY1 = (325) paddle1positionYn = (275) gameBallX1 = (505)...
9582743d3fa7c883b6df95f5fad6bad00c5cc60a
abhisjai/python-snippets
/MIT 6.00.1X/Excercises/Week 2/W2E - gcd recurr.py
644
3.984375
4
# Source: # Write a function gcdRecur(a, b) that implements this idea recursively. This function takes in two positive integers and returns one integer. # A clever mathematical trick (due to Euclid) makes it easy to find greatest common divisors. Suppose that a and b are two positive integer # If b = 0, then the answ...
520ac63216a371940b7c98b2a152bd67b73c1bff
abhisjai/python-snippets
/Exercise Files/Ch2/functions_start.py
1,780
4.78125
5
# # Example file for working with functions # # define a basic function def func1(): print("I am a function") # func1() # Braces means to execute a function # value on console was any print command inside the function # If there was any return value, it was not assigned to any variable # print(func1()) # Execu...
4239a7ae04f3adc3b0546b9e18d03d7dbd90946c
abhisjai/python-snippets
/Misc Code/python-tuples.py
1,180
4.28125
4
# Task # # Given an integer n and n space-separated integers as input, create a tuple t, of those n integers. Then compute and print the result of # Note: hash() is one of the functions in the __builtins__ module, so it need not be imported. # Input Format # The first line contains an integer, n, denoting the number of...
4bb31a2053c5f0629fd7e98907bacc6fe40c036c
abhisjai/python-snippets
/Python Essential/Exercise Files/Chap05/arithmetic.py
535
3.90625
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ x = 5 y = 3 z = x + y print(f'result is {z}') # Arithmatic Operators # +, -, *, /, // (Integer division - use to get result as integer eg: 3//2 = 1), % (remaineder or modulo), ** (exponent) # =- or =+ (urinary) # Conditional Operators # Comparison Ope...
9b5aae311a253e7f46830efdb6e8bc2c00d67f9e
abhisjai/python-snippets
/Python Essential/Exercise Files/Chap03/sequence.py
603
4.15625
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # x = [ 1, 2, 3, 4, 5 ] # for i in x: # print('i is {}'.format(i)) x = {"one": 1, "two": 2, "three": 3, "four": 4} # for i in x: # print("key {}".format(i)) # for key, value in x.items(): # print("key {0:<5} value {1:<5}".format(key, value)...
494f69e2bbd9f3410ebd59b3c355e8bcb96a0ce0
abhisjai/python-snippets
/Python Essential/Exercise Files/Chap05/boolean.py
592
4.03125
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ a = True b = False x = ( 'bear', 'bunny', 'tree', 'sky', 'rain' ) y = 'bear' if a or b: print('expression is true') else: print('expression is false') if y in x[0]: print('expression is true') else: print('expression is false') if 'tre...
6d067b8a432b0de7e15cc10fdf86884d08649ffc
MinasKatsiokalis/encryption-algorythms
/crypto_2.py
4,595
3.59375
4
""" ---------------------------------- Minas Katsiokalis AM: 2011030054 email: minaskatsiokalis@gmail.com ---------------------------------- """ import pickle import crypto_1 import random from collections import namedtuple """ ----------------------------------------- Helpfull ...
f86712492d57ccbe12766e4a5586511650d11110
lcharleux/MED08_Python_SISEO
/demos/personnes.py
792
3.578125
4
# -*- coding: utf-8 -*- """ Objets avec Python @author: lcharleux """ class Personne(object): def __init__(self, nom, prenom, numero): self.nom = nom self.prenom = prenom self.numero = numero def __repr__(self): return "Je suis {0} {1} (tel:{2})".format(self.nom, self.prenom, self.numero) ...
768538fc013e5c66096312236cec7c7732e7bfc3
dhatch207/PracticeCode
/EulerPhi.py
519
3.53125
4
# Simple python implementation of Euler Phi function # Math sourced from Elementary Number Theory by Kenneth H. Rosen # 2020 Dominic Hatch dhatch207 dmh207@gmail.com import BruteforceFactorization def EulerPhi(n): # does the math. takes number, returns value of euler phi function x = n for i in Bruteforce...