content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
name = '{name:s}' isins = 'isinstance(' + name + ', ' isStr = 'isinstance({name:s}, str)' isstr = isStr + ' or {name:s} is None' isTpl = 'isinstance({name:s}, tuple)' istpl = isTpl + ' or {name:s} is None' isBool = 'isinstance({name:s}, (bool, np.bool_))' isbool = isBool + ' or {name:s} is None' isInt = 'isinstance({n...
name = '{name:s}' isins = 'isinstance(' + name + ', ' is_str = 'isinstance({name:s}, str)' isstr = isStr + ' or {name:s} is None' is_tpl = 'isinstance({name:s}, tuple)' istpl = isTpl + ' or {name:s} is None' is_bool = 'isinstance({name:s}, (bool, np.bool_))' isbool = isBool + ' or {name:s} is None' is_int = 'isinstance...
# keyboard input and concatenation name = input("Enter Name: ") color = input("What's your favorite color? ") count = input("How many? ") print(name + " ate " + count + ' ' + color + " dicks today.")
name = input('Enter Name: ') color = input("What's your favorite color? ") count = input('How many? ') print(name + ' ate ' + count + ' ' + color + ' dicks today.')
#!/usr/bin/env python3 # # MIT License # # Copyright (c) 2020-2021 EntySec # # 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...
class Dictionary: def __init__(self): self.paths = ['~root', '~toor', '~bin', '~daemon', '~adm', '~lp', '~sync', '~shutdown', '~halt', '~mail', '~pop', '~postmaster', '~news', '~uucp', '~operator', '~games', '~gopher', '~ftp', '~nobody', '~nscd', '~mailnull', '~ident', '~rpc', '~rpcuser', '~xfs', '~gdm', '...
SERVER_HOST = '0.0.0.0' SERVER_PORT = 5000 SECRET_KEY = 'ABCJKSKMKJFJIF' DEBUG = True
server_host = '0.0.0.0' server_port = 5000 secret_key = 'ABCJKSKMKJFJIF' debug = True
# my_lambbdata/polos.py # Polo Class! # attributes / properties (NOUNS): size, style, color, texture, price # methods (VERBS): wash, fold, pop collar class Polo(): def __init__(self, size, color): self.size = size self.color = color @property def full_name(self): return f"{self.si...
class Polo: def __init__(self, size, color): self.size = size self.color = color @property def full_name(self): return f'{self.size} {self.color}' def wash(self): print(f'WASHING THE {self.size} {self.color} POLO!') @staticmethod def fold(): print(f'FO...
# Constants IMG_SIZE = (48, 48) EMOTIONS = { # 'anger': 1, # 'disgust': 2, # 'fear': 3, 4: 'happy', # 'sad': 5, 6: 'surprise', } THRESHOLDS = { # 1: 0.5, # 2: 0.5, # 3: 0.5, 4: 0.80, # 5: 0.5, 6: 0.6, }
img_size = (48, 48) emotions = {4: 'happy', 6: 'surprise'} thresholds = {4: 0.8, 6: 0.6}
class FrontendPortName(object): def read_get(self, name, idx_name, unity_client): return unity_client.get_frontend_port_name(idx_name) class FrontendPortNameColumn(object): def get_idx(self, name, idx, unity_client): return unity_client.get_frontend_ports()
class Frontendportname(object): def read_get(self, name, idx_name, unity_client): return unity_client.get_frontend_port_name(idx_name) class Frontendportnamecolumn(object): def get_idx(self, name, idx, unity_client): return unity_client.get_frontend_ports()
# part 1 with open("inputs/day1.txt", "r") as f: lines = f.read().strip().split("\n") n_increases = 0 for left, right in zip(lines[:-1], lines[1:]): if int(right) > int(left): n_increases += 1 print("Part 1:", n_increases) # part 2 n_increases = 0 prevval = None for left, middle, right in zip(lin...
with open('inputs/day1.txt', 'r') as f: lines = f.read().strip().split('\n') n_increases = 0 for (left, right) in zip(lines[:-1], lines[1:]): if int(right) > int(left): n_increases += 1 print('Part 1:', n_increases) n_increases = 0 prevval = None for (left, middle, right) in zip(lines[:-2], lines[1:-1],...
class C: def method(self): def foo(): def bar(): pass # bar # bar # bar # method # class
class C: def method(self): def foo(): def bar(): pass
def test_user_login_logged_in(cli_run, mock_user): result = cli_run(['user', 'login']) assert result.exit_code == 0 assert 'Hello' in result.output
def test_user_login_logged_in(cli_run, mock_user): result = cli_run(['user', 'login']) assert result.exit_code == 0 assert 'Hello' in result.output
class Solution: def findMedianSortedArrays(self, nums1: [int], nums2: [int]) -> float: if len(nums1) > len(nums2): nums1, nums2 = nums2, nums1 l, r = 0, 2 * len(nums1) while l <= r: m1 = (l + r) // 2 m2 = len(nums1) + len(nums2) - m1 left1 = nums1[(m1 - 1)...
class Solution: def find_median_sorted_arrays(self, nums1: [int], nums2: [int]) -> float: if len(nums1) > len(nums2): (nums1, nums2) = (nums2, nums1) (l, r) = (0, 2 * len(nums1)) while l <= r: m1 = (l + r) // 2 m2 = len(nums1) + len(nums2) - m1 ...
class BUILD_TREE(object): def __init__(self, **args): self.tree = {} def _convertargs(self, args): for item, value in args.items(): if not ((type(value) is list) or (type(value) is dict)): args[item] = str(value) def populateTree(self, tag, text='', attr=None, c...
class Build_Tree(object): def __init__(self, **args): self.tree = {} def _convertargs(self, args): for (item, value) in args.items(): if not (type(value) is list or type(value) is dict): args[item] = str(value) def populate_tree(self, tag, text='', attr=None, c...
__author__ = 'ktisha' class A: ccc = True def foo(self): self.ccc = False
__author__ = 'ktisha' class A: ccc = True def foo(self): self.ccc = False
# # PySNMP MIB module ERI-DNX-SMC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ERI-DNX-SMC-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:51:36 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, constraints_intersection, value_range_constraint, constraints_union) ...
class File_List: wordList=[] def __init__(self): self.wordList = ['.c', '.h', '.java', '.py', '.php', '.html', '.css', '.xml', '.tcp', 'sqlite3.o', 'sqlite.o', 'sqlite2.o', '.sh', '.dat', '.josn', 'http', 'www', 'sconscript', ...
class File_List: word_list = [] def __init__(self): self.wordList = ['.c', '.h', '.java', '.py', '.php', '.html', '.css', '.xml', '.tcp', 'sqlite3.o', 'sqlite.o', 'sqlite2.o', '.sh', '.dat', '.josn', 'http', 'www', 'sconscript'] def get_list(self): return self.wordList
_base_ = [ '../_base_/models/resnet50_doc_quality.py', '../_base_/datasets/doc_quality.py', '../_base_/schedules/schedule_200.py', '../_base_/default_runtime.py' ]
_base_ = ['../_base_/models/resnet50_doc_quality.py', '../_base_/datasets/doc_quality.py', '../_base_/schedules/schedule_200.py', '../_base_/default_runtime.py']
load("//python:python_grpc_compile.bzl", "python_grpc_compile") def python_grpc_library(**kwargs): # Compile protos name_pb = kwargs.get("name") + "_pb" python_grpc_compile( name = name_pb, **{k: v for (k, v) in kwargs.items() if k in ("deps", "verbose")} # Forward args ) # Pick de...
load('//python:python_grpc_compile.bzl', 'python_grpc_compile') def python_grpc_library(**kwargs): name_pb = kwargs.get('name') + '_pb' python_grpc_compile(name=name_pb, **{k: v for (k, v) in kwargs.items() if k in ('deps', 'verbose')}) if 'python_version' not in kwargs or kwargs['python_version'] == 'PY3'...
class ChangelogError(Exception): pass class ChangelogParseError(ChangelogError): pass class ChangelogValidationError(ChangelogError): pass class ChangelogMissingConfigError(ChangelogError): def __init__(self, message: str, field: str = None): super().__init__(message) self.field = ...
class Changelogerror(Exception): pass class Changelogparseerror(ChangelogError): pass class Changelogvalidationerror(ChangelogError): pass class Changelogmissingconfigerror(ChangelogError): def __init__(self, message: str, field: str=None): super().__init__(message) self.field = fiel...
def no_space(x): l = [] for i in x: if i == " " : continue l.append(i) return ''.join(l) def no_space1(x): x = x.replace(" ", "") return x
def no_space(x): l = [] for i in x: if i == ' ': continue l.append(i) return ''.join(l) def no_space1(x): x = x.replace(' ', '') return x
# fn to generate fibonacci numbers upto a given range def fibonacci_Series(upto): fibonacci_list = [] x = 0 y = 1 while x < upto: fibonacci_list.append(x) x, y = y, x+y return fibonacci_list # Driver's Code print(fibonacci_Series(100))
def fibonacci__series(upto): fibonacci_list = [] x = 0 y = 1 while x < upto: fibonacci_list.append(x) (x, y) = (y, x + y) return fibonacci_list print(fibonacci__series(100))
people = {'name': 'Henrique', 'sex': 'M', 'age': 24} print(f'{people["name"]} is {people["age"]} years old') print(people.keys()) print(people.values()) print(people.items()) for key, values in people.items(): print(f'{key} = {values}') del people['sex'] print(people) people['name'] = 'Gustavo' people['weight'] ...
people = {'name': 'Henrique', 'sex': 'M', 'age': 24} print(f"{people['name']} is {people['age']} years old") print(people.keys()) print(people.values()) print(people.items()) for (key, values) in people.items(): print(f'{key} = {values}') del people['sex'] print(people) people['name'] = 'Gustavo' people['weight'] =...
try: print(int(input())) except: print("Bad String")
try: print(int(input())) except: print('Bad String')
def pairwise(iterable): it = iter(iterable) a = next(it, None) for b in it: yield (a, b) a = b num_tests = int(input()) for test in range(num_tests): num_walls = int(input()) walls = list(map(int, input().split())) h = l = 0 if len(walls) >= 2: for c, n in pairwise(walls): if n > c: ...
def pairwise(iterable): it = iter(iterable) a = next(it, None) for b in it: yield (a, b) a = b num_tests = int(input()) for test in range(num_tests): num_walls = int(input()) walls = list(map(int, input().split())) h = l = 0 if len(walls) >= 2: for (c, n) in pairwise(...
# MIT License # # Copyright (c) 2019 Nathaniel Brough # # 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, modify, me...
load('@rules_cc//cc:defs.bzl', 'cc_toolchain') load('@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl', 'tool_path') load('@bazel_tools//tools/build_defs/cc:action_names.bzl', 'ACTION_NAMES') load('@com_llvm_compiler//:defs.bzl', 'SYSTEM_INCLUDE_COMMAND_LINE', 'SYSTEM_INCLUDE_PATHS', 'SYSTEM_SYSROOT') load('//toolch...
# # This file is subject to the terms and conditions defined in # file 'LICENSE', which is part of this source code package. # class Menu: def __init__(self, header=None, choices=None, on_show=None, on_invalid_choice=None, key_sep=': ', input_text='Choice: ', invalid_choice_text='Invalid input.'): self.head...
class Menu: def __init__(self, header=None, choices=None, on_show=None, on_invalid_choice=None, key_sep=': ', input_text='Choice: ', invalid_choice_text='Invalid input.'): self.header = header self.choices = choices self.on_show = on_show self.on_invalid_choice = on_invalid_choice ...
''' Reversed Queue Write a function that takes a queue as an input and returns a reversed version of it. ''' # Solution class LinkedListNode: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self): self.num_elements = 0 self.head = None ...
""" Reversed Queue Write a function that takes a queue as an input and returns a reversed version of it. """ class Linkedlistnode: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self): self.num_elements = 0 self.head = None def push...
class Solution: def maximalSquare(self, matrix): if not matrix: return 0 row = [0] * len(matrix[0]) res = 0 for i in xrange(len(matrix)): top_left = 0 for j in xrange(len(matrix[i])): if matrix[i][j] == "0": ...
class Solution: def maximal_square(self, matrix): if not matrix: return 0 row = [0] * len(matrix[0]) res = 0 for i in xrange(len(matrix)): top_left = 0 for j in xrange(len(matrix[i])): if matrix[i][j] == '0': to...
optimizer = dict(type='Adam', lr=0.001) optimizer_config = dict(grad_clip=None) lr_config = dict(policy='poly', power=0.9) total_epochs = 5000 checkpoint_config = dict(interval=10) log_config = dict(interval=5, hooks=[dict(type='TextLoggerHook')]) dist_params = dict(backend='nccl') log_level = 'INFO' load_from = None r...
optimizer = dict(type='Adam', lr=0.001) optimizer_config = dict(grad_clip=None) lr_config = dict(policy='poly', power=0.9) total_epochs = 5000 checkpoint_config = dict(interval=10) log_config = dict(interval=5, hooks=[dict(type='TextLoggerHook')]) dist_params = dict(backend='nccl') log_level = 'INFO' load_from = None r...
# Simple game in python print('Hi, welcome to the Tim quiz!') print('Try to get as many questions correct as possible...') totalQuestions = 4 score = 0 ans = input('1. What is the name of my youtube channel? ') if ans.lower() == 'tech with tim': print('Correct!') score += 1 else: print('In...
print('Hi, welcome to the Tim quiz!') print('Try to get as many questions correct as possible...') total_questions = 4 score = 0 ans = input('1. What is the name of my youtube channel? ') if ans.lower() == 'tech with tim': print('Correct!') score += 1 else: print('Incorrect') ans = input('2. What is my age?...
# add this file to your .gitignore file of the project LOCAL_SETTINGS = dict( media_root='/Users/user/projects/project/media', path='/Users/user/projects/project', virtualenv_path='/Users/user/virtualenvs/project', )
local_settings = dict(media_root='/Users/user/projects/project/media', path='/Users/user/projects/project', virtualenv_path='/Users/user/virtualenvs/project')
def tw(f,t,st): for x in range(t): f.write("\t") nl = True if st[-1] == "#": nl = False st = st[:-1] f.write(st) if nl: f.write("\n") def write_property_lua(f, tab, name, value, pref = ""): tw(f, tab, '%s{ name = "%s",' % (pref, name)) tab = tab + 1 if (type(value)==str): tw(f, tab, 'value = "%s...
def tw(f, t, st): for x in range(t): f.write('\t') nl = True if st[-1] == '#': nl = False st = st[:-1] f.write(st) if nl: f.write('\n') def write_property_lua(f, tab, name, value, pref=''): tw(f, tab, '%s{ name = "%s",' % (pref, name)) tab = tab + 1 if ty...
fileout = open("requests.sh", "w") for i in range(1,57): if i >= 10: s = "0" + str(i) else: s = "00" + str(i) fileout.write("curl -s -H 'Content-Type: application/json' -H " + '"Authorization: Bearer `gcloud auth print-access-token`"' + " https://speech.googleapis.com/v1/speech:recognize -d" + ''' "{'config': ...
fileout = open('requests.sh', 'w') for i in range(1, 57): if i >= 10: s = '0' + str(i) else: s = '00' + str(i) fileout.write("curl -s -H 'Content-Type: application/json' -H " + '"Authorization: Bearer `gcloud auth print-access-token`"' + ' https://speech.googleapis.com/v1/speech:recognize -d...
def define_env(env): "Definition of the module" @env.macro def feedback(title, section, slug): email_address = f"{section}+{slug}@technotes.jakoubek.net" md = "\n\n## Feedback / Kontakt\n\n" md += f"Wenn Sie Fragen oder Anregungen zum Artikel *{title}* haben, senden Sie mir bitte ei...
def define_env(env): """Definition of the module""" @env.macro def feedback(title, section, slug): email_address = f'{section}+{slug}@technotes.jakoubek.net' md = '\n\n## Feedback / Kontakt\n\n' md += f'Wenn Sie Fragen oder Anregungen zum Artikel *{title}* haben, senden Sie mir bitt...
class Solution: # # Greedy (Accepted), O(n) time, O(1) space # def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool: # plots = len(flowerbed) # flowerbed.append(0) # prev = planted = 0 # for i in range(plots): # if flowerbed[i] == 0: # if pr...
class Solution: def can_place_flowers(self, A: List[int], N: int) -> bool: for (i, x) in enumerate(A): if not x and (i == 0 or A[i - 1] == 0) and (i == len(A) - 1 or A[i + 1] == 0): n -= 1 A[i] = 1 return N <= 0
# PyZ3950_parsetab.py # This file is automatically generated. Do not edit. _lr_method = 'SLR' _lr_signature = '\xfc\xb2\xa8\xb7\xd9\xe7\xad\xba"\xb2Ss\'\xcd\x08\x16' _lr_action_items = {'QUOTEDVALUE':([18,12,14,0,26,],[1,1,1,1,1,]),'LOGOP':([3,5,20,4,6,27,19,24,25,13,22,1,],[-5,-8,-4,-14,14,14,14,-9,-6,-13,-7,-12,]...
_lr_method = 'SLR' _lr_signature = 'ü²¨·Ùç\xadº"²Ss\'Í\x08\x16' _lr_action_items = {'QUOTEDVALUE': ([18, 12, 14, 0, 26], [1, 1, 1, 1, 1]), 'LOGOP': ([3, 5, 20, 4, 6, 27, 19, 24, 25, 13, 22, 1], [-5, -8, -4, -14, 14, 14, 14, -9, -6, -13, -7, -12]), 'SET': ([12, 14, 0, 26], [10, 10, 10, 10]), 'WORD': ([12, 14, 0, 5, 18, ...
# # PySNMP MIB module RSPAN-MGMT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RSPAN-MGMT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:50:21 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, value_size_constraint, constraints_intersection, constraints_union, single_value_constraint) ...
class Node: def __init__(self, declaration_list): self.declaration_list = declaration_list def visit(self): context = {"type": "program"} return self.declaration_list.visit(context)
class Node: def __init__(self, declaration_list): self.declaration_list = declaration_list def visit(self): context = {'type': 'program'} return self.declaration_list.visit(context)
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def _diameterBTree(self,root): if not root: return 0 l = self._diameterBTree(root.left) r = self._diameterBTree...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def _diameter_b_tree(self, root): if not root: return 0 l = self._diameterBTree(root.left) r = self._diameterBTree(root.right) self.ans = ...
class Modification: def __init__(self): self.AAs=[] self.mass=0.0 self.NL={} self.DI={} self.factor=1 self.name="" self.ID=-1 def setAAs(self, newAAlist): self.AAs=newAAlist return True def getAAs(self): return self.AAs d...
class Modification: def __init__(self): self.AAs = [] self.mass = 0.0 self.NL = {} self.DI = {} self.factor = 1 self.name = '' self.ID = -1 def set_a_as(self, newAAlist): self.AAs = newAAlist return True def get_a_as(self): r...
class Node: def __init__(self,data): self.data=data self.next=None class LinkedList: def __init__(self): self.head=None def append(self,newdata): new_node=Node(newdata) if self.head is None: self.head=new_node return temp=se...
class Node: def __init__(self, data): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None def append(self, newdata): new_node = node(newdata) if self.head is None: self.head = new_node return tem...
class Error(Exception): message = None def __str__(self): return repr(self.message) class GSLZeroDivision(Error): message = "GSL encountered zero division" class GSLFailure(Error): message = "GSL failed" class GSLMemoryFailure(Error): message = "GSL failed to allocate necessary memory" ...
class Error(Exception): message = None def __str__(self): return repr(self.message) class Gslzerodivision(Error): message = 'GSL encountered zero division' class Gslfailure(Error): message = 'GSL failed' class Gslmemoryfailure(Error): message = 'GSL failed to allocate necessary memory' ...
# coding=utf-8 class TestTeamcityMessages: def testPass(self): pass def testAssertEqual(self): assert (True == True) def testAssertEqualFails(self): assert 1 == 2 def testAssertFalse(self): assert False def testException(self): raise Exception("some exce...
class Testteamcitymessages: def test_pass(self): pass def test_assert_equal(self): assert True == True def test_assert_equal_fails(self): assert 1 == 2 def test_assert_false(self): assert False def test_exception(self): raise exception('some exception')
volatile = False log_norm = False # Maximal sequence length in training data max_seq_len = 50 ''' Embedding layer ''' # Size of word embedding of source word and target word src_wemb_size = 512 trg_wemb_size = 512 ''' Encoder layer ''' # Size of hidden units in encoder enc_hid_size = 512 ''' Attention layer ''' #...
volatile = False log_norm = False max_seq_len = 50 '\nEmbedding layer\n' src_wemb_size = 512 trg_wemb_size = 512 '\nEncoder layer\n' enc_hid_size = 512 '\nAttention layer\n' align_size = 512 '\nDecoder layer\n' dec_hid_size = 512 out_size = 512 drop_rate = 0.5 dir_model = 'wmodel' dir_valid = 'wvalid' dir_tests = 'wtes...
# PROBLEM # # Now write a program that calculates the minimum fixed monthly payment needed # in order to pay off a credit card balance within 12 months. By a fixed # monthly payment, we mean a single number which does not change each month, # but instead is a constant amount that will be paid each month. # # In this...
balance = 5000 annual_interest_rate = 0.18 def year_end_balance(balance, monthlyPayment): """ balance: outstanding balance on the credit card (int or float) monthlyPayment: fixed monthly payment (int or float) returns: ending balance on the credit card after 12 months (int or float) """ fo...
##Hello World Example #!/user/bin/env python3 print("Hello", "world!")
print('Hello', 'world!')
buttons = { "brightness up": [9097, 4455, 635, 495, 629, 502, 632, 499, 636, 494, 630, 500, 603, 528, 627, 503, 632, 500, 603, 1628, 599, 1632, 606, 1625, 602, 1627, 600, 530, 604, 1626, 601, 1630, 628, 1603, 603, 529, 606, 525, 599, 532, 602, 530, 604, 528, 607, 524, 599, 532, 603, 528, 606, 1625, 610, 1622, 608, 1624...
buttons = {'brightness up': [9097, 4455, 635, 495, 629, 502, 632, 499, 636, 494, 630, 500, 603, 528, 627, 503, 632, 500, 603, 1628, 599, 1632, 606, 1625, 602, 1627, 600, 530, 604, 1626, 601, 1630, 628, 1603, 603, 529, 606, 525, 599, 532, 602, 530, 604, 528, 607, 524, 599, 532, 603, 528, 606, 1625, 610, 1622, 608, 1624,...
# Haystack settings for running tests. DATABASE_ENGINE = 'sqlite3' DATABASE_NAME = 'haystack_tests.db' INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'haystack', 'core', ] ROOT_URLCONF = 'c...
database_engine = 'sqlite3' database_name = 'haystack_tests.db' installed_apps = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'haystack', 'core'] root_urlconf = 'core.urls' haystack_connections = {'default': {'ENGINE': 'core.tests.mock...
# Python program for implementation of MergeSort(Implement Divide and conquer) # MergeSort(arr[], l, r) # If r > l # 1. Find the middle point to divide the array into two halves: # middle m = l+ (r-l)/2 # 2. Call mergeSort for first half: # Call mergeSort(arr, l, m) # ...
def merge_sort(arr): if len(arr) > 1: mid = len(arr) // 2 l = arr[:mid] r = arr[mid:] merge_sort(L) merge_sort(R) i = j = k = 0 while i < len(L) and j < len(R): if L[i] < R[j]: arr[k] = L[i] i += 1 else: ...
class Component(object): _env = None _di = None _args = None _kwargs = None def setDi(self, di): self._di = di def getDi(self): return self._di def getEnv(self): return self._env def setEnv(self, env): self._env = env def setAr...
class Component(object): _env = None _di = None _args = None _kwargs = None def set_di(self, di): self._di = di def get_di(self): return self._di def get_env(self): return self._env def set_env(self, env): self._env = env def set_args(self, args):...
with open('F:\\url.txt', 'r') as f: list1 = f.readlines() def remain720p(args): return args.find('720P') > 0 list2 = filter(remain720p, list1) with open('F:\\url2.txt', 'w') as f2: for str2 in list2: f2.writelines(str2)
with open('F:\\url.txt', 'r') as f: list1 = f.readlines() def remain720p(args): return args.find('720P') > 0 list2 = filter(remain720p, list1) with open('F:\\url2.txt', 'w') as f2: for str2 in list2: f2.writelines(str2)
def fib(i: int) -> int: if i == 0 or i == 1: return 1 return fib(i - 1) + fib(i - 2) if __name__ == "__main__": # Using a variable to workaround # https://github.com/adsharma/py2many/issues/64 rv = fib(5) print(rv)
def fib(i: int) -> int: if i == 0 or i == 1: return 1 return fib(i - 1) + fib(i - 2) if __name__ == '__main__': rv = fib(5) print(rv)
class Defaults(object): window_size = 7 hidden_sizes = [300] hidden_activation = 'relu' max_vocab_size = 1000000 optimizer = 'sgd' # 'adam' learning_rate = 0.1 # 1e-4 epochs = 20 iobes = True # Map tags to IOBES on input max_tokens = None # Max dataset size in tokens encodi...
class Defaults(object): window_size = 7 hidden_sizes = [300] hidden_activation = 'relu' max_vocab_size = 1000000 optimizer = 'sgd' learning_rate = 0.1 epochs = 20 iobes = True max_tokens = None encoding = 'utf-8' output_drop_prob = 0.0 token_level_eval = False verbosi...
class Config: EPS = 1e-14 RPN_CLOBBER_POSITIVES = False RPN_NEGATIVE_OVERLAP = 0.3 RPN_POSITIVE_OVERLAP = 0.7 RPN_FG_FRACTION = 0.5 RPN_BATCHSIZE = 300 RPN_BBOX_INSIDE_WEIGHTS = (1.0, 1.0, 1.0, 1.0) RPN_POSITIVE_WEIGHT = -1.0 RPN_PRE_NMS_TOP_N = 12000 RPN_POST_NMS_TOP_N = 1000 ...
class Config: eps = 1e-14 rpn_clobber_positives = False rpn_negative_overlap = 0.3 rpn_positive_overlap = 0.7 rpn_fg_fraction = 0.5 rpn_batchsize = 300 rpn_bbox_inside_weights = (1.0, 1.0, 1.0, 1.0) rpn_positive_weight = -1.0 rpn_pre_nms_top_n = 12000 rpn_post_nms_top_n = 1000 ...
hps = { "0351291110650853": { "ott_len": 35, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 65, "max_risk_long": 85 }, "0561821341040643": { "ott_len": 56, "ott_percent": 182, "ott_bw_up": 134, "tps_qty_index": 104, "max_risk_long": 64 }, "0351291110200403": { "ott_len": 35, "ott_pe...
hps = {'0351291110650853': {'ott_len': 35, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 65, 'max_risk_long': 85}, '0561821341040643': {'ott_len': 56, 'ott_percent': 182, 'ott_bw_up': 134, 'tps_qty_index': 104, 'max_risk_long': 64}, '0351291110200403': {'ott_len': 35, 'ott_percent': 129, 'ott_bw_up': 111, 'tps...
class Configuration(object): def __init__(self, **kwargs): for key, value in kwargs.items(): if isinstance(value, dict): value = Configuration(**value) setattr(self, key, value) def to_dict(self): rv = {} for key, value in self.__dict__.items(): ...
class Configuration(object): def __init__(self, **kwargs): for (key, value) in kwargs.items(): if isinstance(value, dict): value = configuration(**value) setattr(self, key, value) def to_dict(self): rv = {} for (key, value) in self.__dict__.items...
product = input() day = input() quantity = float(input()) price = 0 isError = False if day == 'Saturday' or day == 'Sunday': if product == 'banana': price = 2.7 elif product == 'apple': price = 1.25 elif product == 'orange': price = 0.9 elif product == 'grapefruit':...
product = input() day = input() quantity = float(input()) price = 0 is_error = False if day == 'Saturday' or day == 'Sunday': if product == 'banana': price = 2.7 elif product == 'apple': price = 1.25 elif product == 'orange': price = 0.9 elif product == 'grapefruit': pric...
# -*- coding: utf-8 -*- class Precipitation(object): def __init__(self, precipitation): self.value = float(precipitation['value']) try: self.minValue = float(precipitation['minvalue']) except KeyError: self.minValue = None try: self.maxValue = fl...
class Precipitation(object): def __init__(self, precipitation): self.value = float(precipitation['value']) try: self.minValue = float(precipitation['minvalue']) except KeyError: self.minValue = None try: self.maxValue = float(precipitation['maxval...
def run(): r.setpos(0,0,0)
def run(): r.setpos(0, 0, 0)
class Command: TO_CN = 1 TO_EN = 2 JSON_FORMAT = 3 URL_ENCODE = 4 URL_DECODE = 5
class Command: to_cn = 1 to_en = 2 json_format = 3 url_encode = 4 url_decode = 5
# checking for armstrong number a = input("Enter a number") n = int(a) S = 0 while n > 0: d = n % 10 S = S + d * d * d n = n / 10 if int(a) == S: print("Armstrong Number") else: print("Not an Armstrong Number")
a = input('Enter a number') n = int(a) s = 0 while n > 0: d = n % 10 s = S + d * d * d n = n / 10 if int(a) == S: print('Armstrong Number') else: print('Not an Armstrong Number')
class BuildEnvironmentError(Exception): def __init__(self, msg, build_env): self.msg = msg self.build_env = build_env def __str__(self): return "{}({})".format(self.__class__.__name__, repr(self.msg)) class VariantDBConnectionError(BuildEnvironmentError): def __init__(self, connec...
class Buildenvironmenterror(Exception): def __init__(self, msg, build_env): self.msg = msg self.build_env = build_env def __str__(self): return '{}({})'.format(self.__class__.__name__, repr(self.msg)) class Variantdbconnectionerror(BuildEnvironmentError): def __init__(self, conne...
class Queue: def __init__(self): self.queue = list() def enqueue(self,data): if data not in self.queue: self.queue.insert(0,data) return True return False def dequeue(self): if len(self.queue)>0: return self.queue.pop() return ("Queue ...
class Queue: def __init__(self): self.queue = list() def enqueue(self, data): if data not in self.queue: self.queue.insert(0, data) return True return False def dequeue(self): if len(self.queue) > 0: return self.queue.pop() retur...
class TerminalSet: NODE_TYPE = 'terminal' @classmethod def is_terminal_value(cls, node): return node['node_type'] == cls.NODE_TYPE and node.has_key('value') and (node['type'] in ['int', 'float']) @classmethod def terminal_value(cls, value): return {'node_type': cls.NODE_TYPE, 'name': str(value), 'va...
class Terminalset: node_type = 'terminal' @classmethod def is_terminal_value(cls, node): return node['node_type'] == cls.NODE_TYPE and node.has_key('value') and (node['type'] in ['int', 'float']) @classmethod def terminal_value(cls, value): return {'node_type': cls.NODE_TYPE, 'name...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright (c) 2019 Idiap Research Institute, http://www.idiap.ch/ # Written by Bastian Schnell <bastian.schnell@idiap.ch> # class EmbeddingConfig(object): def __init__(self, f_get_emb_index, num_embeddings, embedding_dim, name=None, **args): assert calla...
class Embeddingconfig(object): def __init__(self, f_get_emb_index, num_embeddings, embedding_dim, name=None, **args): assert callable(f_get_emb_index), 'f_get_emb_index must be callable.' self.f_get_emb_index = f_get_emb_index self.num_embeddings = num_embeddings self.embedding_dim ...
y=int(input("Enter The year: ")) if(((y%2==0)or (y%400==0))and y%100!=0): print("leap Year") else: print("Not Leap year")
y = int(input('Enter The year: ')) if (y % 2 == 0 or y % 400 == 0) and y % 100 != 0: print('leap Year') else: print('Not Leap year')
class Notifier: def __init(self): pass def notify(self, msg): print(msg) def message(self, msg): print(msg) def message2(self, msg2): print(msg2)
class Notifier: def __init(self): pass def notify(self, msg): print(msg) def message(self, msg): print(msg) def message2(self, msg2): print(msg2)
class Solution: def reverseWords(self, s: str) -> str: list1 = s.split(' ')[::-1] new_string = "" for i in range(0,len(list1)): if(list1[i]!=""): if(len(new_string)>0): new_string+=" " new_string+=list1[i] return new_str...
class Solution: def reverse_words(self, s: str) -> str: list1 = s.split(' ')[::-1] new_string = '' for i in range(0, len(list1)): if list1[i] != '': if len(new_string) > 0: new_string += ' ' new_string += list1[i] retur...
def relay_states_registar_value(relay_states): num = 0 n = 8 for relay_state in relay_states: if relay_state: num += 2**n n += 1 return num def relay_states_from_register_value(value): relay_states = [] num = value for i in range(11, 7, -1): if...
def relay_states_registar_value(relay_states): num = 0 n = 8 for relay_state in relay_states: if relay_state: num += 2 ** n n += 1 return num def relay_states_from_register_value(value): relay_states = [] num = value for i in range(11, 7, -1): if num >= 2...
# for loop # Iterating over a list print("List Iteration") l = ["Ankit", "Gupta"] for i in l: print(i) # Iterating over a tuple (immutable) print("\nTuple Iteration") t = ("ankit", "gupta") for i in t: print(i) # Iterating over a String print("\nString Iteration") s = "Ankit" for i in s: print(i...
print('List Iteration') l = ['Ankit', 'Gupta'] for i in l: print(i) print('\nTuple Iteration') t = ('ankit', 'gupta') for i in t: print(i) print('\nString Iteration') s = 'Ankit' for i in s: print(i) print('\nDictionary Iteration') d = dict() d['xyz'] = 123 d['abc'] = 345 for i in d: print('% s % d' % (...
with open('html_file.html','r') as rf: with open('output.txt','w') as of: for string in rf.readlines(): if "<a href=" in string : of.write(string) #Some Better Solution for video lecture no. 223
with open('html_file.html', 'r') as rf: with open('output.txt', 'w') as of: for string in rf.readlines(): if '<a href=' in string: of.write(string)
#!/usr/bin/env python input = input("Enter IP address: ") octets = input.split(".") first_octet = bin(int(octets[0])) second_octet = bin(int(octets[1])) third_octet = bin(int(octets[2])) forth_octet = bin(int(octets[3])) print("%-20s%-20s%-20s%-20s" % ("First Octet", "Second Octet", "T...
input = input('Enter IP address: ') octets = input.split('.') first_octet = bin(int(octets[0])) second_octet = bin(int(octets[1])) third_octet = bin(int(octets[2])) forth_octet = bin(int(octets[3])) print('%-20s%-20s%-20s%-20s' % ('First Octet', 'Second Octet', 'Third Octet', 'Forth Octet')) print('%-20s%-20s%-20s%-20s...
class Region: def __init__ (self, bbox, region_): self.bbox = bbox # [xmin, ymin, xmax, ymax] float self.region_ = region_ # (d_region)
class Region: def __init__(self, bbox, region_): self.bbox = bbox self.region_ = region_
def metade(x): s = x / 2 return s def dobro(n): return 2 * n def aumentar(n, p): return (n * (p / 100)) + n
def metade(x): s = x / 2 return s def dobro(n): return 2 * n def aumentar(n, p): return n * (p / 100) + n
# -*- coding: utf-8 -*- ''' Package containing network handshakes '''
""" Package containing network handshakes """
def _merge(a, b): members = set() members.update(a.members if isinstance(a, TagSet) else {a}) members.update(b.members if isinstance(b, TagSet) else {b}) return TagSet(members) class Tag: def __init__(self, name): self.name = name __and__ = _merge __rand__ = _merge def __repr...
def _merge(a, b): members = set() members.update(a.members if isinstance(a, TagSet) else {a}) members.update(b.members if isinstance(b, TagSet) else {b}) return tag_set(members) class Tag: def __init__(self, name): self.name = name __and__ = _merge __rand__ = _merge def __repr...
'''Unstamp Mail Submission Agent Server This server receives outgoing mail from the email client, and gives it to the Mail Transfer Agent to send. '''
"""Unstamp Mail Submission Agent Server This server receives outgoing mail from the email client, and gives it to the Mail Transfer Agent to send. """
# Copyright 2013 Locaweb. # 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 appli...
class Formatter(object): def host(self, host_id, name, address): return {'id': host_id, 'name': name, 'address': address} def storage(self, sr_id, name, sr_type, used_space, allocated_space, physical_size): return {'id': sr_id, 'name': name, 'type': sr_type, 'used_space': int(used_space), 'all...
class Settings: def __init__(self): # Rotors = Moveable wheels self.rotors = { "I": {"sequence": "ekmflgdqvzntowyhxuspaibrcj", "notches": ["r"]}, "II": {"sequence": "ajdksiruxblhwtmcqgznpyfvoe", "notches": ["f"]}, "III": {"sequence": "bdfhjlcprtxvznyeiwgakmusqo", ...
class Settings: def __init__(self): self.rotors = {'I': {'sequence': 'ekmflgdqvzntowyhxuspaibrcj', 'notches': ['r']}, 'II': {'sequence': 'ajdksiruxblhwtmcqgznpyfvoe', 'notches': ['f']}, 'III': {'sequence': 'bdfhjlcprtxvznyeiwgakmusqo', 'notches': ['w']}, 'IV': {'sequence': 'esovpzjayquirhxlnftgkdcmwb', 'no...
# Copyright 2019 Nicole Borrelli # # 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...
vanilla_flags = {'garland_defeated': 1, 'bridge_to_be_rebuilt': 2, 'obtained_bridge': 3, 'obtained_lute': 4, 'obtained_ship': 5, 'obtained_crown': 6, 'obtained_crystal_eye': 7, 'obtained_jolt_tonic': 8, 'obtained_mystic_key': 9, 'obtained_nitro_powder': 10, 'obtained_canal': 11, 'vampire_defeated': 12, 'obtained_ruby':...
#!/usr/bin/env python3 #encoding=utf-8 #------------------------------------------------- # Usage: python3 4-getattribute_to_compute_attribute.py # Description: attribute management 4 of 4 # Same, but with generic __getattribute__ all attribute interception #----------------------------------------------...
class Powers(object): def __init__(self, square, cube): self._square = square self._cube = cube def __getattribute__(self, name): if name == 'square': return object.__getattribute__(self, '_square') ** 2 elif name == 'cube': return object.__getattribute_...
#!/usr/bin/python3 # files.py by Bill Weinman [http://bw.org/] # This is an exercise file from Python 3 Essential Training on lynda.com # Copyright 2010 The BearHeart Group, LLC def main(): f = open('lines.txt') for line in f: print(line, end = '') if __name__ == "__main__": main()
def main(): f = open('lines.txt') for line in f: print(line, end='') if __name__ == '__main__': main()
#Extensions: # I have Taken Example 5.9 and extended it to dictionary #no users: usernames = { 'aes':{ 'password':'64545465', 'key' : '56' }, 'bes':{ 'password':'64545465', 'key' : '56' }, 'ces':{ 'password':'64546545', 'key' : '56' }, 'ad...
usernames = {'aes': {'password': '64545465', 'key': '56'}, 'bes': {'password': '64545465', 'key': '56'}, 'ces': {'password': '64546545', 'key': '56'}, 'admin': {'password': '64546465', 'key': '5'}} if usernames != {}: for (user, info) in usernames.items(): if user == 'admin': print('Hello, admin...
MACS_VERSION = "3.0.0a7" MAX_PAIRNUM = 1000 MAX_LAMBDA = 100000 FESTEP = 20 BUFFER_SIZE = 100000 # np array will increase at step of 1 million items READ_BUFFER_SIZE = 10000000 # 10M bytes for read buffer size N_MP = 2 # Number of processers
macs_version = '3.0.0a7' max_pairnum = 1000 max_lambda = 100000 festep = 20 buffer_size = 100000 read_buffer_size = 10000000 n_mp = 2
# error if not grade for a student # OPTION 2: change the policy def get_stats(class_list): new_stats = [] for item in class_list: new_stats.append([item[0], item[1], avg(item[1])]) return new_stats def avg(grades): try: return sum(grades)/len(grades) except ZeroDivisionError: ...
def get_stats(class_list): new_stats = [] for item in class_list: new_stats.append([item[0], item[1], avg(item[1])]) return new_stats def avg(grades): try: return sum(grades) / len(grades) except ZeroDivisionError: print('no grades data') return 0.0 test_grades = [[[...
class BaseHelper: def __init__(self, device): self.device = device def params(self, locals_: dict): params = locals_.copy() params.pop('self') return params
class Basehelper: def __init__(self, device): self.device = device def params(self, locals_: dict): params = locals_.copy() params.pop('self') return params
#!/usr/bin/env python # -*- coding: utf-8 -*- class Watchdog(object): KEEP_ALIVE = '\n' DEVICE = '/dev/watchdog' # STOP = 'V' in bleaglebone black not works def __init__(self): pass def notify(self, device, msg): ''' /dev/watchdog is opened and will reboot un...
class Watchdog(object): keep_alive = '\n' device = '/dev/watchdog' def __init__(self): pass def notify(self, device, msg): """ /dev/watchdog is opened and will reboot unless the watchdog is pinged within a certain time. :param device str: path of watchd...
class Solution: def backspaceCompare(self, S: str, T: str) -> bool: s_bcount, t_bcount = 0, 0 s_idx, t_idx = len(S) - 1, len(T) - 1 while s_idx >= 0 or t_idx >= 0: while s_idx >= 0: if S[s_idx] == '#': s_bcount += 1 ...
class Solution: def backspace_compare(self, S: str, T: str) -> bool: (s_bcount, t_bcount) = (0, 0) (s_idx, t_idx) = (len(S) - 1, len(T) - 1) while s_idx >= 0 or t_idx >= 0: while s_idx >= 0: if S[s_idx] == '#': s_bcount += 1 ...
class Solution: def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int: if endWord not in wordList: return 0 result = 0 l = len(beginWord) beginSet = {beginWord} endSet = {endWord} wordList = set(wordList) ...
class Solution: def ladder_length(self, beginWord: str, endWord: str, wordList: List[str]) -> int: if endWord not in wordList: return 0 result = 0 l = len(beginWord) begin_set = {beginWord} end_set = {endWord} word_list = set(wordList) while begin...
# coding: utf8 # try something like # coding: utf8 # try something like def index(): rows = db((db.activity.type=='stand')&(db.activity.status=='accepted')).select() if rows: return dict(projects=rows) else: return plugin_flatpage()
def index(): rows = db((db.activity.type == 'stand') & (db.activity.status == 'accepted')).select() if rows: return dict(projects=rows) else: return plugin_flatpage()
#re-learning about class and objects. class MyClass: #ini class, class adalah blueprint dari object var = "blah" #variable ini adalah object didalan class def function(self): #ini adalah fungsi didalam class print("This is a message inside the class.") myobjectx = MyClass() #myobjectx adalah variabl...
class Myclass: var = 'blah' def function(self): print('This is a message inside the class.') myobjectx = my_class() myobjectx.var print(myobjectx.var) print('####\n') myobjecty = my_class() myobjectz = my_class() myobjectz.var = 'zlah' print(myobjectx.var) print(myobjectz.var) print('####\n') myobjectx...
def lend_money(debts, person, amount): value = debts.get(person, 0) quantity = [amount] if value != 0: debts[person] = value + quantity else: debts[person] = quantity print(debts) def amount_owed_by(debts, person): value = debts.get(person, [0]) out = sum(va...
def lend_money(debts, person, amount): value = debts.get(person, 0) quantity = [amount] if value != 0: debts[person] = value + quantity else: debts[person] = quantity print(debts) def amount_owed_by(debts, person): value = debts.get(person, [0]) out = sum(value) return o...
kwh_used = 1000 out = 0 if(kwh_used < 500): out += 500 * 0.45 elif(kwh_used >= 500 and kwh_used < 1500): out += 500 * 0.45 + ((kwh_used - 500) * 0.74) elif(kwh_used >= 1500 and kwh_used < 2500): out += 500 * 0.45 + ((kwh_used - 500) * 0.74) + ((kwh_used - 1500) * 1.25) elif(kwh_used >= 2500): out += 50...
kwh_used = 1000 out = 0 if kwh_used < 500: out += 500 * 0.45 elif kwh_used >= 500 and kwh_used < 1500: out += 500 * 0.45 + (kwh_used - 500) * 0.74 elif kwh_used >= 1500 and kwh_used < 2500: out += 500 * 0.45 + (kwh_used - 500) * 0.74 + (kwh_used - 1500) * 1.25 elif kwh_used >= 2500: out += 500 * 0.45 + ...
def solution(A): list_range = len(A) difference_list = [] for p in range(1, list_range): post_sum = sum(A[p:]) behind_sum = sum(A[:p]) difference = behind_sum - post_sum if difference < 0: difference *= -1 difference_list.append(difference) retur...
def solution(A): list_range = len(A) difference_list = [] for p in range(1, list_range): post_sum = sum(A[p:]) behind_sum = sum(A[:p]) difference = behind_sum - post_sum if difference < 0: difference *= -1 difference_list.append(difference) return min(...
def heapify(heap, root): newRoot = root leftChild = 2*root+1 rightChild = 2*root+2 if leftChild < len(heap) and heap[leftChild] > heap[newRoot]: newRoot = leftChild if rightChild < len(heap) and heap[rightChild] > heap[newRoot]: newRoot = rightChild if root!=newRoot: heap[root],heap[newRoot]=heap[newRoot],h...
def heapify(heap, root): new_root = root left_child = 2 * root + 1 right_child = 2 * root + 2 if leftChild < len(heap) and heap[leftChild] > heap[newRoot]: new_root = leftChild if rightChild < len(heap) and heap[rightChild] > heap[newRoot]: new_root = rightChild if root != newRoo...
EXAMPLES1 = ( ('1122', 3), ('1111', 4), ('1234', 0), ('91212129', 9) ) EXAMPLES2 = ( ('1212', 6), ('1221', 0), ('123425', 4), ('123123', 12), ('12131415', 4) ) INPUT = '31813174349235972159811869755166343882958376474278437681632495222499211488649543755655138842553...
examples1 = (('1122', 3), ('1111', 4), ('1234', 0), ('91212129', 9)) examples2 = (('1212', 6), ('1221', 0), ('123425', 4), ('123123', 12), ('12131415', 4)) input = '31813174349235972159811869755166343882958376474278437681632495222499211488649543755655138842553867246131245462881756862736922925752647341673342756514856663...
p = np.eye(3)[y][:, None] grad_d = q - p grad_C = grad_d @ U.T grad_b = (C.T @ grad_d ) * Drelu(A@x+b) grad_A = grad_b @ x.T
p = np.eye(3)[y][:, None] grad_d = q - p grad_c = grad_d @ U.T grad_b = C.T @ grad_d * drelu(A @ x + b) grad_a = grad_b @ x.T
#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file class MandatoryOptions(object): def __init__(self,options): self.options=options def __getattr__(self,name): call=getattr(self.options,name) def require(*args,**kwargs): value=call(*args,*...
class Mandatoryoptions(object): def __init__(self, options): self.options = options def __getattr__(self, name): call = getattr(self.options, name) def require(*args, **kwargs): value = call(*args, **kwargs) if not value: raise runtime_error('WT...
class Queue(): # Queue Initialization def __init__(self): self.MAX = 5 self.queue = [] # OVERFLOW CONDITION def OVERFLOW(self): if len(self.queue) == self.MAX: return True else: return False # UNDERFLOW CONDITION def UNDERFLOW(self): if len(self.queue) == 0: return True else: return Fals...
class Queue: def __init__(self): self.MAX = 5 self.queue = [] def overflow(self): if len(self.queue) == self.MAX: return True else: return False def underflow(self): if len(self.queue) == 0: return True else: ...
# input N, X, r = map(int, input().split()) MOD = pow(10, 9) # compute # output print(X * (pow(r, N, MOD) - 1) % MOD)
(n, x, r) = map(int, input().split()) mod = pow(10, 9) print(X * (pow(r, N, MOD) - 1) % MOD)
boys = ['John', 'Jack', 'Jeremy'] girls = ['Mary', 'Nancy', 'Joyce'] names = [*boys, *girls]
boys = ['John', 'Jack', 'Jeremy'] girls = ['Mary', 'Nancy', 'Joyce'] names = [*boys, *girls]