content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
total = 0 for number in range(2, 101, 2): total += number print(total)
total = 0 for number in range(2, 101, 2): total += number print(total)
# In the admin panel, when adding new fields, # sets the 'user' field to be the current logged in user # as the default class AutoUserMixin(object): def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == 'user': kwargs['initial'] = request.user.id retu...
class Autousermixin(object): def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == 'user': kwargs['initial'] = request.user.id return db_field.formfield(**kwargs) return super(AutoUserMixin, self).formfield_for_foreignkey(db_field, request, **k...
BASE_PATH = 'covid19_scenarios_data' JSON_DIR = 'assets' SOURCES_FILE = 'sources.json' TMP_CASES = 'case_counts.json' TMP_POPULATION = 'population.json' TMP_SCENARIOS = "scenario_defaults.json"
base_path = 'covid19_scenarios_data' json_dir = 'assets' sources_file = 'sources.json' tmp_cases = 'case_counts.json' tmp_population = 'population.json' tmp_scenarios = 'scenario_defaults.json'
# Variant 1 - Best class Parent: _possible_drinks = ['beer', 'wine'] class Child(Parent): _possible_drinks = ['beer', 'wine', 'vodka'] # Variant 2 - Ok class Child2(Parent): def __init__(self): self._possible_drinks = super()._possible_drinks + ['vodka'] # Variant 3 - Wrong class Child3(Parent...
class Parent: _possible_drinks = ['beer', 'wine'] class Child(Parent): _possible_drinks = ['beer', 'wine', 'vodka'] class Child2(Parent): def __init__(self): self._possible_drinks = super()._possible_drinks + ['vodka'] class Child3(Parent): _possible_drinks = Parent._possible_drinks + ['vodk...
print("Example 04: [The continue Statement] \n" " Continue to the next iteration if i is 5") i = 0 while i < 10: i += 1 if i == 5: continue print(i)
print('Example 04: [The continue Statement] \n Continue to the next iteration if i is 5') i = 0 while i < 10: i += 1 if i == 5: continue print(i)
pkgname = "python-idna" pkgver = "3.3" pkgrel = 0 build_style = "python_module" hostmakedepends = ["python-setuptools"] depends = ["python"] pkgdesc = "Internationalized Domain Names in Applications (IDNA) for Python" maintainer = "q66 <q66@chimera-linux.org>" license = "BSD-3-Clause" url = "https://github.com/kjd/idna...
pkgname = 'python-idna' pkgver = '3.3' pkgrel = 0 build_style = 'python_module' hostmakedepends = ['python-setuptools'] depends = ['python'] pkgdesc = 'Internationalized Domain Names in Applications (IDNA) for Python' maintainer = 'q66 <q66@chimera-linux.org>' license = 'BSD-3-Clause' url = 'https://github.com/kjd/idna...
# https://leetcode.com/problems/word-break class Solution: def wordBreak(self, s: str, wordDict: List[str]) -> bool: s = " " + s dp = [False for _ in range(len(s))] dp[0] = True for i in range(len(s)): for j in range(i): if (dp[j] == True) and (s[j + 1 :...
class Solution: def word_break(self, s: str, wordDict: List[str]) -> bool: s = ' ' + s dp = [False for _ in range(len(s))] dp[0] = True for i in range(len(s)): for j in range(i): if dp[j] == True and s[j + 1:i + 1] in wordDict: dp[i] =...
def run_simulation(): with open('./data/MorningTraffic-b.csv', 'r') as file: content = file.readlines() content = [x.strip() for x in content] timestep = 0 while True: if len(content) > 0: parts = content[0].split(';') start_time = parts[0]...
def run_simulation(): with open('./data/MorningTraffic-b.csv', 'r') as file: content = file.readlines() content = [x.strip() for x in content] timestep = 0 while True: if len(content) > 0: parts = content[0].split(';') start_time = parts[0]...
class Solution: # def romanToInt(self, s): # """ # :type s: str # :rtype: int # """ # roman = {'I': 1, 'V': 5, 'X': 10, # 'L': 50, 'C': 100, 'D': 500, 'M': 1000} # result = 0 # last = s[-1] # for t in reversed(s): # ...
class Solution: def roman_to_int(self, s): roman = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} (prev, total) = (0, 0) for c in s: curr = roman[c] total += curr if curr > prev: total -= 2 * prev prev = curr...
_TRANSFORMATIONS = dict() def register(name): def add_to_dict(fn): global _TRANSFORMATIONS _TRANSFORMATIONS[name] = fn return fn return add_to_dict
_transformations = dict() def register(name): def add_to_dict(fn): global _TRANSFORMATIONS _TRANSFORMATIONS[name] = fn return fn return add_to_dict
""" File: constraint.py Author: Come Bertrand Email: bertrand.cosme@gmail.com Github: https://github.com/ComeBertrand Description: TODO """
""" File: constraint.py Author: Come Bertrand Email: bertrand.cosme@gmail.com Github: https://github.com/ComeBertrand Description: TODO """
# Branch code with if, elif and else structure user_input = input("Would you like to continue? ") if user_input == "no" or user_input == "n": print("Exiting") elif user_input == "yes" or user_input == "y": print("Continuing ...\nComplete!") else: print("Please try again and respond with yes or no.")
user_input = input('Would you like to continue? ') if user_input == 'no' or user_input == 'n': print('Exiting') elif user_input == 'yes' or user_input == 'y': print('Continuing ...\nComplete!') else: print('Please try again and respond with yes or no.')
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # 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 applicab...
"""Build definitions for TypeScript from Closure JavaScript libraries.""" load('@io_bazel_rules_closure//closure/private:defs.bzl', 'JS_FILE_TYPE', 'collect_js', 'unfurl') deprecated_clutz_attributes = {'_clutz': attr.label(default=label('@io_angular_clutz//:clutz'), executable=True, cfg='host'), '_clutz_externs': attr...
class Solution: def solve(self, nums, k): i = 0 j = len(nums) - 1 while i < j: curSum = nums[i] + nums[j] if curSum == k: return True elif curSum < k: i += 1 else: j -= 1 retu...
class Solution: def solve(self, nums, k): i = 0 j = len(nums) - 1 while i < j: cur_sum = nums[i] + nums[j] if curSum == k: return True elif curSum < k: i += 1 else: j -= 1 return False
class Minus: reserved = {} tokens = ('MINUS',) # Tokens t_MINUS = r'-' precedence = ( ('left', 'MINUS'), )
class Minus: reserved = {} tokens = ('MINUS',) t_minus = '-' precedence = (('left', 'MINUS'),)
# Copyright (c) 2009 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. { 'includes': [ '../../../../common_settings.gypi', # Common settings ], 'targets': [ { 'target_name': 'test_framework', 'type'...
{'includes': ['../../../../common_settings.gypi'], 'targets': [{'target_name': 'test_framework', 'type': '<(library)', 'dependencies': ['../../../../system_wrappers/source/system_wrappers.gyp:system_wrappers', '../../../../common_video/vplib/main/source/vplib.gyp:webrtc_vplib'], 'include_dirs': ['../interface', '../../...
# 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. """Recipe to build CIPD package with sealed Conda environment. Supposed to be used from manually triggered Buildbot builders. We aren't expecting rebuilding...
"""Recipe to build CIPD package with sealed Conda environment. Supposed to be used from manually triggered Buildbot builders. We aren't expecting rebuilding this environment often, so setting up and periodic schedule is a waste of resources. To build a new package for all platforms: 1. Manually trigger all builders b...
map_collections = { "user": "Users", "user_relation": "UsersRelation", }
map_collections = {'user': 'Users', 'user_relation': 'UsersRelation'}
variavel_global = 'Global' def funcao(): variavel_local = 'Local' print(variavel_global) print(variavel_local) funcao()
variavel_global = 'Global' def funcao(): variavel_local = 'Local' print(variavel_global) print(variavel_local) funcao()
#!/usr/bin/env python # -*- coding: utf-8 -*- def greetings(st_1, st_2, st_3=None, st_4=None): template = "<b>Alumno</b>: {0:30} <b>rol</b>: {1:10}<br>" hi = "" hi += template.format(*st_1) hi += template.format(*st_2) if st_3: hi += template.format(*st_3) if st_4: hi += templa...
def greetings(st_1, st_2, st_3=None, st_4=None): template = '<b>Alumno</b>: {0:30} <b>rol</b>: {1:10}<br>' hi = '' hi += template.format(*st_1) hi += template.format(*st_2) if st_3: hi += template.format(*st_3) if st_4: hi += template.format(*st_4) ending = 'Good luck!' r...
########################### # 6.0002 Problem Set 1b: Space Change # Name: Chintan Singh # Collaborators: # Time: 15 minutes # Author: charz, cdenise #================================ # Part B: Golden Eggs #================================ # Problem 1 def dp_make_weight(egg_weights, target_weight, memo = {}): """ ...
def dp_make_weight(egg_weights, target_weight, memo={}): """ Find number of eggs to bring back, using the smallest number of eggs. Assumes there is an infinite supply of eggs of each weight, and there is always a egg of value 1. Parameters: egg_weights - tuple of integers, available egg weights...
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def hasCycle(self, head: ListNode) -> bool: cur1 = head cur2 = head while(cur1 or cur2): cur1 = cur1 and cur1.next and cur1.next.next ...
class Listnode: def __init__(self, x): self.val = x self.next = None class Solution: def has_cycle(self, head: ListNode) -> bool: cur1 = head cur2 = head while cur1 or cur2: cur1 = cur1 and cur1.next and cur1.next.next cur2 = cur2 and cur2.next ...
def join_path(row_path, column_path): if column_path is None: raise Exception("Column path is empty!") if row_path is None: raise Exception("Row path is empty") column_path = column_path.strip() row_path = row_path.strip() if len(row_path) > 0 and row_path[-1] == ".": ...
def join_path(row_path, column_path): if column_path is None: raise exception('Column path is empty!') if row_path is None: raise exception('Row path is empty') column_path = column_path.strip() row_path = row_path.strip() if len(row_path) > 0 and row_path[-1] == '.': row_pat...
# # LeetCode # # Problem - 35 # URL - https://leetcode.com/problems/search-insert-position/ # class Solution: def searchInsert(self, nums: List[int], target: int) -> int: return bisect.bisect_left(nums, target)
class Solution: def search_insert(self, nums: List[int], target: int) -> int: return bisect.bisect_left(nums, target)
MAX_PERCENT = 100 PERCENT_DENOMINATION = 10 class Category: width_of_ledger = 30 def __init__(self, title : str) -> None: #to define your own attributes for this category self.title = title #eg of a constructor Category("Food") self.currentAmount : float = 0 self.ledger : list = [] ...
max_percent = 100 percent_denomination = 10 class Category: width_of_ledger = 30 def __init__(self, title: str) -> None: self.title = title self.currentAmount: float = 0 self.ledger: list = [] def deposit(self, amount: float, description=''): self.ledger.append({'amount': ...
#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: Xukun Luo # Date: 2021.03.31 """ Our settings. """ ### For dataset. ### # origin file path. origin_train_path = "../datasets/training.txt" origin_test_path = "../datasets/test.txt" vocab_path = "../datasets/training_vocab.txt" # preprocessed file path. prepro...
""" Our settings. """ origin_train_path = '../datasets/training.txt' origin_test_path = '../datasets/test.txt' vocab_path = '../datasets/training_vocab.txt' preprocessed_train_path = '../datasets/training_pre.json' preprocessed_test_path = '../datasets/test_pre.json' k = 5 (train, valid, test) = (0, 1, 2) label_list = ...
def y_test(message_list): if message_list is None: raise StopIteration else: for message in message_list: yield message[0], message[1], message[2] message_list = [[1,2,3]] a = 1
def y_test(message_list): if message_list is None: raise StopIteration else: for message in message_list: yield (message[0], message[1], message[2]) message_list = [[1, 2, 3]] a = 1
# Test global pointers to data and code test_data = { "desc": "Global pointers to data and code", "modules": [["mod_global_ptrs1.c"]], "required": ["Running test 'mod_global_ptrs1'"] }
test_data = {'desc': 'Global pointers to data and code', 'modules': [['mod_global_ptrs1.c']], 'required': ["Running test 'mod_global_ptrs1'"]}
# Problem Statement: # Given N, find the number of ways to express N as a sum of 1,3 and 4 # # Example: # - N = 4 # - Number of ways = 4 # - Explanation: There are 4 ways we can express N, {4}, {1,3}, {3,1}, {1,1,1,1} # # Algorithm: # Divide and Conquer method comes handy for solving this problem # This can be solved...
def number_factor(n): if n in [0, 1, 2]: return 1 elif n == 3: return 2 else: sub1 = number_factor(n - 1) sub2 = number_factor(n - 3) sub3 = number_factor(n - 4) return sub1 + sub2 + sub3
class Util(): def __init__(self,item): self.item=item def getUtil(self): return self.item u=Util("Ram") print(u.getUtil())
class Util: def __init__(self, item): self.item = item def get_util(self): return self.item u = util('Ram') print(u.getUtil())
# # PySNMP MIB module ZHONE-FS-ALARM (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZHONE-FS-ALARM # Produced by pysmi-0.3.4 at Wed May 1 15:47:32 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint, constraints_union) ...
# -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect connect-cli. # Copyright (c) 2019-2022 Ingram Micro. All Rights Reserved. PARAM_TYPES = [ 'email', 'address', 'checkbox', 'choice', 'domain', 'subdomain', 'url', 'dropdown', 'object', 'password',...
param_types = ['email', 'address', 'checkbox', 'choice', 'domain', 'subdomain', 'url', 'dropdown', 'object', 'password', 'phone', 'text'] precisions = ('integer', 'decimal(1)', 'decimal(2)', 'decimal(4)', 'decimal(8)') commitment = ('-', '1 year', '2 years', '3 years', '4 years', '5 years') billing_period = ('onetime',...
class BaseNumberConverter(TypeConverter): """ Provides a base type converter for nonfloating-point numerical types. """ def CanConvertFrom(self,*__args): """ CanConvertFrom(self: BaseNumberConverter,context: ITypeDescriptorContext,sourceType: Type) -> bool Determines if this converter can convert an...
class Basenumberconverter(TypeConverter): """ Provides a base type converter for nonfloating-point numerical types. """ def can_convert_from(self, *__args): """ CanConvertFrom(self: BaseNumberConverter,context: ITypeDescriptorContext,sourceType: Type) -> bool Determines if this converter can ...
# find the biggest gap, AB or BC pos = [int(x) for x in input().split()] AB = pos[1]-pos[0] BC = pos[2]-pos[1] if AB-BC < 0: #BC greatest print(BC-1) else: # AB or equal print(AB-1)
pos = [int(x) for x in input().split()] ab = pos[1] - pos[0] bc = pos[2] - pos[1] if AB - BC < 0: print(BC - 1) else: print(AB - 1)
if __name__ == '__main__': N =int(input()) l = [] for i in range(0,N): t = input().split() if t[0]=="insert" : l.insert(int(t[1]),int(t[2])) elif t[0]=="print": print (l) elif t[0]=="remove" : l.remove(int(t[1])) elif t[0]=="ap...
if __name__ == '__main__': n = int(input()) l = [] for i in range(0, N): t = input().split() if t[0] == 'insert': l.insert(int(t[1]), int(t[2])) elif t[0] == 'print': print(l) elif t[0] == 'remove': l.remove(int(t[1])) elif t[0] == ...
""" test_inceptiontools ~~~~~~~~~~~~~~~~~~~ Houses all unit test cases, supporting the :py:mod:`inceptiontools` package. This package is not intended to be part of the distribution. """ __author__ = "Andrew van Herick" __copyright__ = "Unpublished Copyright (c) 2020 Andrew van Herick. All Rights Reserved." __license_...
""" test_inceptiontools ~~~~~~~~~~~~~~~~~~~ Houses all unit test cases, supporting the :py:mod:`inceptiontools` package. This package is not intended to be part of the distribution. """ __author__ = 'Andrew van Herick' __copyright__ = 'Unpublished Copyright (c) 2020 Andrew van Herick. All Rights Reserved.' __license__...
begin_unit comment|'# Copyright 2012 IBM Corp.' nl|'\n' comment|'# Copyright (c) AT&T Labs Inc. 2012 Yun Mao <yunmao@gmail.com>' nl|'\n' comment|'#' nl|'\n' comment|'# Licensed under the Apache License, Version 2.0 (the "License");' nl|'\n' comment|'# you may not use this file except in compliance with the License.' nl...
begin_unit comment | '# Copyright 2012 IBM Corp.' nl | '\n' comment | '# Copyright (c) AT&T Labs Inc. 2012 Yun Mao <yunmao@gmail.com>' nl | '\n' comment | '#' nl | '\n' comment | '# Licensed under the Apache License, Version 2.0 (the "License");' nl | '\n' comment | '# you may not use this file except in compliance wit...
def r_a(a, b): return a def r_b(a, b): return b def r_str(): return '' def r_object(): return object() class A: def r_A(self): return type(self)()
def r_a(a, b): return a def r_b(a, b): return b def r_str(): return '' def r_object(): return object() class A: def r_a(self): return type(self)()
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" EMAIL_HOST = "" EMAIL_HOST_USER = "" KEY = "" EMAIL_PORT = 587 EMAIL_USE_TLS = True DEFAULT_FROM_EMAIL = "" # This should be in the format [('A User','user@example.com'), ('B User', 'person@example.com')] REGISTRATION_ADMINS = []
email_backend = 'django.core.mail.backends.smtp.EmailBackend' email_host = '' email_host_user = '' key = '' email_port = 587 email_use_tls = True default_from_email = '' registration_admins = []
def pick_peaks(arr): prev_dex = prev_val = None result = {'pos': [], 'peaks': []} upwards = False for i, a in enumerate(arr): if prev_val == a: continue elif prev_val is None or prev_val < a: upwards = True else: if prev_dex and upwards: ...
def pick_peaks(arr): prev_dex = prev_val = None result = {'pos': [], 'peaks': []} upwards = False for (i, a) in enumerate(arr): if prev_val == a: continue elif prev_val is None or prev_val < a: upwards = True else: if prev_dex and upwards: ...
def displayBanner(): banner = open('./banner/banner.txt', 'r', encoding = 'utf8') print(banner.read()) def choice(): while True: choice = int(input(">")) if choice == 0: break elif choice == 1: exit() else: print("Retry")
def display_banner(): banner = open('./banner/banner.txt', 'r', encoding='utf8') print(banner.read()) def choice(): while True: choice = int(input('>')) if choice == 0: break elif choice == 1: exit() else: print('Retry')
def renumerate(iterable): """ Enumerates an `iterable` starting from the end. Examples: ```python from flashback.iterating import renumerate # Drop-in replacement for enumerate() lst = ["a", "b", "c"] for index, item in renumerate(lst): print(index, item...
def renumerate(iterable): """ Enumerates an `iterable` starting from the end. Examples: ```python from flashback.iterating import renumerate # Drop-in replacement for enumerate() lst = ["a", "b", "c"] for index, item in renumerate(lst): print(index, item...
print("hello") a=9 b=10 print(a+b)
print('hello') a = 9 b = 10 print(a + b)
# # Copyright (C) 2008 The Android Open Source Project # # 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 la...
class Manifestparseerror(Exception): """Failed to parse the manifest file. """ class Manifestinvalidrevisionerror(Exception): """The revision value in a project is incorrect. """ class Editorerror(Exception): """Unspecified error from the user's text editor. """ def __init__(self, reason): ...
class A(): def __init__(self): pass def f(self): return "A" class B(A): def __init__(self): pass def f(self): return "B" def g(self): return "B" class C(B): def __init__(self): pass def g(self): return "C" class D(C): def __...
class A: def __init__(self): pass def f(self): return 'A' class B(A): def __init__(self): pass def f(self): return 'B' def g(self): return 'B' class C(B): def __init__(self): pass def g(self): return 'C' class D(C): def _...
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ # curA, cu...
class Solution(object): def get_intersection_node(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ (pointer_a, pointer_b) = (headA, headB) while pointer_a is not pointer_b: pointer_a = headB if pointer_a is None else pointer_a.ne...
registry = { "twicer_service": { "grpc": 7003, }, "halfer_service": { "grpc": 7004, }, "incrementer_service": { "grpc": 7005, }, "registry_service": { "grpc": 7006, }, "compo_service": { "grpc": 7007, }, }
registry = {'twicer_service': {'grpc': 7003}, 'halfer_service': {'grpc': 7004}, 'incrementer_service': {'grpc': 7005}, 'registry_service': {'grpc': 7006}, 'compo_service': {'grpc': 7007}}
# 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. def CheckChangeOnUpload(input_api, output_api): return _CommonChecks(input_api, output_api) def CheckChangeOnCommit(input_api, output_api): return _Co...
def check_change_on_upload(input_api, output_api): return __common_checks(input_api, output_api) def check_change_on_commit(input_api, output_api): return __common_checks(input_api, output_api) def __common_checks(input_api, output_api): results = [] results += input_api.RunTests(input_api.canned_chec...
elements = {"Ag": 106.905095, "Al": 26.981541, "Ar": 39.962383, "As": 74.921596, "Au": 196.96656, "B": 11.009305, "Ba": 137.905236, "Be": 9.012183, "Bi": 208.980388, "Br": 78.918336, "C": 12, ...
elements = {'Ag': 106.905095, 'Al': 26.981541, 'Ar': 39.962383, 'As': 74.921596, 'Au': 196.96656, 'B': 11.009305, 'Ba': 137.905236, 'Be': 9.012183, 'Bi': 208.980388, 'Br': 78.918336, 'C': 12, 'Ca': 39.962591, 'Cd': 113.903361, 'Ce': 139.905442, 'Cl': 34.968853, 'Co': 58.933198, 'Cr': 51.94051, 'Cs': 132.905433, 'Cu': 6...
class stack(object): def __init(self, limit = 10): self.stk = [] self.limit = limit def is_empty(self): return len(self.stk) <= 0 def push(self, data): if len(self.stk) > self.limit: print("The stack is full") else: self.stk.app...
class Stack(object): def __init(self, limit=10): self.stk = [] self.limit = limit def is_empty(self): return len(self.stk) <= 0 def push(self, data): if len(self.stk) > self.limit: print('The stack is full') else: self.stk.append(data) ...
#!/usr/bin/env python3 # Copyright (c) 2016-2020, henry232323 # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, mo...
class Mentions(object): @staticmethod def process_mentions(text, message): fin = text for member in message.mentions: fin = text.replace(member.mention, f'<a href="mention={member.id}">@{member.display_name}</a>') for channel in message.channel_mentions: fin = te...
''' Pattern Enter number of rows: 5 1 123 12345 1234567 123456789 ''' print('Number pattern:') number_rows=int(input('Enter number of rows: ')) for row in range(1,number_rows+1): for column in range(1,(2*row-1)+1): print(column,end=' ') print()
""" Pattern Enter number of rows: 5 1 123 12345 1234567 123456789 """ print('Number pattern:') number_rows = int(input('Enter number of rows: ')) for row in range(1, number_rows + 1): for column in range(1, 2 * row - 1 + 1): print(column, end=' ') print()
# Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'targets': [ { 'target_name': 'target', 'type': 'none', 'actions': [ { 'action_name': 'action1', 'inputs': []...
{'targets': [{'target_name': 'target', 'type': 'none', 'actions': [{'action_name': 'action1', 'inputs': [], 'outputs': ['action1.txt'], 'action': ['python', '../touch.py', '<(_outputs)'], 'msvs_cygwin_shell': 0}]}, {'target_name': 'target_same_action_name', 'type': 'none', 'actions': [{'action_name': 'action', 'inputs'...
''' Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index. If no such index exists, we should return -1. If there are multip...
""" Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index. If no such index exists, we should return -1. If there are multip...
#!/usr/bin/env python3 with open("p079_keylog.txt") as f: c = [line.rstrip() for line in f] c = list(set(c)) print(c) for n in c: print("Pas {} vijne {}".format(n[0], n[1:])) print("Pas {} vijne {}".format(n[1], n[2:]))
with open('p079_keylog.txt') as f: c = [line.rstrip() for line in f] c = list(set(c)) print(c) for n in c: print('Pas {} vijne {}'.format(n[0], n[1:])) print('Pas {} vijne {}'.format(n[1], n[2:]))
def selectionSort(lst): for i in range(len(lst)): ind = lst.index(min(lst[i:])) print(i,ind,min(lst[i:])) lst[i],lst[ind] = lst[ind],lst[i] return lst lst = list(map(int,input('Enter the number list: ').split())) print(lst.index(min(lst))) print(selectionSort(lst))
def selection_sort(lst): for i in range(len(lst)): ind = lst.index(min(lst[i:])) print(i, ind, min(lst[i:])) (lst[i], lst[ind]) = (lst[ind], lst[i]) return lst lst = list(map(int, input('Enter the number list: ').split())) print(lst.index(min(lst))) print(selection_sort(lst))
#!/usr/bin/env python3 def is_palindromic(a): if int(a / 1e5) != a % 10: return False if int(a / 1e4) % 10 != int(a / 10) % 10: return False if int(a / 1e3) % 10 != int(a/ 100) % 10: return False return True if __name__ == '__main__': max_pad = 0 for i in range(99...
def is_palindromic(a): if int(a / 100000.0) != a % 10: return False if int(a / 10000.0) % 10 != int(a / 10) % 10: return False if int(a / 1000.0) % 10 != int(a / 100) % 10: return False return True if __name__ == '__main__': max_pad = 0 for i in range(999, 101, -1): ...
# Copyright 2016 VMware, Inc. # All Rights Reserved # # 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 appl...
admin_state_up = 'UP' admin_state_down = 'DOWN' mtep = 'MTEP' attachment_vif = 'VIF' attachment_lr = 'LOGICALROUTER' attachment_dhcp = 'DHCP_SERVICE' attachment_mdproxy = 'METADATA_PROXY' vif_resource_type = 'VifAttachmentContext' vif_type_parent = 'PARENT' vif_type_child = 'CHILD' allocate_address_none = 'None' init_s...
# Big O complexity # Average = O(log2(log2(n))) # Pessimistic = O(n) def interpolationSearch(arr, arg): left = 0 right = (len(arr) - 1) while left <= right and arr[left] <= arg <= arr[right]: index = left + int(((float(right - left) / (arr[right] - arr[left])) * (arg - arr[left]))) if arr...
def interpolation_search(arr, arg): left = 0 right = len(arr) - 1 while left <= right and arr[left] <= arg <= arr[right]: index = left + int(float(right - left) / (arr[right] - arr[left]) * (arg - arr[left])) if arr[index] == arg: return index if arr[index] < arg: ...
DATALINK_CONTENT_TYPE = 'application/x-votable+xml;content=datalink' DATALINK_TABLE = { 'name': 'datalink', 'description': 'The table of datalinks for the service', 'order': 4, 'access_level': 'PUBLIC', 'metadata_access_level': 'PUBLIC' } DATALINK_FIELDS = [ { 'name': 'ID', 'orde...
datalink_content_type = 'application/x-votable+xml;content=datalink' datalink_table = {'name': 'datalink', 'description': 'The table of datalinks for the service', 'order': 4, 'access_level': 'PUBLIC', 'metadata_access_level': 'PUBLIC'} datalink_fields = [{'name': 'ID', 'order': 1, 'description': 'Input identifier.', '...
# Project Euler 2 - Even Fibonacci Numbers # GitHub: urtuba def evenFibonacciGenerator(limit: int): ''' The function to create a generator for even fibonacci numbers :param limit: maximum number for the generator :return: even fibonacci numbers generator ''' fib = 1 fib_next = 2 while ...
def even_fibonacci_generator(limit: int): """ The function to create a generator for even fibonacci numbers :param limit: maximum number for the generator :return: even fibonacci numbers generator """ fib = 1 fib_next = 2 while fib_next < limit: (fib, fib_next) = (fib_next, fib_...
#Q2. Given a list of integers, my_list = [4,2,4,0,2,4,5,7,8,9,23,8,5,4,2,2,34,4,45]. # Find the maximum and minimum numbers in the list. my_list = [4,2,4,0,2,4,5,7,8,9,23,8,5,4,2,2,34,4,45] sorted_my_list=sorted(my_list) print("The minimum number is:",my_list[0]) i=len(my_list) print("The maximum number is:",my_list[i...
my_list = [4, 2, 4, 0, 2, 4, 5, 7, 8, 9, 23, 8, 5, 4, 2, 2, 34, 4, 45] sorted_my_list = sorted(my_list) print('The minimum number is:', my_list[0]) i = len(my_list) print('The maximum number is:', my_list[i - 1])
# coding: utf-8 """ File contains base API Exception. """ class ApiException(Exception): """ Base exception. """ def __init__(self, message, status_code=None, api_error_code=None, payload=None): Exception.__init__(self) self.message = message self.status_code = status_code if s...
""" File contains base API Exception. """ class Apiexception(Exception): """ Base exception. """ def __init__(self, message, status_code=None, api_error_code=None, payload=None): Exception.__init__(self) self.message = message self.status_code = status_code if status_code else ...
print( """ Please use one of the following: python -m gmailcopy.core python -m gmailcopy.server """ )
print('\nPlease use one of the following:\n\npython -m gmailcopy.core\npython -m gmailcopy.server\n')
#! /usr/bin/env python # -*- coding: utf-8 -*- # # # MIT License # # Copyright (c) 2020 Mike Simms # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without...
class Activitymerge(object): """Class for merging two activities.""" start_time_unix = 0 end_time_unix = 0 locations = [] heart_rate_readings = [] power_readings = [] cadence_readings = [] temperature_readings = [] def __init__(self): pass def sort(self, unsorted_list):...
src =Split(''' base/log/LITE-log/lite-log.c base/utils/LITE-utils/src/json_parser.c base/utils/LITE-utils/src/json_token.c base/utils/LITE-utils/src/mem_stats.c base/utils/LITE-utils/src/string_utils.c base/utils//misc/utils_httpc.c base/utils//misc/utils_list.c base/utils//misc...
src = split(' \n base/log/LITE-log/lite-log.c\n base/utils/LITE-utils/src/json_parser.c\n base/utils/LITE-utils/src/json_token.c\n base/utils/LITE-utils/src/mem_stats.c\n base/utils/LITE-utils/src/string_utils.c\n base/utils//misc/utils_httpc.c\n base/utils//misc/utils_list.c\n base/utils//misc/...
class Bucket: def __init__(self): self.bucket = [] def get(self, key): for (k, v) in self.bucket: if k == key: return v return -1 def update(self, key, value): found = False for i, value in enumerate(self.bu...
class Bucket: def __init__(self): self.bucket = [] def get(self, key): for (k, v) in self.bucket: if k == key: return v return -1 def update(self, key, value): found = False for (i, value) in enumerate(self.bucket): if value[...
MAIL_SERVER = 'smtp.gmail.com' MAIL_PORT = 465 MAIL_USE_TLS = False MAIL_USE_SSL = True MAIL_USERNAME = 'playiq.com@gmail.com' MAIL_PASSWORD = 'notplaynet'
mail_server = 'smtp.gmail.com' mail_port = 465 mail_use_tls = False mail_use_ssl = True mail_username = 'playiq.com@gmail.com' mail_password = 'notplaynet'
""" this class is responsible for storing all the information about the current state of a chess game, it will aslo be responsible for determning the valid move at the current state. It will also keep a move log """ class Gamestate(): def __init__(self): #board is an 8X8 2D list #string "--"...
""" this class is responsible for storing all the information about the current state of a chess game, it will aslo be responsible for determning the valid move at the current state. It will also keep a move log """ class Gamestate: def __init__(self): self.board = [['bR', 'bN', 'bB', 'bQ', 'bK', 'bB', 'b...
def HCF (x,y): if x > y: d=[] for i in range(1,y+1): if y % i == 0 and x % i == 0: d.append(i) print(d[-1]) elif x < y: d=[] for i in range(1,x+1): if y % i == 0 and x % i == 0: d.append(i) print(d[-1]) prin...
def hcf(x, y): if x > y: d = [] for i in range(1, y + 1): if y % i == 0 and x % i == 0: d.append(i) print(d[-1]) elif x < y: d = [] for i in range(1, x + 1): if y % i == 0 and x % i == 0: d.append(i) print(d[...
# By Kamran Bigdely Nov. 2020 # Replace temp variable with query # TODO: Use 'extract method' refactoring technique to improve this code. # TODO: If required, use 'replace temp variable with query' technique to make it easier to extract methods. class Employer: """A class to represent a employer""" def __ini...
class Employer: """A class to represent a employer""" def __init__(self, name): self.name = name def send(self, students): print("Students' contact info were sent to", self.name + '.') class Student: """A class to represent a student""" def __init__(self, gpa, name): self...
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "core_binary", "core_library", "core_resource") def buildall(framework): core_library( name = "assert.xunit", srcs = native.glob(["**/*.cs"]), visibility = ["//visibility:public"], deps = [ "@io_bazel_rules_dotnet//dotnet/s...
load('@io_bazel_rules_dotnet//dotnet:defs.bzl', 'core_binary', 'core_library', 'core_resource') def buildall(framework): core_library(name='assert.xunit', srcs=native.glob(['**/*.cs']), visibility=['//visibility:public'], deps=['@io_bazel_rules_dotnet//dotnet/stdlib.core/{}:system.runtime.dll'.format(framework), '...
# # Copyright (C) 2013 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions an...
{'includes': ['devtools.gypi'], 'targets': [{'target_name': 'devtools_frontend_resources', 'type': 'none', 'dependencies': ['supported_css_properties', 'frontend_protocol_sources', 'build_applications'], 'conditions': [['debug_devtools==0', {'dependencies': ['concatenated_devtools_css', 'concatenated_inspector_css', 'c...
def resolve(): ''' code here ''' X = int(input()) memo = 0 res = 0 for i in range(1, X+3): memo += i if memo >= X: res = i break print(res) if __name__ == "__main__": resolve()
def resolve(): """ code here """ x = int(input()) memo = 0 res = 0 for i in range(1, X + 3): memo += i if memo >= X: res = i break print(res) if __name__ == '__main__': resolve()
# if-else # Created by JKChang # 14/08/2018, 10:48 # Tag: # Description: https://www.hackerrank.com/challenges/py-if-else/problem # Task # Given an integer, , perform the following conditional actions: # If n is odd, print Weird # If n is even and in the inclusive range of 2 to 5, print Not Weird # If n is even and in ...
n = int(input()) if N % 2 != 0: print('Weird') elif N >= 2 and N <= 5: print('Not Weird') elif N >= 6 and N <= 20: print('Weird') elif N > 20: print('Not Weird')
def recursive_sum(n): if n <= 0: return 0 return n + recursive_sum(n - 1) print(recursive_sum(3)) # O(n) time; O(n) space
def recursive_sum(n): if n <= 0: return 0 return n + recursive_sum(n - 1) print(recursive_sum(3))
major, minor, patch = (0, 1, 1) __version__ = f"{major}.{minor}.{patch}" __author__ = "Unai Saralegui" __email__ = "usaralegui@gmail.com" __credits__ = ["Unai Saralegui"] __maintainer__ = "Unai Saralegui" __status__ = "Development"
(major, minor, patch) = (0, 1, 1) __version__ = f'{major}.{minor}.{patch}' __author__ = 'Unai Saralegui' __email__ = 'usaralegui@gmail.com' __credits__ = ['Unai Saralegui'] __maintainer__ = 'Unai Saralegui' __status__ = 'Development'
def diagonal(width): yield 1 # middle cell for level in range(1, (width + 1)//2 ): first = (2*level+1)**2 for i in range(4): yield(first - i * (2*level)) print(sum(diagonal(1001)))
def diagonal(width): yield 1 for level in range(1, (width + 1) // 2): first = (2 * level + 1) ** 2 for i in range(4): yield (first - i * (2 * level)) print(sum(diagonal(1001)))
# Write a Python script using class to reverse a string word by word class String: def __init__(self, string): self.string = string def reverse(self): self.words = self.string.split() self.reversed_words = self.words[::-1] self.reversed_string = ' '.join(self.reversed_words) ...
class String: def __init__(self, string): self.string = string def reverse(self): self.words = self.string.split() self.reversed_words = self.words[::-1] self.reversed_string = ' '.join(self.reversed_words) return self.reversed_string string = input('Enter a string: ') ...
a, b = input().split() s = str(int(a)**int(b)) for i in range(len(s)): if i % 70 == 0 and i != 0: print() print(s[i], end='')
(a, b) = input().split() s = str(int(a) ** int(b)) for i in range(len(s)): if i % 70 == 0 and i != 0: print() print(s[i], end='')
"""After looking at question we can see that we need 5 iterations for finding a match between a substring(length 3) and string(length 7). Keep th count using whole. """ def count_substring(string, sub_string): whole = 0 for i in range(len(string) - len(sub_string) + 1): if(string[i:i+len(sub_string...
"""After looking at question we can see that we need 5 iterations for finding a match between a substring(length 3) and string(length 7). Keep th count using whole. """ def count_substring(string, sub_string): whole = 0 for i in range(len(string) - len(sub_string) + 1): if string[i:i + len(sub_string)]...
def applyOpts(opts=None, otherOpts=None, override=None, *args, **kwargs): otherOptNames = dir(otherOpts) for i in range(1, len(otherOptNames)): optName = otherOptNames[i] if not (hasattr(opts, optName)) or override: setattr(opts, optName, getattr(otherOpts, (optName))) return op...
def apply_opts(opts=None, otherOpts=None, override=None, *args, **kwargs): other_opt_names = dir(otherOpts) for i in range(1, len(otherOptNames)): opt_name = otherOptNames[i] if not hasattr(opts, optName) or override: setattr(opts, optName, getattr(otherOpts, optName)) return opt...
# TODO: fix auto-increase class IntCodeSolver: # Calls the helper, which runs the majority of the code def intCodeSolver(self, intcode): return self.intCodeStepper(intcode, 0) # Performs one step of the IntCode def intCodeStepper(self, intcode, headloc): opcode = intcode[headloc] ...
class Intcodesolver: def int_code_solver(self, intcode): return self.intCodeStepper(intcode, 0) def int_code_stepper(self, intcode, headloc): opcode = intcode[headloc] intcode_list = list(map(int, str(opcode))) if len(intcodeList) < 2: intcodeList.insert(0, 0) ...
_base_ = ['../../recognizers/_base_/model_r3d18.py', '../../recognizers/_base_/runtime_ssv1.py'] work_dir = './output/ctp/r3d_18_kinetics/finetune_ssv1/' model = dict( backbone=dict( pretrained='./output/ctp/r3d_18_kinetics/pretraining/epoch_90.pth', ), st_module=dict(temporal_size=4), ...
_base_ = ['../../recognizers/_base_/model_r3d18.py', '../../recognizers/_base_/runtime_ssv1.py'] work_dir = './output/ctp/r3d_18_kinetics/finetune_ssv1/' model = dict(backbone=dict(pretrained='./output/ctp/r3d_18_kinetics/pretraining/epoch_90.pth'), st_module=dict(temporal_size=4), cls_head=dict(num_classes=174))
# from Bio.Seq import Seq # with open('dataset_3_2.txt', 'r') as file: # text = file.read().replace('\n', '') # my_seq = Seq(text) # print(my_seq.reverse_complement()) # def swap(char): # if char == 'A': # return 'T' # if char == 'T': # return 'A' # if char == 'C': # return 'G...
comp_map = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'} def rev_comp1(seq): rev = seq[::-1] comp = [comp_map[x] for x in rev] return ''.join(comp) def rev_comp2(seq): rev = seq[::-1] rev = rev.replace('A', 'B') rev = rev.replace('T', 'A') rev = rev.replace('B', 'T') rev = rev.replace('C', ...
# -*- coding: utf-8 -*- """ pip_services_logging.__init__ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Logging module initialization :copyright: Conceptual Vision Consulting LLC 2015-2016, see AUTHORS for more details. :license: MIT, see LICENSE for more details. """ __all__ = []
""" pip_services_logging.__init__ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Logging module initialization :copyright: Conceptual Vision Consulting LLC 2015-2016, see AUTHORS for more details. :license: MIT, see LICENSE for more details. """ __all__ = []
class BaseCache: """Baseclass for the cache systems. All the cache systems implement this API or a superset of it. :param default_timeout: the default timeout (in seconds) that is used if no timeout is specified on :meth:`set`. A timeout of 0 indicat...
class Basecache: """Baseclass for the cache systems. All the cache systems implement this API or a superset of it. :param default_timeout: the default timeout (in seconds) that is used if no timeout is specified on :meth:`set`. A timeout of 0 indicat...
self.description = 'download a remote package with -U' self.require_capability("curl") url = self.add_simple_http_server({}) self.args = '-Uw {url}/foo.pkg'.format(url=url) self.addrule('!PACMAN_RETCODE=0') self.addrule('!CACHE_FEXISTS=foo.pkg') self.addrule('!CACHE_FEXISTS=foo.pkg.sig')
self.description = 'download a remote package with -U' self.require_capability('curl') url = self.add_simple_http_server({}) self.args = '-Uw {url}/foo.pkg'.format(url=url) self.addrule('!PACMAN_RETCODE=0') self.addrule('!CACHE_FEXISTS=foo.pkg') self.addrule('!CACHE_FEXISTS=foo.pkg.sig')
foo = 0 while foo < 5: foo = foo + 1 if foo == 3: continue # jump back to while loop, print 'foo is n' is not called print('foo is ' + str(foo))
foo = 0 while foo < 5: foo = foo + 1 if foo == 3: continue print('foo is ' + str(foo))
def binary_or_not(str): binary="01" return all([num in binary for num in str]) str="001021010001010" if binary_or_not(str): print("Binary") else: print("Not Binary")
def binary_or_not(str): binary = '01' return all([num in binary for num in str]) str = '001021010001010' if binary_or_not(str): print('Binary') else: print('Not Binary')
magicians = ['Dynamo', 'Jason Latimer', 'Franz Harary'] temp_magicians = [] def show_magicians(name): for i in name: print(i) def make_great(current_name): # j = len(current_name) while current_name: # j = current_name.pop() temp_magicians.append('The great ' + current_name.pop()...
magicians = ['Dynamo', 'Jason Latimer', 'Franz Harary'] temp_magicians = [] def show_magicians(name): for i in name: print(i) def make_great(current_name): while current_name: temp_magicians.append('The great ' + current_name.pop()) print(temp_magicians) make_great(magicians) show_magician...
class Solution: def isPalindrome(self, x: int) -> bool: if x < 0: return False if x < 10: return True return str(x) == str(x)[::-1]
class Solution: def is_palindrome(self, x: int) -> bool: if x < 0: return False if x < 10: return True return str(x) == str(x)[::-1]
# user input # https://www.hackerrank.com/challenges/nested-list/problem?h_r=internal-search if __name__ == '__main__': z = int(input()) phy = [] grd = [] for _ in range(z): name = input().strip() score = float(input().strip()) phy.append([name, score]) grd.append(score) ...
if __name__ == '__main__': z = int(input()) phy = [] grd = [] for _ in range(z): name = input().strip() score = float(input().strip()) phy.append([name, score]) grd.append(score) pass phy.sort() grd.sort() sco = grd[1] cou = grd.count(sco) if c...
n, i = int(input()), 0 while n: i += 1 n = int(input()) print(i)
(n, i) = (int(input()), 0) while n: i += 1 n = int(input()) print(i)
""" You will learn more about "Bayesian brains" and the theory surrounding these ideas once the course begins. Here is a brief explanation: it may be ideal for human brains to implement Bayesian inference by integrating "prior" information the brain has about the world (memories, prior knowledge, etc.) with new eviden...
""" You will learn more about "Bayesian brains" and the theory surrounding these ideas once the course begins. Here is a brief explanation: it may be ideal for human brains to implement Bayesian inference by integrating "prior" information the brain has about the world (memories, prior knowledge, etc.) with new evidenc...
# Write a python script to generate Fibonacci terms using generator function. def fin(n): a, b = 0, 1 for _ in range(n): yield a a, b = b, a + b ln = int(input('Enter a number: ')) print(list(fin(ln)))
def fin(n): (a, b) = (0, 1) for _ in range(n): yield a (a, b) = (b, a + b) ln = int(input('Enter a number: ')) print(list(fin(ln)))
class Calc: def calc(opr, num1, num2): if (opr.lower() == "+") or (opr.lower() == "sum") or (opr.lower() == "plus"): print(num1 + num2) elif (opr.lower() == "-") or (opr.lower() == 'subtract') or (opr.lower() == 'minus'): print(num1 - num2) elif (opr.lower() == "*") ...
class Calc: def calc(opr, num1, num2): if opr.lower() == '+' or opr.lower() == 'sum' or opr.lower() == 'plus': print(num1 + num2) elif opr.lower() == '-' or opr.lower() == 'subtract' or opr.lower() == 'minus': print(num1 - num2) elif opr.lower() == '*' or opr.lower()...
BOT_TOKEN = "1629027959:AAEaTw4s2qaAL3mYP3fQRnE" RESULTS_COUNT = 4 # NOTE Number of results to show, 4 is better SUDO_CHATS_ID = [-1001477025068, -1001440596979] DRIVE_NAME = [ "Root", # folder 1 name "Cartoon", # folder 2 name "Course", # folder 3 name "Movies", # .... "Series", # ...... ...
bot_token = '1629027959:AAEaTw4s2qaAL3mYP3fQRnE' results_count = 4 sudo_chats_id = [-1001477025068, -1001440596979] drive_name = ['Root', 'Cartoon', 'Course', 'Movies', 'Series', 'Others'] drive_id = ['1B9A3QqQqF31IuW2om3Qhr-wkiVLloxw8', '12wNJTjNnR-CNBOTnLHqe-1vqFvCRLecn', '11nZcObsJJHojHYg43dBS0_eVvJrSD7Nf', '10_hTMK...
def list_sum(input_list): sum = 0 # todo: Write a for loop that adds the elements # of input_list to the sum variable for value in input_list: sum += value return sum #These test cases check the list_sum works correctly test1 = list_sum([1, 2, 3]) print("expected result: 6, actual result...
def list_sum(input_list): sum = 0 for value in input_list: sum += value return sum test1 = list_sum([1, 2, 3]) print('expected result: 6, actual result: {}'.format(test1)) test2 = list_sum([-1, 0, 1]) print('expected result: 0, actual result: {}'.format(test2))
# -*- coding: utf-8 -*- # Copyright 2021 Cohesity Inc. class GcpParams(object): """Implementation of the 'GcpParams' model. Specifies various resources when converting and deploying a VM to GCP. Attributes: instance_id (long|int): Specifies id of the GCP instance type in which to de...
class Gcpparams(object): """Implementation of the 'GcpParams' model. Specifies various resources when converting and deploying a VM to GCP. Attributes: instance_id (long|int): Specifies id of the GCP instance type in which to deploy the VM. region (long|int): Specifies id of th...