blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
53422e27b41bff3603ae09dfb7b5c3d7e33fb136
Inlic/machine_learning
/iris.py
987
3.578125
4
from csv import reader def load_csv(filename): dataset = list() with open(filename, "r") as file: csv_reader = reader(file) for row in csv_reader: if not row: continue dataset.append(row) return dataset def str_column_to_int(dataset,column): clas...
cb78b540195011496a2fc5927ae0d78c989694c3
amritanair254/Python
/Restraunt_Biller/Restaurant_Biller.py
6,343
4.09375
4
#! /usr/bin/env python """Automated Ordering and Billing System: This program allows user to select menu items, prints out the total amount on screen, saves the bill to be physically printed out, sends the order to the kitchen via mail, maintains a record of all orders placed for official purpose""" from datetime imp...
da8d05d236981553859970093970f8f621a7ce51
mamrabet/Self-Driving-Projects
/Course4FinalProject/collision_checker.py
6,244
3.515625
4
#!/usr/bin/env python3 # This work is licensed under the terms of the MIT license. # For a copy, see <https://opensource.org/licenses/MIT>. # Author: Ryan De Iaco # Date: October 29, 2018 import numpy as np import scipy.spatial from math import sin, cos, pi, sqrt class CollisionChecker: def __init__(self, circl...
7a6b0ccbf4cf38ca0061087260229da089bc0815
HegemanLab/MassSpecLogParser
/MSLP/filepos.py
3,511
4.15625
4
#The library used for determining if a file exists import os.path def filePosUpdate(fileName, newLine, LastLineFile): """ A function that updates the last parsed line of the various files in a file The function looks for an already exists last line file, if it exists it looks for fileName's entry. If found, it...
91474165d55ceb1e8596f1b3340ab6f4c3f2ff89
HenryRobertRice/kattis
/python/torn2pieces.py
1,334
3.84375
4
from collections import deque from sys import exit class Node(): def __init__(self, name): self.name = name self.adj = [] self.prev = None self.visited = False def main(): n = int(input()) nodes = dict() for _ in range(n): temp_nodes = input().split() fo...
b343c1e632c941c3be796298e0797230ed699aab
HenryRobertRice/kattis
/python/securedoors.py
529
3.828125
4
log = {} n = input() for i in range(n): act, name = raw_input().split() if not name in log and act == "entry": log[name] = "in" print(name + " entered") elif not name in log: log[name] = "out" print(name + " exited (ANOMALY)") elif act == "entry" and log[name] == "in": print(name + " entered...
95695dae90421b3bbc0162b3626d8ba5c21c4fde
HenryRobertRice/kattis
/python/cokolada.py
402
3.796875
4
squares = input() #min size = min power of 2 greater than squares b = 1 while b < squares: b *= 2 out = str(b) #break squares into powers of 2 chunks = [] while b: if squares // b == 1: chunks.append(b) squares %= b b /= 2 b = int(out) breaks = 0 target = min(chunks) while(b): if b == ta...
83262a8f042c55663b1cbd0b0065ec8ce5cd3e87
HenryRobertRice/kattis
/python/apples.py
972
3.5625
4
def main(): r, c = map(int, input().split()) rows = [input() for _ in range(r)] cols = [[row[i] for row in rows] for i in range(c)] for i, col in enumerate(cols): cols[i] = fall(col) printcols(cols, r) def fall(col): newcol = [] apples = 0 dots = 0 for i in range(len(col) - ...
580911c01e91142bbc819b6d880edf2183e336bc
HenryRobertRice/kattis
/python/listgame.py
279
3.78125
4
def prime_factors(n): pf = 0 f = 2 while n > 1: while n % f == 0: pf += 1 n /= f f += 1 if f * f > n: if n > 1: pf += 1 break return pf print(prime_factors(int(input())))
c1fb84153f21347ba3e080f5a838295f24871e3c
HenryRobertRice/kattis
/python/baconeggsandspam.py
636
3.71875
4
while True: n = int(input()) if n != 0: foods = dict() for i in range(n): line = input().split() for j in range(1, len(line)): #print("checking " + line[j]) if line[j] not in foods: #print("no") foods...
f2bbad7587db1c0c847fcd5361e07d73582fd278
HenryRobertRice/kattis
/python/textencryption.py
526
3.6875
4
def main(): while True: n = int(input()) if n == 0: break msg = input().replace(" ", "").upper() if n > len(msg): print(msg) else: print(encrypt(n, msg)) def encrypt(n, msg): out = list(msg) index = 0 for i in range(len(msg)): ...
55b6b4b7ee35ca1536636ffb04e55f6509dc4214
HenryRobertRice/kattis
/python/cropeasy.py
979
3.53125
4
from itertools import combinations def main(): for i in range(int(input())): print(f"Case #{i + 1}: {process(input())}") def process(input_string): input_ints = [int(x) for x in input_string.split()] points = get_points(input_ints) triangles = combinations(points, 3) vali...
ea720a642c2cf9ec6ec1c933e68a848040af2c04
HenryRobertRice/kattis
/python/collatz.py
797
3.828125
4
def main(): while True: a, b = map(int, input().split()) if a == 0 and b == 0: return a_steps = collatz(a) b_steps = collatz(b) a_set = set(a_steps) for step in b_steps: if step in a_set: common = step break ...
4fe070824fd7c6b63e6a9dbbad78d3aab550c99b
HenryRobertRice/kattis
/python/almostperfect.py
521
3.59375
4
from math import ceil, sqrt from sys import stdin def main(): for line in stdin: n = int(line) print(str(n) + " " + perfection(n)) def perfection(n): factors = [i for i in range(2, ceil(sqrt(n))) if n % i == 0] p = sum(factors) + sum([n // f for f in factors]) + 1 if sqrt(n).is_integer...
52222342bc1ab11dec7635e236701c09813d8248
effgenlyapin29081983/algorithms
/task_3_lesson_7.py
1,296
3.5625
4
import random MIN_DIAPAZON = 0 MAX_DIAPAZON = 100 """ Массив размером 2m + 1, где m — натуральное число, заполнен случайным образом. Найдите в массиве медиану. Медианой называется элемент ряда, делящий его на две равные части: в одной находятся элементы, которые не меньше медианы, в другой — не больше медианы. Примеч...
b56d687051a61420e832da5e2e0fe4c576b18ca6
advaithb97/Exercises
/introduction_and_environment/introduction_to_programming/2_farm_area/Solution/solution.py
114
3.765625
4
length = int(input("Enter length: ")) breadth = int(input("Enter breadth: ")) data = length*breadth print(data)
cf144a7629648d06576ad9b507b9dda092418852
advaithb97/Exercises
/data_structures/linked_lists/2_create_list/create_list.py
765
4.0625
4
# A LinkedList is either: # None # Node class Node: # first: int # rest: LinkedList def __init__(self, first, rest = None): self.first = first self.rest = rest # Write a function named create_list that consumes a number n and returns a LinkedList of 1,2,..,n # create_list(3) -> Node(1, No...
98954ae4cd065575a5d5e90f02996ba8fb935676
Nachtalb/python_book_exercises
/book/kap_05/tilgungsplan.py
825
3.796875
4
# --------------------------------------------------- # Dateiname: tilgungsplan.py # # Objektorientierte Programmierung mit Python # Kap. 5 Loesung 6 # Michael Weigend 1. 10. 03 # ---------------------------------------------------- print("Berechnung des Tilgungsplans für einen Kredit") print() schulden = float(input(...
85efdefa72b36390e101de529ca4f5cc34a20360
Nachtalb/python_book_exercises
/book/kap_27/warteschlange.py
1,046
3.6875
4
# ---------------------------------------------------- # Dateiname: warteschlange.py # Implementierung einer Warteschlange beim TUEV # # Objektorientierte Programmierung mit Python # Kapitel 27 # Michael Weigend 19.11.2009 # ---------------------------------------------------- from queue_ import Queue # selbst gema...
6d38cc5ba46543e2d90379766c41b0e3259f8597
mohammedf2606/poisson_dist
/Poisson.py
916
3.796875
4
import math # For e and factorial import random # Generate random stuff import matplotlib.pyplot as plt # Graphing probList = [] mean = int(input("Enter the mean: ")) trials = int(input("How many numbers do you want? ")) pProb = lambda x: math.e**(-mean) * (mean**x)/math.factorial(x) def CumulativeCompare(): ...
0a16a1a56124956b42ad264146c92acf7e9b5fa8
Miouch/ScriptingLanguages-Complex
/Complex.py
4,413
4.15625
4
#!/usr/bin/python from math import sqrt import cmath # Define the complex numbers class class Complex: """Class for complex numbers computations""" def __init__(self, real=0, imag=0): self.r = real self.i = imag def real(self): return self.r def imag(self): return self.i def conjugate(self): self.i =...
f79eec16117a361f8dd571089f497a06d70a962f
asingh120/textanalysis
/textanalysis.py
1,167
3.8125
4
''' Program: textanalysis.py Author: Amit Date: 9/9/19 Program computes and displays the Flesch Index and the Grade Level Equivalent for the readability of a text file ''' # Take the inputs fileName = input("Enter the file name: ") inputFile = open(fileName, 'r') text = inputFile.read() # Count the se...
5aabeace23239de6415b6c2060ca793db030d440
Archiebolt/The_Start_Of_The_Journey
/03_English_to_Russian_Switcher.py
1,311
3.96875
4
# This small program was made for people who accidentally typed english letters, # but they wanted to type russian words. # This program will change your english characters to russian text = input("Enter: ") final = '' characters = { "q": "й", "w": "ц", "e": "у", "r": "к", "t": "е", "z": "н...
7ef0ddfaeb979d5f9eb5132c64161e271ce9dc83
kstseng/dsa-ml-tool-note
/DSA/ProblemSolvingWithAlgorithmsAndDataStructures/CODE/TreesAndTreeAlgorithm/trees_binary_heap.py
3,139
3.671875
4
class BinHeap: def __init__(self): self.heapList = [0] self.currentSize = 0 def percUp(self, i): """ 從「下」到「上」檢查第 i 個元素是否符合「順序」結構 """ while i // 2 > 0: if self.heapList[i] > self.heapList[i // 2]: ## 如果 leaf 的 key 大於其 parent 的 key ...
132874980fb730bc3f8a1e60df3e1ac1a1fe366f
shandrabates/into-python
/generator_objects.py
897
3.890625
4
""" Generator Objects are a cross between comprehensions and generator functions Syntax: Similar to list comprehension: (expr(item) for item in iterable) but use () not [] A lot of built-ins can be used on any collection: sum(), min(), max(), sort() """ from list_comps import is_prime def main(): ...
1fc6f56dc0fce06ea0c2fd2d02dc7fffd55f848f
shandrabates/into-python
/my_iterations.py
2,372
3.921875
4
""" When working with iterations, generators, etc Look at the documentation for the itertools module """ from itertools import islice, count, chain from list_comps import is_prime from statistics import mean def main(): """ test function :return: nothing """ ten_thousand_primes = islice((x fo...
8e84cfa02b053b57a2341cd6edb638768e953b2f
hamanovich/py-100days
/07-09-data-structures/program1.py
1,417
3.84375
4
cars = { 'Ford': ['Falcon', 'Focus', 'Festiva', 'Fairlane'], 'Holden': ['Commodore', 'Captiva', 'Barina', 'Trailblazer'], 'Nissan': ['Maxima', 'Pulsar', '350Z', 'Navara'], 'Honda': ['Civic', 'Accord', 'Odyssey', 'Jazz'], 'Jeep': ['Grand Cherokee', 'Cherokee', 'Trailhawk', 'Trackhawk'] } def get_al...
79aa8a94a6c3953ea852f3a087f1f0a89dbd0af7
hamanovich/py-100days
/01-03-datetimes/program2.py
1,197
4.25
4
from datetime import datetime THIS_YEAR = 2018 def main(): years_ago('8 Aug, 2015') convert_eu_to_us_date('11/03/2002') def years_ago(date): """Receives a date string of 'DD MMM, YYYY', for example: 8 Aug, 2015 Convert this date str to a datetime object (use strptime). Then extract the yea...
36db89d642a023ebf27032b59fc55505da4a7379
jameskzhao/python36
/level_one/numbers.py
1,156
3.984375
4
my_income = 100 # int tax_rate = 0.1 #float my_taxes = my_income * tax_rate #float #comment print(my_taxes)#comment """This is a single line docstring""" """This is a multiline docstring""" if my_taxes < 50: print("you are such a poor guy") # no single line if so the next line will get an invalid syntax error ...
b96c8fe07909b4042eb13ff7f21c65e1eda9b98d
inest-us/python
/algorithms/c1/list.py
438
3.96875
4
my_list = [1,3,True,6.5] print(my_list) # [1,3,True,6.5] my_list = [0] * 6 print(my_list) # [0, 0, 0, 0, 0, 0] my_list = [1,2,3,4] # The variable A holds a collection of three references to the original list called my_list. # Note that a change to one element of my_list shows up in all three occurrences in A. A = [m...
d1db24e49d5698c3d9f2b6db4794fa94aebb3e5f
inest-us/python
/algorithms/c1/tuple.py
642
4.15625
4
# Tuples are very similar to lists in that they are heterogeneous sequences of data. # The difference is that a tuple is immutable, like a string. # A tuple cannot be changed. # Tuples are written as comma-delimited values enclosed in parentheses. my_tuple = (2,True,4.96) print(my_tuple) # (2, True, 4.96) print(len...
90c309b7049aabd853e1520494df51296dc9a0f6
inest-us/python
/algorithms/c1/dictionary.py
1,360
4.65625
5
capitals = {'Iowa':'DesMoines','Wisconsin':'Madison'} print(capitals) # {'Wisconsin': 'Madison', 'Iowa': 'DesMoines'} # We can manipulate a dictionary by accessing a value via its key or by adding another key-value pair. # The syntax for access looks much like a sequence access # except that instead of using the ind...
42d484424e2bb30b0bae4e3ea9a9f3cb668d8f8c
jsburckhardt/pythw
/ex3.py
693
4.15625
4
# details print("I will now count my chickens:") # counts hens print("Hens", float(25 + 30 / 6)) # counts roosters print("Roosters", float(100 - 25 *3 % 4)) # inform print("Now I will count the eggs:") # eggs print(float(3 + 2 + 1 + - 5 + 4 % 2 - 1 / 4 + 6)) # question 5 < -2 print("Is it true that 3 + 2 < 5 - 7?") # ...
016b7a5b67bcb7959d8bde2999bdf8328904500f
Risto-Stevcev/python-church-encodings
/church_encoding/church.py
6,745
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # # # # # # # # # # # Church Encodings # # # # # # # # # # # # __author__ = "Risto Stevcev" # Boolean Operators # # # # # # # # # # # # # Church Boolean (True) # λt.λf.t true = lambda a: lambda b: (a) # Church Boolean (False) # λt.λf.f false = lambda a: lambda b: ...
e9bd943194a94928e8bbb45f53690259e8acea5d
sanghavi06/dummyprj
/str2.py
172
4.09375
4
d=input('enter the string name ') #d==('a','e','i','o','u') for vowel in 'aeiou': if vowel in d: print('the vowels are',vowel) #else: # print(novowels)
7831e00dbb5a72ae30d36a039a6e3c91cd4d5326
sanghavi06/dummyprj
/odd.py
136
3.828125
4
for a in range(1,10,1): if a%2!=0: print(a) for b in range(1,10,1): if b%2==0: print(b)
110551096f12a01e0eddd0ec7db61edba006aceb
trapperian/Workout-Generator
/diceWorkoutGenerator.py
640
4
4
# random dice workout generator # uses two 'dice' to randomly generate a basic workout without equipment. #exercises used are squat, pushup, jumping jacks, squat thrust, mountain climber, prone swimmers #set/reps are actually times each numbe represents corresponding amount of minutes so, 1 = 1 minute, 2 = 2 minutes, ...
75a72bd18b4717142aff312c1616fe491378d2bc
lima-BEAN/python-workbook
/algorithm-workbench/ch2/format-float2.py
245
3.96875
4
## Assume the following statement has been executed: ## number = 1234567.456 ## Write a Python statement that displays the value referenced by ## the number variable formatted as ## 1,234,567.5 number = 1234567.456 print(format(number,',.1f'))
0081ea28bee4c8b24910c6a3a8b3d559431efde5
lima-BEAN/python-workbook
/programming-exercises/ch7/larger_than_n.py
1,565
4.40625
4
# Larger Than n # In a program, write a function that accepts two arguments: # a list and a number, n. Assume that the list contains numbers. # The function should display all of the numbers in the list that # are greater than the number n. import random def main(): numbers = Numbers() user_num = UserNum() ...
e8e2762a14e9158bb3d517924453b2ccbfe91375
lima-BEAN/python-workbook
/algorithm-workbench/ch7/string_list.py
308
3.859375
4
# Write a statement that creates a list with the following strings: # 'Einstein', 'Newton', 'Copernicus', and 'Kepler' def main(): count = 0 greats = ['Tesla', 'Einstein', 'Newton', 'Copernicus', 'Kepler'] for great in greats: count += 1 print(str(count) + ': ' + great) main()
43dc28165ec22f719d9e594091c82366cc574384
lima-BEAN/python-workbook
/programming-exercises/ch2/distance-traveled.py
618
4.34375
4
## Assuming there are no accidents or delays, the distance that a car ## travels down the interstate can be calculated with the following formula: ## Distance = Speed * Time ## A car is traveling at 70mph. Write a program that displays the following: ## The distance a car will travel in 6 hours ## The distance a car wi...
a913e26be57a7dcad82df5ddf127b85933c4c0c0
lima-BEAN/python-workbook
/programming-exercises/ch5/kinetic_energy.py
983
4.53125
5
# Kinetic Energy # In physics, an object that is in motion is said to have kinetic energy. # The following formula can be used to determine a moving object's kinetic # energy: KE = 1/2 mv**2 # KE = Kinetic Energy # m = object's mass (kg) # v = velocity (m/s) # Write a program that asks the user to enter values for ma...
44ecf7731cf113a646f9fbfb9358a09f5dead62a
lima-BEAN/python-workbook
/programming-exercises/ch8/date_printer.py
933
4.375
4
# Date Printer # Write a program that reads a string from the user containing a date in # the form mm/dd/yyyy. It should print the date in the form # March 12, 2014 def main(): user_date = UserDate() date_form = DateForm(user_date) Results(date_form) def UserDate(): date = input('Enter a date in the f...
e8404b90ca40907cfca6018ce0c4bebf8752caec
lima-BEAN/python-workbook
/programming-exercises/ch2/ingredient-adjuster.py
832
4.40625
4
## A cookie recipe calls for the following ingredients: ## - 1.5 cups of sugar ## - 1 cup of butter ## - 2.75 cups of flour ## The recipe produces 48 cookies with this amount of the ingredients. ## Write a program that asks the user how many cookies he or she wants to ## make, and then displays the number of cups o...
e169c24a189096d940703a1c4ac034571189f005
lima-BEAN/python-workbook
/programming-exercises/ch10/Retail/cash_register.py
1,426
3.6875
4
# Exercise assumes you've created a RetailItem class. # Create a CashRegister class that can be used with the # RetailItem class. The CashRegister class should be able # to internally keep a list of RetailItem objects. The # class should have the following methods: # # purchase_item method that accepts a RetailItem obj...
cbae1470e46184c8a3b830ff5ad9076fe0f1864f
lima-BEAN/python-workbook
/programming-exercises/ch4/population.py
720
4.46875
4
# Write a program that predicts the approximate size of a population of organisms # The application should use text boxes to allow the user to enter the starting # number of organisms, the average daily population increase (as percentage), # and the number of days the organisms will be left to multiply. number_organis...
27eda59c433dd226459b8966720505f2c78d0cd1
lima-BEAN/python-workbook
/programming-exercises/ch10/Information/my_info.py
794
4.46875
4
# Also, write a program that creates three instances of the class. One # instance should hold your information, and the other two should hold # your friends' or family members' information. import information def main(): my_info = information.Information('LimaBean', '123 Beanstalk St.', ...
8d62cbef5cbe028c9a8d83ddd18c5e52106d9c6b
lima-BEAN/python-workbook
/programming-exercises/ch3/roman-numerals.py
982
4.34375
4
# Write a program that prompts the user to enter a number within the range of 1 # through 10. The program should display the Roman numeral version of that # number. If the number is outside the range of 1 through 10, # the program should display an error message. number = int(input("What number do you want to convert ...
3c683a28f22e656365df3d5a555d2f3128fa1bb8
lima-BEAN/python-workbook
/programming-exercises/ch8/initials.py
1,126
4.25
4
# Write a program that gets a string containing a person's first, middle # and last names, and then display their first, middle and last initials. # For example, John William Smith => J. W. S. def main(): name = Name() initials = Initials(name) Results(initials) def Name(): name = input('What is y...
0099944fcfe8838ff21c6dd6bb73fb97bc3f6365
lima-BEAN/python-workbook
/programming-exercises/ch5/math_quiz.py
999
4.0625
4
# Write a program that gives simple math quizzes. The program should display # random numbers that are to be added, such as: 247 + 129 # The program should allow the student to enter the answer. If the answer is # incorrect, a message showing the correct answer should be displayed import random def main(): Greet...
57308ece92148afb6af68d7d3e7391e0272a6726
lima-BEAN/python-workbook
/algorithm-workbench/ch4/for-loop1.py
140
3.78125
4
# Write a for loop that displays the following set of numbers: # 0, 10, 20, 30, 40, 50, ... 1000 for x in range(0, 1001, 10): print(x)
e49db3dcec0c60cb18e661e53d969b3999f98dea
lima-BEAN/python-workbook
/algorithm-workbench/ch2/precedence.py
159
3.59375
4
## What would the following display? ## a = 5 ## b = 2 ## c = 3 ## result = a + b * c a = 5 b = 2 c = 3 result = a + b * c # will show 11 print(result)
f9500fd6cfdd6d846ed4b6fa2b034bd681d3d637
lima-BEAN/python-workbook
/algorithm-workbench/ch2/favorite-color.py
220
4.21875
4
## Write Python code that prompts the user to enter his/her favorite ## color and assigns the user's input to a variale named color color = input("What is your favorite color? ") print("Your favorite color is", color)
fff181b050dcaeefba94dc1829f3413da3b8b0ff
lima-BEAN/python-workbook
/algorithm-workbench/ch2/subtract.py
233
3.71875
4
## Write a Python statement that subtracts the variable down_payment from ## the variable total and assigns the result to the variable due total = 65000 down_payment = 10500 due = total - down_payment print("You owe $" + str(due))
54b6e4930811ab19c5c64d37afc05fb0a8d69270
lima-BEAN/python-workbook
/programming-exercises/ch10/Retail/item_in_register.py
1,023
4.25
4
# Demonstrate the CashRegister class in a program that allows the user to # select several items for purchase. When the user is ready to check # out, the program should display a list of all the items he/she has # selected for a purchase, as well as total price. import retail_item import cash_register def main(): ...
14abd73ae4d52d04bfa9c06e700d9191d194f6b3
lima-BEAN/python-workbook
/programming-exercises/ch5/sales_tax_program_refactor.py
1,702
4.1875
4
# Program exercise #6 in Chapter 2 was a Sales Tax Program. # Redesign solution so subtasks are in functions. ## purchase_amount = int(input("What is the purchasing amount? ")) ## state_tax = 0.05 ## county_tax = 0.025 ## total_tax = state_tax + county_tax ## total_sale = format(purchase_amount + (purchase_amount * t...
80ed9d38f2f0629a52fb4caa2eaa99eb1610ebbe
martamacias/pythonlearning
/Curso/POO/POO_02_Herencia_01.py
1,960
3.859375
4
class Vehiculo: # clase padre def __init__(self, marca, modelo): self.marca = marca self.modelo = modelo self.enmarcha = False self.acelera = False self.frena = False def arrancar(self): self.enmarcha = True def acelerar(self): self.acelera = True ...
c58f1fde067814dddaaa558ad1c3e93eab95c9cc
martamacias/pythonlearning
/Curso/Paquete_Calculos/Calculos_Generales.py
239
3.5625
4
def sumar(op1,op2): print("La suma es:", op1+op2) def restar(op1,op2): print("La resta es:", op1-op2) def multip(op1,op2): print("La multiplicación es:", op1*op2) def dividir(op1,op2): print("La división es:", op1/op2)
90d7cece662fe6bc1e953102a281d4dc8fe49e03
AbdulBasit0044/Computer-Vision-OpenCV-in-python
/Advanced Programs/resizing images.py
916
3.640625
4
# -*- coding: utf-8 -*- """ Created on Fri Jul 20 2:08:16 2018 logical operations on images @author: AbdulBasit0044 resizing images with resize function """ import cv2 def main(): #images dataset path path="images-dataset\\" #storing image path explicitly for every image imgpath1 = path + "4.2.0...
21a91880f7ee879d90a4d30cd4c42be7c80a2ece
ashifan/anand-python
/rev.py
52
3.71875
4
a = [1,2,3,4] a.reverse() for i in a: print i
a72942f1dc8cf3cffe47d48cd3b41bd6b14a0981
ashifan/anand-python
/g9.py
155
3.65625
4
def mix_up(a,b): a_swapped = b[:2] + a[2:] b_swapped = a[:2] + b[2:] return a_swapped + '' + b_swapped a = 'dog' b = 'dinner' print mix_up(a,b)
cdbff5213737ac7293cc28214ee6c9a485e18998
ashifan/anand-python
/g17.py
543
3.734375
4
import sys def word_count_dict(): word_count = {} with open('alice.txt', 'r') as a: for line in a: for word in line.split(): word = word.lower() if not word_count.has_key(word): word_count[word] = 1 else: word_count[word] = word_cou...
659735200953b90547bc02e18b22ef6e1460c70e
ashifan/anand-python
/g12.py
274
3.75
4
def front_back(a,b): a_middle = len(a) / 2 b_middle = len(b) / 2 if len(a) % 2 == 1: a_middle = a_middle + 1 if len(b) % 2 ==1: b_middle = b_middle + 1 return a[:a_middle] + b[:b_middle] + a[a_middle:] + b[b_middle:] a = 'asdfg' b = 'qazxs' print front_back(a,b)
351fcabbf424b56b025c6363fc649595ff62c06f
lancezlin/LintCode
/Convert Expression to Reverse Polish Notation.py
1,580
3.921875
4
""" Given an expression string array, return the Reverse Polish notation of this expression. (remove the parentheses) Example For the expression [3 - 4 + 5] (which denote by ["3", "-", "4", "+", "5"]), return [3 4 - 5 +] (which denote by ["3", "4", "-", "5", "+"]) """ __author__ = 'Daniel' class Solution: def co...
69b27ecadadfa72910e3a71bbf61e51b1c0417f7
danisandiaz/video-store-cli
/main.py
7,633
3.546875
4
import video_store import pyfiglet def print_stars(): print("*********************") def make_choice(options): valid_choices = options.keys() choice = None while choice not in valid_choices: print("What would you like to do? Select 14 to see all options again") choice = input(...
139e88a6ba69953ffc6a0b534f7c4b93000be251
piemekanika/college
/codewars/python/weirdstr.py
419
3.65625
4
def duplicate_encode(word): str = '' for letter in word: count = 0 for letter2 in word: if letter.lower() == letter2.lower(): count += 1 if count > 1: str += ')' else: str += '(' return str print(duplicate_encode('din')) pr...
3d9deda751cdfa233cdf0c711f3432be950980d3
tejastank/allmightyspiff.github.io
/CS/Day6/linkedList01.py
1,399
4.21875
4
""" @author Christopher Gallo Linked List Example """ from pprint import pprint as pp class Node(): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node def __str__(self): return str(self.data) class linked_list(): def __init__(self): self.he...
fe8dee16b6adcc40975675d6e911fa3ec1cbb042
tejastank/allmightyspiff.github.io
/CS/Day13/heapSortTest.py
3,130
4.0625
4
import unittest class heapSort(): def heapify(self, array, heap_size, top_index): largest = top_index left = (2 * top_index) + 1 right = (2 * top_index) + 2 # Check if left exists, and if LARGEST < left if left < heap_size and array[largest] < array[left]: ...
628a119a8e05c38f218e4ab0cbe8fe36433f24dd
spidervan17/chebotarev
/praktika9/upr3v.py
757
3.703125
4
import numpy as np import matplotlib.pyplot as plt from decimal import Decimal print('vvesti summu ipoteki') s=float(input()) print('vvesti procent godovoy i kolvo let') x=0.01*float(input()) y=int(input()) a=(12+x)/12 n=12*y z=Decimal(a**(n-1)*s*(1-a)/(1-a**(n-1))).quantize(Decimal('0.01')) t = np.arange(0., n, 0.2)...
611d3db5bf36c987bb459ff19b7ab0a215cfec83
laurenwheat/ICS3U-Assignment-5B-Python
/lcm.py
753
4.25
4
#!/usr/bin/env python3 # Created by: Lauren Wheatley # Created on: May 2021 # This program displays the LCM of 2 numbers def main(): a = input("Please enter the first value: ") b = input("Please enter the second value: ") try: a_int = int(a) b_int = int(b) if (a_int > b_int): ...
290c6998fa70ce105d09079dcfe281e1f2df898b
liu-kanghui/anomaly-detecor-597q
/predict.py
692
3.6875
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.externals import joblib #jbolib # load previous trained model kmean = joblib.load('save/kmeans.pkl') # input your predict csv data = pd.read_csv("deta_sel_normalize.csv") # choose the features column you want to use for predicting...
f951a8ebd35c6c1a38b5b3f099fac7c0845d4a56
rajbhutoria/homework-csci046
/containers/unicode.py
2,604
3.765625
4
import unicodedata class NormalizedStr: ''' By default, Python's str type stores any valid unicode string. This can result in unintuitive behavior. For example: >>> 'César' in 'César Chávez' True >>> 'César' in 'César Chávez' False ''' def __init__(self, text, normal_form=...
07ad147bd09b5fb051dc47c91fb1f655f6854667
uriXD/tarea1
/documentacion.py
4,120
3.796875
4
#: c01:if.py #codigo 1 response = "yes" if response == "yes": print "affirmative" val = 1 print "continuing..." #<hr> output = ''' affirmative continuing... ''' # 1) tabulacion, al momento de mover la tabulacion del "val = 1" # nos marca el siguiente error: # File "if.py", line 5 # val = 1 # ^ # 2) el va...
df8b8ca3e9e4f6e17ff0bcec5a0126192d73e1eb
negromartin/Practica-Python
/practica python/practicaModulos/calculadora.py
189
3.671875
4
def suma(num1,num2): return num1 + num2 def resta(num1,num2): return num1-num2 def multiplicacion(num1,num2): return num1*num2 def division(num1,num2): return num1//num2
4eba80910b75efee5f1a5366b906d8eb350355af
negromartin/Practica-Python
/practica python/practicaGeneradores.py
455
3.640625
4
def generador(*args): """ Esta funcion recibe n cantidad de numeros y regresa elevado al cubo, junto con un string""" for valor in args: yield valor **3, "Ñereee" for valor1,valor2 in generador(7,4,6,11,23,87): print (valor1,valor2) nombre = generador.__name__ #Estos es acceder a los atributos de...
42fa0670ce218b5080e405ecd7afa7db03eb82fa
yasssshhhhhh/DataStructuresAndAlgo
/Trees/BoundaryTraversal.py
1,432
3.6875
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None class solution: def leftree(self,root,nums): if root is None: return if root.left: nums.append(root.data) self.leftree(root.left,nums) ...
8b67e047d303f9c43073438a102b5f9027e1786a
yasssshhhhhh/DataStructuresAndAlgo
/arrays/PrimeNumber.py
251
3.984375
4
def isPrime(num): for i in range(2,num): if num%i==0: break else: print(num,end=" ") a = int(input("enter lower bound:")) b = int(input("enter upper bound")) for i in range(a,b+1): if i!=1: isPrime(i)
9f99c663b4191d8544cd13097f728a452dbde18a
yasssshhhhhh/DataStructuresAndAlgo
/Trees/LongestSum.py
2,416
3.640625
4
# class node: # def __init__(self,data): # self.data = data # self.left = None # self.right = None # class solution: # def solve(self,root): # if root is None: # return # self.value = 0 # if root.left is None and root.right is None: # sel...
54901f1b568958988a3104a80fb0100a891fd216
yasssshhhhhh/DataStructuresAndAlgo
/Trees/IsomorphicTree.py
862
3.859375
4
class node: def __init__(self,data): self.data = data self.left = None self.right = None class solution: def IsomorphicTree(self,root1,root2): if root1 is None and root2 is None: return True if root1 is None or root2 is None: return False ...
1684fae715954f6bd33a1e24fa9c89f1100d8f40
Ajkuna/SortingVisualizer
/sortingAlgorithms.py
3,649
3.640625
4
from tkinter import * from tkinter import ttk import random from bubbleSort import bubble_sort from quickSort import quick_sort from insertionSort import insertion_sort from selectionSort import selection_sort root = Tk() root.title('Sorting Algorithms Visualization') root.maxsize(920, 620) root.config(bg='#000045') ...
3ea3217587606704aee84333003646205f4de3db
NicoleVenachi/Int_Pensamiento_Computacional
/5_Pruebas_Y_Debuggin/1_Caja_negra.py
497
3.765625
4
import unittest def suma(num_1, num2_2): return num_1 + num2_2 class CajaNegraTest(unittest.TestCase): def test_suma_dos_positivos(self): num_1 = 10 num2_2 = 5 resultado = suma(num_1, num2_2) self.assertEqual(resultado, 15) # Lo que espero def test_suma_dos_negativos(s...
2a8f74100cb9f31145e7f67dc408d391afabab63
Victor515/DOP
/L2/assignment/noleadingzero.py
3,508
4.40625
4
# -------------- # User Instructions # # Modify the function compile_formula so that the function # it returns, f, does not allow numbers where the first digit # is zero. So if the formula contained YOU, f would return # False anytime that Y was 0 import re import itertools def compile_formula(formula, verbose=False...
fea1c6ad867da5b4f0d0a66bdedeeff5a10de8e1
Shelsoncool/Trainee
/Assignment/Python/Set1/Q5.py
206
4.03125
4
tup=(1,2,3,4,5,6,7,8,9,10) list1=[] for i in tup: if i % 2 ==0: list1.append(i) tupp=tuple(list1) print("The Sequence of numbers are:") print(tup) print("The Even numbers are:") print(tupp)
6f25237301af3bc2091f508261104fa38873c1e1
Shelsoncool/Trainee
/Assignment/Python/Set3/Q3.py
124
3.9375
4
import re phone=input("Enter the sentence:") patt="^([6-9])\d{9}$" patt1="[0-9]{10}" num=re.findall(patt1,phone) print(num)
3e3e34b3dc14b6ad781f61cf5fe5180a42d51537
iwtbs/jianzhi-offer
/58.py
1,216
3.921875
4
''' 请实现一个函数,用来判断一颗二叉树是不是对称的。注意,如果一个二叉树同此二叉树的镜像是同样的,定义其为对称的。 ''' class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def same_tree(self, p1, p2): if p1 == None and p2 == None: return True if (p1 and p2) and p1....
ee8b0a7b66fdf43f0e3c8b8ff1178d2696502b03
iwtbs/jianzhi-offer
/48.py
270
3.609375
4
''' 写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号 ''' class Solution: def Add(self, num1, num2): # write code here l = [] l.append(num1) l.append(num2) return sum(l)
6e0c9b107e8f6f9317d0deefe73df7ac01587f8b
iwtbs/jianzhi-offer
/10.py
542
3.84375
4
''' 我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法? ''' class Solution: def rectCover(self, number): # write code here if number == 0: return 0 elif number == 1: return 1 elif number == 2: return 2 else: l = [1,...
a4e4969c4ef195cad24df337733b6a680f100d6e
iwtbs/jianzhi-offer
/55.py
475
3.65625
4
''' 给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出null ''' class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def EntryNodeOfLoop(self, pHead): # write code here p = pHead l = [] while p: if p not in l: l.append(p) ...
5ab70e32d26990660825e4b979ce17407c151b6c
iwtbs/jianzhi-offer
/34.py
875
3.5
4
''' 在一个字符串(0<=字符串长度<=10000,全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1(需要区分大小写) ''' class Solution1: def FirstNotRepeatingChar(self, s): # write code here result = {} for i in s: if i in result: result[i] = result[i]+1 else: result[i] =...
d0e28d6ce1fb4c7638be814915726b9541cad4b8
razmikarm/structures_in_python
/queue.py
1,559
3.625
4
from __future__ import annotations class Node: def __init__(self, value): self.__previous = None self.__value = value @property def value(self): return self.__value @value.setter def value(self, value): self.__value = value @property def next(self): ...
580abf1780cada223679f5f80ef023e613887287
smtorres/python-washu-2014
/day4/lab4.py
464
3.71875
4
from math import sqrt def max_div (number1, number2): while number2 != 0: rem = number1 % number2 number1 = number2 number2 = rem max_div(number1, number2) return(number1) print max_div(1071, 462) print max_div(30,25) def primes(): boolean_ary = [True] * 121 for i in range(2,12): if boolean_ary[i]:...
b9ce86e260e1a7eefefa48ab21ff63254fb512ea
smtorres/python-washu-2014
/day3/bla.py
1,900
3.75
4
txt = "hola mundo! como estas? Bien. Y tu." print txt tmp = txt.replace("?", "?\n") tmp2 = txt.replace("?", ".") print tmp print tmp2 tmp = tmp.replace("!", "!\n") tmp2 = tmp2.replace("!", ".") print tmp print tmp2 tmp = tmp.replace(".", ".\n") print tmp print tmp2 sentences = tmp.split("\n") orig_sentences = tmp2.spli...
722c9fef00cc8c68bda1a32eb5964413311f1a2d
smtorres/python-washu-2014
/Assignment01/school.py
1,042
4.21875
4
from collections import OrderedDict class School(): def __init__(self, school_name): self.school_name = school_name self.db = {} # Function that adds values and keys to a dictionary. Keys are school grades and each can take as value the name of a kid belonging to that grade. # It returns a dictionary with th...
3d5f52937ce2afbd1b508b12d712fce89558590c
ahtornado/study-python
/day10/convertip.py
526
3.53125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author :Alvin.Xie # @Time :2017/10/15 19:43 # @File :convertip.py def int2ip(num): ip_list = [] for i in range(4): num, mod = divmod(num, 256) ip_list.insert(0, str(mod)) return '.'.join(ip_list) def ip2int(ip): ip_list = ip.spl...
be0c16cca6670ce15dad886127143d8536628e48
ahtornado/study-python
/day11/shengcs.py
240
3.5
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author :Alvin.Xie # @Time :2017/11/3 22:00 # @File :shengcs.py m = [x for x in range(1, 10)] print m g=(x for x in range(1, 10)) print g.next() print g.next() for x in g: print x
9917193a8aefd4f4948f13b975c6223c824f059b
ahtornado/study-python
/day2/filetest.py
600
3.6875
4
#!/usr/bin/env python # _*_coding:utf_8_*_ # Author:Alvin.xie f = open('data.txt', 'w') f.write('hello\n') f.write('world\n') f.close() f = open('data.txt', "r") print f bytes1 = f.read() print bytes1 print bytes1.split() class Worker: def __init__(self, name, pay): self.name = name self.pay =...
b2c42b0b7aff16f32b3b5c812a9ae0f6475c5497
ahtornado/study-python
/day8/randpass.py
331
3.625
4
# !/usr/bin/env python # -*- coding:utf-8 -*- # Author:Alvin.Xie import random import string all_chs = string.letters + string.digits def gen_pass(num=8): pwd = [] for i in range(num): ch = random.choice(all_chs) pwd.append(ch) return ''.join(pwd) if __name__ == '__main__': print g...
621a1cc9ed9a4c86c5516216ba51d4e4afe64d6a
ahtornado/study-python
/day19/convertip.py
601
3.5625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author :Alvin.Xie # @Time :2018/7/7 23:14 # @File :convertip.py #3232235786 = 192* 256 ** 3 + 168 * 256 ** 2 + 1 * 256 ** 1 + 10 * 256 ** 0 def int2ip(num): ip_list = [] for i in range(4): num, mod = divmod(num, 256) ip_list.insert(0, str...
3906b2984793709ddb195640c576f649fe9d045b
esernaalonso/dev
/maya/python/lib/listUtils.py
322
3.734375
4
####################################### # imports ####################################### # functionality def isSublist(a, b): if a == []: return True if b == []: return False return b[:len(a)] == a or isSublist(a, b[1:]) ####################################### # execution if __name__ == "__main__": pa...
96f1f801c1bc9e59e9b24c9194e24f6ddf553b5f
tylerkemp2/cs114
/wallprint.py
770
4.09375
4
from time import sleep print("Hello.") sleep(2) #setup #input print('what is the width if the wall?') width = float(input()) print('What is the Height of the wall?') lenght = float(input()) print('How much does 1 gallon of print cost?') cost = float(input()) #transform square_feet = width * lenght gallons = square_...