content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
''' A 2d grid map of m rows and n columns is initially filled with water. We may perform an `addLand` operation which turns the water at position (row, col) into a land. Given a list of positions to operate, count the number of islands after each addLand operation. An island is surrounded by water and is formed by conn...
""" A 2d grid map of m rows and n columns is initially filled with water. We may perform an `addLand` operation which turns the water at position (row, col) into a land. Given a list of positions to operate, count the number of islands after each addLand operation. An island is surrounded by water and is formed by conn...
class ErrorsMixin: """Test for errors in corner case situations """ async def test_bad_authentication(self): request = await self.client.get( self.api_url('user'), headers=[('Authorization', 'bjchdbjshbcjd')] ) self.json(request.response, 400)
class Errorsmixin: """Test for errors in corner case situations """ async def test_bad_authentication(self): request = await self.client.get(self.api_url('user'), headers=[('Authorization', 'bjchdbjshbcjd')]) self.json(request.response, 400)
str1=str(input("Enter an unbalanced bracket sequence:")) op=0 #number of open brackets clo=0 #number of closed brackets #for calculating open and closed brackets for i in range(0,len(str1)): if (str1[i]=="("): op=op+1 if (str1[i]==")"): clo=clo+1 if (op==clo): x = "(" + str1 + "...
str1 = str(input('Enter an unbalanced bracket sequence:')) op = 0 clo = 0 for i in range(0, len(str1)): if str1[i] == '(': op = op + 1 if str1[i] == ')': clo = clo + 1 if op == clo: x = '(' + str1 + ')' stack = [] for i in range(0, len(x)): if x[i] == '(': stack.a...
def print_to_number(number): """ Prints to the number value passed in, beginning at 1""" for counter in range(1,number): print (counter) if __name__ == "__main__": print_to_number(5)
def print_to_number(number): """ Prints to the number value passed in, beginning at 1""" for counter in range(1, number): print(counter) if __name__ == '__main__': print_to_number(5)
""" @author: magician @date: 2019/12/19 @file: rm_element.py """ def remove_element(nums, val: int) -> int: """ remove_element :param nums: :param val: :return: """ num_list = [] for i in nums: if i != val: num_list.append(i) print(num_list) re...
""" @author: magician @date: 2019/12/19 @file: rm_element.py """ def remove_element(nums, val: int) -> int: """ remove_element :param nums: :param val: :return: """ num_list = [] for i in nums: if i != val: num_list.append(i) print(num_list) retur...
Rainbow = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet'] print("the first element of the list Rainbow is:",Rainbow[0]) print("The true colors of a rainbow are:") for i in range(len(Rainbow)): print(Rainbow[i]) #print all the elements in one line or one item per line. Here are two examples of th...
rainbow = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet'] print('the first element of the list Rainbow is:', Rainbow[0]) print('The true colors of a rainbow are:') for i in range(len(Rainbow)): print(Rainbow[i]) a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] print(a) for i in range(len(a)): print(a[i]) for...
#!/usr/bin/env python3 """ What is an anagram? Well, two words are anagrams of each other if they both contain the same letters. For example: 'abba' & 'baab' == true 'abba' & 'bbaa' == true 'abba' & 'abbba' == false 'abba' & 'abca' == false Write a function that will find all the anagrams of a word from a list. You ...
""" What is an anagram? Well, two words are anagrams of each other if they both contain the same letters. For example: 'abba' & 'baab' == true 'abba' & 'bbaa' == true 'abba' & 'abbba' == false 'abba' & 'abca' == false Write a function that will find all the anagrams of a word from a list. You will be given two input...
#This program shows how many birds there are in each state. def texas() -> None: '''function output how many birds Texas has''' bird = 5000 print("Texas has", bird, "birds") def california() -> None: '''function output how many birds California has''' bird = 8000 print("California has", bird...
def texas() -> None: """function output how many birds Texas has""" bird = 5000 print('Texas has', bird, 'birds') def california() -> None: """function output how many birds California has""" bird = 8000 print('California has', bird, 'birds') def main(): texas() california() if __name_...
# Figure A.6 ZIGZAG = ( 0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63 )
zigzag = (0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63)
class Person: def __init__(self, name: Name): self.name = name def test_barry_is_harry(): harry = Person(Name("Harry", "Percival")) barry = harry barry.name = Name("Barry", "Percival") assert harry is barry and barry is harry
class Person: def __init__(self, name: Name): self.name = name def test_barry_is_harry(): harry = person(name('Harry', 'Percival')) barry = harry barry.name = name('Barry', 'Percival') assert harry is barry and barry is harry
def eh_par(n): if n < 2: return '' if n % 2 != 0: n -= 1 print(n) return eh_par(n-2) x = int(input()) print(eh_par(x))
def eh_par(n): if n < 2: return '' if n % 2 != 0: n -= 1 print(n) return eh_par(n - 2) x = int(input()) print(eh_par(x))
# -*- coding: utf-8 -*- __author__ ='Charles Keith Brown' __email__ = 'charles.k.brown@gmail.com' __version__ = '0.1.1'
__author__ = 'Charles Keith Brown' __email__ = 'charles.k.brown@gmail.com' __version__ = '0.1.1'
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ seen = {} b...
class Solution(object): def length_of_longest_substring(self, s): """ :type s: str :rtype: int """ seen = {} begin_ptr = 0 max_len = 0 for (i, v) in enumerate(s): last_seen = seen.get(v, None) if last_seen != None and last_seen...
WOQL_IDGEN_JSON = { "@type": "woql:IDGenerator", "woql:base": { "@type": "woql:Datatype", "woql:datatype": {"@type": "xsd:string", "@value": "doc:Station"}, }, "woql:key_list": { "@type": "woql:Array", "woql:array_element": [ { "@type": "woql:A...
woql_idgen_json = {'@type': 'woql:IDGenerator', 'woql:base': {'@type': 'woql:Datatype', 'woql:datatype': {'@type': 'xsd:string', '@value': 'doc:Station'}}, 'woql:key_list': {'@type': 'woql:Array', 'woql:array_element': [{'@type': 'woql:ArrayElement', 'woql:index': {'@type': 'xsd:nonNegativeInteger', '@value': 1 - 1}, '...
# # @lc app=leetcode.cn id=1632 lang=python3 # # [1632] number-of-good-ways-to-split-a-string # None # @lc code=end
None
# Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # Path where remote_file_reader should be installed on the device. REMOTE_FILE_READER_DEVICE_PATH = '/data/local/tmp/remote_file_reader' # Path where remote...
remote_file_reader_device_path = '/data/local/tmp/remote_file_reader' remote_file_reader_cloud_path = 'gs://mojo/devtools/remote_file_reader'
def setup(): pass def draw(): fill(255, 0, 0) ellipse(mouseX, mouseY, 20, 20)
def setup(): pass def draw(): fill(255, 0, 0) ellipse(mouseX, mouseY, 20, 20)
class ValidationError(Exception): """ Error in validation stage """ pass _CODE_TO_DESCRIPTIONS = { -1: ( 'EINTERNAL', ( 'An internal error has occurred. Please submit a bug report, ' 'detailing the exact circumstances in which this error occurred' ) ...
class Validationerror(Exception): """ Error in validation stage """ pass _code_to_descriptions = {-1: ('EINTERNAL', 'An internal error has occurred. Please submit a bug report, detailing the exact circumstances in which this error occurred'), -2: ('EARGS', 'You have passed invalid arguments to this comm...
#!/usr/bin/env python # -*- coding: utf-8 -*- class CacheDecorator: def __init__(self): self.cache = {} self.func = None def cachedFunc(self, *args): if args not in self.cache: print("Ergebnis berechnet") self.cache[args] = self.func(*args) else:...
class Cachedecorator: def __init__(self): self.cache = {} self.func = None def cached_func(self, *args): if args not in self.cache: print('Ergebnis berechnet') self.cache[args] = self.func(*args) else: print('Ergebnis geladen') return...
def MA(series, period=5): """Calculate moving average with period 5 as default """ i = 0 moving_averages = [] while i < len(numbers) - period + 1: this_window = numbers[i: i + period] window_average = sum(this_window) / period moving_averages.append(window_average) i += 1 return ...
def ma(series, period=5): """Calculate moving average with period 5 as default """ i = 0 moving_averages = [] while i < len(numbers) - period + 1: this_window = numbers[i:i + period] window_average = sum(this_window) / period moving_averages.append(window_average) i += 1 return m...
#!/usr/bin/env python3 def gen_repr(obj, **kwargs): fields = ', '.join([ f'{key}={value}' for key, value in dict(obj.__dict__, **kwargs).items() ]) return f'{obj.__class__.__name__}({fields})' def __repr__(self): return gen_repr(self)
def gen_repr(obj, **kwargs): fields = ', '.join([f'{key}={value}' for (key, value) in dict(obj.__dict__, **kwargs).items()]) return f'{obj.__class__.__name__}({fields})' def __repr__(self): return gen_repr(self)
# -*- coding: utf-8 -*- # # Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved # """ Authors: liyuncong(liyuncong@baidu.com) Date: 2020/5/25 14:54 """
""" Authors: liyuncong(liyuncong@baidu.com) Date: 2020/5/25 14:54 """
# Challenge 58, intermediate # https://www.reddit.com/r/dailyprogrammer/comments/u8jn9/5282012_challenge_58_intermediate/ # Take an input number and return next palindrome # f(808) = 818 # f(999) = 1001 -- need to take char length increases into account # f(2133) = 2222 # what is f(3 ^ 39)? # what is f(7 ^ 100)? # B...
def p(input_number): if len(str(input_number)) % 2 == 0: number = str(input_number) front_half = number[:int(len(number) / 2)] new_palindrome = int(front_half + front_half[::-1]) if new_palindrome <= int(number): new_front = str(int(front_half) + 1) if len(new...
__all__ = [ 'MongoengineMigrateError', 'MigrationGraphError', 'ActionError', 'SchemaError', 'MigrationError', 'InconsistencyError' ] class MongoengineMigrateError(Exception): """Generic error""" class MigrationGraphError(MongoengineMigrateError): """Error related to migration modules...
__all__ = ['MongoengineMigrateError', 'MigrationGraphError', 'ActionError', 'SchemaError', 'MigrationError', 'InconsistencyError'] class Mongoenginemigrateerror(Exception): """Generic error""" class Migrationgrapherror(MongoengineMigrateError): """Error related to migration modules names, dependencies, etc.""...
#!/usr/bin/python # test 1: seed top level, no MIP map command += testtex_command (parent + " -res 256 256 -d uint8 -o out1.tif --testicwrite 1 blah") # test 2: seed top level, automip command += testtex_command (parent + " -res 256 256 -d uint8 -o out2.tif --testicwrite 1 --automip blah") # test 3: procedural MIP m...
command += testtex_command(parent + ' -res 256 256 -d uint8 -o out1.tif --testicwrite 1 blah') command += testtex_command(parent + ' -res 256 256 -d uint8 -o out2.tif --testicwrite 1 --automip blah') command += testtex_command(parent + ' -res 256 256 -d uint8 -o out3.tif --testicwrite 2 blah') command += testtex_comman...
# --- internal paths --- # mimic_root_dir = '/cluster/work/grlab/clinical/mimic/MIMIC-III/cdb_1.4/' root_dir = '/cluster/work/grlab/clinical/Inselspital/DataReleases/01-19-2017/InselSpital/' # --- all about mimic --- # source_data = mimic_root_dir + 'source_data/' derived = mimic_root_dir + 'derived_stephanie/' charte...
mimic_root_dir = '/cluster/work/grlab/clinical/mimic/MIMIC-III/cdb_1.4/' root_dir = '/cluster/work/grlab/clinical/Inselspital/DataReleases/01-19-2017/InselSpital/' source_data = mimic_root_dir + 'source_data/' derived = mimic_root_dir + 'derived_stephanie/' chartevents_path = source_data + 'CHARTEVENTS.csv' labevents_p...
"""Functionality related to interactions between DIT and companies.""" INTERACTION_EMAIL_INGESTION_FEATURE_FLAG_NAME = 'interaction-email-ingestion' INTERACTION_EMAIL_NOTIFICATION_FEATURE_FLAG_NAME = 'interaction-email-notification' MAILBOX_INGESTION_FEATURE_FLAG_NAME = 'mailbox-ingestion' MAILBOX_NOTIFICATION_FEATUR...
"""Functionality related to interactions between DIT and companies.""" interaction_email_ingestion_feature_flag_name = 'interaction-email-ingestion' interaction_email_notification_feature_flag_name = 'interaction-email-notification' mailbox_ingestion_feature_flag_name = 'mailbox-ingestion' mailbox_notification_feature_...
class CompositorNodeZcombine: use_alpha = None use_antialias_z = None def update(self): pass
class Compositornodezcombine: use_alpha = None use_antialias_z = None def update(self): pass
def tetra(n): t = (n * (n + 1) * (n + 2)) / 6 return t print(tetra(5))
def tetra(n): t = n * (n + 1) * (n + 2) / 6 return t print(tetra(5))
class Platform(object): def __init__(self, id=None, name=None, slug=None, napalm_driver=None, rpc_client=None): self.id = id self.name = name self.slug = slug self.napalm_driver = napalm_driver self.rpc_client = rpc_client @classmethod def from_dict(cls, contents): ...
class Platform(object): def __init__(self, id=None, name=None, slug=None, napalm_driver=None, rpc_client=None): self.id = id self.name = name self.slug = slug self.napalm_driver = napalm_driver self.rpc_client = rpc_client @classmethod def from_dict(cls, contents): ...
class Solution(object): def combine(self, n, k): ans = [] def dfs(list_start, list_end, k, start, depth, curr, ans): if depth == k: ans.append(curr[::]) for i in range(start, list_end): curr.append(list_start+i) ...
class Solution(object): def combine(self, n, k): ans = [] def dfs(list_start, list_end, k, start, depth, curr, ans): if depth == k: ans.append(curr[:]) for i in range(start, list_end): curr.append(list_start + i) dfs(list_star...
def getDimensions(tf): X = tf.constant([1, 0]) Y = tf.constant([0, 1]) BOTH = tf.constant([1, 1]) return X, Y, BOTH def compute_centroid(tf, points): # points {[2, ?]} tensor of float_64 """Computes the centroid of the points.""" return tf.reduce_mean(points, 0) def move_to_center(tf, poi...
def get_dimensions(tf): x = tf.constant([1, 0]) y = tf.constant([0, 1]) both = tf.constant([1, 1]) return (X, Y, BOTH) def compute_centroid(tf, points): """Computes the centroid of the points.""" return tf.reduce_mean(points, 0) def move_to_center(tf, points, centroid=None): """moves the l...
# -*- coding: utf-8 -*- qte = int(input()) lista = {} for i in range(qte): v = int(input()) if(v in lista): lista[v] += 1 else: lista[v] = 1 chaves = lista.keys() chaves = sorted(chaves) for k in chaves: print("{} aparece {} vez(es)".format(k,lista[k]))
qte = int(input()) lista = {} for i in range(qte): v = int(input()) if v in lista: lista[v] += 1 else: lista[v] = 1 chaves = lista.keys() chaves = sorted(chaves) for k in chaves: print('{} aparece {} vez(es)'.format(k, lista[k]))
ES_HOST = 'localhost:9200' ES_INDEX = 'pending-mrcoc' ES_DOC_TYPE = 'cooccurence' API_PREFIX = 'mrcoc' API_VERSION = ''
es_host = 'localhost:9200' es_index = 'pending-mrcoc' es_doc_type = 'cooccurence' api_prefix = 'mrcoc' api_version = ''
DEBUG = True SECRET_KEY = 'no' SQLALCHEMY_DATABASE_URI = 'sqlite:///master.sqlite3' CELERY_BROKER_URL = 'amqp://guest:guest@localhost:5672//' GITHUB_CLIENT_ID = 'da79a6b5868e690ab984' GITHUB_CLIENT_SECRET = '1701d3bd20bbb29012592fd3a9c64b827e0682d6' ALLOWED_EXTENSIONS = set(['csv', 'tsv', 'ods', 'xls', 'xlsx', 'txt']...
debug = True secret_key = 'no' sqlalchemy_database_uri = 'sqlite:///master.sqlite3' celery_broker_url = 'amqp://guest:guest@localhost:5672//' github_client_id = 'da79a6b5868e690ab984' github_client_secret = '1701d3bd20bbb29012592fd3a9c64b827e0682d6' allowed_extensions = set(['csv', 'tsv', 'ods', 'xls', 'xlsx', 'txt'])
dict = {'a': 1, 'b': 2} list = [1,2,3] str = 'hh' num = 123 num2 = 0.4 class Test: def test(self): print("gg") t = Test() print(type(dict)) print(type(list)) print(type(str)) print(type(num)) print(type(num2)) print(type(Test)) print(type(t))
dict = {'a': 1, 'b': 2} list = [1, 2, 3] str = 'hh' num = 123 num2 = 0.4 class Test: def test(self): print('gg') t = test() print(type(dict)) print(type(list)) print(type(str)) print(type(num)) print(type(num2)) print(type(Test)) print(type(t))
# -*- coding: utf-8 -*- description = "Denex detector setup" group = "optional" includes = ["det_common"] excludes = ["det2"] tango_base = "tango://phys.maria.frm2:10000/maria/" devices = dict( detimg = device("nicos.devices.tango.ImageChannel", description = "Denex detector image", tangodevice ...
description = 'Denex detector setup' group = 'optional' includes = ['det_common'] excludes = ['det2'] tango_base = 'tango://phys.maria.frm2:10000/maria/' devices = dict(detimg=device('nicos.devices.tango.ImageChannel', description='Denex detector image', tangodevice=tango_base + 'fastcomtec/detector', fmtstr='%d cts', ...
""" the only requirements of a CAPTCHA module is that it's generate function returns a tuple of (challenge, solution) strings and that it takes one argument -- the modifiers (if there are any) the challenge string should be a data URI https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs prototypic...
""" the only requirements of a CAPTCHA module is that it's generate function returns a tuple of (challenge, solution) strings and that it takes one argument -- the modifiers (if there are any) the challenge string should be a data URI https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs prototypic...
class Solution: chars = [None, None, "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"] def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ if len(digits) == 0: return [] if len(digits) == 1: return list(self.chars[int(digits)]) cs, co = self.chars[in...
class Solution: chars = [None, None, 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz'] def letter_combinations(self, digits): """ :type digits: str :rtype: List[str] """ if len(digits) == 0: return [] if len(digits) == 1: return list(self.chars[int(...
n = int(input()) a = list(map(int, input().split(" "))) a.sort() for i in range(1, len(a)): a[i] += a[i - 1] print(sum(a))
n = int(input()) a = list(map(int, input().split(' '))) a.sort() for i in range(1, len(a)): a[i] += a[i - 1] print(sum(a))
# arr[i] may be present at arr[i+1] or arr[i-1]. # TC: O(log(N)) | SC: O(1) def search(nums, key): start = 0 end = len(nums)-1 while start <= end: mid = start+((end-start)//2) if nums[mid] == key: return mid if mid < len(nums)-1 and nums[mid+1] == key: re...
def search(nums, key): start = 0 end = len(nums) - 1 while start <= end: mid = start + (end - start) // 2 if nums[mid] == key: return mid if mid < len(nums) - 1 and nums[mid + 1] == key: return mid + 1 if mid > 0 and nums[mid - 1] == key: r...
expected_output = { "version": { "bootldr": "System Bootstrap, Version 17.5.2r, RELEASE SOFTWARE (P)", "build_label": "BLD_POLARIS_DEV_LATEST_20210302_012043", "chassis": "C9300-24P", "chassis_sn": "FCW2223G0B9", "compiled_by": "mcpre", "compiled_date": "Tue 02-Mar-21...
expected_output = {'version': {'bootldr': 'System Bootstrap, Version 17.5.2r, RELEASE SOFTWARE (P)', 'build_label': 'BLD_POLARIS_DEV_LATEST_20210302_012043', 'chassis': 'C9300-24P', 'chassis_sn': 'FCW2223G0B9', 'compiled_by': 'mcpre', 'compiled_date': 'Tue 02-Mar-21 00:07', 'copyright_years': '1986-2021', 'location': '...
user_number = input("Please enter your digit : ") total = 0 for i in range(1, 5): number = user_number * i total = total + int(number) print(total)
user_number = input('Please enter your digit : ') total = 0 for i in range(1, 5): number = user_number * i total = total + int(number) print(total)
primary_separator = '\n' secondary_separator = ',' default_filename_classification = 'tests/test_classification.data' dafault_filename_regression = 'tests/test_regression.data' def load_data(data, isfile=True): if isfile: with open(data) as data_file: data_set = data_file.read() else: ...
primary_separator = '\n' secondary_separator = ',' default_filename_classification = 'tests/test_classification.data' dafault_filename_regression = 'tests/test_regression.data' def load_data(data, isfile=True): if isfile: with open(data) as data_file: data_set = data_file.read() else: ...
def getColors(color): colors=set() if color not in inverseRules.keys(): return colors for c in inverseRules[color]: colors.add(c) colors.update(getColors(c)) return(colors) with open('day7/input.txt') as f: rules=dict([l.split(' contain') for l in f.read().replace(' bags', '...
def get_colors(color): colors = set() if color not in inverseRules.keys(): return colors for c in inverseRules[color]: colors.add(c) colors.update(get_colors(c)) return colors with open('day7/input.txt') as f: rules = dict([l.split(' contain') for l in f.read().replace(' bags...
# fig06_01.py """Using a dictionary to represent an instructor's grade book.""" grade_book = { 'Susan' : [92,85,100], 'Eduardo' : [83,95,79], 'Azizi': [91,89,82], 'Pantipa': [97,91,92] } all_grades_total = 0 all_grades_count = 0 for name, grades in grade_book.items(): total = sum(grades) print...
"""Using a dictionary to represent an instructor's grade book.""" grade_book = {'Susan': [92, 85, 100], 'Eduardo': [83, 95, 79], 'Azizi': [91, 89, 82], 'Pantipa': [97, 91, 92]} all_grades_total = 0 all_grades_count = 0 for (name, grades) in grade_book.items(): total = sum(grades) print(f'Average for {name} is {...
# # PySNMP MIB module OMNI-gx2Dm200-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OMNI-gx2Dm200-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:33:11 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection, constraints_union) ...
mybooltr= True #We declare the mybooltrue equal to True myboolfa= False #We declare the myboolfalse equal to False print(mybooltr == myboolfa) #It will print false because my mybooltr doesnt equal to myboolfa print(mybooltr != myboolfa) #it will print true for the same reason print(2 == 3) #It will print fals...
mybooltr = True myboolfa = False print(mybooltr == myboolfa) print(mybooltr != myboolfa) print(2 == 3) print(7 > 7.0) print(9 >= 9.0)
# # @lc app=leetcode id=717 lang=python # # [717] 1-bit and 2-bit Characters # # https://leetcode.com/problems/1-bit-and-2-bit-characters/description/ # # algorithms # Easy (49.25%) # Likes: 278 # Dislikes: 705 # Total Accepted: 44.9K # Total Submissions: 91.1K # Testcase Example: '[1,0,0]' # # We have two speci...
class Solution(object): def is_one_bit_character(self, bits): """ :type bits: List[int] :rtype: bool """ index = 0 while index < len(bits) - 1: if bits[index] == 1: index += 2 else: index += 1 return ind...
# Databricks notebook source # MAGIC %scala # MAGIC spark.conf.set("com.databricks.training.module_name", "Sensor_IoT") # MAGIC val dbNamePrefix = { # MAGIC val tags = com.databricks.logging.AttributionContext.current.tags # MAGIC val name = tags.getOrElse(com.databricks.logging.BaseTagDefinitions.TAG_USER, java.ut...
database_name = spark.conf.get('com.databricks.training.spark.dbName') user_name = spark.conf.get('com.databricks.training.spark.userName').replace('.', '_') display_html('User name is <b style="color:green">{}</b>.'.format(userName)) spark.sql('CREATE DATABASE IF NOT EXISTS {}'.format(databaseName)) spark.sql('USE {}'...
# from https://gist.github.com/jalavik/976294 # original XML at http://www.w3.org/Math/characters/unicode.xml # XSL for conversion: https://gist.github.com/798546 unicode_to_latex = { u"\u0020": "\\space ", u"\u0023": "\\#", u"\u0024": "\\textdollar ", u"\u0025": "\\%", u"\u0026": "\\&amp;", u...
unicode_to_latex = {u' ': '\\space ', u'#': '\\#', u'$': '\\textdollar ', u'%': '\\%', u'&': '\\&amp;', u"'": '\\textquotesingle ', u'*': '\\ast ', u'\\': '\\textbackslash ', u'^': '\\^{}', u'_': '\\_', u'`': '\\textasciigrave ', u'{': '\\lbrace ', u'|': '\\vert ', u'}': '\\rbrace ', u'~': '\\textasciitilde ', u'¡': '\...
# 445. Add Two Numbers II ''' You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, exce...
""" You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. I...
# If T-Rex is angry, hungry, and bored he will eat the Triceratops # Otherwise if T-Rex is tired and hungry, he will eat the Iguanadon # Otherwise if T-Rex is hungry and bored, he will eat the Stegasaurus. # Otherwise if T-Rex is tired, he goes to sleep # Otherwise if T-Rex is angry and bored, he will fight with the Ve...
angry = True bored = True hungry = False tired = False if angry and hungry and bored: print('T-Rex eats the Triceratops!') elif tired and hungry: print('T-Rex eats the Iguanadon') elif hungry and bored: print('T-Rex eats the Stegasaurus') elif tired: print('T-Rex goes to sleep.') elif angry and bored: ...
# Gamemode Utilities def get_gamemode_name(id): if (id is 0): return "Conquest" if (id is 1): return "Domination" if (id is 2): return "Team Deathmatch" if (id is 3): return "Zombies" if (id is 4): return "Disarm"
def get_gamemode_name(id): if id is 0: return 'Conquest' if id is 1: return 'Domination' if id is 2: return 'Team Deathmatch' if id is 3: return 'Zombies' if id is 4: return 'Disarm'
#: Mapping of files from unihan-etl (UNIHAN database) UNIHAN_FILES = [ 'Unihan_DictionaryLikeData.txt', 'Unihan_IRGSources.txt', 'Unihan_NumericValues.txt', 'Unihan_RadicalStrokeCounts.txt', 'Unihan_Readings.txt', 'Unihan_Variants.txt', ] #: Mapping of field names from unihan-etl (UNIHAN datab...
unihan_files = ['Unihan_DictionaryLikeData.txt', 'Unihan_IRGSources.txt', 'Unihan_NumericValues.txt', 'Unihan_RadicalStrokeCounts.txt', 'Unihan_Readings.txt', 'Unihan_Variants.txt'] unihan_fields = ['kAccountingNumeric', 'kCangjie', 'kCantonese', 'kCheungBauer', 'kCihaiT', 'kCompatibilityVariant', 'kDefinition', 'kFenn...
"""This is python equivalent of Wrapping/Tcl/vtktesting/mccases.tcl. Used for setting vertex values for clipping, cutting, and contouring tests. This script is used while running python tests translated from Tcl.""" def case1 ( scalars, IN, OUT, caseLabel ): scalars.InsertValue(0,IN ) scalars.InsertValue...
"""This is python equivalent of Wrapping/Tcl/vtktesting/mccases.tcl. Used for setting vertex values for clipping, cutting, and contouring tests. This script is used while running python tests translated from Tcl.""" def case1(scalars, IN, OUT, caseLabel): scalars.InsertValue(0, IN) scalars.InsertValue(1, OUT) ...
def is_email_valid(email): if not '@' in email: return False name, domain = email.split('@', 1) if not name: return False return '.' in domain
def is_email_valid(email): if not '@' in email: return False (name, domain) = email.split('@', 1) if not name: return False return '.' in domain
class Solution: """ @param str: An array of char @param offset: An integer @return: nothing """ def rotateString(self, str, offset): ''' abcdefg dcba gfe efgabcd ''' n = len(str) if n == 0: return offset %= n s...
class Solution: """ @param str: An array of char @param offset: An integer @return: nothing """ def rotate_string(self, str, offset): """ abcdefg dcba gfe efgabcd """ n = len(str) if n == 0: return offset %= n ...
''' Doctor's Secret Cheeku is ill. He goes to Homeopathic Doctor - Dr. Thind. Doctor always recommends medicines after reading from a secret book that he has. This secret book has recipe to cure any disease. Cheeku is chalak. He wants to know if Doctor is giving him correct medicine or not. So he asks Doctor 2 quest...
""" Doctor's Secret Cheeku is ill. He goes to Homeopathic Doctor - Dr. Thind. Doctor always recommends medicines after reading from a secret book that he has. This secret book has recipe to cure any disease. Cheeku is chalak. He wants to know if Doctor is giving him correct medicine or not. So he asks Doctor 2 quest...
# Copyright 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Content public presubmit script See https://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for more details about the presubmit API bui...
"""Content public presubmit script See https://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for more details about the presubmit API built into gcl. """ def __check_const_interfaces(input_api, output_api): pattern = input_api.re.compile('virtual[^;]*const\\s*(=\\s*0)?\\s*({}|;)', input_api.re....
# This file holds metadata about the project. It should import only from # standard library modules (this includes not importing other modules in the # package) so that it can be loaded by setup.py before dependencies are # installed. source = "https://github.com/wikimedia/wmfdata-python" version = "1.3.3"
source = 'https://github.com/wikimedia/wmfdata-python' version = '1.3.3'
''' Pattern Enter number of rows: 5 54321 4321 321 21 1 ''' print('number pattern: ') number_rows=int(input('Enter number of rows: ')) for row in range(number_rows,0,-1): for column in range(row,0,-1): if column < 10: print(f'0{column}',end=' ') else: print(column,end=' ') print()
""" Pattern Enter number of rows: 5 54321 4321 321 21 1 """ print('number pattern: ') number_rows = int(input('Enter number of rows: ')) for row in range(number_rows, 0, -1): for column in range(row, 0, -1): if column < 10: print(f'0{column}', end=' ') else: print(column, end...
class Solution: def threeSum(self, nums): arr = [] map = {nums[i]: i for i in range(len(nums))} if (len(list(map.keys())) == 1 and nums[0] == 0 and len(nums) > 3): return [[0]*3] for m in range(len(nums)-1): for n in range(m+1, len(nums)): targ...
class Solution: def three_sum(self, nums): arr = [] map = {nums[i]: i for i in range(len(nums))} if len(list(map.keys())) == 1 and nums[0] == 0 and (len(nums) > 3): return [[0] * 3] for m in range(len(nums) - 1): for n in range(m + 1, len(nums)): ...
class Solution: def projectionArea(self, grid): """ :type grid: List[List[int]] :rtype: int """ M, N = len(grid), len(grid[0]) rowMax, colMax = [0] * M, [0] * N xy = sum(0 if grid[i][j] == 0 else 1 for i in range(M) for j in range(N)) xz = sum(list(map...
class Solution: def projection_area(self, grid): """ :type grid: List[List[int]] :rtype: int """ (m, n) = (len(grid), len(grid[0])) (row_max, col_max) = ([0] * M, [0] * N) xy = sum((0 if grid[i][j] == 0 else 1 for i in range(M) for j in range(N))) xz ...
class C(): pass # a really complex class class D(C, B): pass
class C: pass class D(C, B): pass
num = 353 reverse_num = 0 temp = num # print(num,reverse_num) while(temp != 0): remainder = int(temp % 10) print(remainder) reverse_num = int((reverse_num*10) + remainder) print(reverse_num) temp = int(temp / 10) # print(reverse_num) if reverse_num == num: print('It is Palindrome') else: p...
num = 353 reverse_num = 0 temp = num while temp != 0: remainder = int(temp % 10) print(remainder) reverse_num = int(reverse_num * 10 + remainder) print(reverse_num) temp = int(temp / 10) if reverse_num == num: print('It is Palindrome') else: print('not Palindrome')
# # Solution to Project Euler problem 6 # Copyright (c) Project Nayuki. All rights reserved. # # https://www.nayuki.io/page/project-euler-solutions # https://github.com/nayuki/Project-Euler-solutions # # Computers are fast, so we can implement this solution directly without any clever math. # However for the mathe...
def compute(): n = 100 s = sum((i for i in range(1, N + 1))) s2 = sum((i ** 2 for i in range(1, N + 1))) return str(s ** 2 - s2) if __name__ == '__main__': print(compute())
"""Globally defined and used variables for the JWQL query anomaly feature. Variables will be re-defined when anomaly query forms are submitted. Authors ------- - Teagan King Use --- This variables within this module are intended to be directly imported, e.g.: :: from jwql.utils.query_config...
"""Globally defined and used variables for the JWQL query anomaly feature. Variables will be re-defined when anomaly query forms are submitted. Authors ------- - Teagan King Use --- This variables within this module are intended to be directly imported, e.g.: :: from jwql.utils.query_config...
with open("sonar.txt") as sonar: depthstr = sonar.readline() previous = int(depthstr.strip()) increases = 0 for depthstr in sonar.readlines(): depth = int(depthstr.strip()) if depth > previous: increases += 1 previous = depth print(increases)
with open('sonar.txt') as sonar: depthstr = sonar.readline() previous = int(depthstr.strip()) increases = 0 for depthstr in sonar.readlines(): depth = int(depthstr.strip()) if depth > previous: increases += 1 previous = depth print(increases)
class Solution: def validPalindrome(self, s: str) -> bool: if s == s[::-1]: return True left, right = 0 , len(s)-1 s = list(s) while left < right: if s[left] != s[right]: s_l = s[left+1:right+1] s_r = s[left:ri...
class Solution: def valid_palindrome(self, s: str) -> bool: if s == s[::-1]: return True (left, right) = (0, len(s) - 1) s = list(s) while left < right: if s[left] != s[right]: s_l = s[left + 1:right + 1] s_r = s[left:right] ...
""" Null object for Telegram bot """ class BotNull: def __init__(self, logger): self.logger = logger def sendMessage(self, chat_id, text): self.logger.info("Skipping Telegram since no configuration was found")
""" Null object for Telegram bot """ class Botnull: def __init__(self, logger): self.logger = logger def send_message(self, chat_id, text): self.logger.info('Skipping Telegram since no configuration was found')
""" Simple Python's Tornado wrapper which provides helpers for creating a new project, writing management commands, service processes, ... """ __version__ = '2.1.2'
""" Simple Python's Tornado wrapper which provides helpers for creating a new project, writing management commands, service processes, ... """ __version__ = '2.1.2'
""" Container for macros to fix proto files. """ load("@rules_proto//proto:defs.bzl", "proto_library") def format_import_proto_library(name, src, deps): """ Creates a new proto library with corrected imports. This macro exists as a way to build proto files that contain import statements in both Gradle ...
""" Container for macros to fix proto files. """ load('@rules_proto//proto:defs.bzl', 'proto_library') def format_import_proto_library(name, src, deps): """ Creates a new proto library with corrected imports. This macro exists as a way to build proto files that contain import statements in both Gradle ...
#coding:utf-8 ''' filename:custom_exception.py judge the number of age is even or odd ''' class NegativeAgeException(RuntimeError): def __init__(self,age): super().__init__() self.age = age def enterage(age): if age<0: raise NegativeAgeException('Only *POSITIVE* integers ar...
""" filename:custom_exception.py judge the number of age is even or odd """ class Negativeageexception(RuntimeError): def __init__(self, age): super().__init__() self.age = age def enterage(age): if age < 0: raise negative_age_exception('Only *POSITIVE* integers are allowed') ...
def getExtensionObjectFromString(strExtension): try: assetID,tempData=strExtension.split("$") itemVER, tempData=tempData.split("@") itemID,tempData=tempData.split(";") return extensions(assetID,itemVER,itemID,tempData) except: return None class extensions...
def get_extension_object_from_string(strExtension): try: (asset_id, temp_data) = strExtension.split('$') (item_ver, temp_data) = tempData.split('@') (item_id, temp_data) = tempData.split(';') return extensions(assetID, itemVER, itemID, tempData) except: return None class...
# encoding: utf-8 # Copyright 2017 Virgil Dupras # This software is licensed under the "BSD" License as described in the "LICENSE" file, # which should be included with this package. The terms are also available at # http://www.hardcoded.net/licenses/bsd_license def preprocess_paths(paths): if not isinstance(pat...
def preprocess_paths(paths): if not isinstance(paths, list): paths = [paths] paths = [path.__fspath__() if hasattr(path, '__fspath__') else path for path in paths] return paths
number = int(input()) salaperhour = int(input()) valorperhour = float(input()) print("NUMBER = {}".format(number)) print('SALARY = U$ {:.2f}'.format(salaperhour * valorperhour))
number = int(input()) salaperhour = int(input()) valorperhour = float(input()) print('NUMBER = {}'.format(number)) print('SALARY = U$ {:.2f}'.format(salaperhour * valorperhour))
# # PySNMP MIB module CISCO-LWAPP-DOT11-CLIENT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-LWAPP-DOT11-CLIENT-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:05:02 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python vers...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, value_size_constraint, constraints_intersection, single_value_constraint) ...
''' pyleaves/pyleaves/trainers/__init__.py trainers submodule of the pyleaves package contains trainer subclasses for use in pyleaves for assembling and executing full experiments. e.g. data preprocessing -> data loading -> model training -> model testing '''
""" pyleaves/pyleaves/trainers/__init__.py trainers submodule of the pyleaves package contains trainer subclasses for use in pyleaves for assembling and executing full experiments. e.g. data preprocessing -> data loading -> model training -> model testing """
# n = int(input()) # for i in range(n): # print("*"*i) # n = int(input()) # i = n # while i >=0: # print("*"*i) # i -= 1 # n = int(input()) # i = 0 # j = n # while i <=n: # print(" "*j+"*"*i) # i += 1 # j -= 1 # n = int(input()) # i = n # j = 0 # while i >=0: # p...
n = int(input()) i = n j = 0 while i >= 0: print(' ' * j + '*' * i) i -= 2 j += 1
# Space: O(n) # Time: O(n) class RecentCounter: def __init__(self): self.data = [] self.count = 0 def ping(self, t: int) -> int: self.data.append(t) self.count += 1 while self.data[0] < max(0, t - 3000): self.data.pop(0) self.count -= 1 ...
class Recentcounter: def __init__(self): self.data = [] self.count = 0 def ping(self, t: int) -> int: self.data.append(t) self.count += 1 while self.data[0] < max(0, t - 3000): self.data.pop(0) self.count -= 1 return self.count
languages = [] languages.append("Java") languages.append("Python") languages.append("C#") languages.append("Ruby") print(languages) numbers = [1, 2, 3] imdb_top_3 = [ "The Shawshank Redemption", "The Godfather", "The Godfather: Part II" ] print(imdb_top_3) empty = [] mixed = [1, True, "Three", [], Non...
languages = [] languages.append('Java') languages.append('Python') languages.append('C#') languages.append('Ruby') print(languages) numbers = [1, 2, 3] imdb_top_3 = ['The Shawshank Redemption', 'The Godfather', 'The Godfather: Part II'] print(imdb_top_3) empty = [] mixed = [1, True, 'Three', [], None] print(mixed) if l...
""" Client stub for connecting to file operations server. Any Windows client (controller) abstractions should go here. """
""" Client stub for connecting to file operations server. Any Windows client (controller) abstractions should go here. """
class Solution: def reorganizeString(self, S: str) -> str: """Heap. Running time:O(nlogn) where n is the length of S. """ c = collections.Counter(S) heap = [(-v, k) for k, v in c.items()] heapq.heapify(heap) res = '' while heap: v, k = hea...
class Solution: def reorganize_string(self, S: str) -> str: """Heap. Running time:O(nlogn) where n is the length of S. """ c = collections.Counter(S) heap = [(-v, k) for (k, v) in c.items()] heapq.heapify(heap) res = '' while heap: (v, k)...
# Datasets FACE_FORENSICS = 'ff++' FACE_FORENSICS_DF = 'ff++_df' FACE_FORENSICS_F2F = 'ff++_f2f' FACE_FORENSICS_FSW = 'ff++_fsw' FACE_FORENSICS_NT = 'ff++_nt' FACE_FORENSICS_FSH = 'ff++_fsh' CELEB_DF = 'celeb-df' DEEPER_FORENSICS = 'deeperface' DFDC = 'dfdc' # Manipulation type of FaceForensics++ DF = 'Deepfakes' F2F ...
face_forensics = 'ff++' face_forensics_df = 'ff++_df' face_forensics_f2_f = 'ff++_f2f' face_forensics_fsw = 'ff++_fsw' face_forensics_nt = 'ff++_nt' face_forensics_fsh = 'ff++_fsh' celeb_df = 'celeb-df' deeper_forensics = 'deeperface' dfdc = 'dfdc' df = 'Deepfakes' f2_f = 'Face2Face' fsh = 'FaceShifter' fsw = 'FaceSwap...
""" Copyright 2019 Skyscanner Ltd 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 http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
""" Copyright 2019 Skyscanner Ltd 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 http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
def test_input_text(expected_result, actual_result): assert expected_result == actual_result, \ "expected {}, got {}".format(expected_result, actual_result) def main(): test_input_text(8, 8) test_input_text(8, 11) if __name__ == "__main__": main()
def test_input_text(expected_result, actual_result): assert expected_result == actual_result, 'expected {}, got {}'.format(expected_result, actual_result) def main(): test_input_text(8, 8) test_input_text(8, 11) if __name__ == '__main__': main()
pattern_zero=[0.0, 0.01492194674, 0.02938475666, 0.0303030303, 0.04338842975, 0.04522497704, 0.05693296602, 0.05968778696, 0.06060606061, 0.07001836547, 0.07369146006, 0.07552800735, 0.0826446281, 0.08723599633, 0.08999081726, 0.09090909091, 0.0948117539, 0.10032139578, 0.10399449036, 0.10583103765, 0.10651974288, 0.11...
pattern_zero = [0.0, 0.01492194674, 0.02938475666, 0.0303030303, 0.04338842975, 0.04522497704, 0.05693296602, 0.05968778696, 0.06060606061, 0.07001836547, 0.07369146006, 0.07552800735, 0.0826446281, 0.08723599633, 0.08999081726, 0.09090909091, 0.0948117539, 0.10032139578, 0.10399449036, 0.10583103765, 0.10651974288, 0....
LIMITS = {'BNB/BTC': {'amount': {'max': 90000000.0, 'min': 0.01}, 'cost': {'max': None, 'min': 0.001}, 'price': {'max': None, 'min': None}}, 'BNB/ETH': {'amount': {'max': 90000000.0, 'min': 0.01}, 'cost': {'max': None, 'min': 0.01}, ...
limits = {'BNB/BTC': {'amount': {'max': 90000000.0, 'min': 0.01}, 'cost': {'max': None, 'min': 0.001}, 'price': {'max': None, 'min': None}}, 'BNB/ETH': {'amount': {'max': 90000000.0, 'min': 0.01}, 'cost': {'max': None, 'min': 0.01}, 'price': {'max': None, 'min': None}}, 'BNB/USDT': {'amount': {'max': 10000000.0, 'min':...
class Bullet: def __init__(self, x, y, vx, vy, sender, color): self.pos = (x, y) self.vel = (vx, vy) self.sender = sender self.color = color bullets = [] bullets.append(Bullet(0, 1, 2, 3, 'mr. r', (13, 14, 15))) print(bullets[0].sender)
class Bullet: def __init__(self, x, y, vx, vy, sender, color): self.pos = (x, y) self.vel = (vx, vy) self.sender = sender self.color = color bullets = [] bullets.append(bullet(0, 1, 2, 3, 'mr. r', (13, 14, 15))) print(bullets[0].sender)
SQLTYPECODE_CHAR = 1 # NUMERIC * / SQLTYPECODE_NUMERIC = 2 SQLTYPECODE_NUMERIC_UNSIGNED = -201 # DECIMAL * / SQLTYPECODE_DECIMAL = 3 SQLTYPECODE_DECIMAL_UNSIGNED = -301 SQLTYPECODE_DECIMAL_LARGE = -302 SQLTYPECODE_DECIMAL_LARGE_UNSIGNED = -303 # INTEGER / INT * / SQLTYPECODE_INTEGER = 4 SQLTYPECODE_INTEGER_UNSIGNED = -...
sqltypecode_char = 1 sqltypecode_numeric = 2 sqltypecode_numeric_unsigned = -201 sqltypecode_decimal = 3 sqltypecode_decimal_unsigned = -301 sqltypecode_decimal_large = -302 sqltypecode_decimal_large_unsigned = -303 sqltypecode_integer = 4 sqltypecode_integer_unsigned = -401 sqltypecode_largeint = -402 sqltypecode_larg...
# Must check this video: https://tinyurl.com/vfmnqt4 class Solution(object): def nextPermutation(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place instead. """ i = j = len(nums) - 1 while i > 0 and nums[i - 1] >= nums...
class Solution(object): def next_permutation(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place instead. """ i = j = len(nums) - 1 while i > 0 and nums[i - 1] >= nums[i]: i -= 1 if i == 0: ...
class Solution(object): def addStrings(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ result = [] i, j, carry = len(num1) - 1, len(num2) - 1, 0 while i >= 0 or j >= 0 or carry: if i >= 0: carry += or...
class Solution(object): def add_strings(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ result = [] (i, j, carry) = (len(num1) - 1, len(num2) - 1, 0) while i >= 0 or j >= 0 or carry: if i >= 0: carry ...
NORTH = 0 EAST = 1 SOUTH = 2 WEST = 3 class Robot: def __init__(self, bearing=NORTH, x=0, y=0): self.coordinates = (x, y) self.bearing = bearing def turn_right(self): self.bearing += 1 self.bearing %= 4 def turn_left(self): self.bearing += 3 self.bearing %...
north = 0 east = 1 south = 2 west = 3 class Robot: def __init__(self, bearing=NORTH, x=0, y=0): self.coordinates = (x, y) self.bearing = bearing def turn_right(self): self.bearing += 1 self.bearing %= 4 def turn_left(self): self.bearing += 3 self.bearing %...
mydict = {'name':'albert','age':28,'city':'Beijing'} print(mydict) mydict2 = dict(name='allen',age=26,city='boston') print(mydict2) value = mydict['name'] print(value) mydict['email'] = 'albert@hotmail.com' print(mydict) mydict['email'] = 'hello@hotmail.com' print(mydict) del mydict['name'] print(mydict) mydict.p...
mydict = {'name': 'albert', 'age': 28, 'city': 'Beijing'} print(mydict) mydict2 = dict(name='allen', age=26, city='boston') print(mydict2) value = mydict['name'] print(value) mydict['email'] = 'albert@hotmail.com' print(mydict) mydict['email'] = 'hello@hotmail.com' print(mydict) del mydict['name'] print(mydict) mydict....
def get_UnorderedGroupChildren(self): """ List all non-metadata children of an :py:class:`UnorderedGroupType` """ # TODO: should not change order return self.get_RegionRef() + self.get_OrderedGroup() + self.get_UnorderedGroup()
def get__unordered_group_children(self): """ List all non-metadata children of an :py:class:`UnorderedGroupType` """ return self.get_RegionRef() + self.get_OrderedGroup() + self.get_UnorderedGroup()
def writeFastqFile(filename,reads): fhw=open(filename,"w") for read in reads: fhw.write("@"+read+"\n") fhw.write(reads[read][0]+"\n"+reads[read][1]+"\n"+reads[read][2]+"\n") def writeFastaFile(filename,seqs): fhw=open(filename,"w") for id in seqs: fhw.write(">"+id+"\n"+seqs[id...
def write_fastq_file(filename, reads): fhw = open(filename, 'w') for read in reads: fhw.write('@' + read + '\n') fhw.write(reads[read][0] + '\n' + reads[read][1] + '\n' + reads[read][2] + '\n') def write_fasta_file(filename, seqs): fhw = open(filename, 'w') for id in seqs: fhw.w...
class AlembicUtilsException(Exception): """Base exception for AlembicUtils package""" class SQLParseFailure(AlembicUtilsException): """An entity could not be parsed""" class FailedToGenerateComparable(AlembicUtilsException): """Failed to generate a comparable entity""" class UnreachableException(Alemb...
class Alembicutilsexception(Exception): """Base exception for AlembicUtils package""" class Sqlparsefailure(AlembicUtilsException): """An entity could not be parsed""" class Failedtogeneratecomparable(AlembicUtilsException): """Failed to generate a comparable entity""" class Unreachableexception(AlembicU...
tup1 = ('physics', 'chemistry', 1997, 2000) tup2 = (1, 2, 3, 4, 5, 6, 7 ) print ("tup1[0]: ", tup1[0]) print ("tup2[1:5]: ", tup2[1:5]) # Following action is not valid for tuples # tup1[0] = 100
tup1 = ('physics', 'chemistry', 1997, 2000) tup2 = (1, 2, 3, 4, 5, 6, 7) print('tup1[0]: ', tup1[0]) print('tup2[1:5]: ', tup2[1:5])
def validate_name(name): if name.replace(" ", "").isalpha(): return True else: return False def validate_height_in_cm(height): if height < 300 and height > 10: return True else: return False def validate_weigth_in_kg(weight): if weight < 200 and weight > 0: ...
def validate_name(name): if name.replace(' ', '').isalpha(): return True else: return False def validate_height_in_cm(height): if height < 300 and height > 10: return True else: return False def validate_weigth_in_kg(weight): if weight < 200 and weight > 0: ...