content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Error Handling def inp(a): while True: try: n = int(input(a)) except ValueError: print('Please enter a number only !!') else: return n print(inp("Enter a number: ")) try: while x: print("Hello\n") raise NameError except NameError as e...
def inp(a): while True: try: n = int(input(a)) except ValueError: print('Please enter a number only !!') else: return n print(inp('Enter a number: ')) try: while x: print('Hello\n') raise NameError except NameError as e: print(e) finall...
high = 0 for x in range(100,1000): for y in range(100,1000): if str(x*y) == str(x*y)[::-1] and x*y>high: high = x*y print(high)
high = 0 for x in range(100, 1000): for y in range(100, 1000): if str(x * y) == str(x * y)[::-1] and x * y > high: high = x * y print(high)
# %% [504. Base 7](https://leetcode.com/problems/base-7/) class Solution: def convertToBase7(self, num: int) -> str: sign, num = "-" * (num < 0), abs(num) res = [] while num: res.append(str(num % 7)) num //= 7 return sign + "".join(res[::-1] or ["0"])
class Solution: def convert_to_base7(self, num: int) -> str: (sign, num) = ('-' * (num < 0), abs(num)) res = [] while num: res.append(str(num % 7)) num //= 7 return sign + ''.join(res[::-1] or ['0'])
class ModelConfig(object): def __init__(self, max_epochs, batch_size, learning_rate, per_series_lr_multip, gradient_eps, gradient_clipping_threshold, lr_scheduler_step_size, noise_std, level_variability_penalty, tau, c_state_penalty, state_hsize, dilation...
class Modelconfig(object): def __init__(self, max_epochs, batch_size, learning_rate, per_series_lr_multip, gradient_eps, gradient_clipping_threshold, lr_scheduler_step_size, noise_std, level_variability_penalty, tau, c_state_penalty, state_hsize, dilations, add_nl_layer, seasonality, input_size, output_size, frequ...
''' class Solution { public ListNode swapNodes(ListNode head, int k) { int listLength = 0; ListNode currentNode = head; // find the length of linked list while (currentNode != null) { listLength++; currentNode = currentNode.next; } // set the f...
""" class Solution { public ListNode swapNodes(ListNode head, int k) { int listLength = 0; ListNode currentNode = head; // find the length of linked list while (currentNode != null) { listLength++; currentNode = currentNode.next; } // set the f...
#9.28 6:23AM def reverse_sub_list(head, p, q): # TODO: Write your code here # to capture the apart pre_p, post_q = head, head # to capture the range p_node, q_node = head, head # to track others pointer = head oneStep = pointer.next while oneStep is not None: if oneStep.value == p: pre_p = ...
def reverse_sub_list(head, p, q): (pre_p, post_q) = (head, head) (p_node, q_node) = (head, head) pointer = head one_step = pointer.next while oneStep is not None: if oneStep.value == p: pre_p = pointer p_node = oneStep elif pointer.value == q: post...
# # PySNMP MIB module ADTRAN-ATLAS-MODULE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ADTRAN-ATLAS-MODULE-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:14:30 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
(ad_atlas_unit_fp_status, ad_atlas_unit_slot_address, ad_atlas_unit_port_address) = mibBuilder.importSymbols('ADTRAN-ATLAS-UNIT-MIB', 'adATLASUnitFPStatus', 'adATLASUnitSlotAddress', 'adATLASUnitPortAddress') (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier'...
# https://www.codewars.com/kata/555eded1ad94b00403000071/train/python def series_sum(n): if n == 0: return "0.00" if n == 1: return "1.00" sum = 1 floor = 4 for _ in range(n-1): sum += (1/floor) floor += 3 return '%.2f' % round(sum,2)
def series_sum(n): if n == 0: return '0.00' if n == 1: return '1.00' sum = 1 floor = 4 for _ in range(n - 1): sum += 1 / floor floor += 3 return '%.2f' % round(sum, 2)
# magicblast_alignment.py # # Author: Jan Piotr Buchmann <jan.buchmann@sydney.edu.au> # Description: # # Version: 0.0 class MappingAlignment: class Read: def __init__(self, name, start, stop, strand, qlen): self.name = name self.length = int(qlen) self.sra_rowid = name.split('.')[1] ...
class Mappingalignment: class Read: def __init__(self, name, start, stop, strand, qlen): self.name = name self.length = int(qlen) self.sra_rowid = name.split('.')[1] self.start = int(start) - 1 self.stop = int(stop) - 1 self.strand = ...
# SPDX-License-Identifier: Apache-2.0 # # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. class CiTarget: version: str name: str snapshot: bool def __init__(self, version: str, name: str, snapshot: b...
class Citarget: version: str name: str snapshot: bool def __init__(self, version: str, name: str, snapshot: bool=True) -> None: self.version = version self.name = name self.snapshot = snapshot @property def opensearch_version(self) -> str: return self.version + ...
''' Exercise 1: 1. Write a recursive function print_all(numbers) that prints all the elements of list of integers, one per line (use no while loops or for loops). The parameters numbers to the function is a list of int. 2. Same problem as the last one but prints out the elements in reverse order. ''' #printing all in...
""" Exercise 1: 1. Write a recursive function print_all(numbers) that prints all the elements of list of integers, one per line (use no while loops or for loops). The parameters numbers to the function is a list of int. 2. Same problem as the last one but prints out the elements in reverse order. """ def print_all(num...
class Generations(object): def __init__(self): self.age = self.next_age = 0 self.neighbors = [None] * 8 self.live_count = 0 def count_live_neighbors(self): self.live_count = 0 for n in self.neighbors: if n.age == 1: self.live_count += 1 ...
class Generations(object): def __init__(self): self.age = self.next_age = 0 self.neighbors = [None] * 8 self.live_count = 0 def count_live_neighbors(self): self.live_count = 0 for n in self.neighbors: if n.age == 1: self.live_count += 1 ...
# Problem URL: https://leetcode.com/problems/search-in-rotated-sorted-array-ii class Solution: def binarySearch(self, array, begin, end, target): mid = (begin + end)//2 while (begin<=end): if array[mid] == target: return True elif array[mid] < target:...
class Solution: def binary_search(self, array, begin, end, target): mid = (begin + end) // 2 while begin <= end: if array[mid] == target: return True elif array[mid] < target: begin = mid + 1 return self.binarySearch(array, beg...
# -*- coding: utf-8 -*- class Solution: def largestOddNumber(self, num: str) -> str: for index, digit in enumerate(reversed(num)): if int(digit) % 2 == 1: return num[:len(num) - index] return '' if __name__ == '__main__': solution = Solution() assert '5' == so...
class Solution: def largest_odd_number(self, num: str) -> str: for (index, digit) in enumerate(reversed(num)): if int(digit) % 2 == 1: return num[:len(num) - index] return '' if __name__ == '__main__': solution = solution() assert '5' == solution.largestOddNumber...
produce = ['apple','banana', 'cucumber'] volumes = ['one piece', 'cup', 'handful'] d = {} for i in range(len(produce)): if produce[i] not in d: d[produce[i]] = volumes[i] print(d.items())
produce = ['apple', 'banana', 'cucumber'] volumes = ['one piece', 'cup', 'handful'] d = {} for i in range(len(produce)): if produce[i] not in d: d[produce[i]] = volumes[i] print(d.items())
class Jobs: tag = '' time_requested = 0 finished = False def __init__(self, tag_, time_requested_): self.tag = tag_ self.time_requested = time_requested_
class Jobs: tag = '' time_requested = 0 finished = False def __init__(self, tag_, time_requested_): self.tag = tag_ self.time_requested = time_requested_
class Solution: #given a list of integer #return an integer def maxArea(self, height): res = 0 left = 0 right = len(height) - 1 while left < right: if height[left] < height[right]: res = max(res, height[left] * (right - left)) left ...
class Solution: def max_area(self, height): res = 0 left = 0 right = len(height) - 1 while left < right: if height[left] < height[right]: res = max(res, height[left] * (right - left)) left += 1 else: res = max(r...
l3 = list(filter(lambda x: 1000 <= x <= 9999, list(int(n * (n + 1)/2) for n in range(9999)))) l4 = list(filter(lambda x: 1000 <= x <= 9999, list(int(n*n) for n in range(9999)))) l5 = list(filter(lambda x: 1000 <= x ...
l3 = list(filter(lambda x: 1000 <= x <= 9999, list((int(n * (n + 1) / 2) for n in range(9999))))) l4 = list(filter(lambda x: 1000 <= x <= 9999, list((int(n * n) for n in range(9999))))) l5 = list(filter(lambda x: 1000 <= x <= 9999, list((int(n * (3 * n - 1) / 2) for n in range(9999))))) l6 = list(filter(lambda x: 1000 ...
# # PySNMP MIB module FN100-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/FN100-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:00:25 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...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, value_size_constraint, constraints_union, constraints_intersection) ...
def aio_documented_by(original): def wrapper(target): target.__doc__ = "Aio function: {original_doc}".format(original_doc=original.__doc__) return target return wrapper def documented_by(original): def wrapper(target): target.__doc__ = original.__doc__ return target r...
def aio_documented_by(original): def wrapper(target): target.__doc__ = 'Aio function: {original_doc}'.format(original_doc=original.__doc__) return target return wrapper def documented_by(original): def wrapper(target): target.__doc__ = original.__doc__ return target re...
class TurboSMSRouter(object): app_label = 'turbosms' db_name = 'turbosms' def db_for_read(self, model, **hints): if model._meta.app_label == self.app_label: return self.db_name return None def db_for_write(self, model, **hints): if model._meta.app_label == self...
class Turbosmsrouter(object): app_label = 'turbosms' db_name = 'turbosms' def db_for_read(self, model, **hints): if model._meta.app_label == self.app_label: return self.db_name return None def db_for_write(self, model, **hints): if model._meta.app_label == self.app_...
BROWSER_IMPLICIT_WAIT_TIME = 5 MODAL_TRANSITION_WAIT_TIME = 2 BOOTSTRAP_SWITCH_TRANSITION_WAIT_TIME = 1 PAGE_LOADING_WAIT_TIME = 5 PAGE_LOADING_LONG_WAIT_TIME = 10
browser_implicit_wait_time = 5 modal_transition_wait_time = 2 bootstrap_switch_transition_wait_time = 1 page_loading_wait_time = 5 page_loading_long_wait_time = 10
''' Class /is holding plate = True / attributes:/ / \ / tables_responsible = [4, 5, 6] waiter (object) \ \ / def take_order(table, order) ...
""" Class /is holding plate = True / attributes:/ / / tables_responsible = [4, 5, 6] waiter (object) \\ / def take_order(table, order) / ...
# Split-initiator sequences from # Sequences retrieved from https://dev.biologists.org/content/develop/suppl/2018/06/21/145.12.dev165753.DC1/DEV165753supp.pdf # Sequences below include 2nt spacers on 3' end of odd and 5' end of even to allow for bending to present initiator. initiators = { "B1": { "odd": "...
initiators = {'B1': {'odd': 'gAggAgggCAgCAAACggAA', 'even': 'TAgAAgAgTCTTCCTTTACg'}, 'B2': {'odd': 'CCTCgTAAATCCTCATCAAA', 'even': 'AAATCATCCAgTAAACCgCC'}, 'B3': {'odd': 'gTCCCTgCCTCTATATCTTT', 'even': 'TTCCACTCAACTTTAACCCg'}, 'B4': {'odd': 'CCTCAACCTACCTCCAACAA', 'even': 'ATTCTCACCATATTCgCTTC'}, 'B5': {'odd': 'CTCACTC...
2227 247 2216 3705 555 166 977 1900 4858 1337 3934 3599 4200 1598 2940 2359 2756 3753 1332 3646 706 428 3958 974 2744 2501 1209 2579 4987 334 2169 2175 4273 2890 3569 1006 2539 3855 1353 2677 1369 2008 59 311 1294 3008 1717 3271 1563 867 3466 187 4939 4719 1485 1243 1898 1169 4667 228 1743 4146 661 2831 158 724 2289 19...
2227 247 2216 3705 555 166 977 1900 4858 1337 3934 3599 4200 1598 2940 2359 2756 3753 1332 3646 706 428 3958 974 2744 2501 1209 2579 4987 334 2169 2175 4273 2890 3569 1006 2539 3855 1353 2677 1369 2008 59 311 1294 3008 1717 3271 1563 867 3466 187 4939 4719 1485 1243 1898 1169 4667 228 1743 4146 661 2831 158 724 2289 19...
def docking_data_01(lines): mask = None data = dict() for line in [line.split() for line in lines]: if line[0] == 'mask': mask = line[2] else: index = line[0] bits = "{0:b}".format(int(line[2])) bits = (36-len(bits))*'0' + bits mask...
def docking_data_01(lines): mask = None data = dict() for line in [line.split() for line in lines]: if line[0] == 'mask': mask = line[2] else: index = line[0] bits = '{0:b}'.format(int(line[2])) bits = (36 - len(bits)) * '0' + bits ...
# File: smime_consts.py # Copyright (c) 2020 Splunk Inc. # # Licensed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) # Sign email action related constants SMIME_SIGN_PROGRESS_MSG = "Signing email message" SMIME_SIGN_OK_MSG = "Email message signed successfully" SMIME_SIGN_ERR_MSG = "Error occurred w...
smime_sign_progress_msg = 'Signing email message' smime_sign_ok_msg = 'Email message signed successfully' smime_sign_err_msg = 'Error occurred while signing message. {err}' smime_verify_progress_msg = 'Verifying signed email message' smime_verify_ok_msg = 'Signed email message verified successfully' smime_verify_err_ms...
_list = ['int', 'bool', 'str'] def sys_macro_load(): result = '' for _type in _list: with open(f'cool_compiler/codegen/v1_mips_generate/general_macros//{_type}.mips') as mips: text = mips.read() mips.close() result += text[text.index('#region'): text.index('#endregi...
_list = ['int', 'bool', 'str'] def sys_macro_load(): result = '' for _type in _list: with open(f'cool_compiler/codegen/v1_mips_generate/general_macros//{_type}.mips') as mips: text = mips.read() mips.close() result += text[text.index('#region'):text.index('#endregion...
# coding=utf-8 class App: TESTING = True # ReverseProxy.HTTP_X_SCRIPT_NAME='/__' HOST_URL = 'http://pay.lvye.com' class Checkout: ZYT_MAIN_PAGE = 'http://pay.lvye.com/__/main' VALID_NETLOCS = ['pay.lvye.com'] AES_KEY = "2HF5UKPIADDYBHDSKOVP9GMA80MU2IV2" PAYMENT_CHECKOUT_VALID_SECONDS = 1 * 60 ...
class App: testing = True host_url = 'http://pay.lvye.com' class Checkout: zyt_main_page = 'http://pay.lvye.com/__/main' valid_netlocs = ['pay.lvye.com'] aes_key = '2HF5UKPIADDYBHDSKOVP9GMA80MU2IV2' payment_checkout_valid_seconds = 1 * 60 * 60 class Lvyepaysitepayclientconfig: root_url = 'http...
n = int(input()) p_list = sorted(list(map(int, input().split()))) ret = 0 for i in range(n): ret += (n-i) * p_list[i] print(ret)
n = int(input()) p_list = sorted(list(map(int, input().split()))) ret = 0 for i in range(n): ret += (n - i) * p_list[i] print(ret)
expected_output = { "power_stack": { "Powerstack-1": { "allocated_power": 575, "mode": "SP-PS", "power_supply_num": 1, "reserved_power": 0, "switch_num": 1, "switches": { 1: { "allocated_power": 575,...
expected_output = {'power_stack': {'Powerstack-1': {'allocated_power': 575, 'mode': 'SP-PS', 'power_supply_num': 1, 'reserved_power': 0, 'switch_num': 1, 'switches': {1: {'allocated_power': 575, 'available_power': 525, 'consumed_power_poe': 0, 'consumed_power_sys': 155, 'power_budget': 1100, 'power_supply_a': 1100, 'po...
# # PySNMP MIB module ENTERASYS-ACTIVATION-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ENTERASYS-ACTIVATION-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:03:07 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7....
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection, constraints_union) ...
def Qklnu(cfg,k,l,nu) : #function q=Qklnu(k,l,nu) # #% Computes Q, neccesary constant#% Computes Q, neccesary consta...
def qklnu(cfg, k, l, nu): aux_1 = cfg.power(-1, k + nu) / cfg.power(4.0, k) aux_2 = cfg.sqrt((2 * l + 4 * k + 3) / 3.0) aux_3 = cfg.trinomial(nu, k - nu, l + nu + 1) * cfg.nchoosek(2 * (l + nu + 1 + k), l + nu + 1 + k) aux_4 = cfg.nchoosek(2.0 * (l + nu + 1), l + nu + 1) q = aux_1 * aux_2 * aux_3 / ...
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017-05-23 16:23 # @Author : Max # @File : singleton.py def singleton(cls): instance = cls() instance.__call__ = lambda: instance return instance
def singleton(cls): instance = cls() instance.__call__ = lambda : instance return instance
# HSX hsxuc_events.v1.00p hsxuc_derived.v1.00p # aliases aliases = { "QPIRxMatch1": "Q_Py_PCI_RX_PMON_BOX_MATCH1", "QPIRxMask1": "Q_Py_PCI_RX_PMON_BOX_MASK1", "IRPFilter": "IRP_PCI_PMON_BOX_FILTER", "PCUFilter": "PCU_MSR_PMON_BOX_FILTER", "QPIRxMask0": "Q_Py_PCI_RX_PMON_BOX_MASK0", "CBoFi...
aliases = {'QPIRxMatch1': 'Q_Py_PCI_RX_PMON_BOX_MATCH1', 'QPIRxMask1': 'Q_Py_PCI_RX_PMON_BOX_MASK1', 'IRPFilter': 'IRP_PCI_PMON_BOX_FILTER', 'PCUFilter': 'PCU_MSR_PMON_BOX_FILTER', 'QPIRxMask0': 'Q_Py_PCI_RX_PMON_BOX_MASK0', 'CBoFilter0': 'Cn_MSR_PMON_BOX_FILTER', 'HA_AddrMatch0': 'HAn_PCI_PMON_BOX_ADDRMATCH0', 'QPITxM...
def find_syntax_error(line): correct = True incorrect_char = None complete = True closing_chars = [] to_close = [] chunk_characters = { '(': ')', '{': '}', '[': ']', '<': '>' } for char in line: if char in chunk_characters.keys(): ...
def find_syntax_error(line): correct = True incorrect_char = None complete = True closing_chars = [] to_close = [] chunk_characters = {'(': ')', '{': '}', '[': ']', '<': '>'} for char in line: if char in chunk_characters.keys(): to_close.append(char) elif chunk_ch...
class Solution: def getMaximumGenerated(self, n: int) -> int: nums = [0,1] + [0]*(n-1) if n < 2: return nums[n] for i in range(2, n+1): if i % 2 == 0 and i//2 <= n: nums[i] = nums[i//2] if i % 2 == 1 and i//2 + 1 <= n: nums[i] = nums[i//2] + nums[i//2+1] return max(nums)
class Solution: def get_maximum_generated(self, n: int) -> int: nums = [0, 1] + [0] * (n - 1) if n < 2: return nums[n] for i in range(2, n + 1): if i % 2 == 0 and i // 2 <= n: nums[i] = nums[i // 2] if i % 2 == 1 and i // 2 + 1 <= n: ...
setup( name="better-max-tools-installer", version="1.0.0", description="Installer for the Better Max Tools Python package.", long_description="", long_description_content_type="text/markdown", url="https://github.com/thomascswalker/better-max-tools", author="Thomas Walker", author_email=...
setup(name='better-max-tools-installer', version='1.0.0', description='Installer for the Better Max Tools Python package.', long_description='', long_description_content_type='text/markdown', url='https://github.com/thomascswalker/better-max-tools', author='Thomas Walker', author_email='thomascswalker@gmail.com', licen...
def merge(A, left, mid, right): global cnt inf = 10**9 L = A[left:mid] + [inf] R = A[mid:right] + [inf] i = 0 j = 0 for k in range(left, right): cnt += 1 if L[i] < R[j]: A[k] = L[i] i += 1 else: A[k] = R[j] j += 1 def...
def merge(A, left, mid, right): global cnt inf = 10 ** 9 l = A[left:mid] + [inf] r = A[mid:right] + [inf] i = 0 j = 0 for k in range(left, right): cnt += 1 if L[i] < R[j]: A[k] = L[i] i += 1 else: A[k] = R[j] j += 1 def...
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "mango"] thislist[1:3] = ["blackcurrant", "watermelon"] print(thislist)
thislist = ['apple', 'banana', 'cherry', 'orange', 'kiwi', 'mango'] thislist[1:3] = ['blackcurrant', 'watermelon'] print(thislist)
print("Hello Word.") def nome(parameter_list): a = parameter_list.split(" ", 2) print(a) nome('dag cirino mano dev') nome('dagmar aparecido')
print('Hello Word.') def nome(parameter_list): a = parameter_list.split(' ', 2) print(a) nome('dag cirino mano dev') nome('dagmar aparecido')
def construct_square(s): p = len(s) d_max = int((10**p)**.5) d_min = int((10**(p-1))**.5) for d in range(d_max, d_min -1, -1): n = str(d * d) if sorted(s.count(c) for c in set(s)) == sorted(n.count(c) for c in set(n)): return int(n) return -1 if __name__ == '__main__':...
def construct_square(s): p = len(s) d_max = int((10 ** p) ** 0.5) d_min = int((10 ** (p - 1)) ** 0.5) for d in range(d_max, d_min - 1, -1): n = str(d * d) if sorted((s.count(c) for c in set(s))) == sorted((n.count(c) for c in set(n))): return int(n) return -1 if __name__ ...
# nested2.py # # Nested loop Example 2 # CSC 110 # Fall 2011 #accumulators for the outer loop sumOuter = 0 for outer in [1, 2, 3, 4]: print('Outer loop iteration', outer) sumOuter += outer sumInner = 0 # accumulator for this inner loop # notice that the inner loop's repetitions is based on the va...
sum_outer = 0 for outer in [1, 2, 3, 4]: print('Outer loop iteration', outer) sum_outer += outer sum_inner = 0 for inner in range(1, outer + 1): print(' Inner loop iteration', inner) sum_inner += inner print(' Inner loop sum = ', sumInner) print() print('Outer loop sum = ',...
# rock = 0 # paper = 1 # scissors = 2 # paper beats rock # scissors beats paper # rock beats scissors print("Player 1: Type 0 for rock, type 1 for paper, type 2 for scissors") first_player = int(input()) print("Player 2: Type 0 for rock, type 1 for paper, type 2 for scissors") second_player = int(input()) if first_pl...
print('Player 1: Type 0 for rock, type 1 for paper, type 2 for scissors') first_player = int(input()) print('Player 2: Type 0 for rock, type 1 for paper, type 2 for scissors') second_player = int(input()) if first_player == 1 and second_player == 0: print('Player 1 wins') elif first_player == 2 and second_player ==...
table_id_map = { 1: "__all_core_table", 2: "__all_root_table", 3: "__all_table", 4: "__all_column", 5: "__all_ddl_operation", 101: "__all_meta_table", 102: "__all_user", 103: "__all_user_history", 104: "__all_database", 105: "__all_database_history", 106: "__all_tablegroup", 107: "__all_tablegro...
table_id_map = {1: '__all_core_table', 2: '__all_root_table', 3: '__all_table', 4: '__all_column', 5: '__all_ddl_operation', 101: '__all_meta_table', 102: '__all_user', 103: '__all_user_history', 104: '__all_database', 105: '__all_database_history', 106: '__all_tablegroup', 107: '__all_tablegroup_history', 108: '__all_...
# # PySNMP MIB module HUAWEI-RIPV2-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-RIPV2-EXT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:36:24 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint, constraints_union) ...
# # PySNMP MIB module TIPPINGPOINT-REG-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIPPINGPOINT-REG-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:23:40 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) ...
class SandwichBar: def whichOrder(self, available, orders): for i, o in enumerate(orders): if all(map(lambda e: e in available, o.split())): return i return -1
class Sandwichbar: def which_order(self, available, orders): for (i, o) in enumerate(orders): if all(map(lambda e: e in available, o.split())): return i return -1
CENTS_PER_DOLLAR = 100 class Order(object): def __init__(self, id, owner, ticker, type, price, qty): if int(id) < 0: raise ValueError() if round(float(price), 2) <= 0: raise ValueError() if int(qty) <= 0: raise ValueError() self.__id = id ...
cents_per_dollar = 100 class Order(object): def __init__(self, id, owner, ticker, type, price, qty): if int(id) < 0: raise value_error() if round(float(price), 2) <= 0: raise value_error() if int(qty) <= 0: raise value_error() self.__id = id ...
#!/usr/bin/python3 for i in range(ord('z'), ord('a') - 1, -1): if (i % 2 != 0): i = i - 32 i = chr(i) print("{}".format(i), end='')
for i in range(ord('z'), ord('a') - 1, -1): if i % 2 != 0: i = i - 32 i = chr(i) print('{}'.format(i), end='')
VERSION = (0, 4, 2) def get_version(): return '%s.%s.%s' % VERSION version = get_version()
version = (0, 4, 2) def get_version(): return '%s.%s.%s' % VERSION version = get_version()
cont = contIdade = contHomens = contMulher20 = 0 print('-=' * 15, '\nCadastro de Pessoas') print('-=' * 15) while True: idade = int(input('\033[1mDigite a idade:\033[m ')) if idade >= 18: contIdade += 1 sexo = ' ' while sexo not in 'MmFf': sexo = str(input('\033[1mDigite o sexo [M/F]:\03...
cont = cont_idade = cont_homens = cont_mulher20 = 0 print('-=' * 15, '\nCadastro de Pessoas') print('-=' * 15) while True: idade = int(input('\x1b[1mDigite a idade:\x1b[m ')) if idade >= 18: cont_idade += 1 sexo = ' ' while sexo not in 'MmFf': sexo = str(input('\x1b[1mDigite o sexo [M/F]...
n = int(input().strip()) for i in range(1, n + 1): cnt = 0 for j in list(str(i)): if j in ['3', '6', '9']: cnt += 1 if cnt > 0: print('-' * cnt, end=' ') else: print(i, end=' ')
n = int(input().strip()) for i in range(1, n + 1): cnt = 0 for j in list(str(i)): if j in ['3', '6', '9']: cnt += 1 if cnt > 0: print('-' * cnt, end=' ') else: print(i, end=' ')
def test_add_group(app, json_groups): group = json_groups old_groups = app.group.get_group_list() app.group.create(group) # new list is longer, because we added 1 element assert app.group.count() == len(old_groups) + 1 # if new list length is correct, then we can compare lists. # so we can...
def test_add_group(app, json_groups): group = json_groups old_groups = app.group.get_group_list() app.group.create(group) assert app.group.count() == len(old_groups) + 1 new_groups = app.group.get_group_list() old_groups.append(group) assert sorted(new_groups) == sorted(old_groups)
class Vector(object): def __init__(self, x,y): self.x = x self.y = y super(Vector, self).__init__(self, x,y)
class Vector(object): def __init__(self, x, y): self.x = x self.y = y super(Vector, self).__init__(self, x, y)
# Lists courses=['History','Math','Physics','Compsci'] courses_2=['Football','Basketball'] print("Slicing Examples") print(len(courses)) print(courses) print(courses[-1]) print(courses[0:3]) print(courses[::-1]) print("\nAdd") courses.append('Art') print(courses) print("\nInsert at the beginning") co...
courses = ['History', 'Math', 'Physics', 'Compsci'] courses_2 = ['Football', 'Basketball'] print('Slicing Examples') print(len(courses)) print(courses) print(courses[-1]) print(courses[0:3]) print(courses[::-1]) print('\nAdd') courses.append('Art') print(courses) print('\nInsert at the beginning') courses.insert(0, 'Sc...
#!/usr/bin/python3 # -*- coding: utf-8 -*- # Created by Ross on 19-1-8 class ListNode: def __init__(self, x): self.val = x self.next = None def solve(ln: ListNode): if not ln: return p = ln while p: print(p.val, end=' ') p = p.next print() def test1(): ...
class Listnode: def __init__(self, x): self.val = x self.next = None def solve(ln: ListNode): if not ln: return p = ln while p: print(p.val, end=' ') p = p.next print() def test1(): print('test1') ln = None solve(ln) def test2(): print('tes...
#!/bin/python3 # Calculates factorial def fact(n): f = 1 while n > 0: f *= n n -= 1 return f # Calculates Poisson Distribution def poissonDist(k, l): return (l**k*(2.71828**(-l)))/fact(k) if __name__ == '__main__': x = float(input()) y = float(input()) print(...
def fact(n): f = 1 while n > 0: f *= n n -= 1 return f def poisson_dist(k, l): return l ** k * 2.71828 ** (-l) / fact(k) if __name__ == '__main__': x = float(input()) y = float(input()) print(round(poisson_dist(y, x), 3))
expected_output = { 'model': 'WS-C3650-48PD', 'os': 'iosxe', 'platform': 'cat3k_caa', 'version': '03.06.07E', }
expected_output = {'model': 'WS-C3650-48PD', 'os': 'iosxe', 'platform': 'cat3k_caa', 'version': '03.06.07E'}
# # PySNMP MIB module DKSF-54-1-X-X-1 (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DKSF-54-1-X-X-1 # Produced by pysmi-0.3.4 at Wed May 1 12:47:27 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, single_value_constraint, constraints_intersection, value_range_constraint, constraints_union) ...
# # print("What's your name?") # name = input("> ") # # print("Hi " + name) a = 60 b = 7 c = 500 if a > b: if a > c: print(a) else: print(c) else: if b > c: print(b) else: print(c)
a = 60 b = 7 c = 500 if a > b: if a > c: print(a) else: print(c) elif b > c: print(b) else: print(c)
coset_init = lib.coset_init_ll insert = lib.cs_insert_ll remove = lib.cs_remove_ll get_s = lib.cs_get_size_ll clear = lib.cs_clear_ll get_min = lib.cs_min_ll get_max = lib.cs_min_ll upper_bound = lib.cs_upper_bound_ll rupper_bound = lib.cs_rupper_bound_ll get_k = lib.cs_get_k_ll
coset_init = lib.coset_init_ll insert = lib.cs_insert_ll remove = lib.cs_remove_ll get_s = lib.cs_get_size_ll clear = lib.cs_clear_ll get_min = lib.cs_min_ll get_max = lib.cs_min_ll upper_bound = lib.cs_upper_bound_ll rupper_bound = lib.cs_rupper_bound_ll get_k = lib.cs_get_k_ll
a = int(input()) b = int(input()) if a > b: print(1) elif a < b: print(2) else: print(0)
a = int(input()) b = int(input()) if a > b: print(1) elif a < b: print(2) else: print(0)
parrot = "Norwegian Blue" for char in parrot: print(char)
parrot = 'Norwegian Blue' for char in parrot: print(char)
Z = [[0,0,0,0,0,0], [0,0,0,1,0,0], [0,1,0,1,0,0], [0,0,1,1,0,0], [0,0,0,0,0,0], [0,0,0,0,0,0]] def compute_neighbours(Z): rows,cols = len(Z), len(Z[0]) N = [[0,]*(cols) for i in range(rows)] for x in range(1,cols-1): for y in range(1,rows-1): N[y][x] = Z[y-1][...
z = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]] def compute_neighbours(Z): (rows, cols) = (len(Z), len(Z[0])) n = [[0] * cols for i in range(rows)] for x in range(1, cols - 1): for y in range(1, rows - 1): N[y]...
def foo(): pass def bar(*args, kwonly_arg: str = None): pass
def foo(): pass def bar(*args, kwonly_arg: str=None): pass
# DATA UNIT CLASS class _Unit: def __init__(self, name, con_2_si, con_unit, si_unit): self._name = name self._con_2_si = con_2_si self._con_unit = con_unit self._si_unit = si_unit def get_name(self): return self._name def get_con_2_si(self): return self._con...
class _Unit: def __init__(self, name, con_2_si, con_unit, si_unit): self._name = name self._con_2_si = con_2_si self._con_unit = con_unit self._si_unit = si_unit def get_name(self): return self._name def get_con_2_si(self): return self._con_2_si def ge...
def missing_number(nums): arr = [0 for _ in range(len(nums))] for i in range(len(nums)): if nums[i] < len(nums): arr[nums[i]] = -1 for i in range(len(nums)): if arr[i] != -1: return i return len(nums)
def missing_number(nums): arr = [0 for _ in range(len(nums))] for i in range(len(nums)): if nums[i] < len(nums): arr[nums[i]] = -1 for i in range(len(nums)): if arr[i] != -1: return i return len(nums)
#!/usr/bin/env python # -*- encoding: utf-8 -*- # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache...
""" system_constants.py: defines constants for generic purposes and system config""" kb = 1024 mb = 1024 * KB gb = 1024 * MB ms_to_sec = 0.001 sec_to_ns = 1000000000 ns_to_ms = 1e-06 ram_for_stmgr = 1 * GB default_ram_for_instance = 1 * GB default_disk_padding_per_container = 12 * GB heron_logging_directory = 'heron.lo...
__title__ = "mathy_envs" __version__ = "0.11.0" __summary__ = "Learning environments for solving math problems step-by-step" __uri__ = "https://mathy.ai" __author__ = "Justin DuJardin" __email__ = "justin@dujardinconsulting.com" __license__ = "All rights reserved"
__title__ = 'mathy_envs' __version__ = '0.11.0' __summary__ = 'Learning environments for solving math problems step-by-step' __uri__ = 'https://mathy.ai' __author__ = 'Justin DuJardin' __email__ = 'justin@dujardinconsulting.com' __license__ = 'All rights reserved'
class HostInitiators(object): def read_get(self, name, idx_name, unity_client): return unity_client.get_host_initiators(idx_name) class HostInitiatorsColumn(object): def get_idx(self, name, idx, unity_client): return unity_client.get_hosts()
class Hostinitiators(object): def read_get(self, name, idx_name, unity_client): return unity_client.get_host_initiators(idx_name) class Hostinitiatorscolumn(object): def get_idx(self, name, idx, unity_client): return unity_client.get_hosts()
def check_password_hash(hash,password): if hash == password: return True else: return False def get_cards_summary_model(): data = dict() data["used_on_amazon"] = 0 data['used_on_google'] = 0 data['total_used'] = 0 data['expired'] = 0 data['total'] = 0 data['in_progre...
def check_password_hash(hash, password): if hash == password: return True else: return False def get_cards_summary_model(): data = dict() data['used_on_amazon'] = 0 data['used_on_google'] = 0 data['total_used'] = 0 data['expired'] = 0 data['total'] = 0 data['in_progr...
KABUM_PAGES = { "https://www.kabum.com.br/hardware/placas-mae?page_number=1&page_size=100&facet_filters=eyJwcmljZSI6eyJtaW4iOjM2NS45OCwibWF4IjoxMTE3NS4yOX19&sort=price": "placa-mae", "https://www.kabum.com.br/hardware/processadores?page_number=1&page_size=100&facet_filters=eyJwcmljZSI6eyJtaW4iOjM1MC42OSwibWF4I...
kabum_pages = {'https://www.kabum.com.br/hardware/placas-mae?page_number=1&page_size=100&facet_filters=eyJwcmljZSI6eyJtaW4iOjM2NS45OCwibWF4IjoxMTE3NS4yOX19&sort=price': 'placa-mae', 'https://www.kabum.com.br/hardware/processadores?page_number=1&page_size=100&facet_filters=eyJwcmljZSI6eyJtaW4iOjM1MC42OSwibWF4IjoxMTk4OS4...
#!/usr/bin/env python ''' you can use this command to run specific Python code: ..code-block:: python py.test example1.py ''' def f(x): return x + 1 def test_f(): assert f(0) == 1
""" you can use this command to run specific Python code: ..code-block:: python py.test example1.py """ def f(x): return x + 1 def test_f(): assert f(0) == 1
# -*- coding: utf-8 -*- ''' Module takes a series of showimes and first filters them and then prompts the user to select times. Currently the only filter is automatically applied and filters sceances during work hours. Currently the program is not intelligent enough to optimize times or ensure that sceances do not ove...
""" Module takes a series of showimes and first filters them and then prompts the user to select times. Currently the only filter is automatically applied and filters sceances during work hours. Currently the program is not intelligent enough to optimize times or ensure that sceances do not overlap. """ date_index = 1...
with open("lfw-gender-0.80.txt") as lfwgender, \ open("manual-gender.txt") as manual, \ open("lfw-gender-final.txt", "w") as final: nextline = lfwgender.readline() while nextline: firstname, gender = nextline.split() if gender != "?": final.write(nextline) else...
with open('lfw-gender-0.80.txt') as lfwgender, open('manual-gender.txt') as manual, open('lfw-gender-final.txt', 'w') as final: nextline = lfwgender.readline() while nextline: (firstname, gender) = nextline.split() if gender != '?': final.write(nextline) else: man...
N, M = [int(n) for n in input().split()] L, R = (1, N) for i in range(M): l, r = [int(n) for n in input().split()] L, R = (max(l, L), min(r, R)) print(max(0, R-L+1))
(n, m) = [int(n) for n in input().split()] (l, r) = (1, N) for i in range(M): (l, r) = [int(n) for n in input().split()] (l, r) = (max(l, L), min(r, R)) print(max(0, R - L + 1))
n = int(input()) integer_list = map(int, input().split()) integer_list = tuple(integer_list) print(hash(integer_list))
n = int(input()) integer_list = map(int, input().split()) integer_list = tuple(integer_list) print(hash(integer_list))
# This file is used to store password secrets which are not to be committed # to git. The key has to match one of the sources in the ocd_backend/sources # directory. If there a secret is required but not supplied in this file, the # program will fail. A secret like gegevensmagazijn will also match postfixes # like gege...
secrets = {'<ID>': ('<USERNAME>', '<PASSWORD>')}
VERBOSITY = 1 SAMPLE_RATE = 16000 DURATION_MS = 1000 FEATURES_COUNT = 64 DESIRED_SAMPLES = int(SAMPLE_RATE * DURATION_MS / 1000) DROPOUT_RATE = 0.5 TESING_PERCENTAGE = 15 VALIDATION_PERCENTAGE = 15 VALIDATION_FREQUENCY = 10 SAVE_PERIOD = 10 EPOCHS = 100 BATCH_SIZE = 512 DATASET_URL = 'http://download.tensorflow.org/d...
verbosity = 1 sample_rate = 16000 duration_ms = 1000 features_count = 64 desired_samples = int(SAMPLE_RATE * DURATION_MS / 1000) dropout_rate = 0.5 tesing_percentage = 15 validation_percentage = 15 validation_frequency = 10 save_period = 10 epochs = 100 batch_size = 512 dataset_url = 'http://download.tensorflow.org/dat...
# https://www.hackerrank.com/challenges/common-child/problem def longestCommonSubsequence(s1, s2): remove_element = set(s1) - set(s2) new_s1 = "" for element in s1: if element not in remove_element: new_s1 += element s1 = new_s1 memory = [[0] * (len(s2) + 1) for _ in range((le...
def longest_common_subsequence(s1, s2): remove_element = set(s1) - set(s2) new_s1 = '' for element in s1: if element not in remove_element: new_s1 += element s1 = new_s1 memory = [[0] * (len(s2) + 1) for _ in range(len(s1) + 1)] for (index1, value1) in enumerate(s1, 1): ...
class Defines(object): PROTOCOL_ID = b'BitTorrent protocol' RM_CLIENT_ID = b'RM' RM_CLIENT_VERSION = b'0100'
class Defines(object): protocol_id = b'BitTorrent protocol' rm_client_id = b'RM' rm_client_version = b'0100'
{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# lists are used to store a list of things; similar to arrays in java \n", "# note the use of square brackets and\n", "\n", "a = [3, 10, -1]" ] }, { "cell_type": "code", "...
{'cells': [{'cell_type': 'code', 'execution_count': 1, 'metadata': {}, 'outputs': [], 'source': ['# lists are used to store a list of things; similar to arrays in java \n', '# note the use of square brackets and\n', '\n', 'a = [3, 10, -1]']}, {'cell_type': 'code', 'execution_count': 2, 'metadata': {}, 'outputs': [{'nam...
def find_opposites(seq): check=set() res=set() for i in seq: if -i in check: res.add(abs(i)) check.add(i) return sorted(res)
def find_opposites(seq): check = set() res = set() for i in seq: if -i in check: res.add(abs(i)) check.add(i) return sorted(res)
_base_ = './kd_resnet18_resnet50_cifar100_equal.py' # model settings model = dict( adaptive=True, adaptation = dict(out_channels=[256, 512, 1024, 2048], in_channels=[64, 128, 256, 512]), distill_losses=[ dict(type='NST', mode='feature', loss_weight=1.0), dict(type='Logits', mode='logits', lo...
_base_ = './kd_resnet18_resnet50_cifar100_equal.py' model = dict(adaptive=True, adaptation=dict(out_channels=[256, 512, 1024, 2048], in_channels=[64, 128, 256, 512]), distill_losses=[dict(type='NST', mode='feature', loss_weight=1.0), dict(type='Logits', mode='logits', loss_weight=1.0)])
# configs COMBINE_FACE_WEIGHT = 10 COMBINE_FEATURE_WEIGHT = 10 FEATURE_DETECT_MAX_CORNERS = 50 FEATURE_DETECT_QUALITY_LEVEL = 0.1 FEATURE_DETECT_MIN_DISTANCE = 10 FACE_DETECT_REJECT_LEVELS = 1.3 FACE_DETECT_LEVEL_WEIGHTS = 5 HAARCASCADE_PROFILEFACE = 'haarcascade_profileface.xml' HAARCASCADE_FRONTALFACE = 'haarcascade...
combine_face_weight = 10 combine_feature_weight = 10 feature_detect_max_corners = 50 feature_detect_quality_level = 0.1 feature_detect_min_distance = 10 face_detect_reject_levels = 1.3 face_detect_level_weights = 5 haarcascade_profileface = 'haarcascade_profileface.xml' haarcascade_frontalface = 'haarcascade_frontalfac...
n, m = [int(i) for i in input().split()] a = [["*" if (i + j) % 2 != 0 else "." for j in range(m)] for i in range(n)] for row in a: print(' '.join(row))
(n, m) = [int(i) for i in input().split()] a = [['*' if (i + j) % 2 != 0 else '.' for j in range(m)] for i in range(n)] for row in a: print(' '.join(row))
#! python3 print("Task 6.1") persons = { 'first_name': 'john', 'last_name' : 'dog', 'age' : '40', 'city' : 'chicago', } print('All information about person:') print(persons['first_name']) print(persons['last_name']) print(persons['age']) print(persons['city']) print("Task 6.2") persons = { '...
print('Task 6.1') persons = {'first_name': 'john', 'last_name': 'dog', 'age': '40', 'city': 'chicago'} print('All information about person:') print(persons['first_name']) print(persons['last_name']) print(persons['age']) print(persons['city']) print('Task 6.2') persons = {'john': '5', 'caty': '6', 'bob': '40', 'lance':...
def counting(): y = 1 while y<500: yield y #This is a great way to iterate through one number at a time. It will go forever if needed. y += 1 for y in counting(): print(y)
def counting(): y = 1 while y < 500: yield y y += 1 for y in counting(): print(y)
class StringCalculator: def __init__(self): self.string = '' self.list_of_numbers = [] self.delimiter = ',' def add(self, string_of_numbers): self.validate_input(string_of_numbers) self.process_delimiter() self.generate_list_of_numbers() retur...
class Stringcalculator: def __init__(self): self.string = '' self.list_of_numbers = [] self.delimiter = ',' def add(self, string_of_numbers): self.validate_input(string_of_numbers) self.process_delimiter() self.generate_list_of_numbers() return sum(self....
class Airplane: def __init__(self, x=0, y=0, gravity=2, jump=50): self.x = x self.y = y self.defaultX = x self.defaultY = y self.gravity = gravity self.jump = jump self.width = 60 self.height = 35 def init(self): self.x = self.defaultX ...
class Airplane: def __init__(self, x=0, y=0, gravity=2, jump=50): self.x = x self.y = y self.defaultX = x self.defaultY = y self.gravity = gravity self.jump = jump self.width = 60 self.height = 35 def init(self): self.x = self.defaultX ...
#!/usr/bin/env python3 def readint(): return int(input()) def readints(): return map(int, input().split()) def readline(): return str(input()) T = readint() for case in range(T): N = readint() if N == 0: result = "INSOMNIA" else: k = 0 s = set() while len(s) <...
def readint(): return int(input()) def readints(): return map(int, input().split()) def readline(): return str(input()) t = readint() for case in range(T): n = readint() if N == 0: result = 'INSOMNIA' else: k = 0 s = set() while len(s) < 10: s.update...
# Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. # Note: # The solution set must not contain duplicate triplets. # Example: # Given array nums = [-1, 0, 1, 2, -1, -4], # A solution set is: # [ # [-1...
class Solution: def three_sum(self, nums: List[int]) -> List[List[int]]: nums.sort() triplets = [] for i in range(len(nums) - 2): if i > 0 and nums[i] == nums[i - 1]: continue left_idx = i + 1 right_idx = len(nums) - 1 while le...
dias = int(input('Por quantos dias o carro ficou alugado? ')) km = float(input('Quantos quilometros o carro percorreu? ')) preco = (dias * 60) + (km * 0.15) print ('O valor a ser pago eh de R${:.2f}!'.format(preco))
dias = int(input('Por quantos dias o carro ficou alugado? ')) km = float(input('Quantos quilometros o carro percorreu? ')) preco = dias * 60 + km * 0.15 print('O valor a ser pago eh de R${:.2f}!'.format(preco))
# fisrt we get the number of people from the user people = input("enter number of guests \n") # we use the try methord to prevent the program from crashing if the user puts a string try: people = int(people) if(people > 0 and people <= 50): price = 4000 elif(people >50 and people <= 100): pr...
people = input('enter number of guests \n') try: people = int(people) if people > 0 and people <= 50: price = 4000 elif people > 50 and people <= 100: price = 10000 elif people > 100 and people <= 200: price = 15000 elif people > 200: price = 20000 print('${}'.for...
# coding: utf-8 class Person: number_of_people = 0 # Specific to the class GRAVITY = 9.8 # we define constants in the generic class def __init__(self, name): self.name = name Person.add_person() # Decorator @classmethod def number_of_people_(cls): return cls.nu...
class Person: number_of_people = 0 gravity = 9.8 def __init__(self, name): self.name = name Person.add_person() @classmethod def number_of_people_(cls): return cls.number_of_people @classmethod def add_person(cls): cls.number_of_people += 1 p1 = person('Tim...
seq=input() def SortList(sequence): k=0; list1=[] while k<len(sequence): num="" if sequence[k]!=" ": for j in range(k,len(sequence)): if sequence[k]!=" ": num+=sequence[k] k+=1 else: ...
seq = input() def sort_list(sequence): k = 0 list1 = [] while k < len(sequence): num = '' if sequence[k] != ' ': for j in range(k, len(sequence)): if sequence[k] != ' ': num += sequence[k] k += 1 else: ...
n = int(input()) for i in range(n): for j in range(i): print(' ', end="") for j in range((n - i) * 2 - 1): print('*', end="") print() for i in range (n - 1): for j in range(n - i - 2): print(' ', end="") for j in range((i + 1) * 2 + 1): print('*', end="") print()
n = int(input()) for i in range(n): for j in range(i): print(' ', end='') for j in range((n - i) * 2 - 1): print('*', end='') print() for i in range(n - 1): for j in range(n - i - 2): print(' ', end='') for j in range((i + 1) * 2 + 1): print('*', end='') print()
class Config: STATE_SHAPE = [84, 84, 3] SPEED = 20 # cm/step GOAL_DIRECTION_REWARD = 1 CRASH_REWARD = -10 SIM_DIR = '/home/mate/ucv-pkg-outdoor-8-lite/LinuxNoEditor/outdoor_lite/Binaries/Linux/' SIM_NAME = 'outdoor_lite' RANDOM_SPAWN_LOCATIONS = True MAP_X_MIN = -4000 MAP_X_MAX = ...
class Config: state_shape = [84, 84, 3] speed = 20 goal_direction_reward = 1 crash_reward = -10 sim_dir = '/home/mate/ucv-pkg-outdoor-8-lite/LinuxNoEditor/outdoor_lite/Binaries/Linux/' sim_name = 'outdoor_lite' random_spawn_locations = True map_x_min = -4000 map_x_max = 4000 map_...
class Rectangle: def __init__(self, width, height): self.width = width self.height = height def __str__(self): return "Rectangle(width=" + str(self.width) + \ ", height=" + str(self.height) + ")" def set_width(self, width): self.width = width def set_hei...
class Rectangle: def __init__(self, width, height): self.width = width self.height = height def __str__(self): return 'Rectangle(width=' + str(self.width) + ', height=' + str(self.height) + ')' def set_width(self, width): self.width = width def set_height(self, height...