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
42b1243d90660878566a109f9822af9855dca658
whuan20011/coding_2020
/beads/beads.py
1,117
3.59375
4
""" ID: whuan2001 LANG: PYTHON2 TASK: beads """ def solution(): fin = open("beads.in", "r") fout = open("beads.out", "w") N = int(fin.readline().strip()) beads = fin.readline().strip() max_count = 0 tag = 0 for i in range(N): new_necklace = beads[i:] + beads[:i] left_count = ...
b54d823803d94c515cafca3f4f9400fe09c6f481
NCHlab/Key-Checksum-Value
/key_checksum_value.py
645
3.9375
4
#!/usr/bin/env python3 import binascii from Crypto.Cipher import AES print("----------------") print("This is a Key Value Checker for an AES key in UTF8 Input and uses ECB Mode") print("AES key must be either 16, 24, or 32 bytes long") print("----------------") key = input("Please Enter AES KEY: ") key = ...
a469f25453e6ce8cc7b4574e89659b2516490136
jaymit31/Mathematics-for-Machine-Learning
/Course 3: PCA/week1/Mean Covariance of a data set and effect of a linear transformation.py
10,624
4.34375
4
Mean/Covariance of a data set and effect of a linear transformation We are going to investigate how the mean and (co)variance of a dataset changes when we apply affine transformation to the dataset. Learning objectives Get Farmiliar with basic programming using Python and Numpy/Scipy. Learn to appreciate implemen...
e5c45b534741168d9c346c63e29ab642f01cc524
13iqin/leetcode_exercise
/search/69.py
490
3.640625
4
import math class Solution: def mySqrt(self, x: int) -> int: left, right = 0, x while left <= right: mid = math.floor(left + (right - left) / 2) sqt = mid * mid if sqt > x: right = mid - 1 elif sqt < x: left = mid + 1 ...
217c4619e3f61c7ce8793d339277d95914d723c9
13iqin/leetcode_exercise
/sort/179.py
283
3.609375
4
def largestNumber(nums): """ :type nums: List[int] :rtype: str """ from functools import cmp_to_key key = cmp_to_key(lambda x, y: int(y + x) - int(x + y)) nums = [str(num) for num in nums] nums.sort(key=key) return ''.join(nums).lstrip("0") or "0"
b1ffe6a819e9136ed5b66b34966aff6698d48d30
hannahmaung/SE-Homework-4
/test.volume.py
439
3.53125
4
#Test for volume of a cube import unittest import volume class testCase(unittest.TestCase): def setup(self): self.volume = volume() def test1(self): self.assertEqual(volume.calculate(2,1),(8)) def test2(self): self.assertEqual(volume.calculate('x',1), (125)) def...
d62ea1a546cecccf6ce8aaf46ed4c8f170e511b8
Arushiii/TIC-TAC-TOE-IN-PYTHON
/arushi_shrivastava final _level0.py
4,447
4.40625
4
#!/usr/bin/env python # coding: utf-8 # In[4]: #first I have imported these libraries: import numpy as np import random #then I asked the user for the grid dimenstions: m*n and the k value: row= int(input('Please enter the no. of rows you want: ')) print() col= int(input('Please enter the no. of columns you want...
3f3a8be9b88a998bb8b60feb45ea56a7a3e34dde
marcusmendes/python-fudamentos
/oo2/modelo.py
2,386
3.625
4
class Programa: def __init__(self, nome: str, ano: int): self._nome = nome.title() self.ano = ano self._likes = 0 @property def nome(self): return self._nome @nome.setter def nome(self, nome: str): self._nome = nome @property def likes(self): ...
ed043fea8d74a1f790a593901cc0a3f516935329
cuongnb14/python-design-pattern
/sourcecode/data_structure/queue.py
1,126
4.125
4
class Node: data = None next = None def __init__(self, data=None): self.data = data class Queue: def __init__(self): self.length = 0 self.head = None self.last = None def is_empty(self): return self.length == 0 def push(self, node): if not isi...
d75bbaf6a902034ade93a755ce5762091a2f2532
driscolllu17/csf_prog_labs
/hw2.py
2,408
4.375
4
# Name: Joseph Barnes # Evergreen Login: barjos05 # Computer Science Foundations # Homework 2 # You may do your work by editing this file, or by typing code at the # command line and copying it into the appropriate part of this file when # you are done. When you are done, running this file should compute and # print ...
056609f722caa32c2b16971fbf51c70224b8ace4
cashmann/kata-pencil-durability
/pencilAndPaper.py
2,266
3.78125
4
class PencilAndPaper(object): def __init__(self, initPoint=100, initEraser=100, initText=''): if type(initPoint) is not int or type(initEraser) is not int or initPoint <= 0 or initEraser <= 0: raise TypeError('Pencil point and eraser must be a positive integer.') self.point = initPoint self.eraser =...
710c5ff0173e6828ebe50ab1be7f6853d888cbc7
DanRud/PracticePython
/08_Rock_Paper_Scissors.py
1,152
3.984375
4
#Rock beats scissors #Scissors beats paper #Paper beats rock playerOnePoints = 0; playerTwoPoints = 0; while True: a = input('Player 1: rock/paper/scissors or \'end\' to end the game: ') b = input('Player 2: rock/paper/scissors or \'end\' to end the game: ') if((a == 'rock' and b == 'scissors') ...
9b8ab952862047565948ce40c659c92b4c086322
DanRud/PracticePython
/24_Draw_A_Game_Board.py
430
4
4
def print_horizontal_line(user_size): print(' --- ' * user_size) def print_vertical_line(user_size): print('| ' * (user_size + 1)) def main(): user_size = int(input('What size game board u want to draw(from 3): ')) for index in range(user_size): print_horizontal_line(user_size) pr...
b678f408b9eae157189f2178e5f36d74e012b8b5
loveamazon/super_internal
/backend/tests/utils/test_hash_provider.py
449
3.5
4
import unittest from backend.utils import hash_provider class TestHashProvider(unittest.TestCase): # just for test. def test_hash_should_equal_when_same_string(self): v1 = "abcdefg" hashed = hash_provider.hash_str(v1) hashed_2 = hash_provider.hash_str(v1) hashed_3 =...
3e7efaaa1fc5b12078daa7e48d13a00c1c6897c6
VictoriaBrown/Python-Repo
/pythonSeed.py
311
3.71875
4
import random random.seed( 10 ) print "Random number with seed 10 : ", random.random() # It will generate same random number random.seed( 10 ) print "Random number with seed 10 : ", random.random() # It will generate same random number random.seed( 10 ) print "Random number with seed 10 : ", random.random()
f8033844a3939677df6448b77bd337352df2e83c
JafarSadikGhub/Python_Skillshare_Practice_Code
/14.a_list_of_numbers.py
306
4.03125
4
numbers = list(range(1,6)) print(numbers) odd_numbers = list(range(1, 101, 2)) print(odd_numbers) squares = [] for value in range(1,11): square = value ** 2 squares.append(square) print(squares) digits = [1,2,3,4,5] print(min(digits)) print(max(digits)) print(sum(digits)) #print(average(digits))
27b715f8e17f5eb439caf0d1a01b4aefe5fea29b
JafarSadikGhub/Python_Skillshare_Practice_Code
/sv4_analyzing_texts.py
752
4.09375
4
def word_count(filename): try: with open(filename) as file_object: contents = file_object.read() except FileNotFoundError: message = "Sorry, the file " + filename + " cannot be found." print(message) """To show end users no error, just write "pass" to this block an...
15eb4561bf981cd7280736d8d9689a16a00ba7b3
JafarSadikGhub/Python_Skillshare_Practice_Code
/19.input.py
82
3.640625
4
welcome = input("welcome, waht's your name? : ") print("Hello " + welcome.title())
fdc4c633cafc07382d2754ba107847378dca76db
JafarSadikGhub/Python_Skillshare_Practice_Code
/27.multiple_lists.py
301
3.75
4
in_stock = ['blue pens', 'paper', 'staples'] shopping_cart = ['blue pens', 'paper', 'staples', 'pins'] for item in shopping_cart: if item in in_stock: print("Adding " + item + " to your cart") else: print("Sorry " + item + " not in stock") print("Your order is complete!!!")
00cd8714ff4ab83a115fd23475151087e1824527
Kumaravel1607/kums
/vow.py
178
3.890625
4
k=input() list=["a","e","i","o","u","A","E","I","O","U"] if k.isalpha(): if k in list: print("vowel") else: print("consonant") else: print("invalid")
498852c54abdaf2be80bfe67dc88c0490f5a8ae1
chrisalexman/google-it-automation-with-python
/Crash Course in Python/Week_2/main.py
2,822
4.1875
4
# Data Types x = 2.5 print(type(x)) print("\n") # Expressions length = 10 width = 5 area = length * width print(area) print("\n") # Expressions, Numbers, and Type Conversions print(7 + 8.5) # implicit conversion print("a" + "b" + "c") print("\n") base = 6 height = 3 area = (base * height) /...
05ef19d2361a923f0d5ef944981a7db031d6ad4f
agwhitney/chess
/board.py
1,952
3.609375
4
from teams import Team, switch_teams from square import Square from itertools import product class Board: def __init__(self, width=8, height=8): self.width = width self.height = height self.key = self.create_key() # dict(str(alg_coord) : tuple(coordinate)) self.squar...
e06ac8016cd09624a01e232bcf060ee9b33df92d
Tom-Willemsen/splbytecode
/spl/tokens.py
960
3.75
4
class Token(object): def __init__(self, type, value=None): self.type = type self.value = value def __str__(self): result = "{}".format(self.type) if self.value is not None: result += ": " + str(self.value) return result def __repr__(self): return...
3d0acace4bb275b9027cc4459923b44558d4daf4
MikaCK/WPA
/lesson4/new_leap_year.py
298
3.90625
4
def leap_year(year): """Function for leap year validation :param year: int year :return: bool True/False """ if not isinstance(year, int): return False if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0: return True else: return False
d7d25a4d0eed0b020901a5cad860743b4ad24396
sam23456/pythonclassfiles
/list data type.py
856
4.25
4
#!/usr/bin/env python # coding: utf-8 # In[2]: course = ['linux','python','aws','devops','sql'] # In[3]: print(course) # In[ ]: # In[ ]: # In[5]: #indexing # In[6]: print(course[3]) # In[7]: print(course[3].title()) # In[8]: course.append('linux') # In[9]: print(course) # In[10]: ...
fcedca9ef340a853821b1956dab76516b70aabad
jordan0210/NCTU_CryptographyEngineering
/Quiz_4/Q5.py
634
3.5
4
from bitstring import BitArray if __name__ == '__main__': Bits = BitArray(bin='0b01000') print("1000 init:", end="") for i in range(100): print(int(Bits[-1]), end="") Bits[0] = Bits[1] ^ Bits[4] Bits = Bits >> 1 Bits = BitArray(bin='0b01111') print("\n1111 init:", end="") ...
76ed35e67bdffef4e08ccfef8b65dffa56d1a6c8
jeremybboy/EDP_numerique
/homework/B004.py
3,985
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Homework B004 Numerical methods for non-stationary Partial Differential Equations (PDEs): Finite Differences and Finite Volumes Mathematics and Modeling Master of Mathematics and Applications @author: Andre ALMEIDA ROCHA (3701739) """ import numpy as np import matpl...
cf2ed5f62e36f00f2f5dead043ceec03a21a5ab3
AlexFeeley/RummyAIBot
/tests/test_card.py
2,223
4.21875
4
import unittest from src.card import * # Tests the card class using standard unit tests # from src.card import Card class TestCard(unittest.TestCase): # Tests constructor returns valid suit and number of card created def test_constructor(self): card = Card("Hearts", 3) self.assertEqual(card...
69041985f86780c0c0aac0d70e8678fd73d232a5
MakeSchool-17/twitter-bot-python-moakq
/text_analyzer.py
1,479
4.09375
4
# OPTIMIZE # use regular expressions to get better results import re # loads a text file into a list def load_text(source_file): with open(source_file) as text: string = text.read() pattern = re.compile(r'\w+') text_list = re.findall(pattern, string) return text_list # checks if ...
de7296225ab80c6c325bd91d83eae0610115b263
kvraiden/Simple-Python-Projects
/T3.py
266
4.21875
4
print('This a program to find area of a triangle') #The formulae is 1/2 h*b h = float(input("Enter the height of the triangle: ")) b = float(input("Enter the base of the triangle: ")) area = 1/2*h*b print("The area of given triangle is %0.2f" % (area)+" unit.")
77ec1c606600995bd2916b42bb247da5a3b0698c
kqian5/Lisp-Interpreter
/Evaluator.py
904
3.75
4
import Environment def eval(x, env=Environment.global_env): # Evaluates an expression based on an environment if isinstance(x, Environment.Symbol): # Returns mapping from environment if it is a symbol return env[x] elif not isinstance(x, Environment.List): # Returns itself...
0f3723b82943fdcc102e79efa47c351aadd31995
ckite82/function_tests-1
/src/python_functions_practice.py
540
3.859375
4
def return_10(): return 10 def add(num_1, num_2): return num_1 + num_2 def subtract(num_1, num_2): return num_1 - num_2 def multiply(num_1, num_2): return num_1 * num_2 def divide(num_1, num_2): return num_1 / num_2 def length_of_string(test_string): return len(test_string) def join_str...
40bda1b91c053813cd3c7950fa360f692961eb96
Durbek1/1-Lineyniy-algoritm
/24-пример.py
100
3.5625
4
a = int(input('a=')) b = int(input('b=')) c = int(input('c=')) x=a a=c c=b b=x print(a,b,c)
d42ca94ecaf1e572ecda93f54687e588a7c997a6
Durbek1/1-Lineyniy-algoritm
/35-пример.py
150
3.5
4
# s=(v1+v2)*t1+(v1-v2)*t2 v1=int(input('v1=')) v2=int(input('v2=')) t1=int(input('t1=')) t2=int(input('t2=')) s=(v1+v2)*t1+(v1-v2)*t2 print(s)
7b5f4b1b841bb3f49ee4977263ef253b4b5dc320
Durbek1/1-Lineyniy-algoritm
/27-пример.py
64
3.578125
4
A=int(input('A=')) y1=A**2 y2=A**4 y3=A**8 print(y1,y2,y3)
50449c501772db938371017d403e92e83fe6b47f
mohiitaa/major_project_cmfd
/plotex.py
396
3.734375
4
import matplotlib.pyplot as plt import numpy as np x = np.arange(5) y = np.exp(x) fig1, ax1 = plt.subplots() ax1.plot(x, y) ax1.set_title("Axis 1 title") ax1.set_xlabel("X-label for axis 1") z = np.sin(x) fig2, (ax2, ax3) = plt.subplots(nrows=2, ncols=1) # two axes on figure ax2.plot(x, z) ax3.plot(x, -z...
cc2ebc50c3f52c20bcc2b03305b7556301c49698
tristandaly/CS50
/FinalProject/accessible_room_interaction.py
2,853
3.5
4
from adventurelib import * from accessible_room import * from out_front import * from porch import * import time @when('one') def first_door(): say("You open the first door and enter the room.") say("Your blood runs cold as you meet your only companion for the rest") say("of eternity.") ...
b50f2c051b7ae0506cbc6f8a414d943ab3a20c51
tristandaly/CS50
/PSET6/mario/more/mario.py
727
4.1875
4
from cs50 import get_int def main(): # Begin loop - continues until a number from 1-8 is entered while True: Height = get_int("Height: ") if Height >= 1 and Height <= 8: break # Based on height, spaces are added to the equivalent of height - 1, subtracting with each row from t...
c8646e494885027bdf3819d0773b1ebb698db0a1
fatih-iver/Daily-Coding-Interview-Solutions
/Question #7 - Facebook.py
951
4.21875
4
""" This problem was asked by Facebook. Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded. For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka', and 'ak'. You can assume that the messages are decodable. For example, '001' i...
04231b8adcad8dc5c464691cb3e8a105fc3f3527
fatih-iver/Daily-Coding-Interview-Solutions
/Question #2 - Uber.py
908
4.09375
4
""" Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected...
8f0155e0dfc887faca800b55a0997d9ccfc6b718
fatih-iver/Daily-Coding-Interview-Solutions
/Question #30 - Facebook.py
661
3.640625
4
def get_water_capacity(area): width = len(area) highest_from_left = [0] * width highest_from_right = [0] * width highest_from_left[0] = area[0] for index in range(1, width): highest_from_left[index] = max(highest_from_left[index-1], area[index]) highest_from_right[width-1] = area[wid...
3d0fabbf1c61418551a60b7139d47e4c171356b5
Jamye/algos_py
/Algorithm_challenges_CD/chapter_one.py
5,090
4.21875
4
# Setting and swapping # set my_number to 42. set my_name to your name. Now swap my_number into my_name and vice versa def swap(name, number): my_number = number my_name = name temp = my_number my_number = my_name my_name = temp print my_name print my_number # print -52 through 1066 def...
3a08ed8a4cb6f2ce46d856be67d89ad554d38dff
Donfa1con/PythonHse
/Homework-2/statistics.py
1,461
3.703125
4
from help_function import read_the_file def get_list_of_languages(languages, data): list_of_languages = [] for language in languages: is_language_in_object = False payment_of_vacancie = 0 number_of_vacancie = 0 for objects in data: if objects['candidat']...
98cc1e80e70a38038bd9b0818e7b2472bc38c139
imahmood786/SEIRCastSpatialABMSimulator
/Utility/dataframe.py
727
3.765625
4
# import pandas import pandas as pd # List of Tuples employees = [('Stuti', 28, 'Varanasi', 20000), ('Saumya', 32, 'Delhi', 25000), ('Aaditya', 25, 'Mumbai', 40000), ('Saumya', 32, 'Delhi', 35000), ('Saumya', 32, 'Delhi', 30000), ('Saumya', 32, 'Mumbai',...
3e3f17c7877bf2001a9de9d48ca4b9652648bc1f
natepill/problem-solving
/PracticePython/Fibonacci.py
490
4.25
4
# Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. # Take this opportunity to think about how you can use functions. # Make sure to ask the user to enter the number of numbers in the sequence to generate. # (Hint: The Fibonnaci seqence is a sequence of numbers where the...
1f50489c7c55180ee85104b7dab422c0784d3a4f
natepill/problem-solving
/PracticePython/List_Overlap.py
330
3.890625
4
list1 = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] list2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] intersection_list = list() list1 = set(list1) list2 = set(list2) for number in list1: for other_num in list2: if other_num == number: intersection_list.append(other_num) print(set(intersecti...
4e465f7445a5591a54a9f58a817ced274e376fe4
natepill/problem-solving
/PracticePython/merge_sort.py
5,440
4.3125
4
def merge_sort(arr): # print("arr:", arr) # base case if len(arr) <= 1: return arr # recursive call on two halves index_half = len(arr)//2 left_arr = arr[0:index_half] right_arr = arr[index_half:] # print("left_arr:", left_arr) # print("right_arr:", right_arr) merge_...
5924795da91c4804b031742e57d9397aa6c693d2
natepill/problem-solving
/PracticePython/OOP/calc_test.py
1,045
3.515625
4
""" Notes: Fixtures: are functions that run before each test function Can act as a baseline for running test to make sure the enviorement is fixed @pytest.fixture Testing external functions: """ from calc import Calculator def test_add(): calc = Calculator() assert calc.add(5, 5) ...
948a4cc7fcdffd194dde985f522d8e6c426c399d
natepill/problem-solving
/LeetCode/remove_nth_node_from_list.py
2,772
3.90625
4
""" Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. """ # Definition for singly-linked list. class ListNode: def __init__(self, x): ...
f0e54e968489f10e8c725ed1e624b0795c6bc8c7
natepill/problem-solving
/HackerRank/matrix.py
1,226
4
4
matrix = [[1,2,3], [4,5,6], [7,8,9], [10,11,12]] regular_list = [1,2,3] # print(matrix[1][2]) # for i in matrix: # for x in rows = len(matrix) print(rows) columns = len(matrix[0]) # for row in matrix: # for column in row: # print(column) # # for row_index in range(0, rows): # # for column in r...
969af92bafbb7da2fef31622739617f2de23b21f
natepill/problem-solving
/PracticePython/single_num.py
569
3.5625
4
""" I completed this problem with dictionary, if key surpasses 1, then remove key Need to learn bitwise operators to unlock the O(1) memory --> See second function """ def singleNumber(nums) -> int: seen = dict() for num in nums: if num in seen: del seen[num] else: ...
d88bd4699c8976ecf5145a5e11b197f28bb75baf
natepill/problem-solving
/HackerRank/FindSubString.py
965
3.96875
4
""" Find the amount of times the sub_string occurs in the original string """ """ Refactor code to increment the index in range of the length of the original string because the index(obj) function is resetting the index at an earlier occurence of a letter in the sub_string to where the index is supposed to be at. """ ...
e3d95f71069c8e6a9713110d2791b489ced43e78
tulians/eml
/src/neural_network.py
3,399
3.859375
4
# Neural network module. # =================================== """Provides an abstraction to generate neural networks.""" # Project's modules import utils as u import threshold as th from training_methods import backpropagation # Third-party modules import numpy as np class FeedforwardNeuralNetwork(object): """...
03af5e0d7b27cdc51d7a2aab1a42ec64a4c22091
ggonzaleze/cracking-the-code
/Chapter1/1.1IsUnique.py
305
3.984375
4
#Determines if a string has all unique characters def isUnique(string): characters = {} for c in string: if characters.get(c) == None: characters[c] = 1 else: return False return True string = input("Enter a string:") print(isUnique(string))
b14ae1a99afec42aefa8729ebed01d4106ef4aba
bortnovskiygleb/Python_course
/first.py
114
3.578125
4
import numpy as np def plus (a, b): c = a + b return c a = np.zeros(5) a = a + 2 print(a) print(plus(2,3))
03336c69bdac756f67f22a7b5e9a2ac53b568520
Ijnek7/Unicode
/resize.py
365
4.03125
4
# import numpy as np from PIL import Image img = input("input file name: ") width = int(input("How wide should the image be: ")) height = int(input("How tall should the image be: ")) x = Image.open(img,'r') #opens the given image x = x.resize((width, height)) #resizes it to given dementions file = file.open(file ...
a7daa3236e0cc37cfd20476dbf5329b434b6a8fa
Chanceyhugger/python1
/name.py
75
3.921875
4
name = input("what is your name?\n") print('hello wonderful person '+name)
0ad254b695541b3eefe09c0974566b0ffb4857b3
sbambach/SCUTTLE
/software/python/basics/L1_camera.py
980
3.84375
4
# This file retrieves an image from the usb camera. # Import external libraries import numpy as np import cv2 # Initialize important vars # width = 240 # desired width in pixels # height = 160 # desired height in pixels width = 120 # desired width in pixels height = 80 # desired height in pixels camera = cv2.VideoC...
00606b6acbad74c5e1802b1fa3d120bf7b75c65b
elisemayo/CPSC408
/Assignment 2/DatabaseCRUD.py
7,539
4.03125
4
# Elise May # Student ID: 2271041 # Email: may137@mail.chapman.edu # CPSC 408 # Assignment 2 import sqlite3 from Student import Student class CRUD: def __init__(self, db): # connect to database self.conn = sqlite3.connect(db) self.c = self.conn.cursor() # create s...
cd76d0d2fdf68ecda07fd4d6d072ca9b15d5b814
stephen-lazaro/Misc
/py/combinadics.py
793
3.546875
4
debug = True def factorial(a): if a == 0: return 1 else: return a * factorial(a - 1) def choose(a, b): if b > a: return 0 elif b == a: return 1 else: return factorial(a) // factorial(b) // factorial(a - b) class Combinad: def __init__(self, intg, order): acc = [] while order >= 0: i = 1 whi...
aaab9cfd45f2ec2394c49c80506e9a0275dd6519
stephen-lazaro/Misc
/py/pathscount.py
893
3.859375
4
def occurrence(item, lz): acc = 0 for thing in lz: if item == thing: acc += 1 return acc print("20 = " + str(occurrence("d", "dddddddddddddddddddd"))) print("4 = " + str(occurrence("d", ['d','d','r','d','d']))) class Factorial(): def __init__(self): self.acc = {0:1,1:1,2:2} def factorialus(self, n): d...
6d044556688ac43c30646d6acebb2ddab75a64ee
CapaBE/Python
/ex3_HouseMaxSize.py
1,923
4.09375
4
class House: "The house that can contain many rooms" def __init__(self, available_space=100): self.rooms = [] self.available_space = available_space self.totalsize=0 def add_rooms(self, *room): for item in room: if self.size() + item.size > self.a...
013df573816baa9cf6c821223de06b773fbe8d1f
ricardosmotta/python_faculdade
/aulapratica4_ex1.py
1,085
4.15625
4
op = input('Qual operação você deseja realizar? + , - , * ou / : ') if (op == '+') or (op == '-') or (op == '*') or (op == '/'): v1 = int(input('Digite um valor inteiro: ')) v2 = int(input('Digite outro valor inteiro: ')) while op != 's': if (op == '+'): res = v1 + v2 print('Resultado da...
900277278977c51543cb9bee3ef7a350eeb639eb
ricardosmotta/python_faculdade
/aula5-exercicio1.py
470
3.59375
4
def realce(s1): print('-' * 10) print(s1) def soma(a, b): print(f'A = {a} e B = {b}') s = a + b print(f'A soma de A + B é igual = {s}') def contador(*num): for valor in num: print(f'{valor} ', end='') print('FIM!') def contador(*num): tam = len(num) print(f'Recebi os va...
56b407e19a71898f123b688c28d8e5e85cef69ca
ricardosmotta/python_faculdade
/aula3_exercicio4.py
836
4.125
4
print('[ 1 ] Maçã') print('[ 2 ] Laranja') print('[ 3 ] Banana') prod = int(input('Qual dos produtos acima você deseja? ')) while prod != 1 and prod != 2 and prod != 3: print('Escolha um valor válido!!!') prod = int(input('Qual dos produtos acima você deseja? ')) if prod == 1 or prod == 2 or prod == 3: ...
5e7a00c89e63b95c73a5b4faf752015f880a112c
aarontinn13/Winter-Quarter-History
/Tutorial/OOP_MagicMethods_Overloading.py
7,565
4.75
5
''' So what's magic about the __init__ method? The answer is, you don't have to invoke it directly. The invocation is realized behind the scenes. When you create an instance x of a class A with the statement "x = A()", Python will do the necessary calls to __new__ and __init__. We have encountered the concept of ...
7ae1af51325320ac7ebbc7fa0fb758cd840a4c6b
aarontinn13/Winter-Quarter-History
/Tutorial/RecursiveFibonacci.py
3,456
3.984375
4
# 1,1,2,3,5,8,13,21,34,55,89 # 1,2,3,4,5,6, 7, 8, 9,10,11 def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n-1) + fib(n-2) print(fib(40)) print() def fib_iteration(n): old, new = 0, 1 if n == 0: return 0 for i in range(n-...
f9547707da45dbf443f80f58b18d6813a6e941b7
aarontinn13/Winter-Quarter-History
/Tutorial/OOP_abstractclasses.py
3,386
4.375
4
''' Abstract Classes Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods. Subclasses of an abstr...
564154a689876d4776cc672720e957e35df63766
aarontinn13/Winter-Quarter-History
/Homework2/problem1.py
645
4.03125
4
def fahrenheit_to_celsius(i): #Takes your number and transforms to Celsius y = (i-32)*(5.0/9.0) #using format instead of % because decimal print '\nIt is {} in Celsius...\n'.format(y) #Below is an infinite loop, in order to escape, you must type 'break' while True: try: x = raw_input('Enter ...
8039fd9e577f8bdf914ed9cfe8e54f288dc17d40
aarontinn13/Winter-Quarter-History
/Tutorial/Decorators.py
9,681
4.53125
5
''' A decorator in Python is any callable Python object that is used to modify a function or a class. A reference to a function "func" or a class "C" is passed to a decorator and the decorator returns a modified function or class. The modified functions or classes usually contain calls to the original function "fun...
5e37fb9cff13522653e0e9006951e0db5839e259
aarontinn13/Winter-Quarter-History
/Homework2/problem6.py
938
4.3125
4
def palindrome_tester(phrase): #takes raw phrase and removes all spaces phrase_without_spaces = phrase.replace(' ', '') #takes phrase and removes all special characters AND numbers phrase_alpha_numeric = ''.join(i for i in phrase_without_spaces if i.isalpha()) #takes phrase and transforms all upper ...
2122f4523bd8b5985a259581c14f4ae03e9f44eb
aarontinn13/Winter-Quarter-History
/Tutorial/readingwriting,io2.py
655
3.890625
4
import os #how to read strings line by line with open('mydata2.txt', encoding='utf=8') as myFile: linenum = 1 while True: line = myFile.readline() if not line: #if there is no data break print(linenum, ':', line, end='') print('line', linenum) ...
bf26a7742b55fa080d22c1fadffccbf21ae9ce34
aarontinn13/Winter-Quarter-History
/Homework3/problem7.py
1,088
4.28125
4
def centered_average_with_iteration(nums): #sort list first nums = sorted(nums) if len(nums) > 2: #remove last element nums.remove(nums[-1]) #remove first element nums.remove(nums[0]) #create total total = 0.0 #iterate through and add all remaining in ...
4294c3a466ee1f380598ab95d420349507376274
aarontinn13/Winter-Quarter-History
/Homework2/problem2.py
795
3.984375
4
def score(x): if 90 <= x <=100: print '\nYou received an A!\n' elif 80 <= x <90: print '\nYou received an B!\n' elif 70 <= x <80: print '\nYou received an C!\n' elif 60 <= x <70: print '\nYou received an D!\n' elif 0 <= x < 60: print '\nYou received an F!\n' ...
13071e984f80dfeea4fc4fe9b045e7e746d13fb3
aarontinn13/Winter-Quarter-History
/Tutorial/MetaCharactersRegularExpressions2.py
5,370
4.84375
5
import re ''' Can use the findall method to find all examples of the given pattern. ''' t="A fat cat doesn't eat oat but a rat eats bats." mo = re.findall("[force]at", t) print(mo) ''' Another Example... ''' courses = "Python Training Course for Beginners: 15/Aug/2011 - 19/Aug/2011;Python Training Cours...
4bcb12db124a30486d4c4ad6f89212eca0904307
Aguskurnia123/Agus-Kurnia-Akbar_I0320004_Abyan_Tugas-4
/Exercise 4.9.py
78
3.5
4
#string str="Hello World" #substring substr= str[3:5] #output print(substr) #lo
8815b5f75053ba50cc7360a836ededdb8cb1e625
mudso/helloworld
/programming_for_every_body/lesson_9/exercise_2.py
338
3.515625
4
fname = input('please input a file name:') try: fread = open(fname,'r') except: print('bad name!!') quit() counts = {} for line in fread: words = line.split() if len(words) >0 and words[0]=='From': print(words[2]) counts[words[2]] = counts.get(words[2],0) + 1 else: contin...
b4171f37afd7d107b0d9a5e8c06abde46103931b
mudso/helloworld
/programming_for_every_body/lesson_12/exercise_1.py
826
3.703125
4
import socket urlname = input('please input a url->-') try: surlname = urlname.split('/') HOST = surlname[2] mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mysock.connect((HOST, 80)) cmd = 'GET {} HTTP/1.0\r\n\r\n'.format(urlname).encode() mysock.send(cmd) except: print('you ent...
e2ab34036a201db1763f36b4b2d992861fa67b80
utkarsharma01/My-Projects
/face_detection/face_detection.py
1,038
3.5
4
import cv2 from random import randrange #load some pre-trained data on face frontals from opencv (hear cascade algorithm) trained_face_data = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') #choose an image to detect faces in #img = cv2.imread('g.jpg') webcam = cv2.VideoCapture(0) #iterate for...
1193dc1e02a39c442867b2552c9d0b15413aaeb4
jlopezsi/flight-schedule-maker
/Airport.py
1,797
3.671875
4
from math import radians, asin, sin, cos, sqrt class Airport: def __init__(self, name, iata, icao, runway_length, daily_passengers, position, turnaround_factor=1.0): self.__name = name self.__iata = iata self.__icao = icao self.__runway_length = runway_length # Used to see if cert...
6c5b2654553ded7933ab0eae2bc38ffd159235a5
theapphideaway/AutomateWithPython
/app/src/main/python/ChapterThree.py
285
3.71875
4
def exception_handling(givenNumber): try: return givenNumber / 0 except ZeroDivisionError: return "Sorry we can't divide by zero for you. Solve this problem by changing the source code. " \ "This is meant to be an example of exception handling"
27d2e6ccaba452eddc54ec8344b7d071eea9a12f
hirak0373/AI-programs
/leap.py
220
3.984375
4
# Find a leap year def is_leap(y): leap = False if y % 4 == 0: leap = True elif (y % 100 == 0) and (y % 400 == 0): leap = True return leap y = int(input()) print(is_leap(y))
a3c9a845a7e85a6cd26b7984e97071a57301c171
Python-Instruction/Excel-with-Python
/Combining multiple excel file into a single master sheet.py
377
3.5625
4
import pandas df1 = pandas.read_excel("Student_details.xlsx") df2 = pandas.read_excel("Marks.xlsx") # merging the files df3 = df1[["Roll No","Name", "Email id"]].merge(df2[["Roll No","English", "Science", "History"]], on = "Roll No", how = "left") # combining into single excel spreadsheet df3.to_ex...
04c90bb532a41bb17a47c5ba903d38f4992d150e
artisodua/Hillel
/2_5.py
1,531
3.890625
4
# 5) Есть строка со словами и числами, разделенными пробелами (один пробел между словами и/или числами). # Слова состоят только из букв. Вам нужно проверить есть ли в исходной строке три слова подряд. # Для примера, в строке "hello 1 one two three 15 world" есть три слова подряд. pline = 'hello 1 one two three 15 worl...
5d98989d09941e4c736ae3dbf72212904fedd4af
artisodua/Hillel
/1_2.py
157
3.859375
4
def even_num(x): ar = [] for i in range(0, x): if i % 2 == 0: ar.append(i) return ar value = int(100) print(even_num(value))
ac8d7f62e8dc81c70d0bffdbbcf1eb9613c23d35
Sem8/lambda_x_whiteboard
/longestSubstrWoutRepeating.py
543
3.953125
4
#Given a string, find the length of the longest #substring without repeating characters. #ex: 'abcac' return 3 #(abc or bca) def longestSub(s): table = {} max_count =0 index = 0 current_count =0 y = list(s) while index < len(y): new_char = y[index] if new_char not in table: table[new_char]...
4d80546ca7dfd20737f12f2dfddf3f9a0b5db00b
nip009/2048
/twentyfortyeight.py
2,776
4.125
4
# Link to the problem: https://open.kattis.com/problems/2048 def printArr(grid): for i in range(len(grid)): row = "" for j in range(len(grid[i])): if(j != 3): row += str(grid[i][j]) + " " else: row += str(grid[i][j]) print(row) def ...
fa0109c56eb419ebeee2bf52427528e892afeb3e
DhiaulAmar/Dhiaul-Amar-Naufal_I0320027_Tiffany-Bella_Tugas-2
/I0320027_Soal 1_Tugas 2.py
1,392
3.90625
4
#menampilkan informasi program print("Luas Persegi Panjang") #input nilai panjang dan lebar P = float(input("Masukkan nilai panjang: ")) L = float(input("Masukkan nilai lebar : ")) #menghitung luas persegi panjang luas_persegipanjang = P * L #menampilkan hasil perhitungan print("Luas Persegi Panjang: ", luas_persegi...
a1144fefc53d501f5a11b32e4368b4bfa06ca6e3
UserLdm/data-structures-and-algorithms-in-Python
/data_structures_and_algorithms/08-insert_sort.py
567
3.875
4
def insert_sort(alist): """插入排序 稳定""" n = len(alist) for j in range(1, n): # i代表内层循环起始值 i = j # 执行从右边的无序序列中取出第一个元素,即第i位置元素,然后插入前面的正确位置中 while i > 0: if alist[i] < alist[i-1]: alist[i], alist[i-1] = alist[i-1], alist[i] i-=1 ...
64e2151fbe7775377578de2b5af929ee318a3779
beigerice/Project-Euler
/problem 29.py
159
3.625
4
a = 2 b = 2 x = list() while a < 101: while b < 101: if a**b not in x: x.append(a**b) b += 1 b = 2 a += 1 print len(x)
d6fa9e318a414a7e6b09c7a3752dc77e6f6026dc
MarinaHolubenko/pythonProjectHomeworks
/Lists.py
401
3.90625
4
import random random_list = [random.randint(0, 9) for i in range(15)] for index, item in enumerate(random_list): print("Index position: {} , Number: {}".format(index, item)) print("Enter your number") number = int(input()) index=random_list.index(number) for index, item in enumerate(random_list): if number==it...
96dbe55137e59bd4947a814fd8c3ac3dd1ed437c
rlyyah/mazegame
/model.py
1,537
3.640625
4
from collections import defaultdict class Point(): def __init__(self, pos_x, pos_y): self.position_x = pos_x self.position_y = pos_y @property def x(self): return self.position_x @property def y(self): return self.position_y def __add__(self, other): r...
00656448d492d437654d9bc7a513a5239b26e04b
vinny0965/phyton
/1P/meuprojeto/Atividades 1VA/Nova Aula/Correção 1VA/resolucao prova - parte 2 - A vigança.py
2,216
4.21875
4
#Q8 #23 lista = [1,2,3,55,66,77,88,-1,-2,-3] #lista = [-1, -2, -3, -4, -5] """ #Retornar o maior elemento maior = lista[0] for numero in lista : if (numero > maior) : maior = numero print (f"Maior número:{maior}") #Forma alternativa de resolução #print (max(lista)) #Retornar a soma soma = 0 for numero...
f40d03db561a5e2adee0b047aebfae2f3e5fcf90
vinny0965/phyton
/1P/meuprojeto/Atividades 1VA/Nova Aula/Lista de Exercicios 1/Testando Atividades/inverter.py
119
3.921875
4
"""resultado="" letra=input("insira um nome") for letra in letra: resultado=letra+resultado print(resultado) """
0f6a65d3e50324bb659d2149fac256fba940f6cf
vinny0965/phyton
/1P/meuprojeto/Atividades 1VA/Nova Aula/Correção 1VA/01.py
1,004
4.0625
4
"""lista=[] for i in range (10): x=int(input("insira um numero")) lista.append(x) print(lista) print("O maior elemento da lista é {}".format(max(lista))) print("A soma dos elementos é {}".format(sum(lista))) """ """lista=[1,2,4,3,2,1,23,3] count=0 media=sum(lista)/8 print("a soma dos elementos é {}".format(sum...
e20816f07b5a6308dd6cf1945fc606a2456d64ab
vinny0965/phyton
/1P/AULA 2 LISTAS/LISTAS/Questões de 2 a 5.py
1,670
3.84375
4
#Adicione n elementos na lista def q1(): lista=[] n=int(input('insira a quantidade de Elementos:')) for i in range(n): n1=int(input('Insira os Elementos:')) lista.append(n1) print(lista) q1() # 2 questão - Adicionar na lista elementos, parar quando for digitado o numero ZERO def q2():...
fd013e75e1696d633d94146f10e0c615f1d90a28
vinny0965/phyton
/Lista-Simplesmente-Encadeada-Em-Python-master/Lista.py
5,178
3.859375
4
from No import No class Lista(object): # Construtor def __init__(self): self.__inicio = None self.__ultimo = None # Métodos acessores def set_Inicio(self, inicio): self.__inicio = inicio def get_Inicio(self): return self.__inicio def set_Ultimo(self, ultimo)...
ad1a812d58f4fcef60b78de00e73a6bf2a3a3870
vinny0965/phyton
/1P/meuprojeto/Atividades 1VA/Nova Aula/Lista de Exercicios 5/questao5.py
198
3.828125
4
listapar=[] listaimpar=[] for i in range(20): x=int(input("Numero:")) if(x%2==0): listapar.append(x) else: listaimpar.append(x) print(listapar) print(listaimpar)
942fd85ef1b428bc470700f440e91be45d51c8b4
vinny0965/phyton
/1P/meuprojeto/Atividades 1VA/Nova Aula/Lista de Exercicios 5/Atividade3.py
209
3.8125
4
"""Faça um Programa que leia 4 notas, mostre as notas e a média na tela. """ Notas = [ int(input("Informe a nota "+str(x) ) ) for x in range(4) ] print("Notas", Notas) print("média das Notas", sum(Notas)/4)
86f9b0989bedb9c5044baf3beaa7379aca44ef14
vinny0965/phyton
/AED/main1.py
702
3.578125
4
from AED import dupla_encad def menu(): print(''' [1] - Inserir Inicio [2] - Inserir Fim [3] - Remover Inicio [4] - Remover Fim [5] - Listar [0] - Sair ''') lista = dupla_encad.ListaEncadeada() lista = dupla_encad.ListaEncadeada() dado = 0 opcao = -1 while ...