content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class UndergroundSystem: def __init__(self): self.count = defaultdict(int) self.time = defaultdict(int) self.traveling = dict() def checkIn(self, id: int, stationName: str, t: int) -> None: self.traveling[id] = (stationName, t) def checkOut(self, id: int, stationNa...
class Undergroundsystem: def __init__(self): self.count = defaultdict(int) self.time = defaultdict(int) self.traveling = dict() def check_in(self, id: int, stationName: str, t: int) -> None: self.traveling[id] = (stationName, t) def check_out(self, id: int, stationName: st...
class Patcher(object): """ A dumb class to allow a mock.patch object to be used as a decorator and a context manager Typical usage:: import mock import sys my_mock = Patcher(mock.patch("sys.platform", "win32")) @my_mock def func1(): print(sys.platform)...
class Patcher(object): """ A dumb class to allow a mock.patch object to be used as a decorator and a context manager Typical usage:: import mock import sys my_mock = Patcher(mock.patch("sys.platform", "win32")) @my_mock def func1(): print(sys.platform)...
def test_clear_images(client, seeder, app, utils): user_id, admin_unit_id = seeder.setup_base() image_id = seeder.upsert_default_image() url = utils.get_image_url_for_id(image_id) utils.get_ok(url) runner = app.test_cli_runner() result = runner.invoke(args=["cache", "clear-images"]) assert...
def test_clear_images(client, seeder, app, utils): (user_id, admin_unit_id) = seeder.setup_base() image_id = seeder.upsert_default_image() url = utils.get_image_url_for_id(image_id) utils.get_ok(url) runner = app.test_cli_runner() result = runner.invoke(args=['cache', 'clear-images']) assert...
def binary_slow(n): assert n>=0 bits = [] while n: bits.append('01'[n&1]) n >>= 1 bits.reverse() return ''.join(bits) or '0'
def binary_slow(n): assert n >= 0 bits = [] while n: bits.append('01'[n & 1]) n >>= 1 bits.reverse() return ''.join(bits) or '0'
# Containers for txid sequences start with this string. CONTAINER_PREFIX = 'txids' # Transaction ID sequence nodes start with this string. COUNTER_NODE_PREFIX = 'tx' # ZooKeeper stores the sequence counter as a signed 32-bit integer. MAX_SEQUENCE_COUNTER = 2 ** 31 - 1 # The name of the node used for manually setting...
container_prefix = 'txids' counter_node_prefix = 'tx' max_sequence_counter = 2 ** 31 - 1 offset_node = 'txid_offset'
# Solution 1 - recursion # O(log(n)) time / O(log(n)) space def binarySearch1(array, target): return binarySearchHelper1(array, target, 0, len(array) - 1) def binarySearchHelper1(array, target, left, right): if left > right: return -1 middle = (left + right) // 2 potentialMatch = array[middle...
def binary_search1(array, target): return binary_search_helper1(array, target, 0, len(array) - 1) def binary_search_helper1(array, target, left, right): if left > right: return -1 middle = (left + right) // 2 potential_match = array[middle] if target == potentialMatch: return middle...
def levenshtein(source: str, target: str) -> int: """Computes the Levenshtein (https://en.wikipedia.org/wiki/Levenshtein_distance) and restricted Damerau-Levenshtein (https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance) distances between two Unicode strings with given lengths using th...
def levenshtein(source: str, target: str) -> int: """Computes the Levenshtein (https://en.wikipedia.org/wiki/Levenshtein_distance) and restricted Damerau-Levenshtein (https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance) distances between two Unicode strings with given lengths using th...
""" pymatrices Package :- - A Python 3.x Package to implement Matrices and its properties... """ class matrix: """Creates a Matrix using a 2-D list""" def __init__(self, matrix): self.__rows = len(matrix) self.__cols = len(matrix[0]) for rows in matrix: if len(rows) != self.__cols: raise TypeError("I...
""" pymatrices Package :- - A Python 3.x Package to implement Matrices and its properties... """ class Matrix: """Creates a Matrix using a 2-D list""" def __init__(self, matrix): self.__rows = len(matrix) self.__cols = len(matrix[0]) for rows in matrix: if len(rows) != sel...
# Uebungsblatt 2 # Uebung 1 i = 28 f = 28.0 print(i, id(i), type(i)) print(f, id(f), type(f)) # Uebung 2 i = 28.0 f = 28.0 print(i, id(i), type(i)) print(f, id(f), type(f)) # Uebung 3 s = "Hello" s2 = s print(s, id(s), s2, id(s2)) s += " World" print(s, id(s), s2, id(s2)) # Uebung 4 m = ['a', 'b', 'd', 'e', 'f'] ...
i = 28 f = 28.0 print(i, id(i), type(i)) print(f, id(f), type(f)) i = 28.0 f = 28.0 print(i, id(i), type(i)) print(f, id(f), type(f)) s = 'Hello' s2 = s print(s, id(s), s2, id(s2)) s += ' World' print(s, id(s), s2, id(s2)) m = ['a', 'b', 'd', 'e', 'f'] print(m, id(m)) m[0] = 'A' print(m, id(m)) m2 = m print(m, id(m), m...
n, m = map(int, input().split()) f = list(int(i) for i in input().split()) f.sort() # formula -> f[i+n-1] - f[i] ans = 10**9 for i in range(m-n+1): ans = min(ans, f[i+n-1] - f[i]) print(ans)
(n, m) = map(int, input().split()) f = list((int(i) for i in input().split())) f.sort() ans = 10 ** 9 for i in range(m - n + 1): ans = min(ans, f[i + n - 1] - f[i]) print(ans)
ENDPOINT_PATH = 'foobar' BOOTSTRAP_SERVERS = 'localhost:9092' TOPIC_RAW_REQUESTS = 'test.raw_requests' TOPIC_PARSED_DATA = 'test.parsed_data' USERNAME = None PASSWORD = None SASL_MECHANISM = None SECURITY_PROTOCOL = 'PLAINTEXT' # Use these when trying with FVH servers # SASL_MECHANISM = "PLAIN" # SECURITY_PROTOCOL = "...
endpoint_path = 'foobar' bootstrap_servers = 'localhost:9092' topic_raw_requests = 'test.raw_requests' topic_parsed_data = 'test.parsed_data' username = None password = None sasl_mechanism = None security_protocol = 'PLAINTEXT'
""" Analyser of the relation. @author: Minchiuan Gao <minchiuan.gao@gmail.com> Build Date: 2015-Nov-25 Wed """ class RelationValue(object): def __init__(self, title, weight, abbr, level): self.title = title self.weight = weight self.abbr = abbr self.level = level class Analyse(o...
""" Analyser of the relation. @author: Minchiuan Gao <minchiuan.gao@gmail.com> Build Date: 2015-Nov-25 Wed """ class Relationvalue(object): def __init__(self, title, weight, abbr, level): self.title = title self.weight = weight self.abbr = abbr self.level = level class Analyse(ob...
# input print('What is my favourite food?') input_guess = input("Guess? ") # response while input_guess != 'electricity': print("Not even close.") input_guess = input("Guess? ") print("You guessed it! Buzzzz")
print('What is my favourite food?') input_guess = input('Guess? ') while input_guess != 'electricity': print('Not even close.') input_guess = input('Guess? ') print('You guessed it! Buzzzz')
# Use enumerate() and other skills to return the count of the number of items in # the list whose value equals its index. def count_match_index(numbers): return len([number for index, number in enumerate(numbers) if index == number]) result = count_match_index([0, 2, 2, 1, 5, 5, 6, 10]) print(result)
def count_match_index(numbers): return len([number for (index, number) in enumerate(numbers) if index == number]) result = count_match_index([0, 2, 2, 1, 5, 5, 6, 10]) print(result)
__title__ = 'elasticsearch-cli' __version__ = '0.0.1' __author__ = 'nevercaution' __license__ = 'Apache v2'
__title__ = 'elasticsearch-cli' __version__ = '0.0.1' __author__ = 'nevercaution' __license__ = 'Apache v2'
## Largest 5 digit number in a series ## 7 kyu ## https://www.codewars.com/kata/51675d17e0c1bed195000001 def solution(digits): biggest = 0 for index in range(len(digits) - 4): if int(digits[index:index+5]) > biggest: biggest = int(digits[index:index+5]) return biggest
def solution(digits): biggest = 0 for index in range(len(digits) - 4): if int(digits[index:index + 5]) > biggest: biggest = int(digits[index:index + 5]) return biggest
""" Quantum Probability =================== """ class QuantumProbability( int, ): def __init__( self, probability: int, ): super().__new__( int, probability, )
""" Quantum Probability =================== """ class Quantumprobability(int): def __init__(self, probability: int): super().__new__(int, probability)
# Databricks notebook source ## Enter your group specific information here... GROUP='group05' # CHANGE TO YOUR GROUP NAME # COMMAND ---------- """ Enter any project wide configuration here... - paths - table names - constants - etc """ # Some configuration of the cluster spark.conf.set("spark.sql.shuffle.partitio...
group = 'group05' '\nEnter any project wide configuration here...\n- paths\n- table names\n- constants\n- etc\n' spark.conf.set('spark.sql.shuffle.partitions', '32') spark.conf.set('spark.sql.adaptive.enabled', 'true') (class_data_path, group_data_path) = Utils.mount_datasets(GROUP) base_delta_path = Utils.create_delta...
""" A simple script. This file shows why we use print. Author: Walker M. White (wmw2) Date: July 31, 2018 """ x = 1+2 # I am a comment x = 3*x print(x)
""" A simple script. This file shows why we use print. Author: Walker M. White (wmw2) Date: July 31, 2018 """ x = 1 + 2 x = 3 * x print(x)
{ "targets": [ { "target_name": "game", "sources": [ "game.cpp" ] } ] }
{'targets': [{'target_name': 'game', 'sources': ['game.cpp']}]}
class Stack: def __init__(self,max_size=4): self.max_size = max_size self.stk = [None]*max_size self.last_pos = -1 def pop(self): if self.last_pos < 0: raise IndexError() temp = self.stk[self.last_pos] self.stk[self.last_pos]=None if self.last...
class Stack: def __init__(self, max_size=4): self.max_size = max_size self.stk = [None] * max_size self.last_pos = -1 def pop(self): if self.last_pos < 0: raise index_error() temp = self.stk[self.last_pos] self.stk[self.last_pos] = None if se...
#!/usr/bin/env python3 """Peter Rasmussen, Programming Assignment 1, utils.py This module provides miscellaneous utility functions for this package. """ def compute_factorial(n: int) -> int: """ Compute n-factorial. :param n: Number to compute factorial for :return: n-factorial """ if (not i...
"""Peter Rasmussen, Programming Assignment 1, utils.py This module provides miscellaneous utility functions for this package. """ def compute_factorial(n: int) -> int: """ Compute n-factorial. :param n: Number to compute factorial for :return: n-factorial """ if not isinstance(n, int) or n < ...
DEFAULT_SERVER_HOST = "localhost" DEFAULT_SERVER_PORT = 11211 DEFAULT_POOL_MINSIZE = 2 DEFAULT_POOL_MAXSIZE = 5 DEFAULT_TIMEOUT = 1 DEFAULT_MAX_KEY_LENGTH = 250 DEFAULT_MAX_VALUE_LENGTH = 1024 * 1024 # 1 megabyte STORED = b"STORED\r\n" NOT_STORED = b"NOT_STORED\r\n" EXISTS = b"EXISTS\r\n" NOT_FOUND = b"NOT_FOUND\r\n"...
default_server_host = 'localhost' default_server_port = 11211 default_pool_minsize = 2 default_pool_maxsize = 5 default_timeout = 1 default_max_key_length = 250 default_max_value_length = 1024 * 1024 stored = b'STORED\r\n' not_stored = b'NOT_STORED\r\n' exists = b'EXISTS\r\n' not_found = b'NOT_FOUND\r\n' deleted = b'DE...
def median(pool): copy = sorted(pool) size = len(copy) if size % 2 == 1: return int(copy[int((size-1) / 2)]) else: return (int(copy[int((size) / 2)-1]) + int(copy[int(size / 2)])) / 2
def median(pool): copy = sorted(pool) size = len(copy) if size % 2 == 1: return int(copy[int((size - 1) / 2)]) else: return (int(copy[int(size / 2) - 1]) + int(copy[int(size / 2)])) / 2
# Python program to calculate C(n, k) # Returns value of Binomial Coefficient # C(n, k) def binomialCoefficient(n, k): # since C(n, k) = C(n, n - k) if(k > n - k): k = n - k # initialize result res = 1 # Calculate value of # [n * (n-1) *---* (n-k + 1)] / [k * (k-1) *----* 1]...
def binomial_coefficient(n, k): if k > n - k: k = n - k res = 1 for i in range(k): res = res * (n - i) res = res / (i + 1) return res (n, k) = map(int, input().split()) res = binomial_coefficient(n, k) print('Value of C(% d, % d) is % d' % (n, k, res)) '\nTEST CASES\n\nInput =\n5...
#does array have duplicate entries a=[1,2,3,4,5,1,7] i=1 j=1 for num in a: for ab in range(len(a)): if num==a[i]: print("duplicate found! ",num,"is = a[",i,"]") else: print(num,"is not = a[",i,"]" ) if i>4: break else: i=i+1 i=0 ...
a = [1, 2, 3, 4, 5, 1, 7] i = 1 j = 1 for num in a: for ab in range(len(a)): if num == a[i]: print('duplicate found! ', num, 'is = a[', i, ']') else: print(num, 'is not = a[', i, ']') if i > 4: break else: i = i + 1 i = 0
{ 'name': 'To-Do Kanban board', 'description': 'Kanban board to manage to-do tasks.', 'author': 'Daniel Reis', 'depends': ['todo_ui'], 'data': ['views/todo_view.xml'], }
{'name': 'To-Do Kanban board', 'description': 'Kanban board to manage to-do tasks.', 'author': 'Daniel Reis', 'depends': ['todo_ui'], 'data': ['views/todo_view.xml']}
# play sound file = "HappyBirthday.mp3" print('playing sound using native player') os.system("afplay " + file)
file = 'HappyBirthday.mp3' print('playing sound using native player') os.system('afplay ' + file)
class SkiffKernel(object): """SkiffKernel""" def __init__(self, options=None, **kwargs): super(SkiffKernel, self).__init__() if not options: options = kwargs self._json = options self.__dict__.update(options) def __repr__(self): return '<%s (#%s) %s>' ...
class Skiffkernel(object): """SkiffKernel""" def __init__(self, options=None, **kwargs): super(SkiffKernel, self).__init__() if not options: options = kwargs self._json = options self.__dict__.update(options) def __repr__(self): return '<%s (#%s) %s>' % ...
class Solution(object): def splitIntoFibonacci(self, S): """ :type S: str :rtype: List[int] """ Solution.res= [] self.backtrack(0, 0, 0, [],S) return Solution.res def backtrack(self, start, last1, last2, intList, string): for i in range(start,len(...
class Solution(object): def split_into_fibonacci(self, S): """ :type S: str :rtype: List[int] """ Solution.res = [] self.backtrack(0, 0, 0, [], S) return Solution.res def backtrack(self, start, last1, last2, intList, string): for i in range(start...
v = 18 _v = 56 def f(): pass def _f(): pass class MyClass(object): pass class _MyClass(object): pass
v = 18 _v = 56 def f(): pass def _f(): pass class Myclass(object): pass class _Myclass(object): pass
def solve_single_lin(opt_x_s): ''' solve one opt_x[s] ''' opt_x_s.solve(solver='MOSEK', verbose = True) return opt_x_s
def solve_single_lin(opt_x_s): """ solve one opt_x[s] """ opt_x_s.solve(solver='MOSEK', verbose=True) return opt_x_s
pkgname = "xsetroot" pkgver = "1.1.2" pkgrel = 0 build_style = "gnu_configure" hostmakedepends = ["pkgconf"] makedepends = [ "xbitmaps", "libxmu-devel", "libxrender-devel", "libxfixes-devel", "libxcursor-devel" ] pkgdesc = "X root window parameter setting utility" maintainer = "q66 <q66@chimera-linux.org>" lice...
pkgname = 'xsetroot' pkgver = '1.1.2' pkgrel = 0 build_style = 'gnu_configure' hostmakedepends = ['pkgconf'] makedepends = ['xbitmaps', 'libxmu-devel', 'libxrender-devel', 'libxfixes-devel', 'libxcursor-devel'] pkgdesc = 'X root window parameter setting utility' maintainer = 'q66 <q66@chimera-linux.org>' license = 'MIT...
def is_num(in_value): """Checks if a value is a valid number. Parameters ---------- in_value A variable of any type that we want to check is a number. Returns ------- bool True/False depending on whether it was a number. Examples -------- >>> is_num(1) True...
def is_num(in_value): """Checks if a value is a valid number. Parameters ---------- in_value A variable of any type that we want to check is a number. Returns ------- bool True/False depending on whether it was a number. Examples -------- >>> is_num(1) True...
class Item: def __init__(self, block_id, count, damage, data): self.block_id = block_id self.count = count self.damage = damage self.data = data def __str__(self): return 'block: {:3d}, count: {:2d}, damage: {}'.format(self.block_id, self.count, self.damage)
class Item: def __init__(self, block_id, count, damage, data): self.block_id = block_id self.count = count self.damage = damage self.data = data def __str__(self): return 'block: {:3d}, count: {:2d}, damage: {}'.format(self.block_id, self.count, self.damage)
""" 103. Binary Tree Zigzag Level Order Traversal Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 r...
""" 103. Binary Tree Zigzag Level Order Traversal Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree [3,9,20,null,null,15,7], 3 / 9 20 / 15 7 retur...
BAZEL_VERSION_SHA256S = { "0.14.1": "7b14e4fc76bf85c4abf805833e99f560f124a3b96d56e0712c693e94e19d1376", "0.15.0": "7f6748b48a7ea6bdf00b0e1967909ce2181ebe6f377638aa454a7d09a0e3ea7b", "0.15.2": "13eae0f09565cf17fc1c9ce1053b9eac14c11e726a2215a79ebaf5bdbf435241", "0.16.1": "17ab70344645359fd4178002f367885e9...
bazel_version_sha256_s = {'0.14.1': '7b14e4fc76bf85c4abf805833e99f560f124a3b96d56e0712c693e94e19d1376', '0.15.0': '7f6748b48a7ea6bdf00b0e1967909ce2181ebe6f377638aa454a7d09a0e3ea7b', '0.15.2': '13eae0f09565cf17fc1c9ce1053b9eac14c11e726a2215a79ebaf5bdbf435241', '0.16.1': '17ab70344645359fd4178002f367885e9019ae7507c9c1ade...
def censor(text, word): bigstring = text.split() print (bigstring) words = "" " ".join(bigstring) return bigstring print (censor("hello hi hey", "hi"))
def censor(text, word): bigstring = text.split() print(bigstring) words = '' ' '.join(bigstring) return bigstring print(censor('hello hi hey', 'hi'))
# -*- coding: utf-8 -*- """ Created on Sun Jul 5 18:30:18 2020 @author: MarcoSilva """ def general_poly (L): """ L, a list of numbers (n0, n1, n2, ... nk) Returns a function, which when applied to a value x, returns the value n0 * x^k + n1 * x^(k-1) + ... nk * x^0 """ def f(x): total = 0 ...
""" Created on Sun Jul 5 18:30:18 2020 @author: MarcoSilva """ def general_poly(L): """ L, a list of numbers (n0, n1, n2, ... nk) Returns a function, which when applied to a value x, returns the value n0 * x^k + n1 * x^(k-1) + ... nk * x^0 """ def f(x): total = 0 fact = len(L) - 1 ...
config = { 'api_root': 'https://library.cca.edu/api/v1', 'client_id': 'abcedfg-123445678', 'client_secret': 'abcedfg-123445678', }
config = {'api_root': 'https://library.cca.edu/api/v1', 'client_id': 'abcedfg-123445678', 'client_secret': 'abcedfg-123445678'}
""" Power digit sum 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ exponent = 1000 def initial_func(exponent): return sum(int(digit) for digit in f'{2 ** exponent}') def improved_func(exponent): pass # 1366 print(initial_func(ex...
""" Power digit sum 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ exponent = 1000 def initial_func(exponent): return sum((int(digit) for digit in f'{2 ** exponent}')) def improved_func(exponent): pass print(initial_func(exponent))
# -*- coding: utf-8 -*- # this file is released under public domain and you can use without limitations ######################################################################### ## Customize your APP title, subtitle and menus here ######################################################################### response.logo...
response.logo = a(b('Placement portal'), _class='brand', _id='web2py-logo') response.title = request.application.replace('_', ' ').title() response.subtitle = '' response.meta.author = 'Your Name <you@example.com>' response.meta.description = 'a cool new app' response.meta.keywords = 'web2py, python, framework' respons...
def bubble_sort(elements: list): """Sort the list inplace using bubble sort. Args: -- elements (list): list of elements """ size = len(elements) for i in range(size - 1): # if list is already sorted track it using swapped variable swapped = False for j in range...
def bubble_sort(elements: list): """Sort the list inplace using bubble sort. Args: -- elements (list): list of elements """ size = len(elements) for i in range(size - 1): swapped = False for j in range(size - 1 - i): if elements[j] > elements[j + 1]: ...
# game model list base class for all object collections in game class GameModelList(): def __init__( self, game, game_models=[], collidable=False, block_color=None ): self.game = game self.game_models = game_models self.collidable = collidable self.block_color = block_color for model in self.g...
class Gamemodellist: def __init__(self, game, game_models=[], collidable=False, block_color=None): self.game = game self.game_models = game_models self.collidable = collidable self.block_color = block_color for model in self.game_models: model.set_collidable(self...
# Author: Ian Burke # Module: Emerging Technologies # Date: September, 2017 # Problem Sheet: https://emerging-technologies.github.io/problems/python-fundamentals.html # create a function to reverse a string def reverse(): word = input("Enter a string: ") #user enters a string and store it in word word = word[...
def reverse(): word = input('Enter a string: ') word = word[::-1] print(word) reverse()
# GENERATED VERSION FILE # TIME: Tue Oct 26 14:07:11 2021 __version__ = '0.3.0+dc45206' short_version = '0.3.0'
__version__ = '0.3.0+dc45206' short_version = '0.3.0'
class Cuenta: def __init__(self, nombre, numero, saldo): self.nombre = nombre self.numero= numero self.saldo = saldo def depositar(self, a): self.saldo=self.saldo+a return self.saldo def retirar(self, a): self.saldo=self.saldo-a return self...
class Cuenta: def __init__(self, nombre, numero, saldo): self.nombre = nombre self.numero = numero self.saldo = saldo def depositar(self, a): self.saldo = self.saldo + a return self.saldo def retirar(self, a): self.saldo = self.saldo - a return self...
temp=n=int(input("Enter a number: ")) sum1 = 0 while(n > 0): sum1=sum1+n n=n-1 print(f"natural numbers in series {sum1}+{n}") print(f"The sum of first {temp} natural numbers is: {sum1}")
temp = n = int(input('Enter a number: ')) sum1 = 0 while n > 0: sum1 = sum1 + n n = n - 1 print(f'natural numbers in series {sum1}+{n}') print(f'The sum of first {temp} natural numbers is: {sum1}')
# red_black_node.py class Node: """ A class used to represent a Node in a red-black search tree. Attributes: key: The key is the value the node shall be sorted on. The key can be an integer, float, string, anything capable of being sorted. instances (int): The number o...
class Node: """ A class used to represent a Node in a red-black search tree. Attributes: key: The key is the value the node shall be sorted on. The key can be an integer, float, string, anything capable of being sorted. instances (int): The number of times the key for a node was...
def get_max_profit(stock_prices): # initialize the lowest_price to the first stock price lowest_price = stock_prices[0] # initialize the max_profit to the # difference between the first and the second stock price max_profit = stock_prices[1] - stock_prices[0] # loop through every price in stock...
def get_max_profit(stock_prices): lowest_price = stock_prices[0] max_profit = stock_prices[1] - stock_prices[0] for index in range(1, len(stock_prices)): if stock_prices[index] - lowest_price > max_profit: max_profit = stock_prices[index] - lowest_price if stock_prices[index] < l...
# Given an integer n, return the number of trailing zeroes in n!. # Example 1: # Input: 3 # Output: 0 # Explanation: 3! = 6, no trailing zero. # Example 2: # Input: 5 # Output: 1 # Explanation: 5! = 120, one trailing zero. class Solution: def trailingZeroes(self, n): """ :type n: int ...
class Solution: def trailing_zeroes(self, n): """ :type n: int :rtype: int """ x = 5 ans = 0 while n >= x: ans += n // x x *= 5 return ans print(solution().trailingZeroes(1808548329))
class EventMongoRepository: database_address = "localhost" def __init__(self): self.client = "Opens a connection with mongo" def add_event(self, event): pass def remove_event(self, event): pass def update_event(self, event): pass
class Eventmongorepository: database_address = 'localhost' def __init__(self): self.client = 'Opens a connection with mongo' def add_event(self, event): pass def remove_event(self, event): pass def update_event(self, event): pass
class SuperList(list): def __len__(self): return 1000 super_list1 = SuperList() print(len(super_list1)) super_list1.append(5) print(super_list1[0]) print(issubclass(list, object))
class Superlist(list): def __len__(self): return 1000 super_list1 = super_list() print(len(super_list1)) super_list1.append(5) print(super_list1[0]) print(issubclass(list, object))
class Finding: def __init__(self, filename, secret_type, secret_value, line_number=None, link=None): self._filename = filename self._secret_type = secret_type self._secret_value = secret_value self._line_number = line_number self._link = link @property def filename(s...
class Finding: def __init__(self, filename, secret_type, secret_value, line_number=None, link=None): self._filename = filename self._secret_type = secret_type self._secret_value = secret_value self._line_number = line_number self._link = link @property def filename(...
PATH_ROOT = "/sra/sra-instant/reads/ByExp/sra/SRX/SRX{}/{}/" def read_srx_list(file): srxs = set() with open(file, "r") as fh: next(fh) for line in fh: if line.startswith("SRX"): srxs.add(line.rstrip()) return list(srxs) def read_srr_file(srr_file): srr_d...
path_root = '/sra/sra-instant/reads/ByExp/sra/SRX/SRX{}/{}/' def read_srx_list(file): srxs = set() with open(file, 'r') as fh: next(fh) for line in fh: if line.startswith('SRX'): srxs.add(line.rstrip()) return list(srxs) def read_srr_file(srr_file): srr_data...
styles = { "alignment": { "color": "black", "linestyle": "-", "linewidth": 1.0, "alpha": 0.2, "label": "raw alignment" }, "despiked": { "color": "blue", "linestyle": "-", "linewidth": 1.4, "alpha": 1.0, "label": "de-spiked align...
styles = {'alignment': {'color': 'black', 'linestyle': '-', 'linewidth': 1.0, 'alpha': 0.2, 'label': 'raw alignment'}, 'despiked': {'color': 'blue', 'linestyle': '-', 'linewidth': 1.4, 'alpha': 1.0, 'label': 'de-spiked alignment'}, 'line1': {'color': 'black', 'linestyle': '-', 'linewidth': 1.2, 'alpha': 0.3, 'label': '...
# -*- coding: utf-8 -*- """ Created on Thu Oct 21 18:24:11 2021 @author: User """ # Objetos, pilas y colas class Rectangulo(): def __init__(self, x, y): self.x = x self.y = y def base(self): return def altura(self): return def area(self): return ...
""" Created on Thu Oct 21 18:24:11 2021 @author: User """ class Rectangulo: def __init__(self, x, y): self.x = x self.y = y def base(self): return def altura(self): return def area(self): return def desplazar(self, desplazamiento): return d...
# encoding: utf-8 # module errno # from (built-in) # by generator 1.147 """ This module makes available standard errno system symbols. The value of each symbol is the corresponding integer value, e.g., on most systems, errno.ENOENT equals the integer 2. The dictionary errno.errorcode maps numeric codes to symbol name...
""" This module makes available standard errno system symbols. The value of each symbol is the corresponding integer value, e.g., on most systems, errno.ENOENT equals the integer 2. The dictionary errno.errorcode maps numeric codes to symbol names, e.g., errno.errorcode[2] could be the string 'ENOENT'. Symbols that ...
''' ''' class Solution: def removeDuplicates(self, nums: List[int]) -> int: length = len(nums) if length <= 2: return length left = 0 cur = 0 while cur < length - 1: sums = 1 while cur < length - 1 and nums[cur] == nums[cur + 1]: ...
""" """ class Solution: def remove_duplicates(self, nums: List[int]) -> int: length = len(nums) if length <= 2: return length left = 0 cur = 0 while cur < length - 1: sums = 1 while cur < length - 1 and nums[cur] == nums[cur + 1]: ...
# Problem description: http://www.geeksforgeeks.org/dynamic-programming-set-7-coin-change/ def make_change(money, coins): if money < 0: return 0 elif money == 0: return 1 elif not coins: return 0 else: return make_change(money - coins[-1], coins) + make_change(money, coi...
def make_change(money, coins): if money < 0: return 0 elif money == 0: return 1 elif not coins: return 0 else: return make_change(money - coins[-1], coins) + make_change(money, coins[:-1]) coins = [1, 2, 3] money = 4 make_change(money, coins)
_notes_dict_array_hz = { 'C': [8.176, 16.352, 32.703, 65.406, 130.81, 261.63, 523.25, 1046.5, 2093.0, 4186.0, 8372.0], 'C#': [8.662, 17.324, 34.648, 69.296, 138.59, 277.18, 554.37, 1108.7, 2217.5, 4434.9, 8869.8], 'Df': [8.662, 17.324, 34.648, 69.296, 138.59, 277.18, 554.37, 1108.7, 2217.5, 4434.9, 8869.8],...
_notes_dict_array_hz = {'C': [8.176, 16.352, 32.703, 65.406, 130.81, 261.63, 523.25, 1046.5, 2093.0, 4186.0, 8372.0], 'C#': [8.662, 17.324, 34.648, 69.296, 138.59, 277.18, 554.37, 1108.7, 2217.5, 4434.9, 8869.8], 'Df': [8.662, 17.324, 34.648, 69.296, 138.59, 277.18, 554.37, 1108.7, 2217.5, 4434.9, 8869.8], 'D': [9.177,...
def funct(l1, l2): s = len(set(l1+l2)) return s for t in range(int(input())): n = int(input()) l = input().split() a = {} for i in l: p = i[1:] if p in a: a[p].append(i[0]) else: a[p] = [i[0]] b = list(a.keys()) s = 0 for i in range(l...
def funct(l1, l2): s = len(set(l1 + l2)) return s for t in range(int(input())): n = int(input()) l = input().split() a = {} for i in l: p = i[1:] if p in a: a[p].append(i[0]) else: a[p] = [i[0]] b = list(a.keys()) s = 0 for i in range(l...
"""Created by sgoswami on 8/30/17.""" """Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it upside down and turn it into a tree where the original right nodes turned into left leaf nodes.""" # Definition for a binary tre...
"""Created by sgoswami on 8/30/17.""" 'Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the \nsame parent node) or empty, flip it upside down and turn it into a tree where the original right nodes turned into \nleft leaf nodes.' class Solution(object): de...
# C100--- python classes class Car(object): """ blueprint for car """ def __init__(self, modelInput, colorInput, companyInput, speed_limitInput): self.color = colorInput self.company = companyInput self.speed_limit = speed_limitInput self.model = modelInput def s...
class Car(object): """ blueprint for car """ def __init__(self, modelInput, colorInput, companyInput, speed_limitInput): self.color = colorInput self.company = companyInput self.speed_limit = speed_limitInput self.model = modelInput def start(self): print(...
class ConfigSVM: # matrix_size = 1727 # matrix_size = 1219 # matrix_size = 1027 matrix_size = 798 # matrix_size = 3
class Configsvm: matrix_size = 798
print('\033[1;93m-=-\033[m' * 15) print(f'\033[1;31m{"LARGEST AND SMALLEST ON THE LIST":^45}\033[m', ) print('\033[1;93m-=-\033[m' * 15) numbers = list() largest = 0 big_position = list() small_position = list() numbers.append(int(input(f'Type a number for the position {0}: '))) smallest = numbers[0] for i in range(...
print('\x1b[1;93m-=-\x1b[m' * 15) print(f"\x1b[1;31m{'LARGEST AND SMALLEST ON THE LIST':^45}\x1b[m") print('\x1b[1;93m-=-\x1b[m' * 15) numbers = list() largest = 0 big_position = list() small_position = list() numbers.append(int(input(f'Type a number for the position {0}: '))) smallest = numbers[0] for i in range(1, 5)...
# Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. # # Use of this source code is governed by a BSD-style license # that can be found in the LICENSE file in the root of the source # tree. An additional intellectual property rights grant can be found # in the file PATENTS. All contributing project au...
{'includes': ['../build/common.gypi'], 'conditions': [['OS=="ios"', {'targets': [{'target_name': 'rtc_api_objc', 'type': 'static_library', 'dependencies': ['<(webrtc_root)/base/base.gyp:rtc_base_objc'], 'sources': ['objc/RTCIceServer+Private.h', 'objc/RTCIceServer.h', 'objc/RTCIceServer.mm'], 'xcode_settings': {'CLANG_...
getObject = { 'primaryRouter': { 'datacenter': {'id': 1234, 'longName': 'TestDC'}, 'fullyQualifiedDomainName': 'fcr01.TestDC' }, 'id': 1234, 'vlanNumber': 4444, 'firewallInterfaces': None }
get_object = {'primaryRouter': {'datacenter': {'id': 1234, 'longName': 'TestDC'}, 'fullyQualifiedDomainName': 'fcr01.TestDC'}, 'id': 1234, 'vlanNumber': 4444, 'firewallInterfaces': None}
"""Library package info""" author = "linuxdaemon" version_info = (0, 3, 0) version = ".".join(map(str, version_info)) __all__ = ("author", "version_info", "version")
"""Library package info""" author = 'linuxdaemon' version_info = (0, 3, 0) version = '.'.join(map(str, version_info)) __all__ = ('author', 'version_info', 'version')
"""The module has following classes: - Room""" class Room(object): '''Takes name and description of the object and initializes paths.\nProvides methods \n\t go(direction) and,\n\t add_paths(paths)''' def __init__(self, name, description): self.name = name self.description = description ...
"""The module has following classes: - Room""" class Room(object): """Takes name and description of the object and initializes paths. Provides methods go(direction) and, add_paths(paths)""" def __init__(self, name, description): self.name = name self.description = description self...
class Car: def wheels(self): print('Car.wheels') return 4 class Bike(Car): def wheels(self): return 2 class Truck(Car): def wheels(self): print('Truck.wheels: start') super().wheels() print('Truck.wheels: end') return 6 car = Bike() print(car.wh...
class Car: def wheels(self): print('Car.wheels') return 4 class Bike(Car): def wheels(self): return 2 class Truck(Car): def wheels(self): print('Truck.wheels: start') super().wheels() print('Truck.wheels: end') return 6 car = bike() print(car.whee...
class NodeEndpoint: protocol = '' host = '' port = '' @staticmethod def from_parameters(protocol, host, port): endpoint = NodeEndpoint() endpoint.protocol = protocol endpoint.host = host endpoint.port = port return endpoint @staticmethod def from_jso...
class Nodeendpoint: protocol = '' host = '' port = '' @staticmethod def from_parameters(protocol, host, port): endpoint = node_endpoint() endpoint.protocol = protocol endpoint.host = host endpoint.port = port return endpoint @staticmethod def from_js...
class SchemaConstructionException(Exception): def __init__(self, claz): self.cls = claz class SchemaParseException(Exception): def __init__(self, errors): self.errors = errors class ParseError(object): def __init__(self, path, inner): self.path = path self.inner = inner...
class Schemaconstructionexception(Exception): def __init__(self, claz): self.cls = claz class Schemaparseexception(Exception): def __init__(self, errors): self.errors = errors class Parseerror(object): def __init__(self, path, inner): self.path = path self.inner = inner ...
""" Created on Sun Feb 15 01:52:42 2015 @author: Enes Kemal Ergin The Field: Introduction to Complex Numbers (Video 2) """ # complex number = (real part) + (imaginary part) * i ## Pyhton use j for doing complex 1j 1+3j (1+3j) + (10+20j) x = 1+3j (x-1)**2 # (-9+0j) -> -9 x.real # 1.0 x.imag # 3.0 ## Write a pr...
""" Created on Sun Feb 15 01:52:42 2015 @author: Enes Kemal Ergin The Field: Introduction to Complex Numbers (Video 2) """ 1j 1 + 3j 1 + 3j + (10 + 20j) x = 1 + 3j (x - 1) ** 2 x.real x.imag def solve(a, b, c): return (c - b) / a solve(10, 5, 30) solve(10 + 5j, 5, 20)
class Solution: def maxPerformance(self, n: int, speed: List[int], efficiency: List[int], k: int) -> int: modulo = 10 ** 9 + 7 # build tuples of (efficiency, speed) candidates = zip(efficiency, speed) # sort the candidates by their efficiencies candidates = sorted(candidates...
class Solution: def max_performance(self, n: int, speed: List[int], efficiency: List[int], k: int) -> int: modulo = 10 ** 9 + 7 candidates = zip(efficiency, speed) candidates = sorted(candidates, key=lambda t: t[0], reverse=True) speed_heap = [] (speed_sum, perf) = (0, 0) ...
"""Helper functions used in various modules.""" def deserialize_thing_id(thing_id): """Convert base36 reddit 'thing id' string into int tuple.""" return tuple(int(x, base=36) for x in thing_id[1:].split("_")) def update_sr_tables(cursor, subreddit): """Update tables of subreddits and subreddit-moderator...
"""Helper functions used in various modules.""" def deserialize_thing_id(thing_id): """Convert base36 reddit 'thing id' string into int tuple.""" return tuple((int(x, base=36) for x in thing_id[1:].split('_'))) def update_sr_tables(cursor, subreddit): """Update tables of subreddits and subreddit-moderator...
"""Test the link to the help docco.""" def test_help_redirect_to_rtd(webapp, f_httpretty): """Test we redirect to read the docs.""" f_httpretty.HTTPretty.allow_net_connect = False response = webapp.get('/help') assert response.status_code == 302 assert response.headers['location'] == 'https://dn...
"""Test the link to the help docco.""" def test_help_redirect_to_rtd(webapp, f_httpretty): """Test we redirect to read the docs.""" f_httpretty.HTTPretty.allow_net_connect = False response = webapp.get('/help') assert response.status_code == 302 assert response.headers['location'] == 'https://dnstw...
# Minimum Size Subarray Sum class Solution: def minSubArrayLen(self, target, nums): length = len(nums) Invalid = length + 1 left, right = 0, 0 added = nums[left] if added >= target: return 1 ans = Invalid while True: if left + 1 <= r...
class Solution: def min_sub_array_len(self, target, nums): length = len(nums) invalid = length + 1 (left, right) = (0, 0) added = nums[left] if added >= target: return 1 ans = Invalid while True: if left + 1 <= right and added - nums[l...
# http://codingbat.com/prob/p165321 def near_ten(num): return (num % 10 <= 2) or (num % 10 >= 8)
def near_ten(num): return num % 10 <= 2 or num % 10 >= 8
class WorkerNode(object): def __init__(self, ip, k8s_name, k8s_is_ready): self.ip = ip self.k8s_name = k8s_name self.k8s_is_ready = k8s_is_ready self.k8s_pod_num = 0 self.vc = None self.to_turn_on = False self.to_turn_off = False class Pod(object): d...
class Workernode(object): def __init__(self, ip, k8s_name, k8s_is_ready): self.ip = ip self.k8s_name = k8s_name self.k8s_is_ready = k8s_is_ready self.k8s_pod_num = 0 self.vc = None self.to_turn_on = False self.to_turn_off = False class Pod(object): def ...
class Solution: def countAndSay(self, n): numb = 1 w = 1 while n > 1: w = Solution.CountSay(numb) numb = w n -= 1 return str(w) def CountSay(no): tnumb = str(no) x = tnumb[0] count = 1 strr = "" ...
class Solution: def count_and_say(self, n): numb = 1 w = 1 while n > 1: w = Solution.CountSay(numb) numb = w n -= 1 return str(w) def count_say(no): tnumb = str(no) x = tnumb[0] count = 1 strr = '' for ...
# domoticz configuration DOMOTICZ_SERVER_IP = "xxx.xxx.x.xxx" DOMOTICZ_SERVER_PORT = "xxxx" DOMOTICZ_USERNAME = "" DOMOTICZ_PASSWORD = "" # sensor dictionary to add own sensors # if you don't want to use the raw voltage option, just write -1 in the VOLTAGE_IDX value field sensors = { 1: {"MAC": "xx:xx:xx:xx:xx...
domoticz_server_ip = 'xxx.xxx.x.xxx' domoticz_server_port = 'xxxx' domoticz_username = '' domoticz_password = '' sensors = {1: {'MAC': 'xx:xx:xx:xx:xx:xx', 'TH_IDX': 1, 'VOLTAGE_IDX': -1, 'UPDATED': False}, 2: {'MAC': 'xx:xx:xx:xx:xx:xx', 'TH_IDX': 2, 'VOLTAGE_IDX': -1, 'UPDATED': False}, 3: {'MAC': 'xx:xx:xx:xx:xx:xx'...
del_items(0x8009E2A0) SetType(0x8009E2A0, "char StrDate[12]") del_items(0x8009E2AC) SetType(0x8009E2AC, "char StrTime[9]") del_items(0x8009E2B8) SetType(0x8009E2B8, "char *Words[117]") del_items(0x8009E48C) SetType(0x8009E48C, "struct MONTH_DAYS MonDays[12]")
del_items(2148131488) set_type(2148131488, 'char StrDate[12]') del_items(2148131500) set_type(2148131500, 'char StrTime[9]') del_items(2148131512) set_type(2148131512, 'char *Words[117]') del_items(2148131980) set_type(2148131980, 'struct MONTH_DAYS MonDays[12]')
class FunctionLink: def __init__(self, linked_function): self.__linked_function = linked_function @property def linked_function(self): return self.__linked_function
class Functionlink: def __init__(self, linked_function): self.__linked_function = linked_function @property def linked_function(self): return self.__linked_function
workers = 2 timeout = 120 reload = True limit_request_field_size = 0 limit_request_line = 0
workers = 2 timeout = 120 reload = True limit_request_field_size = 0 limit_request_line = 0
GITHUB_TOKENS = ['GH_TOKEN'] GITHUB_URL_FILE = 'rawGitUrls.txt' GITHUB_API_URL = 'https://api.github.com/search/code?q=' GITHUB_API_COMMIT_URL = 'https://api.github.com/repos/' GITHUB_SEARCH_PARAMS = '&sort=indexed&o=desc' GITHUB_BASE_URL = 'https://github.com' GITHUB_MAX_RETRY = 10 XDISCORD_WEBHOOKURL = 'https://disco...
github_tokens = ['GH_TOKEN'] github_url_file = 'rawGitUrls.txt' github_api_url = 'https://api.github.com/search/code?q=' github_api_commit_url = 'https://api.github.com/repos/' github_search_params = '&sort=indexed&o=desc' github_base_url = 'https://github.com' github_max_retry = 10 xdiscord_webhookurl = 'https://disco...
class QuickSort(object): "In Place Quick Sort" def __init__(self, arr): self.arr = arr def sort(self, left_i, right_i): if right_i - left_i < 1: return pivot_i = self.partition(left_i, right_i) self.sort(left_i, pivot_i - 1) self.sort(pivot_i + 1, right_...
class Quicksort(object): """In Place Quick Sort""" def __init__(self, arr): self.arr = arr def sort(self, left_i, right_i): if right_i - left_i < 1: return pivot_i = self.partition(left_i, right_i) self.sort(left_i, pivot_i - 1) self.sort(pivot_i + 1, ri...
def validate(instruction) -> bool: """Validates an instruction Parameters ---------- instruction : BaseCommand The instruction to validate Returns ------- bool Valid or not valid """ switch = { # R Type instructions "add": validate_3_rtype, ...
def validate(instruction) -> bool: """Validates an instruction Parameters ---------- instruction : BaseCommand The instruction to validate Returns ------- bool Valid or not valid """ switch = {'add': validate_3_rtype, 'addu': validate_3_rtype, 'and': validat...
a = [] for i in range(100): a.append(i) if (n := len(a)) > 10: print(f"List is too long ({n} elements, expected <= 10)")
a = [] for i in range(100): a.append(i) if (n := len(a)) > 10: print(f'List is too long ({n} elements, expected <= 10)')
# model initial conditions x = -1 y = 0 z = 0.5 t = 0 # model constants _alpha = 0.3 gamma = 0.01 # gradients palette_relaxing_red = [color(180, 15, 48), color(255, 251, 213)] palette_shahabi = [color(104, 250, 0), color(166, 1, 116)] palette_flare = [color(245, 174, 25), color(241, 40, 16)] palette_rose_colored_lens...
x = -1 y = 0 z = 0.5 t = 0 _alpha = 0.3 gamma = 0.01 palette_relaxing_red = [color(180, 15, 48), color(255, 251, 213)] palette_shahabi = [color(104, 250, 0), color(166, 1, 116)] palette_flare = [color(245, 174, 25), color(241, 40, 16)] palette_rose_colored_lenses = [color(100, 112, 163), color(232, 203, 191)] palette_m...
def get_bid(exchange, symbol, n=1): return 0 def get_bid(exchange, symbol, n=1): return 0
def get_bid(exchange, symbol, n=1): return 0 def get_bid(exchange, symbol, n=1): return 0
def build_tuple_type(*columns): class Tuple(object): __slots__ = columns def __init__(self, d=None, **kw): if d is None: d = kw for k in self.__slots__: setattr(self, k, d.get(k)) def __getitem__(self, k): if k in s...
def build_tuple_type(*columns): class Tuple(object): __slots__ = columns def __init__(self, d=None, **kw): if d is None: d = kw for k in self.__slots__: setattr(self, k, d.get(k)) def __getitem__(self, k): if k in self.__...
# ------------------------------------------------------------------------------ # Site Configuration File # ------------------------------------------------------------------------------ theme = "carbon" title = "Holly Demo" tagline = "A blog-engine plugin for Ivy." extensions = ["holly"] holly = { "homepage": ...
theme = 'carbon' title = 'Holly Demo' tagline = 'A blog-engine plugin for Ivy.' extensions = ['holly'] holly = {'homepage': {'root_urls': ['@root/blog//', '@root/animalia//']}, 'roots': [{'root_url': '@root/blog//'}, {'root_url': '@root/animalia//'}]}
def Prime_number(n): a = [] for i in range(2,n+1): e1 = n % i if e1 == 0: b.append(e1) if len(a) > 1: print('FALSE') print('This is not a prime number!') elif len(a) == 1: print('TRUE') print('This is a Prime number!') Prime_number(int(input('Please give your number: ')))
def prime_number(n): a = [] for i in range(2, n + 1): e1 = n % i if e1 == 0: b.append(e1) if len(a) > 1: print('FALSE') print('This is not a prime number!') elif len(a) == 1: print('TRUE') print('This is a Prime number!') prime_number(int(input...
class Platform: def __init__(self, designer, debug): self.designer = designer self.debug = debug def generate_wrappers(self): raise Exception("Method not implemented") def create_mem(self, mem_type, name, data_type, size, init): raise Exception("Method not implemented") ...
class Platform: def __init__(self, designer, debug): self.designer = designer self.debug = debug def generate_wrappers(self): raise exception('Method not implemented') def create_mem(self, mem_type, name, data_type, size, init): raise exception('Method not implemented') ...
# Here I've implemented a method of finding square root of imperfect square # Steps (Pseudocode): visit http://burningmath.blogspot.in/2013/12/finding-square-roots-of-numbers-that.html # Read the steps carefully or you'll not understand the program! # To check is number is a perfect square or not def is_perfect_square...
def is_perfect_square(n): if isinstance(n, float): return (False, None) for i in range(n + 1): if i * i == n: return (True, i) return (False, None) def average(*args): hold = list(args) return sum(hold) / len(hold) def sqrt_of_imperfect_square(a, certainty=6): is_sq...
"""Constants that define units""" AUTO = 'auto' METRIC = 'metric' US = 'us' UK = 'uk' CA = 'ca'
"""Constants that define units""" auto = 'auto' metric = 'metric' us = 'us' uk = 'uk' ca = 'ca'
usuario = input("Informe o nome de usuario: ") senha = input("Informe a senha: ") while usuario == senha: print("Usuario deve ser diferente da senha!\n") senha = input("Informe uma nova senha: ") else: print("Dados confirmados")
usuario = input('Informe o nome de usuario: ') senha = input('Informe a senha: ') while usuario == senha: print('Usuario deve ser diferente da senha!\n') senha = input('Informe uma nova senha: ') else: print('Dados confirmados')
""" This is a simple binary search algorithm for python. This is the exact implementation of the pseudocode written in README. """ def binary_search(item_list,item): left_index = 0 right_index = len(item_list)-1 while left_index <= right_index: middle_index = (left_index+right_index) // 2 ...
""" This is a simple binary search algorithm for python. This is the exact implementation of the pseudocode written in README. """ def binary_search(item_list, item): left_index = 0 right_index = len(item_list) - 1 while left_index <= right_index: middle_index = (left_index + right_index) // 2 ...
# Dependency Inversion Principle (SOLID) # https://www.geeksforgeeks.org/dependecy-inversion-principle-solid/ # SGVP391900 | 12:03 7Mar19 # Mootto - Any higher classes should always depend upon the abstraction of the class # rather than the detail. class Employee(object): def Work(): pass class Manager...
class Employee(object): def work(): pass class Manager: def __init__(self): self.employees = [] def add_employee(self, a): self.employees.append(a) class Developer(Employee): def __init__(self): print('developer added') def work(): print('truning coffee...