content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
province = input('Enter you province: ') if province.lower() == 'surigao': print('Hi, I am from Surigao too.') else: print(f'Hi, so your from { province.capitalize() }')
province = input('Enter you province: ') if province.lower() == 'surigao': print('Hi, I am from Surigao too.') else: print(f'Hi, so your from {province.capitalize()}')
def print_num(n): """Print a number with proper formatting depending on int/float""" if float(n).is_integer(): return print(int(n)) else: return print(n)
def print_num(n): """Print a number with proper formatting depending on int/float""" if float(n).is_integer(): return print(int(n)) else: return print(n)
PrimeNums = [] Target = 10001 Number = 0 while len(PrimeNums) < Target: isPrime = True Number += 1 for x in range(2,9): if Number % x == 0 and Number != x: isPrime = False if isPrime: if Number == 1: False else: PrimeNums.append(Number) print...
prime_nums = [] target = 10001 number = 0 while len(PrimeNums) < Target: is_prime = True number += 1 for x in range(2, 9): if Number % x == 0 and Number != x: is_prime = False if isPrime: if Number == 1: False else: PrimeNums.append(Number) pri...
# SET MISMATCH LEETCODE SOLUTION: # creating a class. class Solution(object): # creating a function to solve the problem. def findErrorNums(self, nums): # creating multiple variables to store various sums. actual_sum = sum(nums) set_sum = sum(set(nums)) a_sum = len(...
class Solution(object): def find_error_nums(self, nums): actual_sum = sum(nums) set_sum = sum(set(nums)) a_sum = len(nums) * (len(nums) + 1) / 2 return [actual_sum - set_sum, a_sum - set_sum]
def modulo_pastel(key: int) -> str: """ Select a pastel color on a modulo cycle. Args: key (int): The index modulo index. Returns: str: The selected RGB pastel color code. """ hex_codes = [ "957DAD", "B5EAD7", "C7CEEA", "D291BC", "E0BBE4"...
def modulo_pastel(key: int) -> str: """ Select a pastel color on a modulo cycle. Args: key (int): The index modulo index. Returns: str: The selected RGB pastel color code. """ hex_codes = ['957DAD', 'B5EAD7', 'C7CEEA', 'D291BC', 'E0BBE4', 'E2F0CB', 'FEC8D8', 'FF9AA2', 'FFB7B2',...
# Copyright 2020 The Pigweed Authors # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of # the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
"""Generated test data.""" def test_case(*args): return tuple(args) test_data = (test_case('%d', '0', '%u', '0', b'\x00'), test_case('%d', '-32768', '%u', '4294934528', b'\xff\xff\x03'), test_case('%d', '-32767', '%u', '4294934529', b'\xfd\xff\x03'), test_case('%d', '32766', '%u', '32766', b'\xfc\xff\x03'), test_c...
""" Copyright (C) 2004-2010 by Rong ZhengQin <rongzhengqin@honortech.cn> Distributed with BSD license. All rights reserved, see LICENSE for details. """
""" Copyright (C) 2004-2010 by Rong ZhengQin <rongzhengqin@honortech.cn> Distributed with BSD license. All rights reserved, see LICENSE for details. """
""" Bonus task: load all the available coffee recipes from the folder 'recipes/' File format: first line: coffee name next lines: resource=percentage info and examples for handling files: http://cs.curs.pub.ro/wiki/asc/asc:lab1:index#operatii_cu_fisiere https://docs.python.org/3/library/io.html https://do...
""" Bonus task: load all the available coffee recipes from the folder 'recipes/' File format: first line: coffee name next lines: resource=percentage info and examples for handling files: http://cs.curs.pub.ro/wiki/asc/asc:lab1:index#operatii_cu_fisiere https://docs.python.org/3/library/io.html https://do...
s = input() t = input() print()
s = input() t = input() print()
def front_back(str): if len(str) < 2: return str n = len(str) first_char = str[0] last_char = str[n-1] middle_chars = str[1:(n-1)] return last_char + middle_chars + first_char
def front_back(str): if len(str) < 2: return str n = len(str) first_char = str[0] last_char = str[n - 1] middle_chars = str[1:n - 1] return last_char + middle_chars + first_char
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 3 11:54:10 2022 @author: mariaolaru """ def get_next_trial_params(df_trials, max_amp, STIM_AMP_INTERVAL, STIM_FREQ_INTERVAL, init_stim_freq, entrain_trial_kernel): #Place holder algorithm for now t = df_trials['entrained'].count()-1 c...
""" Created on Mon Jan 3 11:54:10 2022 @author: mariaolaru """ def get_next_trial_params(df_trials, max_amp, STIM_AMP_INTERVAL, STIM_FREQ_INTERVAL, init_stim_freq, entrain_trial_kernel): t = df_trials['entrained'].count() - 1 curr_max_amp = get_curr_max_amp(max_amp, init_stim_freq, df_trials['stim_freq'][t])...
''' Mr. X's birthday is in next month. This time he is planning to invite N of his friends. He wants to distribute some chocolates to all of his friends after party. He went to a shop to buy a packet of chocolates. At chocolate shop, each packet is having different number of chocolates. He wants to buy such a packet wh...
""" Mr. X's birthday is in next month. This time he is planning to invite N of his friends. He wants to distribute some chocolates to all of his friends after party. He went to a shop to buy a packet of chocolates. At chocolate shop, each packet is having different number of chocolates. He wants to buy such a packet wh...
# print ("hello world") # import sys # print(sys.version) # columns = [0,2,4,6,8,10,12,14,16,18,20,22,24,25,27,29,31,33,35,37,39,41,43,45,47,49,50,52,54,56,58,60,62,64,66,68,70,72,74,75,77,79,81,83,85,87,89,91,93,95,97,] for x in range(0, 125): print('P[c:{0}] (0,255,0), '.format(x%125), end='') # Green print...
for x in range(0, 125): print('P[c:{0}] (0,255,0), '.format(x % 125), end='') print('P[c:{0}] (255,255,0), '.format((x + 25) % 125), end='') print('P[c:{0}] (255,255,255), '.format((x + 50) % 125), end='') print('P[c:{0}] (127,0,255), '.format((x + 75) % 125), end='') print('P[c:{0}] (0,0,255)'.form...
class Morse: DOT = '.' DASH = '-' characters = { (DOT, DASH): 'A', (DASH, DOT, DOT, DOT): 'B', (DASH, DOT, DASH, DOT): 'C', (DASH, DOT, DOT): 'D', (DOT,): 'E', (DOT, DOT, DASH, DOT): 'F', (DASH, DASH, DOT): 'G', (DOT, DOT, DOT, DOT): 'H', ...
class Morse: dot = '.' dash = '-' characters = {(DOT, DASH): 'A', (DASH, DOT, DOT, DOT): 'B', (DASH, DOT, DASH, DOT): 'C', (DASH, DOT, DOT): 'D', (DOT,): 'E', (DOT, DOT, DASH, DOT): 'F', (DASH, DASH, DOT): 'G', (DOT, DOT, DOT, DOT): 'H', (DOT, DOT): 'I', (DOT, DASH, DASH, DASH): 'J', (DASH, DOT, DASH): 'K',...
n = 5 # limit or size for x in range(1, n + 1): print(" " + str(2 * x - 1), end="") """ OUTPUT: 1 3 5 7 9 """
n = 5 for x in range(1, n + 1): print(' ' + str(2 * x - 1), end='') '\n OUTPUT:\n\n 1 3 5 7 9\n\n '
# ScalePairs.py # Chromatic definitions of different scale types # Guide: # C:1, Db:2, D:3, Eb:4, E:5, F:6, Gb:7, G:8, Ab:9, A:10, Bb:11, B:12 scalePairs = [] # Copied from NodeBeat's "NodeBeat Classic" scalePairs += [("KosBeat\nClassic", [1, 3, 6, 8, 10])] scalePairs += [("Major", [1, 3, 5, 6, 8, 10, 12])] scalePair...
scale_pairs = [] scale_pairs += [('KosBeat\nClassic', [1, 3, 6, 8, 10])] scale_pairs += [('Major', [1, 3, 5, 6, 8, 10, 12])] scale_pairs += [('Major\nPentatonic', [1, 3, 5, 8, 10])] scale_pairs += [('Minor\nPentatonic', [1, 4, 6, 8, 11])] scale_pairs += [('Natural\nMinor', [1, 3, 4, 6, 8, 9, 11])] scale_pairs += [('Har...
# # PySNMP MIB module TIMETRA-SAS-FILTER-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIMETRA-SAS-FILTER-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:21:39 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint, constraints_union) ...
# Singleton (from guido) class Singleton(object): def __new__(cls, *args, **kwds): it = cls.__dict__.get("__it__") if it is not None: return it cls.__it__ = it = object.__new__(cls) it.init(*args, **kwds) return it def init(self, *args, **kwds): pass ...
class Singleton(object): def __new__(cls, *args, **kwds): it = cls.__dict__.get('__it__') if it is not None: return it cls.__it__ = it = object.__new__(cls) it.init(*args, **kwds) return it def init(self, *args, **kwds): pass
""" Complete game implementations/engines. """
""" Complete game implementations/engines. """
""" Asylo-specific copts. Flags specified here should not affect any ABI, but may influence warnings and optimizations. They are used on top of any flags provided by the crosstool in use and are intended to be only used within the Asylo project (not affecting consumers of the Asylo project). """ # Customization of c...
""" Asylo-specific copts. Flags specified here should not affect any ABI, but may influence warnings and optimizations. They are used on top of any flags provided by the crosstool in use and are intended to be only used within the Asylo project (not affecting consumers of the Asylo project). """ _warning_flags = ['-W...
class Node: def __init__(self, type_, arity: int, value=None): self.type = type_ self.arity = arity self.value = value self.children = [] def __repr__(self): return "<Node {t} {v} {c}>".format(t=self.type, v=self.value, c=self.children) def _pprint(self, level): ...
class Node: def __init__(self, type_, arity: int, value=None): self.type = type_ self.arity = arity self.value = value self.children = [] def __repr__(self): return '<Node {t} {v} {c}>'.format(t=self.type, v=self.value, c=self.children) def _pprint(self, level): ...
"""Helper classes for defining translations between .stat file of different formats.""" class Function(object): """Define a column which is actually a function of other columns""" def __init__(self, fn, *input_arg_names): self.fn = fn self.input_arg_names = input_arg_names def __call__(sel...
"""Helper classes for defining translations between .stat file of different formats.""" class Function(object): """Define a column which is actually a function of other columns""" def __init__(self, fn, *input_arg_names): self.fn = fn self.input_arg_names = input_arg_names def __call__(se...
#!/usr/bin/python3 def readfile(filename): ''' :param filename: input is a text file for input :return: Equations: lines with potential equations on them num_line: number of equation lines ''' # open file with open(filename, mode='r') as f: line_l...
def readfile(filename): """ :param filename: input is a text file for input :return: Equations: lines with potential equations on them num_line: number of equation lines """ with open(filename, mode='r') as f: line_list = [] while True: ...
# Configuration file for ipython-notebook. c = get_config() # ------------------------------------------------------------------------------ # NotebookApp configuration # ------------------------------------------------------------------------------ c.GitHubConfig.access_token = '' c.JupyterApp.answer_yes = True c.L...
c = get_config() c.GitHubConfig.access_token = '' c.JupyterApp.answer_yes = True c.LabApp.user_settings_dir = '/data/user-settings' c.LabApp.workspaces_dir = '/data/workspaces' c.NotebookApp.allow_origin = '*' c.NotebookApp.allow_password_change = False c.NotebookApp.allow_remote_access = True c.NotebookApp.allow_root ...
# # PySNMP MIB module JUNIPER-WX-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/JUNIPER-WX-GLOBAL-REG # Produced by pysmi-0.3.4 at Mon Apr 29 19:50:41 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, M...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) ...
# -*- coding: utf-8 -*- """ hon.structure.readme ~~~~~ The structure module for parsing the README.md file. """ def parse_readme(app, text): pass
""" hon.structure.readme ~~~~~ The structure module for parsing the README.md file. """ def parse_readme(app, text): pass
def f(n): if n <=0: return 1 res = 0 for i in range(n): res += f(i) * f(n-i-1) return res
def f(n): if n <= 0: return 1 res = 0 for i in range(n): res += f(i) * f(n - i - 1) return res
# # PySNMP MIB module TPLINK-CLUSTER-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TPLINK-CLUSTER-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:24:19 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_intersection, constraints_union, single_value_constraint, value_range_constraint) ...
x = 1 # int print(type(x)) x = 1.1 # float print(type(x)) x = 1 + 2j # complex number print(type(x)) print(10 + 3) print(10 - 3) print(10 * 3) print(10 / 3) print(10 // 3) print(10 % 3) print(10 ** 3) x = 10 x = x + 3 x += 3 print(x)
x = 1 print(type(x)) x = 1.1 print(type(x)) x = 1 + 2j print(type(x)) print(10 + 3) print(10 - 3) print(10 * 3) print(10 / 3) print(10 // 3) print(10 % 3) print(10 ** 3) x = 10 x = x + 3 x += 3 print(x)
__title__ = 'mudrex' __version__ = '0.1.2' __summary__ = 'Send external webhook signals to Mudrex platform.' __uri__ = 'https://github.com/surajiyer/mudrex' __author__ = 'Suraj Iyer' __email__ = 'me@surajiyer.com' __license__ = 'MIT'
__title__ = 'mudrex' __version__ = '0.1.2' __summary__ = 'Send external webhook signals to Mudrex platform.' __uri__ = 'https://github.com/surajiyer/mudrex' __author__ = 'Suraj Iyer' __email__ = 'me@surajiyer.com' __license__ = 'MIT'
c = 0 while c < 10: print(c) c = c + 1 print('FIM')
c = 0 while c < 10: print(c) c = c + 1 print('FIM')
class Request: def __init__(self, start, end): self.start = start self.end = end def __str__(self): return f'Request:{self.start},{self.end}' def Is_compatible(self, request): return request.start > self.end or request.end < self.start '''This Algorithm give 0...
class Request: def __init__(self, start, end): self.start = start self.end = end def __str__(self): return f'Request:{self.start},{self.end}' def is_compatible(self, request): return request.start > self.end or request.end < self.start 'This Algorithm give 0(n2) running ti...
S = input() S = S.replace('BC', 'D') cnt_a = 0 ans = 0 for i in range(len(S)): if S[i] == 'A': cnt_a += 1 elif S[i] == 'D': ans += cnt_a else: cnt_a = 0 print(ans)
s = input() s = S.replace('BC', 'D') cnt_a = 0 ans = 0 for i in range(len(S)): if S[i] == 'A': cnt_a += 1 elif S[i] == 'D': ans += cnt_a else: cnt_a = 0 print(ans)
#zip my_list = [1,2,3] your_list = [100,200,300] their_list = [1000,2000,3000] print(list(zip(my_list, your_list, their_list))[0][2]) print(list(zip(my_list, your_list, their_list)))
my_list = [1, 2, 3] your_list = [100, 200, 300] their_list = [1000, 2000, 3000] print(list(zip(my_list, your_list, their_list))[0][2]) print(list(zip(my_list, your_list, their_list)))
# https://leetcode.com/problems/minimum-falling-path-sum-ii/ # Given a square grid of integers arr, a falling path with non-zero shifts is a # choice of exactly one element from each row of arr, such that no two elements # chosen in adjacent rows are in the same column. # Return the minimum sum of a falling path with...
class Solution: def min_falling_path_sum(self, arr: List[List[int]]) -> int: n = len(arr) if n == 1: return arr[0][0] dp = [[0 for _ in range(n)] for _ in range(n)] for j in range(n): dp[0][j] = arr[0][j] for i in range(1, n): (min_1st, mi...
# Configuration # [Yoshikawa Taichi] # version 1.3 (Jan. 28, 2020) class Configuration(): ''' Configuration ''' def __init__(self): # ----- k-means components ----- ## cluster numbers self.centers = 3 ## upper limit of iterations self.upper_limit_...
class Configuration: """ Configuration """ def __init__(self): self.centers = 3 self.upper_limit_iter = 1000 self.similarity_index = 'euclidean-distance' self.dataset_url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data' self.datase...
""" Initialize a Metadata object once and access the respective metadata as public variables. Following are the variable names: owner table = owner_metadata auto_sale table = auto_sale_metadata restriction table = restriction_metadata driving_condition table = driving_condition_metadata ticket table = t...
""" Initialize a Metadata object once and access the respective metadata as public variables. Following are the variable names: owner table = owner_metadata auto_sale table = auto_sale_metadata restriction table = restriction_metadata driving_condition table = driving_condition_metadata ticket table = t...
################### PEAK FINDING ################### # 1D peak finding COMPLEXITY --> O(theta)(log n) def peak_1D(l): if len(l) == 1: # if a singleton list then simply returns the element return l[0] elif not len(l): # if a null list then returns None ...
def peak_1_d(l): if len(l) == 1: return l[0] elif not len(l): return None else: mid = len(l) // 2 if l[mid - 1] > l[mid]: return peak_1_d(l[:mid]) elif l[mid + 1] > l[mid]: return peak_1_d(l[mid + 1:]) else: return l[mid] d...
# problem : https://leetcode.com/problems/binary-tree-postorder-traversal/ # time complexity : O(N) # data structure : stack # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def postord...
class Solution: def postorder_traversal(self, root: TreeNode) -> List[int]: ans = [] s = [(root, 0)] while len(s) > 0: (node, appear_cnt) = s.pop() if node is None: continue if appearCnt == 0: s.append((node, 1)) ...
# # PySNMP MIB module GARP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/GARP-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:04:38 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:1...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection, constraints_union) ...
# Construct arrays of data: dems, reps dems = np.array([True] * 153 + [False] * 91) reps = np.array([True] * 136 + [False] * 35) def frac_yea_dems(dems, reps): """Compute fraction of Democrat yea votes.""" frac = np.sum(dems) / len(dems) return frac # Acquire permutation samples: perm_replicates perm_repl...
dems = np.array([True] * 153 + [False] * 91) reps = np.array([True] * 136 + [False] * 35) def frac_yea_dems(dems, reps): """Compute fraction of Democrat yea votes.""" frac = np.sum(dems) / len(dems) return frac perm_replicates = draw_perm_reps(dems, reps, frac_yea_dems, size=10000) p = np.sum(perm_replicat...
class IIDError: INTERNAL_ERROR = 'internal-error' UNKNOWN_ERROR = 'unknown-error' ERROR_CODES = { 400: 'invalid-argument', 401: 'authentication-error', 403: 'authentication-error', 500: INTERNAL_ERROR, 503: 'server-unavailable' }
class Iiderror: internal_error = 'internal-error' unknown_error = 'unknown-error' error_codes = {400: 'invalid-argument', 401: 'authentication-error', 403: 'authentication-error', 500: INTERNAL_ERROR, 503: 'server-unavailable'}
a, b, n = (int(i) for i in raw_input().split()) if n == 1: print(a) elif n == 2: print(b) else: for x in range(2, n): tn = a + b*b a = b b = tn print(tn)
(a, b, n) = (int(i) for i in raw_input().split()) if n == 1: print(a) elif n == 2: print(b) else: for x in range(2, n): tn = a + b * b a = b b = tn print(tn)
# Copyright BigchainDB GmbH and BigchainDB contributors # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 class BigchainDBError(Exception): """Base class for BigchainDB exceptions.""" class CriticalDoubleSpend(BigchainDBError): """Data integrity error that req...
class Bigchaindberror(Exception): """Base class for BigchainDB exceptions.""" class Criticaldoublespend(BigchainDBError): """Data integrity error that requires attention"""
# Name : Exercise7-2.py # Author : Ryan Carr # Date : 02/03/19 # Purpose : Open a file, calculate average spam confidence # Display result to user # Text files are stored in the data folder one level up filename = input('Enter a filename: ') if filename == 'mbox-short.txt': filename = '../data/mbo...
filename = input('Enter a filename: ') if filename == 'mbox-short.txt': filename = '../data/mbox-short.txt' elif filename == 'mbox.txt': filename = '../data/mbox.txt' fh = open(filename, 'r') count = 0 total = 0.0 for line in fh: if not line.startswith('X-DSPAM-Confidence:'): continue position =...
# # PySNMP MIB module CISCO-BITS-CLOCK-CAPABILITY (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-BITS-CLOCK-CAPABILITY # Produced by pysmi-0.3.4 at Mon Apr 29 17:34:01 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python versio...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_union, value_range_constraint, constraints_intersection, value_size_constraint) ...
def allASDTIRpairs(): """ Iterate through all possible ASD TIR pairs and find the ones with the highest average binding energies with host TIRs We wish to find the ASDs that do not bind well with the host translation initiation regions to assure orthogonality of the ribosomes, so here we choose the...
def all_asdti_rpairs(): """ Iterate through all possible ASD TIR pairs and find the ones with the highest average binding energies with host TIRs We wish to find the ASDs that do not bind well with the host translation initiation regions to assure orthogonality of the ribosomes, so here we choose t...
# https://www.acmicpc.net/problem/16167 class Node: def __init__(self, node, cost): self.node = node self.cost = cost def __lt__(self, other): return self.cost < other.cost def bfs(): queue = __import__('collections').deque() queue.append(1) cnt = 1 while queue: ...
class Node: def __init__(self, node, cost): self.node = node self.cost = cost def __lt__(self, other): return self.cost < other.cost def bfs(): queue = __import__('collections').deque() queue.append(1) cnt = 1 while queue: size = len(queue) cnt += 1 ...
LEVEL_MAP = [ ' ', ' ', ' XX ', ' XX XXX XX XX ', ' XX P XX ', ' XXXX XX XX ', ' XXXX XX ...
level_map = [' ', ' ', ' XX ', ' XX XXX XX XX ', ' XX P XX ', ' XXXX XX XX ', ' XXXX XX ...
{ 'targets': [ { 'target_name': 'example1', 'sources': ['manifest.c'], 'libraries': [ '../../target/release/libnapi_example1.a', ], 'include_dirs': [ '../napi/include' ] } ] }
{'targets': [{'target_name': 'example1', 'sources': ['manifest.c'], 'libraries': ['../../target/release/libnapi_example1.a'], 'include_dirs': ['../napi/include']}]}
#!/usr/bin/python3 Rectangle = __import__('1-rectangle').Rectangle my_rectangle = Rectangle(4) print("{} - {}".format(my_rectangle.width, my_rectangle.height))
rectangle = __import__('1-rectangle').Rectangle my_rectangle = rectangle(4) print('{} - {}'.format(my_rectangle.width, my_rectangle.height))
# Problem 1 - Paying Debt off in a Year def calculateBalance(balance, annualInterestRate, monthlyPaymentRate): ''' Input: balance: integer or float - the outstanding balance on the credit card annualInterestRate: float - annual interest rate as a decimal monthlyPaymentRate: float - mi...
def calculate_balance(balance, annualInterestRate, monthlyPaymentRate): """ Input: balance: integer or float - the outstanding balance on the credit card annualInterestRate: float - annual interest rate as a decimal monthlyPaymentRate: float - minimum monthly payment rate as a decimal ...
# ControlRequest RESPONSE_sendControlRequestTrue = ( 'CMD M601 Received.\r\nControl Success V2.1.\r\nok\r\n' ) RESPONSE_sendControlRequestFalse = ( 'CMD M601 Received.\r\nControl failed.\r\nok\r\n' ) # ControlRelease RESPONSE_sendControlRelease = ( 'CMD 602 Received.\r\nok\r\n' ) # InfoRequest RESPONSE_s...
response_send_control_request_true = 'CMD M601 Received.\r\nControl Success V2.1.\r\nok\r\n' response_send_control_request_false = 'CMD M601 Received.\r\nControl failed.\r\nok\r\n' response_send_control_release = 'CMD 602 Received.\r\nok\r\n' response_send_info_request = 'CMD M115 Received.\r\nMachine Type: Flashforge ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # JTSK-350112 # complex.py # Shun-Lung Chang # sh.chang@jacobs-university.de class Complex(object): def __init__(self, real, imag): self._real = real self._imag = imag def __add__(self, other): if type(self) != type(other): ...
class Complex(object): def __init__(self, real, imag): self._real = real self._imag = imag def __add__(self, other): if type(self) != type(other): raise raise_type_error('Type of {0} is not same as Type of {1}'.format(type(self), type(other))) return complex(self._r...
def gc_genome_skew(dna): gc_skew=[] gc_diff=0 for i in range(len(dna)): gc_skew.append(gc_diff) if dna[i]=='C': gc_diff-=1 if dna[i]=='G': gc_diff+=1 oric_list=[] min_value = min(gc_skew) for i in range(len(gc_skew)): if(gc_s...
def gc_genome_skew(dna): gc_skew = [] gc_diff = 0 for i in range(len(dna)): gc_skew.append(gc_diff) if dna[i] == 'C': gc_diff -= 1 if dna[i] == 'G': gc_diff += 1 oric_list = [] min_value = min(gc_skew) for i in range(len(gc_skew)): if gc_sk...
""" Script to show sample use of ipf_api_client and nagios_api_client """ """ export IPF_URL="" export IPF_TOKEN="" d=IPFDevice('L66EXR1') d.hostname d.ipaddr export NAGIOS_URL="" export NAGIOS_TOKEN="" n=NAGIOSClient() n.host_list() n.hostgroup_list() n.create_hostgroup("site") s=NAGIOSHost(name=d.hostname,ipaddr=d....
""" Script to show sample use of ipf_api_client and nagios_api_client """ '\nexport IPF_URL=""\nexport IPF_TOKEN=""\nd=IPFDevice(\'L66EXR1\')\nd.hostname\nd.ipaddr\n\nexport NAGIOS_URL=""\nexport NAGIOS_TOKEN=""\nn=NAGIOSClient()\nn.host_list()\nn.hostgroup_list()\nn.create_hostgroup("site")\ns=NAGIOSHost(name=d.hostna...
""" This module contains the templates for different search requests (conjunction, data products, ephemeris) """ CONJUNCTION_SEARCH_TEMPLATE = { "start": "2020-01-01T00:00:00", "end": "2020-01-01T23:59:59", "ground": [ { "programs": [ "string" ], ...
""" This module contains the templates for different search requests (conjunction, data products, ephemeris) """ conjunction_search_template = {'start': '2020-01-01T00:00:00', 'end': '2020-01-01T23:59:59', 'ground': [{'programs': ['string'], 'platforms': ['string'], 'instrument_types': ['string'], 'ephemeris_metadata_f...
fibonacci_cache= {} def fibonacci(n): # If we have cached the value, then return it if n in fibonacci_cache: return fibonacci_cache[n] # Compute the Nth term if n == 1: value = 1 elif n == 2: value = 1 elif n >2: value = fibonacci(n-1) + fibonacci(n-2) #Cache the value and return it f...
fibonacci_cache = {} def fibonacci(n): if n in fibonacci_cache: return fibonacci_cache[n] if n == 1: value = 1 elif n == 2: value = 1 elif n > 2: value = fibonacci(n - 1) + fibonacci(n - 2) fibonacci_cache[n] = value return value for n in range(1, 101): print...
x = [0.0, 3.0, 5.0, 2.5, 3.7] #an array is a list of numbers print(type(x)) #removing the third element x.pop(2) #it pops off the (index) print(x) #removes the 2.5 element x.remove(2.5) print(x) #add an element to the end x.append(1.2) print(x) #get a copy y = x.copy() #produces a 'deep' ...
x = [0.0, 3.0, 5.0, 2.5, 3.7] print(type(x)) x.pop(2) print(x) x.remove(2.5) print(x) x.append(1.2) print(x) y = x.copy() print(y) print(y.count(0.0)) print(y.index(3.7)) y[0] = 5.9 print(y) y.sort() print(y) y.reverse() print(y) y.clear() print(y)
def imc(a,p): return p / (a**2) peso = float(input("Digite seu peso: ")) altura = float(input("Digite sua altura: ")) imc = imc(altura, peso) if(imc < 17): print("Muito abaixo do peso\n") elif(imc >= 17 and imc <= 18.49): print("Abaixo do peso\n") elif(imc >= 18.5 and imc < 25): print("Peso normal\n") ...
def imc(a, p): return p / a ** 2 peso = float(input('Digite seu peso: ')) altura = float(input('Digite sua altura: ')) imc = imc(altura, peso) if imc < 17: print('Muito abaixo do peso\n') elif imc >= 17 and imc <= 18.49: print('Abaixo do peso\n') elif imc >= 18.5 and imc < 25: print('Peso normal\n') eli...
# DO NOT EDIT -- GENERATED BY CMake -- Change the CMakeLists.txt file if needed bigtable_client_unit_tests = [ "admin_client_test.cc", "app_profile_config_test.cc", "bigtable_version_test.cc", "cell_test.cc", "client_options_test.cc", "cluster_config_test.cc", "column_family_test.cc", "c...
bigtable_client_unit_tests = ['admin_client_test.cc', 'app_profile_config_test.cc', 'bigtable_version_test.cc', 'cell_test.cc', 'client_options_test.cc', 'cluster_config_test.cc', 'column_family_test.cc', 'completion_queue_test.cc', 'data_client_test.cc', 'filters_test.cc', 'force_sanitizer_failures_test.cc', 'grpc_err...
# Assign functions to a variable def add(a, b): return a + b plus = add value = plus(1, 2) print(value) # 3 # Lambda value = (lambda a, b: a + b)(1, 2) print(value) # 3 addition = lambda a, b: a + b value = addition(1, 2) print(value) # 3 authors = [ 'Octavia Butler', 'Isaac Asimov', 'Neal Stephens...
def add(a, b): return a + b plus = add value = plus(1, 2) print(value) value = (lambda a, b: a + b)(1, 2) print(value) addition = lambda a, b: a + b value = addition(1, 2) print(value) authors = ['Octavia Butler', 'Isaac Asimov', 'Neal Stephenson', 'Margaret Atwood', 'Usula K Le Guin', 'Ray Bradbury'] sorted_author...
# my_script print(f"My __name__ is: {__name__}") def i_am_main(): print("I'm main!") def i_am_imported(): print("I'm iported!") if __name__ == "__main__": i_am_main() else: i_am_imported()
print(f'My __name__ is: {__name__}') def i_am_main(): print("I'm main!") def i_am_imported(): print("I'm iported!") if __name__ == '__main__': i_am_main() else: i_am_imported()
#!/usr/bin/env python ''' * Author : Hutter Valentin * Date : 08.05.2019 * Description : Hector agent monitoring * Help : ANSI color from https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python ''' class colors: HEADER = '\033[95m' BLUE = '\033[94m' CBLUE = '\33[34m'...
""" * Author : Hutter Valentin * Date : 08.05.2019 * Description : Hector agent monitoring * Help : ANSI color from https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python """ class Colors: header = '\x1b[95m' blue = '\x1b[94m' cblue = '\x1b[34m' green = '\x1b[92m...
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: the given BST @param k: the given k @return: the kth smallest element in BST """ def kthSmallest(self, root, k): ...
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: the given BST @param k: the given k @return: the kth smallest element in BST """ def kth_smallest(self, root, k): ...
""" SpectralFlux.py Compute the spectral flux between consecutive spectra This technique can be for onset detection rectify - only return positive values Ported from https://github.com/jsawruk/pymir: 30 August 2017 """ def spectralFlux(spectra, rectify=False): spectral_flux = [] # Compute flux for zeroth sp...
""" SpectralFlux.py Compute the spectral flux between consecutive spectra This technique can be for onset detection rectify - only return positive values Ported from https://github.com/jsawruk/pymir: 30 August 2017 """ def spectral_flux(spectra, rectify=False): spectral_flux = [] flux = 0 for nth_bin in s...
print("analise estatistico de grupos") somaid =0 feminino =0 masculino =0 while True: print("_"*20) idade = int(input("Informe sua idade:")) sexo = str(input("informe seu sexo:[M/F]")).upper() print("-"*20) if idade >= 18: somaid = somaid + 1 if sexo == "M": masculino = masculi...
print('analise estatistico de grupos') somaid = 0 feminino = 0 masculino = 0 while True: print('_' * 20) idade = int(input('Informe sua idade:')) sexo = str(input('informe seu sexo:[M/F]')).upper() print('-' * 20) if idade >= 18: somaid = somaid + 1 if sexo == 'M': masculino = ma...
def test_get_symbols(xtb_client): symbols = list(xtb_client.get_all_symbols()) assert len(symbols) > 0 def test_get_balance(xtb_client): balance = xtb_client.get_balance() assert balance.get('balance') is not None def test_ping(xtb_client): response = xtb_client.ping() assert response
def test_get_symbols(xtb_client): symbols = list(xtb_client.get_all_symbols()) assert len(symbols) > 0 def test_get_balance(xtb_client): balance = xtb_client.get_balance() assert balance.get('balance') is not None def test_ping(xtb_client): response = xtb_client.ping() assert response
# user.py class User: """ Class representing an user. Parameters ---------- TODO Attributes ---------- Methods ------- """ def __init__(self, name, uuid=None): self.name = name self.uuid = self._get_uuid(uuid) def _get_uuid(self, uuid): ""...
class User: """ Class representing an user. Parameters ---------- TODO Attributes ---------- Methods ------- """ def __init__(self, name, uuid=None): self.name = name self.uuid = self._get_uuid(uuid) def _get_uuid(self, uuid): """ Get ...
class AgregationController: def __init__(self): """ """ def subscribe(self, url): """ :param url: URL :return: boolean """ def notify(self, message, id): """ :param message: Message :param id: List<TgUID> :return: void ...
class Agregationcontroller: def __init__(self): """ """ def subscribe(self, url): """ :param url: URL :return: boolean """ def notify(self, message, id): """ :param message: Message :param id: List<TgUID> :return: void ...
#Solution code for exercise 1 #We make a loop to make the element by element product of two lists, we then compare to numpy def list_product(list1,list2): new_list=list1 if(len(list1)==len(list2)): try: for i,row in enumerate(list1): for j,el in enumerate(row): ...
def list_product(list1, list2): new_list = list1 if len(list1) == len(list2): try: for (i, row) in enumerate(list1): for (j, el) in enumerate(row): new_list[i][j] = list1[i][j] * list2[i][j] except: print('Both arrays should have the sa...
#Verificar si un numero es cuadrado #sin usar metodo sqrt def findSqrt (num): l=0 r=num-1 while l<=r: mid = l+(r-l)//2 if mid*mid == num: return True if mid*mid < num: l=mid+1 if mid*mid > num: r=mid-1 return False print(findSqrt(14))
def find_sqrt(num): l = 0 r = num - 1 while l <= r: mid = l + (r - l) // 2 if mid * mid == num: return True if mid * mid < num: l = mid + 1 if mid * mid > num: r = mid - 1 return False print(find_sqrt(14))
def iob_ranges(words, tags): """ IOB -> Ranges """ assert len(words) == len(tags) ranges = [] def check_if_closing_range(): if i == len(tags) - 1 or tags[i + 1].split('_')[0] == 'O': ranges.append({ 'entity': ''.join(words[begin: i + 1]), 'typ...
def iob_ranges(words, tags): """ IOB -> Ranges """ assert len(words) == len(tags) ranges = [] def check_if_closing_range(): if i == len(tags) - 1 or tags[i + 1].split('_')[0] == 'O': ranges.append({'entity': ''.join(words[begin:i + 1]), 'type': temp_type, 'start': begin, 'en...
""" Task Given an integer, n, perform the following conditional actions: If n is odd, print Weird If n is even and in the inclusive range of 2 to 5, print Not Weird If n is even and in the inclusive range of 6 to 20, print Weird If n is even and greater than 20, print Not Weird Input Format A single line containing a...
""" Task Given an integer, n, perform the following conditional actions: If n is odd, print Weird If n is even and in the inclusive range of 2 to 5, print Not Weird If n is even and in the inclusive range of 6 to 20, print Weird If n is even and greater than 20, print Not Weird Input Format A single line containing a...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isValidBST(self, root: TreeNode) -> bool: self.prev = None def valid(node): if node: if n...
class Solution: def is_valid_bst(self, root: TreeNode) -> bool: self.prev = None def valid(node): if node: if not valid(node.left): return False if self.prev and self.prev.val >= node.val: return False ...
class Solution: def lengthOfLastWord(self, s: str) -> int: s = s.strip() wordList = s.split(' ') try: lastWord = wordList[-1] return len(lastWord) except IndexError: return 0 sol = Solution() print(sol.lengthOfLastWord("hello world"))
class Solution: def length_of_last_word(self, s: str) -> int: s = s.strip() word_list = s.split(' ') try: last_word = wordList[-1] return len(lastWord) except IndexError: return 0 sol = solution() print(sol.lengthOfLastWord('hello world'))
valid_statues = ['active', 'inactive'] class ServiceIdentities: def __init__(self, britive): self.britive = britive self.base_url = f'{self.britive.base_url}/users' def list(self, filter_expression: str = None) -> list: """ Provide an optionally filtered list of all service id...
valid_statues = ['active', 'inactive'] class Serviceidentities: def __init__(self, britive): self.britive = britive self.base_url = f'{self.britive.base_url}/users' def list(self, filter_expression: str=None) -> list: """ Provide an optionally filtered list of all service iden...
class A: def method(self): print('This belongs to class A') class B(A): def method(self): print('This belongs to class B') pass class C(A): def method(self): print('This belongs to class C') pass class D(B,C): def method(self): p...
class A: def method(self): print('This belongs to class A') class B(A): def method(self): print('This belongs to class B') pass class C(A): def method(self): print('This belongs to class C') pass class D(B, C): def method(self): print('This belongs to class...
def astr(jour, mois): if (mois == 3 and (jour >= 21 and jour <= 31)) or (mois == 4 and (jour >= 1 and jour <= 20)): return "Belier" elif (mois == 4 and (jour >= 21 and jour <= 30) or (mois == 5 and (jour >= 1 and jour <= 21))): return "Taureau" elif (mois == 5 and (jour >= 22 and jo...
def astr(jour, mois): if mois == 3 and (jour >= 21 and jour <= 31) or (mois == 4 and (jour >= 1 and jour <= 20)): return 'Belier' elif mois == 4 and (jour >= 21 and jour <= 30) or (mois == 5 and (jour >= 1 and jour <= 21)): return 'Taureau' elif mois == 5 and (jour >= 22 and jour <= 31) or (...
# Given a singly linked list, write a function which takes in the first node # in a singly linked list and returns a boolean indicating if the linked list # contains a "cycle". # A cycle is when a node's next point actually points back to a previous node # in the list. This is also sometimes known as a circularly link...
class Solution(object): def has_cycle(self, head): """ :type head: ListNode :rtype: bool """ seen = set() cur = head while cur: if cur in seen: return True seen.add(cur) cur = cur.next return False
class segmenter: def __init__(self): self.index_count = 0 self.Tx_buff = [] self.data = [] def load_data(self,s): self.data = s def append_data(self,s): self.data.append(s) def prep_buff(self): self.index_count = 0 l = len(self.data) diff = l - self.index_count if diff ...
class Segmenter: def __init__(self): self.index_count = 0 self.Tx_buff = [] self.data = [] def load_data(self, s): self.data = s def append_data(self, s): self.data.append(s) def prep_buff(self): self.index_count = 0 l = len(self.data) ...
class Solution: def flipAndInvertImage(self, image: List[List[int]]) -> List[List[int]]: image_width = len(image) for idx, row in enumerate(image): image[idx] = [] for element in row: image[idx] = [1 - element] + image[idx] return image
class Solution: def flip_and_invert_image(self, image: List[List[int]]) -> List[List[int]]: image_width = len(image) for (idx, row) in enumerate(image): image[idx] = [] for element in row: image[idx] = [1 - element] + image[idx] return image
N = int(input()) odds = [i for i in range(1, N+1) if i % 2 != 0] result = [] for odd in odds: z = [] for i in range(1, odd+1): if odd % i == 0: z.append(i) if len(z) == 8: result.append(z) print(len(result))
n = int(input()) odds = [i for i in range(1, N + 1) if i % 2 != 0] result = [] for odd in odds: z = [] for i in range(1, odd + 1): if odd % i == 0: z.append(i) if len(z) == 8: result.append(z) print(len(result))
""" 0131. Palindrome Partitioning Medium Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. Example: Input: "aab" Output: [ ["aa","b"], ["a","a","b"] ] """ class Solution: def partition(self, s: str) -> List[List[str]]:...
""" 0131. Palindrome Partitioning Medium Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. Example: Input: "aab" Output: [ ["aa","b"], ["a","a","b"] ] """ class Solution: def partition(self, s: str) -> List[List[str]...
# 11 - Given 2 (integer) lists, calculate if they're equal element by element and print it on the terminal. equal = True L1 = [67, 82, 100, 28, 22, 68] L2 = [18, 27, 33, 13, 83, 61] n = len(L1) for i in range(0, n): if L1[i] != L2[i]: equal = False if equal: print("Lists are equal.") else: print("Lists a...
equal = True l1 = [67, 82, 100, 28, 22, 68] l2 = [18, 27, 33, 13, 83, 61] n = len(L1) for i in range(0, n): if L1[i] != L2[i]: equal = False if equal: print('Lists are equal.') else: print("Lists aren't equal.")
""" 1. Lambda definition """ # def add(a, b): # return a + b # Lambda with name add = lambda a,b : a + b c = add(3, 5) print(c) # Anonymous Lambda result = (lambda a, b: a + b)(9, 10) print(result)
""" 1. Lambda definition """ add = lambda a, b: a + b c = add(3, 5) print(c) result = (lambda a, b: a + b)(9, 10) print(result)
# pylint: disable=invalid-name VERSION = '1.0' default_app_config = 'django_walletpass.apps.DjangoWalletpassConfig'
version = '1.0' default_app_config = 'django_walletpass.apps.DjangoWalletpassConfig'
# # Example file for working with conditional statements # (For Python 3.x, be sure to use the ExampleSnippets3.txt file) def main(): x, y = 10, 100 if x < y : str = "x is less than y" elif x > y: str = "y is less than x"; else: str = "x is equal to y" print(str) st =...
def main(): (x, y) = (10, 100) if x < y: str = 'x is less than y' elif x > y: str = 'y is less than x' else: str = 'x is equal to y' print(str) st = 'x is less than y' if x < y else 'x is greater than or equal to y' print(st) if __name__ == '__main__': main()
""" Create by yy on 2019/9/21 """ __title__ = 'psql-yy' __description__ = 'A tool which is used to connect postgresql, designed by yy' __url__ = 'https://github.com/guaidashu/psql_yy' __version_info__ = ('0', '1', '6') __version__ = '.'.join(__version_info__) __author__ = 'guaidashu' __author_email__ = 'song42960@gmai...
""" Create by yy on 2019/9/21 """ __title__ = 'psql-yy' __description__ = 'A tool which is used to connect postgresql, designed by yy' __url__ = 'https://github.com/guaidashu/psql_yy' __version_info__ = ('0', '1', '6') __version__ = '.'.join(__version_info__) __author__ = 'guaidashu' __author_email__ = 'song42960@gmail...
# Trie Node class TrieNode: def __init__(self, letter): self.letter = letter self.children = {} self.is_end_of_word = False class Trie: def __init__(self): self.root = TrieNode("*") # Root node # -----------------------------------------------------------------------...
class Trienode: def __init__(self, letter): self.letter = letter self.children = {} self.is_end_of_word = False class Trie: def __init__(self): self.root = trie_node('*') def add(self, word): curr_node = self.root for letter in word: if letter ...
# # PySNMP MIB module AT-DHCPSN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AT-DHCPSN-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:29:42 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_intersection, value_size_constraint, value_range_constraint, constraints_union) ...
# From dashcore-lib class SimplifiedMNList: pass class SimplifiedMNListDiff: pass class MerkleBlock: pass class BlockHeader: pass
class Simplifiedmnlist: pass class Simplifiedmnlistdiff: pass class Merkleblock: pass class Blockheader: pass
class Provider(BaseProvider): """ Generates fake ISBNs. ISBN rules vary across languages/regions so this class makes no attempt at replicating all of the rules. It only replicates the 978 EAN prefix for the English registration groups, meaning the first 4 digits of the ISBN-13 will either be 978-0 or 9...
class Provider(BaseProvider): """ Generates fake ISBNs. ISBN rules vary across languages/regions so this class makes no attempt at replicating all of the rules. It only replicates the 978 EAN prefix for the English registration groups, meaning the first 4 digits of the ISBN-13 will either be 978-0 o...
class TexFile: """Represents a body of .tex template. Can change its parameters and gives you body for captions and formulas. List of parameters: sans_font: Set sans font of the document. roman_font, mono_font: The same. pre_packages: These packages will be included into preamble at its beginning. Is array...
class Texfile: """Represents a body of .tex template. Can change its parameters and gives you body for captions and formulas. List of parameters: sans_font: Set sans font of the document. roman_font, mono_font: The same. pre_packages: These packages will be included into preamble at its beginning. Is ar...
# SPDX-License-Identifier: BSD-3-Clause __all__ = ( 'guid', 'GPT_PART_TYPES', 'UEFI_CORE_PART_TYPES' , 'WINDOWS_PART_TYPES' , 'HPUX_PART_TYPES' , 'LINUX_PART_TYPES' , 'FREEBSD_PART_TYPES' , 'DARWIN_PART_TYPES' , 'SOLARIS_PART_TYPES' , 'NETBSD_PART_TYPES' , 'CHROMEOS_PART_TYPES' , 'COREOS_...
__all__ = ('guid', 'GPT_PART_TYPES', 'UEFI_CORE_PART_TYPES', 'WINDOWS_PART_TYPES', 'HPUX_PART_TYPES', 'LINUX_PART_TYPES', 'FREEBSD_PART_TYPES', 'DARWIN_PART_TYPES', 'SOLARIS_PART_TYPES', 'NETBSD_PART_TYPES', 'CHROMEOS_PART_TYPES', 'COREOS_PART_TYPES', 'HAIKU_PART_TYPES', 'MIDNIGHT_PART_TYPES', 'CEPH_PART_TYPES', 'OPENB...
def echo(user , lang , sys) : print('User:', user, 'Language:', lang, 'Platform:', sys) echo('Mike' , 'Python' , 'Window') echo(lang = 'Python' , sys = 'Mac OS' , user = 'Anne') def mirror(user = 'Carole' , lang = 'Python') : print('\nUser:' , user , 'Language:' , lang) mirror() mirror(lang = 'Java') mirro...
def echo(user, lang, sys): print('User:', user, 'Language:', lang, 'Platform:', sys) echo('Mike', 'Python', 'Window') echo(lang='Python', sys='Mac OS', user='Anne') def mirror(user='Carole', lang='Python'): print('\nUser:', user, 'Language:', lang) mirror() mirror(lang='Java') mirror(user='Tony') mirror('Susan...
TOTAL_CHARACTERS = """ SELECT COUNT(name) FROM charactercreator_character; """ TOTAL_SUBCLASS = """ SELECT (SELECT COUNT(*) FROM charactercreator_cleric ) as cleric, (SELECT COUNT(*) FROM charactercreator_fighter ) AS fighter, (SELECT COUNT(*) ...
total_characters = '\n SELECT COUNT(name)\n FROM charactercreator_character;\n' total_subclass = '\n SELECT \n (SELECT COUNT(*)\n FROM charactercreator_cleric\n ) as cleric,\n (SELECT COUNT(*)\n FROM charactercreator_fighter\n ) AS fighter,\n (SELECT COUNT(*)\n ...
numbers = [] while True: num = input('Enter a number: ') if num == 'done': break try: num = int(num) numbers.append(num) except ValueError: print('Invalid input') largest = max(numbers) smallest = min(numbers) print(f'Maximum is {largest}') print(f'Minimum is {smallest}')...
numbers = [] while True: num = input('Enter a number: ') if num == 'done': break try: num = int(num) numbers.append(num) except ValueError: print('Invalid input') largest = max(numbers) smallest = min(numbers) print(f'Maximum is {largest}') print(f'Minimum is {smallest}')
def reverseLeftWords(s: str, n: int) -> str: return s[n:] + s[:n] def reverseLeftWords(s: str, n: int) -> str: str_list = [] length = len(s) for i in range(n, n + length): str_list.append(s[i % length]) return ''.join(str_list)
def reverse_left_words(s: str, n: int) -> str: return s[n:] + s[:n] def reverse_left_words(s: str, n: int) -> str: str_list = [] length = len(s) for i in range(n, n + length): str_list.append(s[i % length]) return ''.join(str_list)
# O(log n) def recursiveBinarySearch(vector, left_index, right_index, wanted): if left_index <= right_index: pivot = round(left_index + (right_index - left_index) / 2) if (vector[pivot] == wanted): return pivot elif vector[pivot] < wanted: return recursiveBinarySearch(vector, pivot+1, right_index...
def recursive_binary_search(vector, left_index, right_index, wanted): if left_index <= right_index: pivot = round(left_index + (right_index - left_index) / 2) if vector[pivot] == wanted: return pivot elif vector[pivot] < wanted: return recursive_binary_search(vector, ...