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 |
|---|---|---|---|---|---|---|
e7c1cdaee3eecc8849e7c013aaaa7afa31362fb9 | lukeb88/data_scientists_utils | /plots/for_keras.py | 717 | 3.921875 | 4 | import matplotlib.pyplot as plt
def plot_loss_history(history):
'''
This functions plots the training vs test loss of a Keras model
Attributes:
- history (keras.callbacks.History): the history of a trained Keras model
'''
# Get training and test loss histories
training_lo... |
f170cd87fc78eed58f6ef7ac9ed2281949f6933b | yagyapandeya/MUS-105-notes | /hw6/meter.py | 3,730 | 3.734375 | 4 | ###############################################################################
from .ratio import Ratio
## A class representing the standard musical meters.
# See: https://en.wikipedia.org/wiki/Metre_(music)
class Meter:
## Constructor.
# @param num The numerator, an integer between 1 and 16 inclusive.
... |
68806c19c3ce8b920bb85233500624d42b5c3793 | olivertd/repo | /Programmering 1/Kokchun_Uppgifter/Dictionary/Dictionary_01.py | 513 | 3.515625 | 4 |
#här gör jag min dictionary med key och value som är en del kurser
doinkctionary = {"tillämpad_1" : 100, "programmering_1" : 100, "daodac" : 100, "svenska_2" : 100, "fysik_1" : 150, "idrott" : 100, "engelska_6" : 100, "matematik_4" : 100}
#skapar ny variabel med 0 värde
POANG = 0
#här gör jag en foor loop
for key,... |
b3d2ffd705ea24c2345246636c010ced7f677e1b | letangco/Learning-Python | /Learning/Sets/remove_item.py | 205 | 3.5 | 4 | myset = {'pineapple', 'orange', 'apple', 'mango', 'banana', 'papaya', 8888, 'kiwi', 'cherry'}
myset.remove(8888)
print(myset)
myset.discard("banana")
print(myset)
x = myset.pop()
print(x)
print(myset) |
32c0b70fbed2ecae622414a35c90d612fd13e55f | letangco/Learning-Python | /Learning/Sets/python_sets.py | 334 | 3.828125 | 4 | # KHông có thứ tự xác định
# không cho phép các giá trị trùng lặp
# Không thể được tham chiếu
myset = {"apple", "banana", "cherry", "cherry"}
print(myset, type(myset))
myset1 = set(("apple", "banana", "cherry"))
print(myset1)
print('---------------------------------------')
for x in myset:
print(x) |
8573548e9809f71cb281f438f26b7829bef79af4 | letangco/Learning-Python | /Learning/L3. Strings/index.py | 614 | 3.625 | 4 | a = """Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua."""
print(a)
b = '''Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.'''
print(b)
# Strings are array
variable_str... |
ace89eddf5ee7ce69071403a14430767785fab0a | mehrdad-shokri/Data-Science-45min-Intros | /python-decorators-101/_uneditable_lib.py | 559 | 3.828125 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
A simple module representing a Coordinate class and related method.
Modified from Simeon Franklin's blog:
- http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/
"""
class Coordinate(object):
"""Represents a point in two-dimensional space."""... |
a3e1a2a1f093a5bd394ff11b0da81d389a76ada7 | mehrdad-shokri/Data-Science-45min-Intros | /python-unittest-101/mathy.py | 661 | 3.921875 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
__author__="Josh Montague"
__license__="MIT License"
class Calcs(object):
"""
Objects of type Calcs have two methods for numerical calculations, and
an attribute of 'zero' which is set to 0
"""
def __init__(self):
self.zero = 0
def add_o... |
9c5e92d507a70383d9f4f0f8e430ced90793fe0e | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/bit_magic/set_kth_bit.py | 984 | 3.9375 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/set-kth-bit/0
# https://wiki.python.org/moin/BitwiseOperators
# Given a number N and a value K. From the right, set the Kth bit in the binary
# representation of N. The position of LSB (or last bit) is 0, second last bit
# is 1 and so on. Also, 0 <= K < X, whe... |
4a430ff5e8d1f8fdea9d8cad3f5656a39211ced9 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/stack_and_queue/queue_using_two_stacks.py | 1,372 | 4.15625 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/queue-using-two-stacks/1
# Implement a Queue using 2 stacks s1 and s2.
###############################################################################
class Stack:
def __init__(self):
self.stack = []
def push(self, x):
self.stack.app... |
10fdb82b732b524a4a9526758e8579e468f9aae0 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/bit_magic/rotate_bits.py | 1,506 | 4.40625 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/rotate-bits/0
# https://wiki.python.org/moin/BitwiseOperators
# Given an integer N and an integer D, you are required to write a program to
# rotate the binary representation of the integer N by D digits to the left as well
# as right and print the results in ... |
63ae4ab72d7ab3dffb9dbe38e13fcf4bf441a8bc | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/amazon/k_largest_elements.py | 750 | 3.5625 | 4 | import sys
import heapq
# using Max/Min heap: O(n) to create heap + O(klogn) to retrieve max/min k elements = O(n + klogn)
def kth_smallest(arr, k):
heapq.heapify(arr)
rv = []
while k:
rv.append(heapq.heappop(arr))
k -= 1
return rv
def kth_largest(arr, k):
arr = [-x for x in arr]... |
babff60991c4ea5c4bfa4c1b3402b5626e284f89 | mdhatmaker/Misc-python | /Apis/YouTube/youtube_audio_dl.py | 2,627 | 3.546875 | 4 | """The only files available for direct download are the ones which are listed under yt.streams.all().
However, it is straightforward to convert the downloaded audio file from .mp4 to .mp3 format.
For example, if you have ffmpeg installed, running this command from the terminal will do the
trick (assuming you're in the ... |
e2324ee0841a8a1019f468240096bff9acafc875 | mdhatmaker/Misc-python | /interview-prep/char_mapping_messages.py | 2,401 | 3.734375 | 4 | import sys
if __name__ == "__main__":
# Google interview question: given a string, return the first recurring
# character in the string (or None if no recurring char exists)
def first_recur(s):
bag = {}
N = len(s)
for i in range(int(N / 2)):
if s[i] in bag: return s[i... |
cd347eea4c89fc68f3efaae4df99ac8d742093b6 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/mathematical/closest_number.py | 1,107 | 4.09375 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/closest-number/0
# Given non-zero two integers N and M. The problem is to find the number closest
# to N and divisible by M. If there are more than one such number, then output
# the one having maximum absolute value.
##########################################... |
7c24ede888f85db998cd35f86758a3f30e957a98 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/arrays/kadanes_algorithm.py | 1,374 | 3.890625 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/kadanes-algorithm/0
# https://hackernoon.com/kadanes-algorithm-explained-50316f4fd8a6
# Given an array arr of N integers. Find the contiguous sub-array with maximum sum.
def kadanes_algo(arr):
max_so_far = [0] * len(arr)
max_so_far[0] = maxsum = arr[0... |
ab8b5f519e8290fa8b39f80dc8012847a7329d84 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/amazon/implement_stack.py | 615 | 3.734375 | 4 | import sys
# Implement a stack with push(), pop() and min() in O(1) time.
stack = []
stack_mins = []
def push(x):
stack.append(x)
if len(stack_mins) == 0 or stack_mins[-1] >= x:
stack_mins.append(x)
print('push:', x)
def pop():
x = stack.pop()
if stack_mins[-1] == x:
stack_mins.p... |
ff46b49fd5c6b28f00bf3d180e802f97ab5f45a1 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/greedy/candy_store.py | 1,760 | 3.984375 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/shop-in-candy-store/0
# In a candy store there are N different types of candies available and the prices
# of all the N different types of candies are provided to you.
# You are now provided with an attractive offer: You can buy a single candy from the
# store ... |
f1af038727319bf18a54b23238721dfb4f73cba3 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/amazon/binary_tree_to_linked_list.py | 1,601 | 3.84375 | 4 | import sys
from collections import deque
# https://practice.geeksforgeeks.org/problems/binary-tree-to-dll/1
# TODO: traverse_inorder() displays nodes in correct order, but WE NEED TO CREATE DLL
# Given a Binary Tree (BT), convert it to a Doubly Linked List(DLL) In-Place.
# The left and right pointers in nodes are to... |
0610e71af64f002c4bedf73eccdb96e0ca6026b4 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/recursion/number_of_paths.py | 1,201 | 3.65625 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/number-of-paths/0
# The problem is to count all the possible paths from top left to bottom right of
# a MxN matrix with the constraints that from each cell you can either move to
# right or down.
################################################################... |
f45004fd8222496559d2fe627a40aa3e72b6e049 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/google/subarray_with_sum.py | 1,147 | 3.671875 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/subarray-with-given-sum/0
# Given an unsorted array A of size N of non-negative integers, find a continuous
# sub-array which adds to a given number S.
###############################################################################
def subarray_with_sum(arr,... |
adc8ab49e62bf37fcba84299e7a2caae3f717306 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/arrays/largest_number_from_array.py | 1,514 | 3.953125 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/largest-number-formed-from-an-array/0
# TODO: this is SO UGLY -- there's got to be a better algorithm for this!
# Given a list of non negative integers, arrange them in such a manner that they
# form the largest number possible.The result is going to be very ... |
a0aa1708854d0af53598e39077fd80925a0adbfa | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/google/maximum_index.py | 1,222 | 3.953125 | 4 | import sys
from collections import namedtuple
Entry = namedtuple('Entry', ['value', 'idx'])
# https://practice.geeksforgeeks.org/problems/maximum-index/0
# Given an array A[] of N positive integers. The task is to find the maximum
# of j - i subjected to the constraint of A[i] <= A[j].
#############################... |
a563dce8ef1b52cc79d46e304961cd72afa21705 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/google/interleaved_strings.py | 1,384 | 4.09375 | 4 | import sys
from collections import deque
# https://practice.geeksforgeeks.org/problems/interleaved-strings/1
# Given three strings A, B and C your task is to complete the function isInterleave
# which returns true if C is an interleaving of A and B else returns false.
# C is said to be interleaving A and B, if it con... |
49fb6f9a862e0ae9e28b16d29b523c6c4e5ffeaf | mdhatmaker/Misc-python | /Pandas/pandas_test.py | 1,725 | 3.625 | 4 | import pandas as pd
import numpy as np
def csv_test():
raw_data = {'first_name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'],
'last_name': ['Miller', 'Jacobson', ".", 'Milner', 'Cooze'],
'age': [42, 52, 36, 24, 73],
'preTestScore': [4, 24, 31, ".", "."],
'postTestSco... |
4c8687e4600a7a29449efa749b56de2b04221e40 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/bit_magic/find_first_set_bit.py | 980 | 4.09375 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/find-first-set-bit/0
# https://wiki.python.org/moin/BitwiseOperators
# Given an integer an N. The task is to print the position of first set bit found
# from right side in the binary representation of the number.
###############################################... |
9dcbb78a4064439289522558200e106eb204d665 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/divide_and_conquer/binary_search.py | 1,507 | 4.1875 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/binary-search/1
# Given a sorted array A[](0 based index) and a key "k" you need to complete
# the function bin_search to determine the position of the key if the key
# is present in the array. If the key is not present then you have to return -1.
# The arg... |
7dc3113b4182b8a38ec202158376311861102157 | mdhatmaker/Misc-python | /interview-prep/techie_delight/puzzles/add_two_numbers.py | 971 | 4.09375 | 4 | import sys
import math
# https://www.techiedelight.com/add-two-numbers-without-using-addition-operator/
# Add two numbers without using addition operator (4 methods)
# using subtraction
def add1(a, b):
return a - (-b)
# using logarithm and exponential function
def add2(a, b):
return int(math.log(math.exp(a)... |
52fa21fa353bc13fb7439569009b710fa37b6a46 | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/tree_and_bst/print_bottom_view.py | 2,329 | 4.34375 | 4 | import sys
from BinaryTree import BinaryNode, BinaryTree
from StackAndQueue import Stack, Queue
# https://practice.geeksforgeeks.org/problems/bottom-view-of-binary-tree/1
# Given a binary tree, print the bottom view from left to right.
# A node is included in bottom view if it can be seen when we look at the tree fr... |
f736faf5b94eaa70c2296b5acdc56b3de322063f | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/arrays/left_smaller_right_greater.py | 1,277 | 4.03125 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/unsorted-array/0
# Given an unsorted array of size N. Find the first element in array such that all
# of its left elements are smaller and all right elements to it are greater than it.
#
# Note: Left and right side elements can be equal to required element. An... |
3f1609aeba15a99c25021f1f199874d9e963169f | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/tree_and_bst/bst_lowest_common_ancestor.py | 2,210 | 3.8125 | 4 | import sys
from BinaryTree import BinaryNode, BinaryTree
from StackAndQueue import Stack, Queue
# https://practice.geeksforgeeks.org/problems/lowest-common-ancestor-in-a-bst/1
# Given a Binary Search Tree and 2 nodes value n1 and n2, your task is to find the
# lowest common ancestor(LCA) of the two nodes.
# Note: Du... |
998af42c1f0b94dd4676a6471c3180da273eba9b | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/mathematical/binary_to_decimal.py | 1,063 | 4.09375 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/binary-number-to-decimal-number/0
# Given a binary number B, print its decimal equivalent.
###############################################################################
def get_digits(N):
s = str(N)
res = []
for ch in s:
res.append(int(c... |
99d820a570641ce8070d01817f20a4d2579f5d39 | mdhatmaker/Misc-python | /Plot/matplotlib/live_data_plot.py | 1,259 | 3.515625 | 4 | import sys
import random
from itertools import count
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
### https://youtu.be/Ercd-lp5PfQ
# Run 'live_data_gen.py' concurrently to add to the data file
plt.style.use('fivethirtyeight')
#x_vals = [0, 1, 2, 3, 4, 5]
#y_vals... |
df51a37a6a5e80c6ee6716175df44e789fa406fb | mdhatmaker/Misc-python | /Pandas/pandas_basics_01.py | 1,145 | 3.921875 | 4 | import pandas as pd
import os
### https://www.learnpython.org/en/Pandas_Basics
def get_dir():
return os.path.dirname(os.path.realpath(__file__))
## Creating a DataFrame using a dictionary
dict = {"country": ["Brazil", "Russia", "India", "China", "South Africa"],
"capital": ["Brasilia", "Moscow", "New De... |
66f6088de492f15df19754982904ff30e3a9444d | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/bit_magic/max_subset_xor.py | 1,467 | 3.96875 | 4 | import sys
# https://practice.geeksforgeeks.org/problems/maximum-subset-xor/1
# https://wiki.python.org/moin/BitwiseOperators
# Given a set of positive integers. The task is to complete the function
# maxSubarrayXOR which returns an integer denoting the maximum XOR subset
# value in the given set.
#################... |
d11ce0ab8090879e050cc5a8ad9429dbc0f4af1c | mdhatmaker/Misc-python | /interview-prep/geeks_for_geeks/heap/median_of_stream.py | 1,117 | 3.984375 | 4 | import sys
import heapq
# https://practice.geeksforgeeks.org/problems/find-median-in-a-stream/0
# Given an input stream of N integers. The task is to insert these numbers into a new
# stream and find the median of the stream formed by each insertion of X to the new stream.
##########################################... |
0055767538f0ee2cf9009fc842e8ab305c886a88 | mhrao97/Data-Structures-And-Algorithms | /project_unscramble_computer_science_problems/Task3.py | 3,231 | 4.25 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 3:
(080) is the area code for fixe... |
cb83677e6fadf9afa03c145a2ca0ddad5db06f12 | mhrao97/Data-Structures-And-Algorithms | /project_problems_vs_algorithms/Problem_2.py | 4,221 | 4.28125 | 4 | # Problem 2: Search in a Rotated Sorted Array
"""
Search in a Rotated Sorted Array
You are given a sorted array which is rotated at some random pivot point.
Example: [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]
You are given a target value to search. If found in the array return its index, otherwise return -1.
You c... |
d7099e4601399965793eef24f89947e98f98a987 | mengyalan/Photo-Mosaic | /photomosaic.py | 8,319 | 3.90625 | 4 | # @date: 2011-10-10
# @author: ymeng7
from PIL import Image
import os, sys
# The "distance" function takes 2 pixels as input and returns the
# squared distance between them.
def distance(pix1, pix2):
dist = 0
for i in range(3):
dist = dist + (pix1[i] - pix2[i])*(pix1[i] - pix2[i])
... |
77458e4c33fa52035948294ddb7f9d4ad8ae1e20 | VinayakBector2002/56miscellaneousPLUS | /cs practical.py | 4,665 | 4.09375 | 4 | #1
from datetime import datetime
import getpass
print("Date: ",datetime.now( ))
print("UserName: ",getpass.getuser( ))
#1
def bubbleSort(arr):
n = len(arr)
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1] :
arr[j], arr[j+1] = arr[j+1], arr[j]
... |
7401e2667f8b59e0e00c10bd2b61d13b8ac9bbc9 | Victoration/Reposit1pub | /12.7.py | 661 | 3.640625 | 4 | money = int(input("Вводите сумму, которую планируете положить под проценты:"))
per_cent = {'ТКБ': 5.6, 'СКБ': 5.9, 'ВТБ': 4.28, 'СБЕР': 4.0}
TKB = int((per_cent['ТКБ']) * (money/100))
SKB = int((per_cent['СКБ']) * (money/100))
VTB = int((per_cent['ВТБ']) * (money/100))
SBER = int((per_cent['СБЕР']) * (money/100))
... |
2926d0d74df6addb7d5663ea2638bed6ad4b1a18 | CastriDani/fundamento-de-programaci-n- | /FUNCIONES/ORDEN_NUM.py | 689 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 25 08:58:17 2021
@author: santi
"""
def orden_num(n1,n2,n3):
if n1 < n2 and n1 < n3:
if n2 < n3:
print(n1,n2,n3)
else:
print(n1,n3,n2)
if n2 < n1 and n2<n3:
if n1<n3:
print(n2, n1, n3)
... |
3924d841a638180dee9572b64a7ecb630ba3b9d0 | CastriDani/fundamento-de-programaci-n- | /FUNCIONES/TABLA_MULT.py | 259 | 3.859375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 25 09:02:45 2021
@author: santi
"""
def mult(num, terminos = 10):
for x in range(terminos):
i = x * num
print(i, ',', sep='', end='')
print()
mult(2)
mult(5,15)
mult(10,15) |
274bfd2c23e1007c3868c2da5aed1fb63bd7f3c1 | CastriDani/fundamento-de-programaci-n- | /FUNCIONES/SUPERFICIE_RECTANGULO.py | 407 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 25 09:02:04 2021
@author: santi
"""
def sup_rect(lado1,lado2):
superficie = lado1*lado2
return superficie
l1 = int(input('Ingrese un lado: '))
l2 = int(input('Ingrese un lado: '))
if l1 > l2:
print(f'{l1} es el lado mayor')
else:
print(f'{l... |
2cb0fdecd7bdd832b355438ae03846dc7ffdaec4 | CastriDani/fundamento-de-programaci-n- | /TALLER PAGINA 186 - 189/FP_PUNTO_4.py | 305 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 25 08:28:51 2021
@author: santi
"""
"""
Diseñar el algoritmo para imprimir la suma de los números impares menores
o iguales que n
"""
n = int(input('Ingrese un número: '))
x= 0
while x <= n:
x = x+1
if x%2 != 0:
print(x) |
26a8e40bfe2efebe7822c023b1ab90dbfddc190e | Lineroy/Password-generator | /password_generator_v1.py | 3,463 | 3.71875 | 4 | from random import choice
from time import sleep
from colorama import init, Fore, Style
from os import system
init(autoreset=True)
letters_and_numbers = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUNWXYZ0123456789"
def cls():
system("cls||clear")
counter, basis_for_the_password = 1, ""
pri... |
7482d315ec5ca37ae566de0d221eebdc06e91b0e | SalvatoreMaraniello/SHARPy | /BeamLib/src/optimiser/wrapper/pysrc/constr/common.py | 421 | 3.5625 | 4 | '''
Created on 12 Feb 2015
@author: sm6110
General Methods/Utility
'''
def return_args(C,AttrList):
'''Given a class C and a list of attributes to the class, the function
creates a tuple with the class attributes
Remark: duplicate of this function in module cost.py!!!
'''
T=[]
... |
5c29aa549d09b85456b9ee25e5895d9aefd369dd | pi-bansal/studious-happiness | /DP_Practice/Tabulation/how_sum.py | 887 | 4.125 | 4 | def how_sum(target_sum, numbers):
# Expected return is an array of integers that add up to target_sum
if target_sum == 0:
# Zero using empty array
return []
# Init the table with null values
sum_table = [None] * (target_sum + 1)
# Seed value for 0
sum_table[0] = []
for ind... |
d25cbf0e3769be7d5e4e4a71d2b4deaebd721052 | pi-bansal/studious-happiness | /DP_Practice/memoization/how_sum_basic.py | 645 | 4.125 | 4 | def how_sum(target_sum, numbers):
"""Function that return a subset of numbers that adds up to the target_sum"""
if target_sum == 0:
return []
if target_sum < 0:
return False
for num in numbers:
remainder = target_sum - num
return_val = how_sum(remainder, numbers)
... |
f01da945e7e5bc8812bb423f01cc9d61140035e7 | whsasf/python | /100/1.py | 474 | 3.96875 | 4 | #!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
count=0
for a in range(1,5):
for b in range(1,5):
for c in range(1,5):
if a == b or a == c or b == c:
pass
else:
print (str(a)+" "+str(b)+" "+str(c))
... |
0c694d824ded274d7ec53095076cc9ec68562b14 | whsasf/python | /self/reverse.py | 295 | 3.734375 | 4 | #!/usr/bin/env python3
sentence="i love u china!"
List=sentence.split()
length=len(List)
for i in range (1,length+1):
print(List.pop(),end=' ')
sentence2="i love u big!"
List2=sentence2.split()
List2.reverse()
length2=len(List2)
for i in range(0,length2):
print (List2[i],end=' ')
|
595dc3920d387d48554275ad541eb1bb6d806772 | n5006325/practice-programs | /odd_even.py | 684 | 4 | 4 | # Filename : odd_even.py
# ask for a number, depending on odd or even print message.
numberOne = input('Enter first number:')
numberTwo = input('Enter second number:')
if (int(numberOne) % 4 == 0):
print(numberOne, "is divisible by 4")
elif (int(numberOne) % 2) == 0:
print(numberOne, 'is even')
else:
pri... |
6359b54923d1c7eef2c7754127ab5090de145be0 | n5006325/practice-programs | /common_list.py | 497 | 4 | 4 | # Filename : common_list.py
# return a list that contains only elements that are common between then
# lists without duplicates. make sure program works on lists of two different sizes.
# extra - randomly generate two lists.
# a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
# b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ... |
47022e0c50dec95152ecb974046e6036c76c2bdb | baod693/python_small | /Ex8.py | 232 | 4.0625 | 4 | num_start = int(input('Choose a number to start '))
num_end = int(input('Choose a number to end '))
print (f'Start from: {num_start}')
print (f'End on: {num_end}')
num = num_start
while num <= num_end:
print (num)
num += 1 |
56900bc9ac15d2344719b40818b87ea1d74fd861 | sak-15/Datastructure-and-Algorithms | /Innoskrit TREE series.py | 6,959 | 3.96875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[5]:
class Node:
def __init__(self,data):
self.data=data
self.left=None
self.right=None
class BinaryTree:
def __init__(self):
self.root=None
# Preorder Traversal
def preorder(self,root):
if root!=None:
... |
df17f090d7aa71548655d0f9a6c4227c33f3b46a | vismit2000/CNN-Keras-MNIST | /cnn_keras.py | 1,168 | 3.515625 | 4 | from keras.layers import *
from keras.models import Sequential
from keras.datasets import mnist
from keras.utils import to_categorical
import matplotlib.pyplot as plt
# MNIST Data - 10 Classes (0-9)
def create_model():
model = Sequential()
model.add(Conv2D(32,(3,3),activation='relu',input_shape=(28,28,1)))
... |
51dc47d3e31359a0ea7b7a00698e8cd75e3b103d | guangya90/Python | /.vscode/Pyton/car.py | 1,919 | 3.875 | 4 | class Car():
def __init__(self,make,model,year):
self.make = make
self.model = model
self.year = year
self.odemeter_reading = 0
def get_descriptive_name(self):
long_name = str(self.year) + '-' + self.make + '-' + self.model
print(long_name)
def get_odometer(... |
4e63ccd903e71f55a4b19389e43d523ccc792fdb | Seann8/python-BMI-Calculator | /quality_check.py | 1,016 | 3.828125 | 4 | class LimitError(Exception):
pass
class ZeroError(Exception):
pass
class Check():
def __init__(self):
pass
@staticmethod
def check_type(value, type):
if isinstance(value, type):
raise TypeError
else:
return False
@staticmethod
def check_z... |
0c7e32e394239354ab566bfaba35511432a8616f | bruncs/practice-python | /07 List Comprehensions/ex07.py | 309 | 3.5 | 4 | """
Exercise 7
"""
# pylint: disable=invalid-name
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
b = []
# Do jeito tradicional:
for element in a:
if element % 2 == 0:
b.append(element)
# Em uma linha só:
c = [item for item in a if item % 2 == 0]
# Imprimindo dos dois jeitos:
print(b)
print(c)
|
fd8aada41b65587341d2db2c6165b8eb437f1a14 | bulaimei1991/MyLeetcode | /Contiguous Array.py | 1,353 | 3.796875 | 4 | # -*- coding=utf-8 -*-
'''
给定一个二进制数组, 找到含有相同数量的 0 和 1 的最长连续子数组。
示例 1:
输入: [0,1]
输出: 2
说明: [0, 1] 是具有相同数量0和1的最长连续子数组。
示例 2:
输入: [0,1,0]
输出: 2
说明: [0, 1] (或 [1, 0]) 是具有相同数量0和1的最长连续子数组。
注意: 给定的二进制数组的长度不会超过50000。
'''
class Solution(object):
def findMaxLength(self, nums):
"""
:type nums: List[int]
... |
fa2b836566cfd73e216f51f5599510c90ede2aa0 | bulaimei1991/MyLeetcode | /CheckTree.py | 1,527 | 4.03125 | 4 | '''
给定一个二叉树,判断其是否是一个有效的二叉搜索树。
假设一个二叉搜索树具有如下特征:
节点的左子树只包含小于当前节点的数。
节点的右子树只包含大于当前节点的数。
所有左子树和右子树自身必须也是二叉搜索树。
'''
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def isV... |
65695d2c28f12b9290e2d9366bf3b1033211d29c | bulaimei1991/MyLeetcode | /FallingWater.py | 1,997 | 3.609375 | 4 | #-*- coding=utf-8 -*-
'''
给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。
上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 感谢 Marcos 贡献此图。
示例:
输入: [0,1,0,2,1,0,1,3,2,1,2,1]
输出: 6
'''
class Solution(object):
def trap(self, height):
"""
:type height: List[int]
:rtyp... |
1044767856642a18a77ea75aad7c49d1f1a0b07f | gara73/iCode | /Manager.py | 1,838 | 3.609375 | 4 | import Actions
import DB
def first_menu():
while True:
key = input("Choose an action:\n"
"1) Get information\n"
"2) Add data\n"
"3) Delete data\n"
"0) Exit\n"
"Enter:")
if key == '1':
... |
3c4a36e49bff8e952264bf32b54f59a734ef7535 | vv1nn1/dsp | /python/q8_parsing.py | 1,679 | 4.625 | 5 | # The football.csv file contains the results from the English Premier League.
# The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of
# goals scored for and against each team in that season (so Arsenal scored 79 goals
# against opponents, and had 36 goals scored against them). Write a program t... |
45cb4aa3fbb197057fe59dff16e6d43aa47b8e3b | jayanidimpal95/repository | /python pracs/day2/calc.py | 1,796 | 3.796875 | 4 | import logging
logging.basicConfig(filename='calc_log.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logging.info('Started')
def addition(x,y): #Function for addition
print str(x)+"+"+str(y)+"= "+str(x+y)
def sub(x,y): #Function for subtraction
print str(x)+"-"+str(y... |
65085acc99f6396a3c4e0caed803a1b6ed7d523e | okieinexile/MathLibrary | /cubic_splines.py | 2,459 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jan 31 15:23:30 2017
@author: bwinters
"""
def graph(knots, values):
"""This graphs a spline with given knots and values"""
import numpy as np
import pylab as plt
y=[]
x=np.linspace(knots[0],knots[-1],1000)
for t in x:
y.append(s... |
634d0db48f8cabc2f1c375dc02386c0b57d0d948 | Aakifha01/Scripting-Languages-Lab | /python/fifth.py | 375 | 4.0625 | 4 | class Person:
def __init__(self,name,age):
self.name=name;
self.age=age;
p1=Person("Supandi",14)
p2=Person("Ramu",12)
print("\nname of 1st person is",p1.name)
print("\nage of 1st person is",p1.age)
print("\nname of 2nd person is",p2.name)
print("\nage of 2nd person is",p2.age)
#modifying p... |
b391d72883430a1ce5581030eddf4279f2fd4fb1 | fndmaioli/T2sisOp | /gerenciador2.py | 5,448 | 3.796875 | 4 | class Node:
def __init__(self, tipo, numero):
self.tipo = tipo # se representa um bloco livre ou ocupado
self.numero = numero # pra identificar o bloco
self.inicio = 0 # inicio do bloco
self.fim = 0 # fim do bloco
self.anterior = None # o bloco anterior
self.proximo =... |
7fa1584d00b31b65ee45950113167393d4937335 | seoLegna/03-Text-adventure | /tellatale_game.py | 13,833 | 3.9375 | 4 | import time
answer_a = "A".lower()
answer_b = "B".lower()
answer_c = "C".lower()
yes = ["Yes", "yes", "y", "Y", "YES"]
no = ["No", "no", "n", "N", "NO"]
axe = 0
fallen_branch = 0
print("Only use A, B and C or Yes and No or you will be sent back to your recent check point.")
time.sleep(1)
axe = 0
def the_abnormal_... |
3b8365e76f252e876d82428cb0400fd8c9d756bd | GBhavin/Hackerearth-Practice | /14. Two strings/twostrings.py | 176 | 3.5625 | 4 | counter = int(input())
for i in range(counter):
inputs = input().split()
if sorted(inputs[0]) == sorted(inputs[1]):
print("YES")
else:
print("NO")
|
d92f3b6c81eff37101c26324694e872272f8762c | leerobert/python-nltk-intro | /code/process.py | 1,022 | 4.125 | 4 | # Sample code for processing a file containing lines of raw text
import nltk
raw = open("reviews.txt").read() # read in the entire file as a single raw string
tokens = nltk.word_tokenize(raw) # tokenizes the raw string
text = nltk.Text(tokens) # generate the text object
# Cleaning the text of punctuation
impo... |
c04b1d4517881691ff78b896d80f355141deb15b | smspillaz/word-benchmarks | /tests/outlier.py | 6,082 | 3.53125 | 4 | #!/usr/bin/env python
"""outlier.py
Test word vectors based on how well they can detect outliers.
Outlier detection is based on the compactness score of
each word, c(w) = 1/(n(n - 1)) * \sum_{w_i \in [W + w]} * \sum_{w_j \in [W + w], w_j != w_i} sim(w_i, w_j).
We then get the compactness score of each word, includin... |
b055aa87dc81c3d363acdcf67d84032789932c06 | philok55/CRDS | /synthetic_data/reordered_conditionals/Python3/Networks/lab6.py | 22,263 | 3.59375 | 4 | # REORDERINGS EXECUTED: 12
"""
Networks and Network Security
Lab 6 - Distributed Sensor Network
NAME: Philo Decroos, Mitchell van den Bulk
STUDENT ID: 11752262, 11333650
DESCRIPTION:
This file contains code to simulate a sensor in a network of communicating
sensors. We use UDP socket programming to let different sens... |
87615e1118e290c4efca03d26f8b39b3245c840f | philok55/CRDS | /synthetic_data/reordered_substatement/Python3/Networks/server.py | 6,090 | 3.640625 | 4 | # REORDERINGS EXECUTED: 26
"""
Lab 2 - HTTP Server
NAME: Philo Decroos
STUDENT ID: 11752262
DESCRIPTION:
This python file is a simple HTTP server. It can recieve and send HTTP
messages through network sockets. It can process HTTP GET messages and respond
to the client with the requested content (HTML or ima... |
03b43b0ae103881de5e866984b969920c4cf9a51 | philok55/CRDS | /synthetic_data/original_regenerated/Python3/Networks/lab6.py | 18,852 | 3.59375 | 4 |
"""
Networks and Network Security
Lab 6 - Distributed Sensor Network
NAME: Philo Decroos, Mitchell van den Bulk
STUDENT ID: 11752262, 11333650
DESCRIPTION:
This file contains code to simulate a sensor in a network of communicating
sensors. We use UDP socket programming to let different sensors communicate
with each o... |
40bdb1d589eb3e4d5518ca03cc98e68713635689 | Young-Pythoneers/fibonacci-feb-2020 | /src/fibonacci/services/__init__.py | 4,000 | 4 | 4 | from functools import lru_cache
from typing import List, Optional
from fibonacci.models import Fibonacci, db
@lru_cache(maxsize=4_000_000_000)
def fibonacci_recursive_with_database(n: int) -> Optional[int]:
""" Function that provides a Fibonacci number given te index, it does so in conjunction with a SQLite data... |
137e520de3094de45193ec71abf652a6666dc59f | LordNouda/flask-hello-world | /app.py | 1,898 | 4.03125 | 4 | # ---- Flask Hello World ---- #
# import the Flask class from the flask package
from flask import Flask
# create the application object
app = Flask(__name__)
# error handling
app.config["DEBUG"] = True
# use the decorator pattern to link the view function to a url
@app.route("/")
@app.route("/hello")... |
746037cc0452c72817a9f150104773d13b887a47 | codatr0n/adv_programming | /list_comprehension.py | 284 | 3.921875 | 4 | # return a sorted list with numbers first, then letters
my_list = [1, 3, 2, "b", "a", "c"]
from itertools import chain
numbers = sorted([x for x in my_list if type(x) == int])
letters = sorted([x for x in my_list if type(x) == str])
for i in chain(numbers, letters):
print(i)
|
b022ff4c6632f671202bcf796085422cc8cab5c3 | Joeycc/algorithm | /python/replace.py | 1,146 | 3.796875 | 4 | #!usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 遍历程序所在文件夹下所有目录,替换文件中的字符串.
#
import os
def replace_file_str(file, cur, replace):
lines = []
with open(file, 'rt') as f:
[lines.append(line.replace(cur, replace)) for line in f]
with open(file, 'wt') as f:
f.writelines(lines)
print(file ... |
9af81e25ce1da49a4502718b98ac208b38522a93 | rohanchopra3/Minimum-spanning-tree | /DataStructures.py | 3,023 | 3.8125 | 4 |
#This file contains all the fucntions to create a minimum Spanning Tree For Operations
#Created By Rohan Chopra
# THIS CLASS IS USED TO CREATE AN ADJACENCY MATRIX
class createGraphUsingAdjMatrix(object):
def __init__(self, v):
self.adjMatrix = []
for i in range(0, v+1):
self.adjMatri... |
d9f66a6ce3ecfeae84df86a28e0b84e454872563 | fightnyy/programmers_algorithm | /more_spicy.py | 441 | 3.546875 | 4 | """
파이썬 sort를 사용했는데 시간 초과가 나는 경우라면
파이썬 heap을 사용해보자
"""
import heapq
def solution(scoville, K):
heap = []
for i in scoville:
heapq.heappush(heap,i)
answer = 0
while heap[0] < K :
if len(heap) >= 2:
answer += 1
heapq.heappush(heap,heapq.heappop(heap)+heapq.heappop(... |
d8412e8deedb9cbf71cec94a339c8dffdda399e5 | kuroedu/archivos | /menu.py | 663 | 3.65625 | 4 | import sys
import csv
print """Agenda
---------------------
1) Leer
2) Insertar Nombre
0) Exit"""
while 1:
char = sys.stdin.read(1)
if char == "0":
break
if char == "1":
with open('data.csv','r')as file:
data = csv.reader(file, delimiter ='|')
for line in data:
... |
98dc8392830311a81e8dd422b52bc3b25f0f733a | KIRAN969/iprimeprogrammbasic | /day6/__pycache__/day7/multi_inhe.py | 503 | 3.96875 | 4 | class Addition:
def add(self,a,b):
return a+b
class Subtraction:
def sub(self,a,b):
return a-b
class Multiplication:
def mul(self,a,b):
return a*b
class Calculator(Addition,Subtraction,Multiplication):
pass
objcalc=Calculator()
# n1=int(input("enter a number:"))
# n2=int(input("e... |
19162c7ce89dc9d1b1f7b6e2a2638f2e3fd64547 | KIRAN969/iprimeprogrammbasic | /addd.py | 275 | 3.6875 | 4 | import addModule
n1=int(input("enter a number:"))
n2=int(input("enter a number:"))
# def addNum(a,b):
# return a+b
print(addModule.addNum(n1,n2))
print(addModule.subNum(n1,n2))
print(addModule.mulNum(n1,n2))
print(addModule.divNum(n1,n2))
print(addModule.floorNum(n1,n2)) |
0c48db500f73a81cb42b18774747638ea51ca947 | KIRAN969/iprimeprogrammbasic | /day9/decorator.py | 544 | 3.78125 | 4 | # def add(a,b):
# return a+b
# # print(add(3,4))
# x=add
# print(x(2,6))
# class A:
# def __init__(self,a,b):
# self.a=a
# self.b=b
# print("decarator is working")
# obj=A
# obj(1,3)
# def sum(a,b):
# return a+b
# def sub(a,b):
# return a-b
# def operation(op,x,y):
# resul... |
9ca89c735955a0f1466e8387b54a78cb728ff71e | programmerajay/guvi | /zen class/7/d7leading.py | 94 | 3.625 | 4 | string=input("enter the string")
print("leading trail trimmed string is ",string.rstrip(" ")) |
6307d29ddf7ec3468c652a1329670ab923bee3c5 | programmerajay/guvi | /zen class/6/sumofodd.py | 188 | 3.734375 | 4 | oddno=[]
n=int(input())
oddsum=0
i=0
while(i<=n):
if(i%2!=0):
oddno.append(i)
i=i+1
print("oddnumbers:",oddno)
for i in oddno:
oddsum=oddsum+i
print("oddnumber sum",oddsum) |
07d4b5faf9350f07c23cb593dcffec0c5d90f900 | programmerajay/guvi | /zen class/7/d7reversestring.py | 73 | 4.0625 | 4 | string=input("enter the string:")
print("reversed string:",string[::-1]) |
f1ee4a0857fda3a527db9f78707b77f889563339 | programmerajay/guvi | /zen class/7/d7deletefirstoccurence.py | 250 | 3.875 | 4 | string=input("enter the string")
list=[]
character=input("enter the letter:")
for i in range(0,len(string)):
list.append(string[i])
for i in list:
if(i==character):
list.remove(i)
break
print("deleted first occurence","".join(list)) |
afda493b49662ae333910c1e3769344cf743e54b | programmerajay/guvi | /zen class/6/amstrongnumber.py | 163 | 3.75 | 4 | n=int(input())
power=len(str(n))
temp=0
while(n>0):
digit=n%10
temp+=digit**power
temp=n//10
if temp==n:
print("amstrongnumber")
else:
print("no")
|
bd2de7f3da11e865b16ff87bacbe4ce260b87504 | programmerajay/guvi | /zen class/1/college.py | 1,478 | 4.09375 | 4 | name1=input("enter your name")
maths1=int(input())
science1=int(input())
social1=int(input())
total1=maths1+science1+social1
print("total:",total1)
average1=total1/3
print("average:",float(average1))
name2=input("enter your name")
maths2=int(input())
science2=int(input())
social2=int(input())
total2=maths... |
901a48beb3fd566796988fe255a1ed1c82f0530b | programmerajay/guvi | /zen class/6/sumofn.py | 187 | 4.21875 | 4 | ## Program to find sum of digits of a number
number = int(input("Enter the number :"))
sum= 0
temp = number
while(temp>0):
digit = temp % 10
sum += digit
temp //= 10
print(sum) |
f5f81eba75596737c743759fe6a696b68062d1f4 | programmerajay/guvi | /zen class/7/d7leadingandtrailing.py | 145 | 3.9375 | 4 | string=input("enter the string")
print("trailing trimmed string is:",string.lstrip(" "))
print("leading trimmed string is:",string.rstrip(" ")) |
73e2bd04f5ecf2c91a54bbc7e55ee364d98f62a0 | genie-o/Mydocument | /python/basic01/Test06.py | 1,952 | 3.703125 | 4 | '''
*** 연산자 operator ***
산술연산자 : + - * / %
대입연산자 : =
복합대입연산자 : += -= *= /= %=
비교 연산자 : > >= < <= ++ !=
논리 연산자 : = True / False
멤버 연산자 : in / not in
식별 연산자 : is / is not
'''
# 대입 연산자
x = 10
y = 10
z = 10
x=y=z=10
print(x)
print(y)
print(z)
x,y,z = 10,20,30
print(x)
print(y)
print(z)
'''
# 문제1. 분자, 분모를 하나씩 입력받고, 몫과 나... |
a8b66bbcc2612f927ed7574965832c14534bb531 | genie-o/Mydocument | /python/basic03/Tuple/Tuple01.py | 650 | 3.859375 | 4 | '''
군집자료형 : str, list, tuple, dict, set
*** 튜플 Tuple ***
리스트 : []
튜플 : (,)
튜플은 요소의 값을 수정할 수가 없다. immutable
데이터가 한개일때는 쉼표 반드시 기술
데이터가 여러개일때는, 소괄호 생략 가능 (쉼표로 구분)
'''
# 빈 튜플
t1 = ()
print(t1)
print(type(t1))
# 한개의 요소만 대입할경우
t2 = ("abc",)
print(t1)
print(type(t1))
# 요소가 두 개 이상일 경우
t3 = 1,2,3
print(t3)
print(type(t3))
... |
b2250aacb90ed82a973211e4dc6a203754f08740 | aws-samples/jsii-python-benchmarking | /native-python/benchmark.py | 305 | 3.53125 | 4 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
from hello_world import hello_world
def my_function():
hw = hello_world.HelloWorld()
print(hw.say_hello('World'))
for i in range(0, 25):
print(str(i) + ': ' + str(hw.fibonacci(i)))
|
5612a93b357fe98f28a87b120e9753e77688c2be | JuliaHardy/python_basics | /exercises/proba.py | 1,849 | 3.96875 | 4 | HAND_SIZE = 7
SCRABBLE_LETTER_VALUES = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10
}
WORDLIST_FILENAME = "./wordgame/words.txt"
def loadWords():
... |
2e563a255eaca532ff9dc129b568fe33ad42e1d8 | JuliaHardy/python_basics | /regular_expresions/find_all.py | 261 | 3.828125 | 4 | import re
text1 = 'Today is a beautiful weather, Tom is very happy'
text2 = 'abbbabbababababababab'
print(re.findall(r'is', text1))
ba = re.finditer(r'ba', text2)
count = 0
for el in ba:
count += 1
print(el.group(), el.start(), el.end())
print(count) |
8647691dfb262a8ab8927dde9d241f2881ae7116 | JuliaHardy/python_basics | /regular_expresions/match_method.py | 176 | 3.890625 | 4 | import re
text1 = 'Today is a beautiful weather, Tom is very happy'
text2 = 'is today beautifu day, is it?'
m = re.match(r'is', text1)
n = re.match(r'is', text2)
print(m, n) |
e8b0861e65e8dde5a5eeb13f52763988cb0ac317 | szhao13/interview_prep | /stack.py | 498 | 4.125 | 4 | class Stack(object):
def __init__(self):
"""Initialize an empty stack"""
self.items = []
def push(self, item):
"""Push new item to stack"""
self.items.append(item)
def pop(self):
"""Remove and return last item"""
# If the stack is empty, return None
# (it would also be reasonable to throw an excepti... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.