content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# problem link: https://leetcode.com/problems/number-of-islands/ class Solution: def numIslands(self, grid: List[List[str]]) -> int: ans = 0 stat_visited = [[0 for _ in range(len(grid[0]))] for _ in range(len(grid))] def dfs(r, c): stat_visited[r][c] = 1 if g...
class Solution: def num_islands(self, grid: List[List[str]]) -> int: ans = 0 stat_visited = [[0 for _ in range(len(grid[0]))] for _ in range(len(grid))] def dfs(r, c): stat_visited[r][c] = 1 if grid[r][c] == '0': return for [i, j] in [[-1...
num = 1000 done = False for a in range(1, num): for b in range(1,num): c = num - a - b if a**2 + b**2 == c**2: print (a*b*c) done = True break if done == True: break
num = 1000 done = False for a in range(1, num): for b in range(1, num): c = num - a - b if a ** 2 + b ** 2 == c ** 2: print(a * b * c) done = True break if done == True: break
class State: def __init__(self, state=None): self.State = state pass
class State: def __init__(self, state=None): self.State = state pass
a=[1,2,3,4,5] k=3 b=a[k-1::-1] b.extend(a[-1:k-1:-1]) print(b)
a = [1, 2, 3, 4, 5] k = 3 b = a[k - 1::-1] b.extend(a[-1:k - 1:-1]) print(b)
# (C) Copyright IBM Corporation 2017, 2018, 2019 # U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted # by GSA ADP Schedule Contract with IBM Corp. # # Author: Leonardo P. Tizzei <ltizzei@br.ibm.com> class Assignee: def __init__(self, login, htmlurl): self.login = login ...
class Assignee: def __init__(self, login, htmlurl): self.login = login self.htmlurl = htmlurl self._assignee_id = None @property def assignee_id(self): return self._assignee_id @assignee_id.setter def assignee_id(self, v): self._assignee_id = v
# # PySNMP MIB module BLADESPPALT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BLADESPPALT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:22:04 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, constraints_union, value_size_constraint, single_value_constraint) ...
#pythran export solve(int) #runas solve(10001) def solve(p): ''' By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? ''' prime_list = [2, 3, 5, 7, 11, 13, 17, 19, 23] # Ensure that this is initialised with at leas...
def solve(p): """ By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? """ prime_list = [2, 3, 5, 7, 11, 13, 17, 19, 23] prime_dict = dict.fromkeys(prime_list, 1) def _isprime(n): """ Raw check to see...
def uses_only(line, custom_symbols): '''check a string-line contain custom only symbols''' for letters in line: if letters not in custom_symbols: return False return True def some_sort_words(filename): '''print and calculate words without broken symbols''' count = 0 with open(filename) as f_open_file: for...
def uses_only(line, custom_symbols): """check a string-line contain custom only symbols""" for letters in line: if letters not in custom_symbols: return False return True def some_sort_words(filename): """print and calculate words without broken symbols""" count = 0 with ope...
__all__ = ( "TapTracksError", "MissingDependency" ) class TapTracksError(Exception): pass class MissingDependency(TapTracksError): pass
__all__ = ('TapTracksError', 'MissingDependency') class Taptrackserror(Exception): pass class Missingdependency(TapTracksError): pass
class StratA: def __init__(self, fives): self.fives = self.order_fives(fives) self.reset() def name(self): return 'Strategy A' def order_fives(self, fives): # Based on https://www3.nd.edu/~busiforc/handouts/cryptography/letterfrequencies.html letscores = { ...
class Strata: def __init__(self, fives): self.fives = self.order_fives(fives) self.reset() def name(self): return 'Strategy A' def order_fives(self, fives): letscores = {'E': 11.16, 'A': 8.5, 'R': 7.58, 'I': 7.54, 'O': 7.16, 'T': 6.95, 'N': 6.65, 'S': 5.73, 'L': 5.49, 'C':...
def drawTABLE(WIDTH, HEIGHT): if WIDTH > 999: WIDTH = 1000 if HEIGHT > 999: HEIGHT = 1000 toprow = "[ ] " for x in range(1, WIDTH): summ = str(x) if len(summ) == 1: summ += "_____" elif len(summ) == 2: summ += "____" elif len(s...
def draw_table(WIDTH, HEIGHT): if WIDTH > 999: width = 1000 if HEIGHT > 999: height = 1000 toprow = '[ ] ' for x in range(1, WIDTH): summ = str(x) if len(summ) == 1: summ += '_____' elif len(summ) == 2: summ += '____' elif len(sum...
class Bunch(object): def __init__(self, **kwds): self.update(kwds) def update(self, other): self.__dict__.update(other) def __getitem__(self, key): return getattr(self, key) def __setitem__(self, key, val): return setattr(self, key, val) def __contains__(self, k...
class Bunch(object): def __init__(self, **kwds): self.update(kwds) def update(self, other): self.__dict__.update(other) def __getitem__(self, key): return getattr(self, key) def __setitem__(self, key, val): return setattr(self, key, val) def __contains__(self, ke...
# Copyright (c) Vera Galstyan Jan 25,2018 def favorite_book(title): print("One of my favorite books is " + title.title()) favorite_book('alice in the wonderland')
def favorite_book(title): print('One of my favorite books is ' + title.title()) favorite_book('alice in the wonderland')
class LoginDeviceParams(object): def __init__(self): self.password: str = "" self.username: str = "" def set_password(self, password: str): self.password = password def set_username(self, username: str): self.username = username def get_username(self): return s...
class Logindeviceparams(object): def __init__(self): self.password: str = '' self.username: str = '' def set_password(self, password: str): self.password = password def set_username(self, username: str): self.username = username def get_username(self): return ...
n = int(input()) arr = [] for i in range(n): arr.append(input()) arr = arr[::-1] for _ in arr: print(_)
n = int(input()) arr = [] for i in range(n): arr.append(input()) arr = arr[::-1] for _ in arr: print(_)
def test_push_pop_peek(): stack = Stack() for i in range(1,10): stack.push(i) stack.push(10) assert stack.top.value == 10 assert stack.pop() == 9 assert stack.peek() == 9 def test_is_empty(): stack = Stack() assert stack.is_empty() == True
def test_push_pop_peek(): stack = stack() for i in range(1, 10): stack.push(i) stack.push(10) assert stack.top.value == 10 assert stack.pop() == 9 assert stack.peek() == 9 def test_is_empty(): stack = stack() assert stack.is_empty() == True
# # PySNMP MIB module MIBMANREMOTE-SUNMANAGEMENTCENTER-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MIBMANREMOTE-SUNMANAGEMENTCENTER-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:01:50 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # U...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, constraints_intersection, constraints_union, value_range_constraint) ...
# define some colors (these are in BGR order) # if you need to add colors, go to Google search engine and search ex: "purble bgr code" # note that Google displays them in RGB order ;) GRAY = (150, 150, 150) RED = (0, 0, 255) YELLOW = (0, 255, 255) GREEN = (0, 255, 0) BLUE = (255, 0, 0) PURPLE = (128, 0, 128) TEAL = (17...
gray = (150, 150, 150) red = (0, 0, 255) yellow = (0, 255, 255) green = (0, 255, 0) blue = (255, 0, 0) purple = (128, 0, 128) teal = (179, 196, 98) pink = (186, 137, 219)
class MemoryBus: def __init__(self, busy_until=0): self.busy_until = busy_until def is_busy(self, clk): return self.busy_until > clk def set_busy_until(self, clk): self.busy_until = clk def get_busy_until(self): return self.busy_until
class Memorybus: def __init__(self, busy_until=0): self.busy_until = busy_until def is_busy(self, clk): return self.busy_until > clk def set_busy_until(self, clk): self.busy_until = clk def get_busy_until(self): return self.busy_until
def merge_sort(numbers): if len(numbers) > 1: mid = len(numbers) // 2 left_half = numbers[:mid] right_half = numbers[mid:] merge_sort(left_half) merge_sort(right_half) i = j = k = 0 while i < len(left_half) and j < len(right_half): if left_half[i...
def merge_sort(numbers): if len(numbers) > 1: mid = len(numbers) // 2 left_half = numbers[:mid] right_half = numbers[mid:] merge_sort(left_half) merge_sort(right_half) i = j = k = 0 while i < len(left_half) and j < len(right_half): if left_half[i] ...
def string_rotation(original, rotation): return is_substr(original + original, rotation) def is_substr(str1, str2): return str2 in str1 print(is_substr("waterbottle", "water"))
def string_rotation(original, rotation): return is_substr(original + original, rotation) def is_substr(str1, str2): return str2 in str1 print(is_substr('waterbottle', 'water'))
lst = ['tomato', 'potato', 'banana', 'apple'] lst = ['tomato'] lst = ['tomato', 'potato'] def list2str(lst): if len(lst) == 0: return '' if len(lst) == 1: return str(lst[0]) new_lst = [lst[i] + ', ' for i in range(len(lst) - 2)] new_lst.append(lst[-2] + ' and ') new_lst.append(ls...
lst = ['tomato', 'potato', 'banana', 'apple'] lst = ['tomato'] lst = ['tomato', 'potato'] def list2str(lst): if len(lst) == 0: return '' if len(lst) == 1: return str(lst[0]) new_lst = [lst[i] + ', ' for i in range(len(lst) - 2)] new_lst.append(lst[-2] + ' and ') new_lst.append(lst[-...
# -------------- class_1=['Geoffrey Hinton','Andrew Ng','Sebastian Raschka','Yoshua Bengio'] class_2=['Hilary Mason','Carla Gentry','Corinna Cortes'] new_class = (class_1 + class_2) print(new_class) # Append the list new_class.append('Peter Warden') print(new_class) new_class.remove('Carla Gentry') print(new_class) ...
class_1 = ['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio'] class_2 = ['Hilary Mason', 'Carla Gentry', 'Corinna Cortes'] new_class = class_1 + class_2 print(new_class) new_class.append('Peter Warden') print(new_class) new_class.remove('Carla Gentry') print(new_class) courses = {'Math': 65, 'English...
class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: result = ListNode(0) resultTail = result carry = 0 while l1 or l2 or carry: val1 = (l1.val if l1 else 0) val2 = (l2.val if l2 else 0) carry, out = divmod(val1 + val2 +...
class Solution: def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode: result = list_node(0) result_tail = result carry = 0 while l1 or l2 or carry: val1 = l1.val if l1 else 0 val2 = l2.val if l2 else 0 (carry, out) = divmod(val1 + val...
f = open("input.txt") text = [] for line in f.readlines(): text += [line[:-1]] # trim '\n' finished = False seen = set() for i, w1 in enumerate(text): for j, w2 in enumerate(text): answer = "" diff = 0 assert(len(w1) == len(w2)) # sanity check # don't compare a string with...
f = open('input.txt') text = [] for line in f.readlines(): text += [line[:-1]] finished = False seen = set() for (i, w1) in enumerate(text): for (j, w2) in enumerate(text): answer = '' diff = 0 assert len(w1) == len(w2) if i is j or (i, j) in seen: continue se...
class ConnexionError(Exception): def __init__(self, url): self.message = "Unnable to connect to this url : " + url class UnknownWebsiteError(Exception): def __init__(self, sitename): self.message = sitename + "isn\'t known nowadays." class InputError(Exception): def __init__(self, message ...
class Connexionerror(Exception): def __init__(self, url): self.message = 'Unnable to connect to this url : ' + url class Unknownwebsiteerror(Exception): def __init__(self, sitename): self.message = sitename + "isn't known nowadays." class Inputerror(Exception): def __init__(self, messag...
# module.py # # Abstract superclass for the modules in this program. class Module(): ## Start the module. Set initial conditions to useful values. def start(self): raise NotImplementedError ## Run the module. This is called once each loop. # # @return The next module which the program calls. def run(self): ...
class Module: def start(self): raise NotImplementedError def run(self): raise NotImplementedError def check_for_initialization_errors(self): return False
# Author: Mujib Ansari # Date: Jan 23, 2021 # Problem Statement: WAP to remove duplicate values from given list def remove_duplicate(l): return list(set(l)) size = int(input("Enter the size of list : ")) user_inputs = [] for i in range(size): user_inputs.append(int(input("Enter value : "))) print...
def remove_duplicate(l): return list(set(l)) size = int(input('Enter the size of list : ')) user_inputs = [] for i in range(size): user_inputs.append(int(input('Enter value : '))) print('List after duplicaete removed is : ', remove_duplicate(user_inputs))
class Solution: def solve(self, s): ans = 0 for c in s: ans *= 26 ans += ord(c)-ord('A')+1 return ans
class Solution: def solve(self, s): ans = 0 for c in s: ans *= 26 ans += ord(c) - ord('A') + 1 return ans
class Rotation: pass
class Rotation: pass
class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: r = 0 l = min(len(s) for s in strs) for i in range(l): c = strs[0][i] for s in strs: if c != s[i]: return strs[0][:r] r += 1 return...
class Solution: def longest_common_prefix(self, strs: List[str]) -> str: r = 0 l = min((len(s) for s in strs)) for i in range(l): c = strs[0][i] for s in strs: if c != s[i]: return strs[0][:r] r += 1 return strs...
# example dict data = [ {'type': 'a', 'v1': 'off', 'v2': '1'}, {'type': 'b', 'v1': 'off', 'v2': '1'}, {'type': 'c', 'v1': 'on', 'v2': '1'}, {'type': 'b', 'v1': 'off', 'v2': '2'}, {'type': 'a', 'v1': 'on', 'v2': '2'}, {'type': 'a', 'v1': 'on', 'v2': '3'} ] def sort_types(my_list, my_key): n...
data = [{'type': 'a', 'v1': 'off', 'v2': '1'}, {'type': 'b', 'v1': 'off', 'v2': '1'}, {'type': 'c', 'v1': 'on', 'v2': '1'}, {'type': 'b', 'v1': 'off', 'v2': '2'}, {'type': 'a', 'v1': 'on', 'v2': '2'}, {'type': 'a', 'v1': 'on', 'v2': '3'}] def sort_types(my_list, my_key): new_dict = {} for i in my_list: ...
class Node(object): def __init__(self, key, value): self.key = key self.value = value self.next = None self.prev = None class LRU(object): def __init__(self, capacity): self.capacity = capacity self.data = dict() self.head = Node(0, 0) self.tail =...
class Node(object): def __init__(self, key, value): self.key = key self.value = value self.next = None self.prev = None class Lru(object): def __init__(self, capacity): self.capacity = capacity self.data = dict() self.head = node(0, 0) self.tail...
#Prints a maximum set of activities that can be done by a #single person, one at a time #n --> Total number of activities #s[]--> An array that contains start time of all activities #f[] --> An array that contains finish time of all activities def find_activities(arr): n = len(arr) selected = [] arr....
def find_activities(arr): n = len(arr) selected = [] arr.sort(key=lambda x: x[1]) i = 0 selected.append(arr[i]) for j in range(1, n): start_time_next_activity = arr[j][0] end_time_prev_activity = arr[i][1] if start_time_next_activity >= end_time_prev_activity: ...
num = int(input("enter a number")) min= int(input("give the minimum of range")) max= int(input("give the maximum of range")) if(min>max): print("range is not valid as min should be less than max") exit() for i in range(min,max+1): if(num%i==0): print(i ,"is a divisor of", num) else: ...
num = int(input('enter a number')) min = int(input('give the minimum of range')) max = int(input('give the maximum of range')) if min > max: print('range is not valid as min should be less than max') exit() for i in range(min, max + 1): if num % i == 0: print(i, 'is a divisor of', num) else: ...
class Train: def __init__(self, uid, train_length, front): self.uid = uid self.train_length = train_length self.front = front class Intersection: def __init__(self, uid, mutex, locked_by): self.uid = uid self.mutex = mutex self.locked_by = locked_by class Cros...
class Train: def __init__(self, uid, train_length, front): self.uid = uid self.train_length = train_length self.front = front class Intersection: def __init__(self, uid, mutex, locked_by): self.uid = uid self.mutex = mutex self.locked_by = locked_by class Cros...
class Solution: def findMaxAverage(self, nums: List[int], k: int) -> float: if not nums: return None n = len(nums) pre_k_num = 0 max_subary_avg = sum(nums[:k])/k accm_num = 0 dp_ = [0] for i, num in enumerate(nums): avg_num = num / k ...
class Solution: def find_max_average(self, nums: List[int], k: int) -> float: if not nums: return None n = len(nums) pre_k_num = 0 max_subary_avg = sum(nums[:k]) / k accm_num = 0 dp_ = [0] for (i, num) in enumerate(nums): avg_num = num...
EPOCHS = 30 data_dir = "./models/pneumonia/data/" TEST = 'test' TRAIN = 'train' VAL ='val' WEIGHT="models/pneumonia/weight/pne.pt"
epochs = 30 data_dir = './models/pneumonia/data/' test = 'test' train = 'train' val = 'val' weight = 'models/pneumonia/weight/pne.pt'
for i in range(1,8,2): for j in range(7,i,-2): print(" ",end='') for j in range(1,i+1): print("*",end='') print() for i in range(5,0,-2): for j in range(5,i-1,-2): print(" ",end='') for j in range(1,i+1): print("*",end='') print()
for i in range(1, 8, 2): for j in range(7, i, -2): print(' ', end='') for j in range(1, i + 1): print('*', end='') print() for i in range(5, 0, -2): for j in range(5, i - 1, -2): print(' ', end='') for j in range(1, i + 1): print('*', end='') print()
class SnifferTask: def __init__(self, id=None, iface=None, active=False, thread_id=None, schedule=None, dynamic=False) -> None: self.id = id if iface is None: raise ValueError("Param 'iface' cannot be None.") self.iface = iface self.active = active self.thread_id ...
class Sniffertask: def __init__(self, id=None, iface=None, active=False, thread_id=None, schedule=None, dynamic=False) -> None: self.id = id if iface is None: raise value_error("Param 'iface' cannot be None.") self.iface = iface self.active = active self.thread_i...
class Logger: def __init__(self): self.errors_list = [] def add_error(self, error_name: str): self.errors_list.append(error_name)
class Logger: def __init__(self): self.errors_list = [] def add_error(self, error_name: str): self.errors_list.append(error_name)
input_ = [int(i) for i in input().split()] n, k = input_[0], input_[1] lengths = [] for i in range(n): lengths.append(int(input())) if not (1 <= n <= 10001 or 1 <= k <= 10001): raise ValueError def func(chisla): l = 1 r = sum(chisla) // k m = (l + r) // 2 while l < r: s = 0 fo...
input_ = [int(i) for i in input().split()] (n, k) = (input_[0], input_[1]) lengths = [] for i in range(n): lengths.append(int(input())) if not (1 <= n <= 10001 or 1 <= k <= 10001): raise ValueError def func(chisla): l = 1 r = sum(chisla) // k m = (l + r) // 2 while l < r: s = 0 ...
#!/usr/bin/env python #coding=utf-8 ''' Definition of Action class. In AMREAGER, an action can be either 'shift', 'reduce', 'rarc' or 'larc'. When it's a shift, the argument is the subgraph triggered by the token. When it's a reduce, the argument is used to specify the optional reeentrant edge to create. For rarcs and...
""" Definition of Action class. In AMREAGER, an action can be either 'shift', 'reduce', 'rarc' or 'larc'. When it's a shift, the argument is the subgraph triggered by the token. When it's a reduce, the argument is used to specify the optional reeentrant edge to create. For rarcs and rarcs, the argument is the label for...
print("Enter the no of rows: ") n = int(input()) for i in range(n, 0, -1): for j in range(n, 0, -1): print(chr(i+64), end=" ") print()
print('Enter the no of rows: ') n = int(input()) for i in range(n, 0, -1): for j in range(n, 0, -1): print(chr(i + 64), end=' ') print()
class Solution: def smallestRepunitDivByK(self, K: int) -> int: remainder = 0 for length_N in range(1,K+1): remainder = (remainder*10+1) % K if remainder == 0: return length_N return -1
class Solution: def smallest_repunit_div_by_k(self, K: int) -> int: remainder = 0 for length_n in range(1, K + 1): remainder = (remainder * 10 + 1) % K if remainder == 0: return length_N return -1
# # PySNMP MIB module Wellfleet-PIM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Wellfleet-PIM-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:34:41 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_union, value_range_constraint, single_value_constraint, constraints_intersection) ...
array_greed = hero.navGrid def getRectngle(index1, index2): width = 0 height = 0 if array_greed[index1][index2] == 'Coin': indy = index2 indx = index1 for x in range(indx, lenght_xy): if array_greed[x][indy] == 'Coin': width = width + 1 else: ...
array_greed = hero.navGrid def get_rectngle(index1, index2): width = 0 height = 0 if array_greed[index1][index2] == 'Coin': indy = index2 indx = index1 for x in range(indx, lenght_xy): if array_greed[x][indy] == 'Coin': width = width + 1 else:...
#In Recursive Method def fun_no1(num): if(num==0 or num==1): #Base Case return num return num * fun_no1(num-1) #Recursive Case print(fun_no1(6))
def fun_no1(num): if num == 0 or num == 1: return num return num * fun_no1(num - 1) print(fun_no1(6))
class NullFilter: def __init__(self): self.buffer = "" def reset(self): self.buffer = "" def insert_char(self, c): self.buffer += c return False def completed(self): if self.buffer: return True return False
class Nullfilter: def __init__(self): self.buffer = '' def reset(self): self.buffer = '' def insert_char(self, c): self.buffer += c return False def completed(self): if self.buffer: return True return False
shopping_list = ["milk","pasta","eggs","spam","bread","rice"] item_to_find = "albatross" # item_to_find = "spam" found_at = None # I guess None ~= null from C/C++ # for index in range(len(shopping_list)): # if shopping_list[index] == item_to_find: # found_at = index # break if item_to_find in shop...
shopping_list = ['milk', 'pasta', 'eggs', 'spam', 'bread', 'rice'] item_to_find = 'albatross' found_at = None if item_to_find in shopping_list: found_at = shopping_list.index(item_to_find) if found_at is not None: print(f'Item found at {found_at}') else: print(f'{item_to_find} was not found in the list')
#!/bin/python3 class Main(): def __init__(self): self.n = int(input()) for _ in range(self.n): self.s = set(input()) print(len(self.s)) if __name__ == '__main__': obj = Main()
class Main: def __init__(self): self.n = int(input()) for _ in range(self.n): self.s = set(input()) print(len(self.s)) if __name__ == '__main__': obj = main()
x = "Cisco" if "i" in x: if len(x) > 3: print(x, len(x))
x = 'Cisco' if 'i' in x: if len(x) > 3: print(x, len(x))
class AdapterError(Exception): pass class FileManagerError(Exception): pass class MongoDBManagerError(Exception): pass class ValidatorError(Exception): pass class TransformError(Exception): pass class AdapterQueryError(Exception): pass
class Adaptererror(Exception): pass class Filemanagererror(Exception): pass class Mongodbmanagererror(Exception): pass class Validatorerror(Exception): pass class Transformerror(Exception): pass class Adapterqueryerror(Exception): pass
# projecteuler.net/problem=4 def main(): answer = LargestPalindromeProduct() print(answer) def LargestPalindromeProduct(): i = 999 pals = [] while i > 1: j = 999 while j > 1: res = IsPalindromeProduct(i, j) if res: pals.append(i...
def main(): answer = largest_palindrome_product() print(answer) def largest_palindrome_product(): i = 999 pals = [] while i > 1: j = 999 while j > 1: res = is_palindrome_product(i, j) if res: pals.append(i * j) j = j - 1 i ...
data = "a"*1024*1024 path = "3000MB.txt" f = open(path,"w") for i in range(3000): f.write(data) f.close()
data = 'a' * 1024 * 1024 path = '3000MB.txt' f = open(path, 'w') for i in range(3000): f.write(data) f.close()
def _load_tensorflow_from_env_impl(ctx): tf_path = ctx.os.environ['TF_PATH'] ctx.symlink(tf_path, "") load_tensorflow_from_env = repository_rule( implementation = _load_tensorflow_from_env_impl, local=True, environ=["TF_PATH"], )
def _load_tensorflow_from_env_impl(ctx): tf_path = ctx.os.environ['TF_PATH'] ctx.symlink(tf_path, '') load_tensorflow_from_env = repository_rule(implementation=_load_tensorflow_from_env_impl, local=True, environ=['TF_PATH'])
names = ["zero","at","v0","v1","a0","a1","a2","a3","t0","t1","t2","t3","t4","t5","t6","t7", "s0","s1","s2","s3","s4","s5","s6","s7","t8","t9","k0","k1","gp","sp","fps8","ra"] def initRegister(num,names=[]): registers = dict() for i in range(len(names)): if names[i] == "fps8": regist...
names = ['zero', 'at', 'v0', 'v1', 'a0', 'a1', 'a2', 'a3', 't0', 't1', 't2', 't3', 't4', 't5', 't6', 't7', 's0', 's1', 's2', 's3', 's4', 's5', 's6', 's7', 't8', 't9', 'k0', 'k1', 'gp', 'sp', 'fps8', 'ra'] def init_register(num, names=[]): registers = dict() for i in range(len(names)): if names[i] == 'f...
# DATACOUP CREDENTIALS DATACOUP_USERNAME = "" DATACOUP_PASSWORD = "" # STARBUCKS CREDENTIALS STARBUCKS_CARD_NUMBER = "" STARBUCKS_CARD_PIN = ""
datacoup_username = '' datacoup_password = '' starbucks_card_number = '' starbucks_card_pin = ''
# -*- coding: utf-8 -*- ################################################################ # vs.event - published under the GPL 2 # Authors: Andreas Jung, Veit Schiele, Anne Walther ################################################################ PROJECTNAME = "vs.event" DEPENDENCIES=['dateable.chronos', ...
projectname = 'vs.event' dependencies = ['dateable.chronos', 'DataGridField', 'p4a.plonevent']
type = 'SMPLify' body_model = dict( type='SMPL', gender='neutral', num_betas=10, keypoint_src='smpl_45', keypoint_dst='smpl_45', model_path='data/body_models/smpl', batch_size=1) stages = [ # stage 1 dict( num_iter=20, fit_global_orient=True, fit_transl=True...
type = 'SMPLify' body_model = dict(type='SMPL', gender='neutral', num_betas=10, keypoint_src='smpl_45', keypoint_dst='smpl_45', model_path='data/body_models/smpl', batch_size=1) stages = [dict(num_iter=20, fit_global_orient=True, fit_transl=True, fit_body_pose=False, fit_betas=False, joint_weights=dict(body_weight=5.0,...
def combsort(numbers_list): ordered = numbers_list.copy() gap = len(numbers_list) # initial gap (first and last element) swaps = True while swaps or gap!=1: swaps = False for i in range(len(numbers_list)-gap): if ordered[i] > ordered[i+gap]: # swaps without extra variable ordered[i] = ordered[i+gap] - o...
def combsort(numbers_list): ordered = numbers_list.copy() gap = len(numbers_list) swaps = True while swaps or gap != 1: swaps = False for i in range(len(numbers_list) - gap): if ordered[i] > ordered[i + gap]: ordered[i] = ordered[i + gap] - ordered[i] ...
err_face_invalid = '3' err_file_invalid = '2' err_baldify_error = '0' class BaldifyException(Exception): def __init__(self, value): self.code = value def __str__(self): return repr(self.code)
err_face_invalid = '3' err_file_invalid = '2' err_baldify_error = '0' class Baldifyexception(Exception): def __init__(self, value): self.code = value def __str__(self): return repr(self.code)
n = int(input()) l, flag = [], False for i in range(32): l.append(1 << i) for i in range(32): if l[i] == n: flag = True break if flag: print(1) else: print(0)
n = int(input()) (l, flag) = ([], False) for i in range(32): l.append(1 << i) for i in range(32): if l[i] == n: flag = True break if flag: print(1) else: print(0)
''' Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Example 1: 11110 11010 11000 00000 Answer: 1 Example 2: ...
""" Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Example 1: 11110 11010 11000 00000 Answer: 1 Example 2: ...
''' fuck rna fuck deep learning process the data ''' # -*- coding: utf-8 -*- with open('fucksta.txt') as f: lines = f.readlines() with open('sequence_new.txt', 'w') as f: for i, line in enumerate(lines): if i%4 == 1: f.write(line) with open('structure_new.txt', 'w') as f: for i,...
""" fuck rna fuck deep learning process the data """ with open('fucksta.txt') as f: lines = f.readlines() with open('sequence_new.txt', 'w') as f: for (i, line) in enumerate(lines): if i % 4 == 1: f.write(line) with open('structure_new.txt', 'w') as f: for (i, line) in enumerate(lines): ...
#! /usr/bin/python # -*- coding:utf-8 -*- class ByteReader(): def __init__(self, byteData): self.byteData = byteData self.dataLength = len(byteData) self.seek = 0 def getByte(self, length): ret = None if self.seek + length <= self.dataLength and length > 0: ...
class Bytereader: def __init__(self, byteData): self.byteData = byteData self.dataLength = len(byteData) self.seek = 0 def get_byte(self, length): ret = None if self.seek + length <= self.dataLength and length > 0: ret = self.byteData[self.seek:self.seek + l...
load("@bazel_federation//:repositories.bzl", "bazel", "bazel_integration_testing", "bazel_skylib", "bazel_toolchains", "protobuf", "rules_sass", "skydoc") load("@bazel_federation//:third_party_repos.bzl", "zlib") def rules_nodejs_internal_deps(): bazel() bazel_integration_testing() bazel_skylib() baze...
load('@bazel_federation//:repositories.bzl', 'bazel', 'bazel_integration_testing', 'bazel_skylib', 'bazel_toolchains', 'protobuf', 'rules_sass', 'skydoc') load('@bazel_federation//:third_party_repos.bzl', 'zlib') def rules_nodejs_internal_deps(): bazel() bazel_integration_testing() bazel_skylib() bazel...
# # PySNMP MIB module ZYXEL-PORT-SECURITY-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZYXEL-PORT-SECURITY-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:45:19 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, constraints_union, single_value_constraint, value_range_constraint) ...
# Palindrome-Checker - A project for IT class checks if your input is a palindrome or not. # Started writing in 2020 by Keanu Timmermans. # To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is di...
def reverse(s): return s[::-1] def is_palindrome(s): rev = reverse(s) if s == rev: return True return False s = input('Enter string:') ans = is_palindrome(s) if ans == 1: print('Yes') else: print('No')
def merge_metrics(existing_metrics, new_metrics): merged = { 'logs_total_amount': 0, 'no_logger_logs_amount': 0, 'debug_verbosity_level_usage': 0, 'info_verbosity_level_usage': 0, 'warning_verbosity_level_usage': 0, 'error_verbosity_level_usage': 0, 'critical_...
def merge_metrics(existing_metrics, new_metrics): merged = {'logs_total_amount': 0, 'no_logger_logs_amount': 0, 'debug_verbosity_level_usage': 0, 'info_verbosity_level_usage': 0, 'warning_verbosity_level_usage': 0, 'error_verbosity_level_usage': 0, 'critical_verbosity_level_usage': 0, 'amount_of_files_which_contain...
class numbers: def __init__(self): self.number = 0 def getNumber(self): return self.number def addNumber(self, numberToAddBy): self.number += numberToAddBy numbersInstance = numbers() def addToInstance(numberToAddBy): numbersInstance.addNumber(numberToAddBy) return "" def getInstance...
class Numbers: def __init__(self): self.number = 0 def get_number(self): return self.number def add_number(self, numberToAddBy): self.number += numberToAddBy numbers_instance = numbers() def add_to_instance(numberToAddBy): numbersInstance.addNumber(numberToAddBy) return '...
# coding: utf-8 BROKER_URL = 'redis://localhost:16379' CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_ACCEPT_CONTENT = ['json'] CELERY_ENABLE_UTC = True
broker_url = 'redis://localhost:16379' celery_task_serializer = 'json' celery_result_serializer = 'json' celery_accept_content = ['json'] celery_enable_utc = True
GENERAL_ACKNOWLEDGEMENTS = { "positive": ["Sounds cool! ", "Great! ", "Wonderful! ", "Cool!", "Nice!"], "neutral": ["Okay. ", "Oh. ", "Huh. ", "Well. ", "Gotcha. ", "Aha. "], "negative": ["Hmm... ", "I see.", "That's okay.", "Okay."], }
general_acknowledgements = {'positive': ['Sounds cool! ', 'Great! ', 'Wonderful! ', 'Cool!', 'Nice!'], 'neutral': ['Okay. ', 'Oh. ', 'Huh. ', 'Well. ', 'Gotcha. ', 'Aha. '], 'negative': ['Hmm... ', 'I see.', "That's okay.", 'Okay.']}
# # Definition for binary tree: class Tree(object): def __init__(self, x): self.value = x self.left = None self.right = None def has_path_with_given_sum(t, s): return t = { "value": 4, "left": { "value": 1, "left": { "value": -2, "le...
class Tree(object): def __init__(self, x): self.value = x self.left = None self.right = None def has_path_with_given_sum(t, s): return t = {'value': 4, 'left': {'value': 1, 'left': {'value': -2, 'left': null, 'right': {'value': 3, 'left': null, 'right': null}}, 'right': null}, 'right':...
with open('myfile.bin', 'wb') as fl: text = 'You are amazing!' fl.write(text.encode('utf-8')) with open('myfile.bin', 'rb') as fl: data = fl.read(128) text = data.decode('utf-8') print(text)
with open('myfile.bin', 'wb') as fl: text = 'You are amazing!' fl.write(text.encode('utf-8')) with open('myfile.bin', 'rb') as fl: data = fl.read(128) text = data.decode('utf-8') print(text)
def BracketMatcher(strParam): abre_parenteses = 0 fecha_parenteses = 0 primeiro = False expressao = strParam for c in expressao: if c in '(': break if c in ')': primeiro = True break if not primeiro: for c in expressao: if c...
def bracket_matcher(strParam): abre_parenteses = 0 fecha_parenteses = 0 primeiro = False expressao = strParam for c in expressao: if c in '(': break if c in ')': primeiro = True break if not primeiro: for c in expressao: if ...
# parsetab.py # This file is automatically generated. Do not edit. # pylint: disable=W,C,R _tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'COMA HOLA QUE TAL\n phrase : a QUE TAL\n \n a : HOLA COMA a\n | HOLA\n |\n ' _lr_action_items = {'HOLA':([0,5,],[3,3,]),'QUE':([0,2,3,5,7,],[...
_tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'COMA HOLA QUE TAL\n phrase : a QUE TAL\n \n a : HOLA COMA a\n | HOLA\n |\n ' _lr_action_items = {'HOLA': ([0, 5], [3, 3]), 'QUE': ([0, 2, 3, 5, 7], [-4, 4, -3, -4, -2]), '$end': ([1, 6], [0, -1]), 'COMA': ([3], [5]), 'TAL': ([4], [6])} _lr_...
expected_output = { "ptp_clock_info": { "clock_domain": 0, "clock_identity": "0x34:ED:1B:FF:FE:7D:F2:80", "device_profile": "Default Profile", "device_type": "Unknown", "message_event_ip_dscp": 59, "message_general_ip_dscp": 47, "network_transport_prot...
expected_output = {'ptp_clock_info': {'clock_domain': 0, 'clock_identity': '0x34:ED:1B:FF:FE:7D:F2:80', 'device_profile': 'Default Profile', 'device_type': 'Unknown', 'message_event_ip_dscp': 59, 'message_general_ip_dscp': 47, 'network_transport_protocol': '802.3', 'number_of_ptp_ports': 75}}
class Solution: def wordBreak(self, s: str, wordDict: List[str]) -> bool: # Converting the given word dict to set to ensure O(1) average case access. wordDictSet = set(wordDict) l = len(s) # Lets have a boolean array that has if the substring till 'i' can be broken into pieces that ...
class Solution: def word_break(self, s: str, wordDict: List[str]) -> bool: word_dict_set = set(wordDict) l = len(s) dp = [False] * (len(s) + 1) dp[0] = True for i in range(1, len(s) + 1): for j in range(0, i): if dp[j] and s[j:i] in wordDictSet: ...
class AssetApi: def __init__(self, db): self.db = db def get_asset_holders(self, asset_id, start, limit): return self.db.rpcexec( 'get_asset_holders', [asset_id, start, limit] ) def get_asset_holders_count(self, asset_id): return self.db.rpcexec( ...
class Assetapi: def __init__(self, db): self.db = db def get_asset_holders(self, asset_id, start, limit): return self.db.rpcexec('get_asset_holders', [asset_id, start, limit]) def get_asset_holders_count(self, asset_id): return self.db.rpcexec('get_asset_holders_count', [asset_id]...
class Solution: def findNumbers(self, nums: list[int]) -> int: return sum(1 for num in nums if len(str(num)) % 2 == 0) tests = [ ( ([12, 345, 2, 6, 7896],), 2, ), ( ([555, 901, 482, 1771],), 1, ), ]
class Solution: def find_numbers(self, nums: list[int]) -> int: return sum((1 for num in nums if len(str(num)) % 2 == 0)) tests = [(([12, 345, 2, 6, 7896],), 2), (([555, 901, 482, 1771],), 1)]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class UWhoisdException(Exception): pass class CreateDirectoryException(UWhoisdException): pass class MissingEnv(UWhoisdException): pass
class Uwhoisdexception(Exception): pass class Createdirectoryexception(UWhoisdException): pass class Missingenv(UWhoisdException): pass
data = [] lock = Lock() r = Reader() w = Writer() r.set(data, lock) w.set(data, lock) r.start() w.start()
data = [] lock = lock() r = reader() w = writer() r.set(data, lock) w.set(data, lock) r.start() w.start()
user= input ("say something! ") print(user) respond= input ("hello") print(respond.upper()) respond= input ("how are you") print (respond.lower()) respond= input ("can you hear me?") print (respond.swapcase())
user = input('say something! ') print(user) respond = input('hello') print(respond.upper()) respond = input('how are you') print(respond.lower()) respond = input('can you hear me?') print(respond.swapcase())
# Problem: https://docs.google.com/document/d/1_Z9_z7szxpcNixJuV8wQw2K6yJHSFKdxjHtJ0DQ_CrQ/edit?usp=sharing g=input() w=int(input()) if g not in ['F','M']: print('UNKNOWN') else: print(int(w*1.2) if g=='F' else int(w/1.2))
g = input() w = int(input()) if g not in ['F', 'M']: print('UNKNOWN') else: print(int(w * 1.2) if g == 'F' else int(w / 1.2))
class Config_sbir(): def __init__(self): self.dataset = 'QMUL-shoes-reid' self.data_path = '/mnt/nasbi/no-backups/datasets/reid_dataset/shoes/sbir/shoes/' self.log_path = "log/" #log dir and saved model dir self.model_path = 'save_model/' self.att_path = './processed_data/zap...
class Config_Sbir: def __init__(self): self.dataset = 'QMUL-shoes-reid' self.data_path = '/mnt/nasbi/no-backups/datasets/reid_dataset/shoes/sbir/shoes/' self.log_path = 'log/' self.model_path = 'save_model/' self.att_path = './processed_data/zap50k/' self.resume = 'z...
#!/usr/bin/env python3 delineator = "//" hashtag = "#" # generate poems from a file # out: list of poem lines def generate_poems(filename): g = [] # get to the first poem in the file with open(filename, 'r') as f: for line in f: line = line.rstrip() if line.startswith( deli...
delineator = '//' hashtag = '#' def generate_poems(filename): g = [] with open(filename, 'r') as f: for line in f: line = line.rstrip() if line.startswith(delineator) and g: yield g g = [] if line: g.append(line) ...
CONF_EXTRAFLAME_ID = "extraflame_id" CONF_MEMORY = "memory" MEMORY_RAM = "RAM" MEMORY_EEPROM = "EEPROM"
conf_extraflame_id = 'extraflame_id' conf_memory = 'memory' memory_ram = 'RAM' memory_eeprom = 'EEPROM'
def printMatrix(mat): for n in range(matrixSize): outstr = "" for k in range(matrixSize): outstr += str(mat[n][k]) if (k < matrixSize - 1): outstr += "," print(outstr) matrixSize = 9 # Matrix sizes I've tested: # slanted diagonal (gud!): 7, 8, 9 # ortho pattern: 3, 4, 6 # ortho diagonal: 5 m...
def print_matrix(mat): for n in range(matrixSize): outstr = '' for k in range(matrixSize): outstr += str(mat[n][k]) if k < matrixSize - 1: outstr += ',' print(outstr) matrix_size = 9 matrix = [x[:] for x in [[-1] * matrixSize] * matrixSize] cell_x = 0 ...
''' Problem 30 @author: Kevin Ji ''' nums = [] # 2-digit nums for a in range(1, 10): for b in range(0, 10): num = 10*a + b pow_a = 1 pow_b = 1 # Power of 5 for _ in range(5): pow_a *= a pow_b *= b pow_num = pow_a + pow_b if num =...
""" Problem 30 @author: Kevin Ji """ nums = [] for a in range(1, 10): for b in range(0, 10): num = 10 * a + b pow_a = 1 pow_b = 1 for _ in range(5): pow_a *= a pow_b *= b pow_num = pow_a + pow_b if num == pow_num: nums.append(num) ...
class ShellZsh: NAME = 'zsh' @staticmethod def get_hook() -> str: cvm_path = 'cvm' return f''' _cvm_hook() {{ trap -- '' SIGINT; eval "$({cvm_path} scan zsh)"; trap - SIGINT; }} typeset -ag precmd_functions;...
class Shellzsh: name = 'zsh' @staticmethod def get_hook() -> str: cvm_path = 'cvm' return f"""\n _cvm_hook() {{\n trap -- '' SIGINT;\n eval "$({cvm_path} scan zsh)";\n trap - SIGINT;\n }}\n typeset -ag precmd_func...
class Solution: def hIndex(self, citations): l, h, m, ln = 0, len(citations) - 1, 0, len(citations) while l <= h: m = (l + h) / 2 if citations[m] == ln - m: return citations[m] elif citations[m] > (ln - m): h = m - 1 els...
class Solution: def h_index(self, citations): (l, h, m, ln) = (0, len(citations) - 1, 0, len(citations)) while l <= h: m = (l + h) / 2 if citations[m] == ln - m: return citations[m] elif citations[m] > ln - m: h = m - 1 ...
class Term: def __init__(self): self.id = "NA" self.ns = ["NA"] self.df = ["NA"] self.name = ["NA"] self.acc1 = "NA" self.acc2 = "NA" self.imp = "NA" self.p = set() self.c = set() self.x = "NA" self.y = "NA"
class Term: def __init__(self): self.id = 'NA' self.ns = ['NA'] self.df = ['NA'] self.name = ['NA'] self.acc1 = 'NA' self.acc2 = 'NA' self.imp = 'NA' self.p = set() self.c = set() self.x = 'NA' self.y = 'NA'
def generator(current_time): sep_position = int(current_time[-1:]) if sep_position % 5 != 0: sep_position %= 5 else: sep_position = 5 yield sep_position
def generator(current_time): sep_position = int(current_time[-1:]) if sep_position % 5 != 0: sep_position %= 5 else: sep_position = 5 yield sep_position
poll_period_seconds = 60 sensors = [ 'logger', 'BC:6A:29:AE:CB:AF' ] features = { 'temperature': True, 'humidity': True } #HTTP http_enabled = True http_url = '' http_headers = { 'Content-Type': 'application/json' } #MQTT mqtt_enabled = True mqtt_ipaddress = '192.168.0.5' mqtt_port = 1883 mqtt_username = 'homeassista...
poll_period_seconds = 60 sensors = ['logger', 'BC:6A:29:AE:CB:AF'] features = {'temperature': True, 'humidity': True} http_enabled = True http_url = '' http_headers = {'Content-Type': 'application/json'} mqtt_enabled = True mqtt_ipaddress = '192.168.0.5' mqtt_port = 1883 mqtt_username = 'homeassistant' mqtt_password = ...
#Class to hold variables of status class Configuration: #Variable that indicates if a name is chosen. If it is, it won't fall into the answer_name_intent name_exists = False def set_name_exists(value): name_exists = value def get_name_exists(): return name_exists
class Configuration: name_exists = False def set_name_exists(value): name_exists = value def get_name_exists(): return name_exists
#----------------------------------------------------------------------------- # Copyright (c) 2015-2021, PyInstaller Development Team. # # Distributed under the terms of the GNU General Public License (version 2 # or later) with exception for distributing the bootloader. # # The full license is in the file COPYING.txt...
assert __name__.endswith('.ccc.ddd'), __name__
CONFIG = { 'FACEBOOK_TOKEN': 'EAAbYZAtdQxxxxxxxxxxxxxxxxxxxxxNg4WSc9Flu56XQLRRBjgZDZD', 'VERIFY_TOKEN': 'verify_nbchatbot', 'SERVER_URL': 'heroku app url' }
config = {'FACEBOOK_TOKEN': 'EAAbYZAtdQxxxxxxxxxxxxxxxxxxxxxNg4WSc9Flu56XQLRRBjgZDZD', 'VERIFY_TOKEN': 'verify_nbchatbot', 'SERVER_URL': 'heroku app url'}
# Down below I created a class for clients. class Clients: def __init__(self, Name, ID_CARD, Occupation, Balance): self.Name = Name self.ID_CARD = ID_CARD self.Occupation = Occupation self.Balance = Balance
class Clients: def __init__(self, Name, ID_CARD, Occupation, Balance): self.Name = Name self.ID_CARD = ID_CARD self.Occupation = Occupation self.Balance = Balance
def clamp(x, minimum=None, maximum=None): x = min(x, maximum) if maximum is not None else x x = max(minimum, x) if minimum is not None else x return x
def clamp(x, minimum=None, maximum=None): x = min(x, maximum) if maximum is not None else x x = max(minimum, x) if minimum is not None else x return x