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
eccb3a6e8b486a7eb1541f62ef50243d741223f3
devcordde/adventofcode-20
/Day-06/python/paul2708/solution.py
804
3.515625
4
from assertions import assert_equals from input_reader import read_split_lines from printer import aoc_print groups = read_split_lines("day06") # Part one total_sum = 0 for group in groups: votes = set() for single_person in group: for question in single_person: votes.add(question) to...
70b4d8db824851add6991ab3d0456f6f04eafdee
rhythm244/30-Days-Of-Python
/06_Day_Tuples/tuple_exercise.py
398
3.625
4
family = tuple() family = ('wasawat', 'jenjira', 'siriwan', 'vichien', 'grittaporn') print(len(family)) #TypeError: 'tuple' object does not support item assignment # family[0] = 'thong' print(family) # fruits = ('banana', 'orange', 'mango', 'lemon') # vegetables = ('Tomato', 'Potato', 'Cabbage','Onion', 'Carrot')...
a33c9ad51711e03c43a8c3d2a0af4adc165a9fec
adnanbaysal/truchet-tiles
/TruchetWithPyGame/Complex.py
2,312
3.71875
4
class ComplexTypeError(TypeError): pass class Complex: """Class of complex numbers and operations""" def __init__(self, re, im): self.re = re self.im = im @classmethod def check_complex_type(cls, x): if type(x) != cls: raise ComplexTypeError ...
235ac2bf53b66b2df9d10a07bdfe0ccc66181a97
rajal123/pythonProjectgh
/LabExercise/q7.py
897
4.40625
4
''' you live 4 miles from university. The bus drives at 25mph but spends 2 minutes at each of the 10 stops on the way. How long will the bus journey take? Alternatively,you could run to university.you jog the first mile at 7mph;then run the next two at 15mph;before jogging the last at 7mph again.Will this be quicker or...
1a099b648d9755588ceb0fa617488f90a3581082
nottyStep/Warriors
/Warriors.py
8,419
3.5
4
import random import sys # for ASCII art import matplotlib.pyplot as plt # for image display from colorama import init # for the ASCII art init(strip=not sys.stdout.isatty()) # strip colors if stdout is redirected from termcolor import cprint, colored # for the ASCII art from pyfiglet import figlet_format # for t...
f03e8ae76243118b2db508cafe39e57d54d16e25
SmashAF/Gaming_Code
/game.py
4,009
3.84375
4
''' Purpose: compare results of random game outcomes between two players with answers provided in same order vs different order for each player, and at different range of event numbers. Hypothesis: With less events, results will be more diverse when one list of outcomes is scrambled. When number of events gets the s...
7c24d6be82ef88ac8eca757f0ad8ee4b1a171664
dystopia-blues/maze-generation-algorithms
/maze_generation.py
6,261
3.71875
4
#import random def print_debug(str, end="\n"): print("\033[93m{}\033[00m".format(str), end=end) def sort_set(input_set): l = list(input_set.copy()) l.sort() return l class Maze(object): def __init__(self, width, height): self.height = height self.width = width self.size =...
f2f920a438ecc731ef3d184d6bacfd49396cae7d
malhar715/path_visualizer
/main.py
2,039
3.546875
4
from grid import * def main(screen, width): rows = 50 grid = make_grid(rows, width) start_node = None end_node = None running = True started = False while running: #main loop draw(screen, grid, rows, width) for event in pygame.event.get(): if event.type == py...
452f6815091a33ed34b1fc306c5082fe99465dc3
BrunoKamui/introductory-python-exercises
/Ex014.py
502
3.671875
4
#Ex014: Crie expressões regulares para extrair as seguintes informações de um texto (use a função findall): - Números - CEPs - URLs import re frase = "Enviaram 12 cartas para Rua das Flores, 23. Cep: 45220-010 e cada uma delas citava um destes 3 sites: https://www.google.com.br https://www.youtube.com https://www.fac...
552a746afece503a3b96cb75eebe71ab6c32f4c4
BrunoKamui/introductory-python-exercises
/Ex015.py
1,197
3.8125
4
#Ex015: Crie uma classe chamada aluno com os seguintes atributos: - Nome - Nota 1 - Nota 2 - Crie um construtor para a classe (__init__) #Crie as seguintes funções (métodos): - Calcula média, retornando a média aritmética entre as notas - Mostra dados, que somente imprime o valor de todos os atributos #- Resultado, que...
c5943eb0c54196e93f9229c562ac128990fae061
Thieberius/python
/gui/listbox.py
537
3.515625
4
import tkinter as tk fenster = tk.Tk() def ausgabe(): print(lbox.curselection()) aktuell_ausgewaehlt = lbox.curselection() textausgabe = tk.Label(fenster, text=aktuell_ausgewaehlt, bg="orange") textausgabe.pack() einkaufsliste = ["Mehl", "Butter", "Hefe", "Wasser", "O-Saft", "Haferflocken"] lbox = t...
81ef6c7c12a40ba95d243b393178e1f1bac0df6f
Thieberius/python
/schleifen/for-schleife.py
201
3.8125
4
vornamen = ['Axel', 'Elke', 'Martin'] for nr, einzelwert in enumerate(vornamen): if einzelwert == "Axel": print(nr, "Ich") else: print(nr, einzelwert) print("Schleifenende")
e885c9d41184f54b4543454752406c2fccea1cef
KhalfaniW/Get-Sales-Tax
/GET Tax (Beautiful Soup)
661
3.734375
4
#!/usr/bin/python import urllib2 from bs4 import BeautifulSoup tax=0 input_state=raw_input("what is your state\n") #extract the tax data from this website I found from searching Bing soup = BeautifulSoup(urllib2.urlopen('http://www.salestaxinstitute.com/resources/rates').read(),"lxml") taxtable =soup.find_all('tab...
56b5482b39acc25c53af9dde98302db19a5106b2
TAMU-IEEE/programming-101-workshop
/Workshop 2/decisions_2.py
676
4.4375
4
'''Gets a number from the user, and prints “yes” if that number is divisible by 4 or 7, and “no” otherwise. Test Suite: inputs: outputs: domain: -7 "yes" Negative factors 1 "no" Positive integers, nonfactors 0 "no" Zero (border case) 4 "yes" Positive integers, factors of 4 7 "yes" Positive integers, factor...
7b580887c8858cc36fa63eed979dedabb981e5f4
TAMU-IEEE/programming-101-workshop
/Workshop 3/funcs_2.py
589
4.3125
4
'''Write a function that returns two given strings in alphabetical order. Test suite: input: output: domain: "hi", "man" "hi man" ordered "zz", "aa" "aa zz" unordered ''' # think about how we compare characters and their hidden ascii value! def alphabetizeMe(string1, string2): for i in range(0, len(...
9a1086fa8bf93460c0740453e8ed40916de608dc
auspic7/complier-scanner
/lexical_analyzer.py
4,515
3.546875
4
import argparse import os from Automata import Life from PredefinedDFA import DFAs, DFAs_solution from tabulate import tabulate parser = argparse.ArgumentParser() parser.add_argument('input_file_name', help='Desired file name to analyze', type=str) parser.add_argument("-v", "--verbose", help="increase output verbosity...
037c479a69f771493e8f65d932dea3baa709c458
DJEk200/GB_lesson3
/lesson3_tack8.py
811
3.703125
4
""" Задача № 8 Матрица 5x4 заполняется вводом с клавиатуры, кроме последних элементов строк. Программа должна вычислять сумму введенных элементов каждой строки и записывать ее в последнюю ячейку строки. В конце следует вывести полученную матрицу.""" matrix = [] for i in range(4): matrix.append([]) su...
ea4d86b12451cade7f482d4fa8e3234517d601ef
ShriPunta/Python-Learnings
/Network Basics/Reverse Shell/Server.py
2,158
3.890625
4
#Reverse Shell uses a CLIENT initiated connection #It connects to the server #As it is initiated from the client, the firewall is bypassed and server can get full access to the client import socket # This sys module contains functions which you would run in a command line. You can run them from Python too import sys ...
e5f75a207712c3866750c0e4ff1392054d9a990e
ShriPunta/Python-Learnings
/Python Basics/Phunctions.py
1,507
4.1875
4
#Each Function named with keyword 'def' def firstFuncEver(x,y,z): sum=x+y+z return sum #Scope of Variable is defined by where its declaration in the program #Higher (higher from start of program) declarations means greater scope of variable #if you give value in the function start, it is the default value de...
3bdb32420ca863e1f476aa81c72db98a23cbbc5f
jsrikrishna11/python-problem-solving
/find-pairs.py
346
4.09375
4
''' Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. ''' input = [2,4,5,1,7,9,3] sum= 5 def find_pairs(array, sum): for i in array: if sum-i in array: print (i,sum-i...
1d677374fcbf189f62816f8e42c3ab292af7faf5
metajinomics/ncbi_tools
/blast_to_fna.py
836
3.609375
4
#!/usr/bin/python # this script use blast output to find nucleotide sequences # usage: python blast_to_fna.py blast ffn > output # example: python blast_to_fna.py EC_3.2.1.21.out bacteria.555.genomic.ffn import sys def main(): # read blast out d = {} blast = open(sys.argv[1],'r') for line in blast: ...
15525e71579f92e8c9d2a8939b597d2c78065679
nickgrummon/kata-babysitter
/BabySitterFeeCalculator.py
4,081
3.6875
4
#!/usr/bin/env python import datetime class BabySitterFeeCalculator: """ This class will calculate the nightly charge of a babysitter who: starts no earlier than 5:00PM leaves no later than 4:00AM gets paid $12/hour from start-time to bedtime gets paid $8/hour from bedtime to midnight gets...
c549d3f971fd41bc5c7633e06023545c04494c79
Diinal/stepik_scripts
/binary_search.py
371
3.6875
4
def search(array, k): l = 1 r = len(array) while l <= r: m = (l+r) // 2 print(l, r, m) if m == len(array): return -1 if array[m] == k: return m + 1 elif array[m] > k: r = m - 1 else: l = m + 1 return -1 arra...
47c450984b7263d1072fd232397d3c6645b3edc0
Basileus1990/Receipt
/ShopAssistant.py
2,435
4.15625
4
import Main from ChosenProducts import ChosenProduct # class meant to check which and how many products you want to buy. then he displays a receipt def ask_for_products(): list_of_chosen_products = [] while True: Main.clear_console(True) chosenNumber = chose_product() if chos...
7cd4b45dca48c2637a9fd1f4c04606092d026aad
Balr0g404/mypysql
/mypysql.py
7,128
3.59375
4
#!/usr/bin/python3 #coding : utf-8 """ Library based on mysql.connector to interact with mysql as simply as possible You can easily perform pre-made querys, or create your custom querys using the mysql.connector library with the database.cursor attribute Dev : Balr0g404 """ ####### Class import mysql.connector impor...
8aabea0db0dd51bf161911cba4dfc245ad245879
SAN06311521/compilation-of-python-programs
/my prog/factorial.py
155
4.34375
4
num = int(input("enter the number whose factorial is to be calculated: ")) product = 1 for i in range(num): product = product * (i+1) print(product)
45605df8e1fe5fed4b3f6ab3c3681c6789e83470
SAN06311521/compilation-of-python-programs
/my prog/summation.py
119
3.953125
4
num1 = int(input("enter the first number: ")) num2 = int(input("enter another number: ")) add = num1 + num2 print(add)
1d86e2c7234b1659cfb9ec11c3421f8e6f9333fb
SAN06311521/compilation-of-python-programs
/my prog/sum_of_digits.py
259
4.21875
4
num = int(input("enter the number whose sum of digits is to be calculated: ")) def SumDigits(n): if n==0: return 0 else: return n % 10 + SumDigits(int(n/10)) print("the sum of the digits is : ") print(SumDigits(num))
a7fca4dd7d6e51fa67c3e22770a6a7b9cbb24fb3
SAN06311521/compilation-of-python-programs
/my prog/leap_yr.py
439
4.1875
4
print("This program is used to determine weather the entered year is a leap year or not.") yr = int(input("Enter the year to be checked: ")) if (yr%4) == 0 : if (yr%100) == 0 : if (yr%400) == 0 : print("{} is a leap year.".format(yr)) else: print("{} is not a leap year.".for...
9012204f8bde854d3d50139ded69bb038aa58f66
SAN06311521/compilation-of-python-programs
/my prog/class_circle.py
475
4.375
4
# used to find out circumference and area of circle class circle(): def __init__(self,r): self.radius = r def area(self): return self.radius*self.radius*3.14 def circumference(self): return 2*3.14*self.radius rad = int(input("Enter the radius of the circle: ")) NewCircle...
5a12658f838430240703eb71b3b397161acf05a9
Josuehidal/Programaci-n-
/python Quiz 3 1.py
596
4
4
#Entradas: Tres numeros enteros #Salidas: Producto y Promedio de los numeros de entrada #Restricciones: Numeros enteros y la suma de los dos primeros numeros debe ser mayor que el tercer numero. def numQuiz(a, b , c): x = a y = b z = c if(x + y > z): Producto = x * y * z Promedi...
8fa740ab1602b634babf4abc4d4042026eec94ff
Drabblesaur/PythonPrograms
/CIS_40_ProgramAssignments/P6.8.py
798
3.890625
4
# P6.8 JOHNNY TO # Add Alternating Sums def altSum(list): Sum = 0 for i in range(len(list)): if i % 2 == 0: Sum += list[i] else: Sum -= list[i] return Sum numList = [] endListTrigger = False print("Finish Input-->(E)") while endListTrigger == False: ...
7e0ddbce3494562338b900cdf6d23db9c686f1dc
Drabblesaur/PythonPrograms
/CIS_40_ProgramAssignments/Chapter2Programs/P2.6.py
633
4
4
#CIS_40 Johnny To CONVERSION_MILES_CONSTANT = 1609.344 CONVERSION_FEET_CONSTANT = 3.281 CONVERSION_INCHES_CONSTANT = 39.37 Input_Meters = float(input("ENTER MEASUREMENT IN METERS:")) Convert_Miles = Input_Meters/CONVERSION_MILES_CONSTANT Convert_Feet = Input_Meters*CONVERSION_FEET_CONSTANT Convert_Inches = Input...
63fb0b565a06476d607c5fca30b818210a8e0fc3
Drabblesaur/PythonPrograms
/CIS_41A_TakeHome_Assignments/CIS_41A_UNIT_I_TAKEHOME.py
5,053
3.984375
4
''' Johnny To CIS 41A Fall 2019 Unit I take-home assignment ''' # The LibraryPatron class has the following four methods: __init__, checkOutBook, returnBook, and printCheckedOutBooks. class LibraryPatron: # The __init__ method should have the parameters self and name, and should store the name as an attribute (n...
fca5c7df62e6aedbe5668893f8417239ea99eb98
Drabblesaur/PythonPrograms
/CIS_40_ProgramAssignments/Chapter3Programs/P3.3.py
724
3.796875
4
#CIS_40 Johnny To Input_Integer = int(input("Enter an integer:")) if(Input_Integer<0): Input_Integer = Input_Integer*-1 if(Input_Integer>0): Int_Size = "one" if(Input_Integer>=10): Int_Size = "two" if(Input_Integer>=100): Int_Size = "three" if(Input_Integer>=1000): Int_Size = "four" if(I...
814bea91e5a472ce2c8f0be3337ab284e1c1498d
Drabblesaur/PythonPrograms
/CIS_40_Johnny_To_Final_1/Driver.py
3,853
3.953125
4
#CIS 40 Final Johnny To #Driver Code to Demo Order class from CIS_40_Johnny_To_Final_1 import Order if __name__ == "__main__": while True: order = Order() order.display_menu() order.prompt_type() order.prompt_menu() order.calculate() order.print_...
ca041f935a861dcd3fea9fc704f7316f574d561e
Drabblesaur/PythonPrograms
/CIS_41A_Inclass_Assignments/UnitH2.py
1,375
3.859375
4
#Part 2 - Different ways of working with Attributes #Here we explore different ways to work with Python attributes. Note that, while one of the approaches we are using is set/get, this approach is generally deprecated in favor of the simpler dot notation. #Create a StateData2 class with the following methods: __init__...
0089887361f63ff82bfb55468aa678374c562513
Drabblesaur/PythonPrograms
/CIS_41A_TakeHome_Assignments/CIS_41A_UNIT_B_TAKEHOME_SCRIPT2.py
2,090
4.125
4
''' Johnny To CIS 41A Fall 2019 Unit B take-home assignment ''' # SCRIPT 2 ''' Use three named "constants" for the following: small beads with a price of 9.20 dollars per box medium beads with a price of 8.52 dollars per box large beads with a price of 7.98 dollars per box ''' SMALL_BEADS_PRICE = 9.20 ...
9fd272a7442c010352f6f50ced88bd0d673f7fff
Drabblesaur/PythonPrograms
/CIS_41A_Inclass_Assignments/UnitG2.py
1,019
3.78125
4
import csv population={} with open('Cities.csv', 'r') as f: next(f) for line in f: (name,city,pop)=line.split(',') population[(name,city)]=int(pop) f.close for i in population: print(i[0],i[1],population.get(i)) cityIn = input("Please enter a city:").strip() stateIn = input("Please ente...
44fc3757ed5e71e6696a11d583dcd796fbbf5f44
Drabblesaur/PythonPrograms
/CIS_41A_Inclass_Assignments/UnitA.py
353
3.78125
4
''' Johnny To CIS 41A Fall 2019 In-Class Assignment 1 ''' height = 2.9 width = 7.1 area = height*width print("Height: %5.1f" % height) print("Width: %6.1f" % width) print("Area: %9.2f" % area) height = height//2 width = width//2 area = height*width print("Height: %5.1f" % height) print("Width: %6.1f" %...
624203c6e03c9dd3c873516fd126ee41b73a8956
tlapusan/woodpecker
/woodpecker/sklearn/randomforest/random_forest_structure_classifier.py
4,740
3.796875
4
import statistics import matplotlib.pyplot as plt class RandomForestStructureClassifier: def __init__(self, rf, train_dataset, features, target): self.rf = rf self.train_dataset = train_dataset self.features = features self.target = target def show_features_importance(self, b...
bfe4e70d1f3d73c7f63c50a9d3d518b0ed1357c1
leofigy/PythonCourse
/basic scripts/multiple.py
350
3.578125
4
class basic(object): def __init__(self): print "at parent" def foo(self): print "at foo" class daughter(basic): def __init__(self): print "at daughter" super(daughter, self).__init__() def foo(self): print "at foo daughter" super(daughter, self).foo() def main(): son = daughter() son.foo() if _...
8aeedc8a81d4ee75649f3abf576f3f9c4a251b46
alexvaron/Python-Projects
/Queens.py
1,213
3.75
4
# problem4.py class Queens: def init(self, size): self.size = size self.answer = 0 self.result() def check(self, pos, row, col) for i in range(row): if pos[i]== col or \ pos[i] - i == col - row or \ pos[i] + i == col + row: ...
6a43baa5d60422942c2106a30362eb61c99a9251
tusharmakkar08/Vector-Quantization
/test.py
1,082
3.5
4
''' Helper class for making test cases Author: Tushar Makkar <tusharmakkar08[at]gmail.com> Date: 12.02.2015 ''' import random def makeTestCases (rangeOfFeatures ,numberOfSamples, numberOfFeatures, numberOfTestCases): ''' Returns the matrix of Test Cases Args: rangeOfFeatures : The numerical range...
b115a0b888b6952be7d920df1179294fe91ac856
TomMonks/gurobi-cvrp
/metapy/local_search/two_opt.py
2,713
3.578125
4
# -*- coding: utf-8 -*- """ local search implemented with 2-opt swap 2-opt = Switch 2 edges @author: Tom Monks """ import numpy as np class OrdinaryDecentTwoOpt(object): """ Local (neighbourhood) search implemented as first improvement with 2-opt swaps """ def __init__(self, ob...
59bbaebdfd555c11a4e9da15bfe9998e77b430fb
tahentx/python.dev
/self_checkout.py
129
4.03125
4
a = input("Enter the price of item 1:") b = input("Enter the quantity of item 1:") def multiply(a,b): return a*b multiply(a,b)
1f9c09df9d10bbf201aa7734aa26e23ffcd0b6ee
shadow625/algorithms
/dothandle.py
2,121
3.65625
4
#****************************************************** # you jusst need to use the two important function add_edge(a,b) and find_ALL_routes(y) #i give an example at the end of the program # class Graph(object): """docstring for Graph""" def __init__(self): super(Graph, self).__init__() self.inventory=[] sel...
5ea9d981bf73059528fad775156fbc4c80198652
klatimer/robot-data-visualizer
/tools/view_lidar.py
3,148
3.5
4
"""lidar_viewer visualizes lidar data by ploting it in matplotlib window.""" import datetime from matplotlib.patches import Arc import matplotlib.pyplot as plt import numpy as np def hokuyo_plot(axis): """ Creates plot of xy lidar data with lidar range arc plotted in blue line. Keyword arguments: ...
89de8665a42ad471dd674cbd64d22645708c84de
klatimer/robot-data-visualizer
/tools/data_loader.py
3,070
3.96875
4
""" This class is responsible for precessing data correctly corresponding to the user's choice. """ import numpy as np import os # __all__=['DataLoader'] DEGREE = 180 class DataLoader: """ A class to load data according to user's choose, and do some preprocess to data. It can be usedin this way: datal...
e430729e07dc10717ef0be62f96ab9ac9278670b
dylanbrams/Classnotes
/practice/change/pig_latin.py
2,056
4.40625
4
''' Pig Latin: put input words into pig latin. ''' VOWELS = 'aeiouy' PUNCTUATION = '.,-;:\"\'&!\/? ' def find_consonant(word_in): """ :param word_in: :return: >>> find_consonant("Green") 2 >>> find_consonant("orange") 0 >>> find_consonant("streetlight") 3 >>> find_consonan...
113d9e5a52832d265ebf5b39ee43d5f1c6cec80e
dylanbrams/Classnotes
/practice/change/PersonTypes.py
1,171
3.875
4
class Person (object): def __init__(self, name, email_address): self.name = name self.email_address = email_address def __repr__(self): return ('Student(' + self.name + ',' + self.email_address + ')' ) def __eq__(self, other): return ((self.name == other.name) and (self.emai...
4ec33b165f997059511ba2e9c80da946e1700af0
dylanbrams/Classnotes
/practice/change/CheckedPractices.py
1,036
3.71875
4
ROW_COUNT = 6 COL_COUNT = 7 def check_if_move_made(local_list, col_num, row_num): if (len(local_list[col_num]) > row_num): return True else: return False def convert_to_color(move_number): if (int(move_number) % 2 == 0): return 'Y' else: return 'R' def make_board_variab...
83dd012801a63115245a8417ed6ba625fee50151
dylanbrams/Classnotes
/FirstCode/codeone.py
408
3.875
4
""" Converts Gallons to Liters""" gallons_user_input = 4 #gallons_user_input #gal #drawline(color, origin, angle, equation, intensity, fade, owner) gallons_in = input("How many gallons do you want to convert?") rounded_liters = round(float(gallons_in) / .264172, 3) print (gallons_in + " gallons is " + str( rounded_lite...
8f78b153817d1391bf3b42649f7d82439ced7db6
dylanbrams/Classnotes
/practice/change/sum_pairs.py
853
4
4
""" Sum Pairs: Input a list of integers followed by a single integer ([1, 2, 3, 4, 6, -2, -3, -1, 5, 9, 0], 4) Check whether the list of integers contains any pairs that sum into the single integer. Output those pairs. """ import itertools myNumbers = (1, 2, 3, 4, 6, -2, -3, -1, 5, 9, 0) myResults ...
4cfc0f090f2917a1aeda0db7a6ab6b473fd0c694
csj101/python-design
/xiushiqi.py
379
3.734375
4
#-*- coding:utf-8 -*- import functools def memoize(func): known = dict() @functools.wraps(func) def memoizer(*args): if args not in known: known[args] = func(*args) print(known[args]) return known[args] return memoizer #@memoize def nums(n): assert(n >= 0) return 0 if n == 0 else n+nums(n-1) ...
a326fcb2e85ed246684b4864f86a23b63e648b4c
makrand12/python_guided_project
/q01_create_class/build.py
2,120
3.90625
4
import math class complex_number: def __init__(self, real=0, imag=0): self.real = real self.imag = imag def __add__(self, other): return complex_number(self.real + other.real, self.imag + other.imag) def __sub__(self, other): return complex_number(s...
e2c3b1b71f2d6ad124d3834ba1562bd974e0a0ee
Mary-raccoon/python_dojo
/fundamentals/bubble_sort.py
230
3.96875
4
arr = [3,5,2,7,8,4,1] def bubbleSort(arr): for k in range(len(arr)-1): for i in range(len(arr)-1-k): if arr[i] > arr[i+1]: arr[i], arr[i+1] = arr[i+1], arr[i] print(arr) bubbleSort(arr)
16a5c124472306ab1cbd48946b67cb16811a2cb8
1ohpw/ShowMeTheDataStructures
/problem_1.py
2,630
3.75
4
class Node(object): def __init__(self, key, value): self.key = key self.value = value self.prev = None self.next = None class DLList(object): def __init__(self): self.sentinel = Node(None, None) self.sentinel.prev = self.sentinel self.sentinel.next = self...
a16a7b1c91095d5bb7ebcd84978b365a711ef433
cuauv/software
/vision/framework/transform.py
4,404
3.5625
4
import cv2 import numpy as np def simple_gaussian_blur(mat, kernel_size: int, std_dev: float): """ Blurs an image using a Gaussian filter with a square kernel :param mat: input image :param kernel_size: size of convolution kernel (must be odd) :param std_dev: standard deviation of Gaussian kernel ...
dcc5b46e7d182c54ed1a6b2f90cb63c5344bc02b
bujingyi/reinforcement-learning-frameworks
/env.py
1,691
3.515625
4
class Environment: """ Reinforcement learning environment """ def __init__(self): # TODO: Environment initializer # initialize the environment self.init_state = self.reset() def initialize_state(self, state_dim): """ Randomly generate initial state. :...
d79f9c311cf86e90ed226128854009baf49cb63c
rolph-recto/markov-text
/markov.py
3,937
3.8125
4
#markov.py #Markov text generator import sys import os.path import random def create_markov_map(filename, chunk_size): """build a Markov map of a text""" markov_map = {} #build word list with open(filename) as f: data = f.read(-1) word_list = data.split() #iterate through the word list #we're going to i...
662c49ef178feebda492cde20736476af7c06c19
benm97/Python
/ex10/ex10.py
9,780
3.765625
4
####################################################################### # FILE: ex10.py # WRITER: Benjamin Maman, benm, 341145811 # EXERCISE: intro2cs ex10 2017-2018 # DESCRIPTION: exercise 10 ####################################################################### import copy import itertools INCREASE = 1 ...
23c9ca290129d792b3e206407d9798c76388c32c
azhagumanikandan/manikandan
/hun7.py
293
3.65625
4
def portt(n2,array): for i in range(0,n2-2): for j in range(i+1,n2-1): for k in range(j+1,2): if array[i]+array[j] == array[k]: print(array[i], array[j], array[k]) n2=int(input()) array=list(map(int,input().split())) portt(n2,array)
f42d8b933ccff76fed28a36f38e973a714b1ec45
azhagumanikandan/manikandan
/14ply.py
169
3.53125
4
#azhagu d=int(input()) e=str(input()) e=list(e) for i in e: if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u'): e.remove(i) k=e[::-1] print("".join(k))
6daf4406ce73b4a37cadaa703fcd2c6c6ddf17e3
PPACI/mojito
/mojito/event/EventGenerator.py
538
3.515625
4
from abc import ABC, abstractmethod from typing import Any, Dict, List class EventGenerator(ABC): @abstractmethod def generate(self) -> Dict[str, Any]: """ Generate a random event :return: a dict like {property_name: value} """ raise NotImplementedError @abstractm...
7a9a7a54b79ad81ce6c7e1dcacb1e51de53f3043
sshashan/PythonABC
/factorial.py
491
4.375
4
print("Factorial program") num1= int(input("Enter the number for which you want to see the factorial: ")) value=1 num =num1 while(num > 1): value=value*num num =num - 1 print("Factorial of "+str(num1)+" is: " ,value) def factorial(n): return 1 if(n==1 or n==0) else n * factorial(n-1) ...
d337fc0ae229454fb657c1830189c31bb12d2f2e
sshashan/PythonABC
/Person_dict.py
353
4.25
4
print("This program gets the property of a person") person={"name":"Sujay Shashank","age":30,"phone":7744812925,"gender":"Male","address":"Mana tropicale"} print("What information you want??") key= input("Enter the property (name,age,phone,gender,address):").lower() result=person.get(key,"Info what you are look...
d86c1fbb67e71e269e118cc9a6565456c57cd39c
sshashan/PythonABC
/calculator.py
713
4.34375
4
print("Calculator for Addition/Deletion/Multiplication/Subtraction") print("Select the operation type") print("1.Addition") print("2.Subtraction") print("3.Multiplication") print("4.Division") user_opt=int(input("Enter your operation number: ")) num1= int(input("Enter the first number :")) num2= int(input("...
cbb490fa22c8b343f77e23081b7ceff669bf1882
sshashan/PythonABC
/kmstoMile.py
124
3.859375
4
print("KMS to Mile Convertor") kms = float(input("Enter the kms here:")) print(kms,"kms = ",round(kms/1.609344,4))
3647979b766e764decfc12db3b0a276c8d3e297d
hadarkahn/Matala3
/Matala3.py
1,975
3.53125
4
# -*- coding: utf-8 -*- """ Created on Wed May 5 13:28:40 2021 @author: Hadar """ ######file= input("enter file name: ") file='�צאט WhatsApp עם יום הולדת בנות לנויה.txt' openFile= open(file, 'r', encoding= 'utf-8') fileRead=openFile.read() fileLines=fileRead.split('\n') ##part 1## #find contact list contacts=list() ...
afde2cea346697fc1f75f8427d574514d9941d76
greenfox-zerda-lasers/gaborbencsik
/week-03/day-2/38.py
259
4.125
4
numbers = [7, 5, 8, -1, 2] # Write a function that returns the minimal element # in a list (your own min function) def find_min(list): mini = list[0] for x in list: if x < mini: mini = x return mini print find_min(numbers)
54a03000772ae9850b78ab587c62a51cd786c61d
greenfox-zerda-lasers/gaborbencsik
/week-04/day-1/01_io/crypto_1dup.py
475
3.796875
4
# Create a method that decrypts the texts/duplicated_chars.txt def decrypt(file_name): file_name = open('texts/duplicated_chars.txt', 'r') rows = file_name.readlines() result = "" for line in rows: for index, character in enumerate(line): # enumerate = range(len(line)) if ind...
051d2effa49713986d3bc82a296ceb18f3b825ef
greenfox-zerda-lasers/gaborbencsik
/week-04/day-3/09.py
618
4.25
4
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 # create a 300x300 canvas. # create a square drawing function that takes 1 parameter: # the square size # and draws a square of that size to the center of the canvas. # draw 3 squares with that function. from tkinter import * root = Tk() size = 300 canv...
730dabc7497180a3b6314421119d89d7735e2684
greenfox-zerda-lasers/gaborbencsik
/week-04/day-4/04-n_power.py
337
4.1875
4
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 # 4. Given base and n that are both 1 or more, compute recursively (no loops) # the value of base to the n power, so powerN(3, 2) is 9 (3 squared). def powerN(base,n): if n < 1: return 1 else: return base * powerN(base,(n-1)) pri...
bb3026e157e91b437487d415e4d8147d7703b375
greenfox-zerda-lasers/gaborbencsik
/week-05/day-1/gabor_bencsik_test.py
1,523
3.59375
4
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 from gabor_bencsik_work import anagramm, count_letters import unittest class TestAnagramm(unittest.TestCase): def test_anagramm(self): self.assertTrue(anagramm("Alma", "Lama")) def test_empty_anagramm(self): self.assertTrue(anagr...
2b1501bb0c90fa275b53a2673d716c1f510b9fa6
greenfox-zerda-lasers/gaborbencsik
/week-04/day-1/01_io/crypto_4encoded.py
485
3.90625
4
# Create a method that decrypts texts/encoded_zen_lines.txt def decrypt(file_name): file_name = open('texts/encoded_zen_lines.txt') rows = file_name.readlines() result = "" for line in rows: for character in line: if character == " " or character == "\n": result += ...
3d08703d557e5fa723cdee2ba3ceadadc802b3ba
greenfox-zerda-lasers/gaborbencsik
/week-04/day-3/02.py
476
3.96875
4
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 # create a 300x300 canvas. # draw a box that has different colored lines on each edge. from Tkinter import * root = Tk() canvas = Canvas(root, width=300, height=300) canvas.pack() canvas.create_line(20, 20, 100, 20, fill = 'red') canvas.create_line(100...
d585e697fde25956f65403c02cfd5d10bc04b530
greenfox-zerda-lasers/gaborbencsik
/week-03/day-2/37.py
296
4.1875
4
numbers = [3, 4, 5, 6, 7] # write a function that filters the odd numbers # from a list and returns a new list consisting # only the evens def filter(list): new_list = [] for x in list: if x % 2 == 0: new_list.append(x) return new_list print filter(numbers)
25efd8aa87243aa7c4403a428e84eb49aa205df7
gokullash2000/Calls-And-Text-Investigation
/task2.py
1,357
3.953125
4
#Read file into texts and calls import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) #convert All lines into list of values with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) #convert All lines into list of values """ TA...
e0519217424c36891ff1f2db3e758009e7c7bf51
jriguera/AdvancedAlgorithmsDataStructures
/Sudoku Solver/sudokuSolverDebugVersion.py
4,289
3.578125
4
from hashset import HashSet from datetime import datetime def buildPuzzle(file): puzzle = [] for line in file: line = line.strip("\n") line = line.split() isEmpty = False if len(line) == 0: isEmpty = True rowEntry = [] if not isEmpty: co...
ad25196861473a1543593a3d7ba50291e9032f34
jriguera/AdvancedAlgorithmsDataStructures
/Dijkstras-OrderedTreeSet/DijkstrasOTS.py
13,606
3.734375
4
# Ahmad M. Osman - Dr. Kent Lee, CS 360 from xml.dom import minidom class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): ...
69c3a930c3bbfde7787431ecbef157a5b3aee65f
jriguera/AdvancedAlgorithmsDataStructures
/MISC/Exam Questions/Exam Question #1 - Stack/myStack.py
1,515
3.921875
4
class Stack: def __init__(self, size=1): self.items = [None] * size self.numitems = 0 self.capacity = size def isEmpty(self): return self.numitems == 0 def peek(self): return self.items[self.numitems-1] def size(self): return self.numitems ...
5ec9098bbeaa87dd56a064b55169d4c24569277e
m1ghtfr3e/Number-Guess-Game
/Number_guess_game_3trials_FINE.py
853
4.3125
4
"""Guess number game""" import random attempt = 0 print(""" I have a number in mind between 1 and 10. Do you want to guess it? You have 3 tries! Enjoy :) """) letsstart = input("Do you want to start? (yes/no): ") if letsstart == 'yes': print("Let's start") else: print("Ok, see you :) ") computernumb...
3c0674f3b3b5bc4f8db97f568a1ee5b6472a8b82
mahimadubey/leetcode-python
/lru_cache/solution.py
1,587
3.875
4
""" Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1. set(key, value) - Set or insert the value if the key is not already...
870ced3b8b7a83a5942ba9378676ec53f6f18928
mahimadubey/leetcode-python
/group_anagrams/solution.py
874
4.09375
4
""" Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: [ ["ate", "eat","tea"], ["nat","tan"], ["bat"] ] Note: For the return value, each inner list's elements must follow the lexicographic order. All inputs will be in lower-case. """ cla...
10fabfbedc56aa8401cbe038bd69b8d0938d48f3
mahimadubey/leetcode-python
/maximum_subarray/solution2.py
675
4.15625
4
""" Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] has the largest sum = 6. """ class Solution: # @param A, a list of integers # @return an integer def maxSubA...
93c4f1e55ea3285f39b1ac8f35af48c235b70f2f
mahimadubey/leetcode-python
/regular_expression_matching/solution.py
1,173
3.734375
4
class Solution: # @return a boolean def isMatch(self, s, p): if not p: return not s if not s: return False return self.is_match_aux(s, p, 0, 0) def is_match_aux(self, s, p, si, pi): if pi == len(p): return si == len(s) # Next char ...
c8787d82cc34f3cc8587bd0330f909dd426463db
mahimadubey/leetcode-python
/populating_next_right_pointers_in_each_node_ii/solution.py
1,116
4
4
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # self.next = None class Solution: # @param root, a tree node # @return nothing def connect(self, root): head = None # Head node...
f4c923df94f587550752a3bd75618aa3b444e2b6
mahimadubey/leetcode-python
/clone_graph/solution3.py
1,374
3.90625
4
""" Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. """ # Definition for a undirected graph node # class UndirectedGraphNode(object): # def __init__(self, x): # self.label = x # self.neighbors = [] class Solution(object): def cloneGraph(self, nod...
002c212b48608c91ee8080ac5b43995fb8859c95
mahimadubey/leetcode-python
/single_number_ii/solution.py
1,076
3.5625
4
class Solution: # @param A, a list of integer # @return an integer def singleNumber(self, A): # Assume 32-bit integer num_of_bits = 32 # Change this to 64 on 64-bit platform res_bit = 0 res = 0 # First check whether the single number is negative for num in A:...
15aafffe4e3874c5926e1391d618035e5dd6ebcf
mahimadubey/leetcode-python
/summary_ranges/solution.py
1,135
3.703125
4
""" Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. """ class Solution(object): def summaryRanges(self, nums): """ :type nums: List[int] :rtype: List[str] """ res = [] n...
cb48c6cf7d71fee1e57a81990878505cc8536c8c
mahimadubey/leetcode-python
/merge_intervals/solution.py
1,075
3.921875
4
# Definition for an interval. # class Interval: # def __init__(self, s=0, e=0): # self.start = s # self.end = e class Solution: # @param intervals, a list of Interval # @return a list of Interval def merge(self, intervals): if not intervals: return [] n = len...
a06b49d6b249763e2cbf2244aec3cfa93565dcd2
mahimadubey/leetcode-python
/unique_binary_search_trees/solution.py
896
3.890625
4
""" Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ \ 2 1 ...
e731c5a719ea869540879dfbaa4d2c5085dac8fb
mahimadubey/leetcode-python
/longest_palindromic_substring/solution.py
770
3.546875
4
class Solution: # @return a string def longestPalindrome(self, s): n = len(s) t = [[False for i in range(n)] for j in range(n)] start = 0 max_len = 1 for i in range(n): t[i][i] = True for i in range(n - 1): j = i + 1 if s[i] == ...
fbb05bbf6f4d14bf507c89c04e3cde3b3e511a69
mahimadubey/leetcode-python
/word_break_ii/solution2.py
1,387
3.875
4
""" Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given s = "catsanddog", dict = ["cat", "cats", "and", "sand", "dog"]. A solution is ["cats and dog", "cat sand dog"]. """ class So...
98a0f8ed9f085d0e6bad1e9f11e071ff0e9c3a75
mahimadubey/leetcode-python
/reverse_integer/solution.py
444
4.09375
4
""" Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 """ class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ pos = True if x < 0: pos = False x = -x t = 0 w...
18bb065f9088a0311983095e3caecb9c54e80848
argosopentech/argos-lingo-flashcards
/src/script.py
3,367
3.875
4
#!/usr/bin/env python3 # This script reads the file 'Esperanto Self-Taught Vocab.csv', # does some cleaning up and writes the result to 'words.csv' # Requires apertium and apertium-en-es linux packages (may work on other # operating systems) import csv import re import os import subprocess # Read in csv file into ...
08ece295474dd405a9ce0266dfecf61fa640be87
Shashi-Chaurasia/Advance_Python
/exception_handling/Chapter_11/11_pr_02.py
165
3.859375
4
list1 = ['shashi' ,4 , 'nikiii' , 8 , 54 , 89 , 45 , 21] for index , item in enumerate(list1): if index == 2 or index == 4 or index == 6: print(item)
d869310f1bf26903c4a683354dd020bd39567ef9
Shashi-Chaurasia/Advance_Python
/exception_handling/01_try_different_exceptionhandling.py
255
3.765625
4
try: a = int(input("Enter Number : ")) c = 1/a print(c) except ZeroDivisionError as e: print("make sure you input is not zero") except TypeError as e: print("Type error") except Exception as e: print("plz chake your input type")
d7617fc768a0e5320e48d70a4a11cb4043c283c5
Shashi-Chaurasia/Advance_Python
/Chapter_13/02_lamda.py
249
3.796875
4
# def func(a): # return a + 5 # a = 9 # print(func(a)) func = lambda x: x + 5 sum = lambda x , a, b, c: x + a + b + c square = lambda x: x**2 cube = lambda x: x**3 x = 5 print(func(x)) print(sum(x , 3, 4, 5)) print(square(x)) print(cube(x))