content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def main(): n = int(input()) ans = list(map(int, input().split())) m = int(input()) bms = list(map(int, input().split())) gears = [bj/ai for bj in bms for ai in ans] checked = list(filter(lambda gear : gear == int(gear), gears)) maximum = max(checked) checked = list(filter(lambda gear ...
def main(): n = int(input()) ans = list(map(int, input().split())) m = int(input()) bms = list(map(int, input().split())) gears = [bj / ai for bj in bms for ai in ans] checked = list(filter(lambda gear: gear == int(gear), gears)) maximum = max(checked) checked = list(filter(lambda gear: ...
class StaticSelf: def __init__(self): class C: SELF = self self.c = C() assert self.c.SELF is self
class Staticself: def __init__(self): class C: self = self self.c = c() assert self.c.SELF is self
""" Helper functions for Bounding boxs ================================== .. autosummary:: :toctree: ../generated/ set_buffer_on_gdf """ def set_buffer_on_gdf( gdf, buffer=50, convex_hull=True, to_epsg_=True, epsg_="EPSG:3857" ): """ Set buffer and simplify (convexhull) geometry. Parameters...
""" Helper functions for Bounding boxs ================================== .. autosummary:: :toctree: ../generated/ set_buffer_on_gdf """ def set_buffer_on_gdf(gdf, buffer=50, convex_hull=True, to_epsg_=True, epsg_='EPSG:3857'): """ Set buffer and simplify (convexhull) geometry. Parameters --...
""" file: list_mode_data_mask.py brief: Defines data masks for all frequencies, bit resolutions, and revisions author: S. V. Paulauskas date: January 16, 2019 """ class ListModeDataMask: """ Defines data masks used to decode data from XIA's Pixie-16 product line. """ def __init__(self, frequency=250, firmwar...
""" file: list_mode_data_mask.py brief: Defines data masks for all frequencies, bit resolutions, and revisions author: S. V. Paulauskas date: January 16, 2019 """ class Listmodedatamask: """ Defines data masks used to decode data from XIA's Pixie-16 product line. """ def __init__(self, frequency=250, firmware...
# player names are used as id. PLAYERS = ['Ronaldo', 'Zidan', 'Raul', 'Beckham', 'Figo', 'Carlos'] # default values for trueskill calculator # I made this (50, 16.33) # even though trueskill's originals are (25, 8.33) # because it ranges 0-100, it's more intuitive and natural I think. MEAN = 50 STDDEV = 16.3333 ...
players = ['Ronaldo', 'Zidan', 'Raul', 'Beckham', 'Figo', 'Carlos'] mean = 50 stddev = 16.3333 graph_xmax = 100 graph_ymax = 0.07 color_red = [1, 0.6, 0.6, 1] color_blue = [0.6, 0.6, 1, 1] color_gray = [0.5, 0.5, 0.5, 1]
# -*- coding: utf-8 -*- """ Created on Wed Jan 23 16:23:59 2019 @author: DevTequilaUser Practica 3: Cadenas """ nombre = "Luis Cobian" print(nombre) mi_bio = """INSTITUTO TECNOLOGICO DOCENTE PTC INFORMATICA""" print(mi_bio) #Formas de concatenar cadenas cade1 = "cadena" cade2 = 'xxxxxx' #Primera forma unidos = "Es...
""" Created on Wed Jan 23 16:23:59 2019 @author: DevTequilaUser Practica 3: Cadenas """ nombre = 'Luis Cobian' print(nombre) mi_bio = 'INSTITUTO TECNOLOGICO \nDOCENTE PTC\nINFORMATICA' print(mi_bio) cade1 = 'cadena' cade2 = 'xxxxxx' unidos = "Esta es la primera cadena '" + cade1 + "' y la otra es '" + cade2 + "'" prin...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres...
## params ## nNodes = 5 nTraders = 2000 nGenesis = 4 nAddresses = nTraders nMaxConfTerms = 100 nMaxConfVertices = 35 tSimtime = 100 # sec tPow = 0.00 # sec tNodeNetwork = 0.2 # sec tHttpRequest = 0.2 # sec tUnitVal = 0.003 # sec tUnitValVar = 10 ** -7 # sec tConfCycle = 1.0 # sec tBroad = 0.01 # sec rTxRate = 50 # r...
n_nodes = 5 n_traders = 2000 n_genesis = 4 n_addresses = nTraders n_max_conf_terms = 100 n_max_conf_vertices = 35 t_simtime = 100 t_pow = 0.0 t_node_network = 0.2 t_http_request = 0.2 t_unit_val = 0.003 t_unit_val_var = 10 ** (-7) t_conf_cycle = 1.0 t_broad = 0.01 r_tx_rate = 50 r_conf_th = 0.8 amounts = [500] * nTrade...
# DO NOT EDIT THIS FILE. This file will be overwritten when re-running go-raml. class AnimalsidService: """ auto-generated. don't touch. """ @staticmethod def _get_methods(): return (("animalsid_get", ""),) def __init__(self, client): self.client = client def animalsid_g...
class Animalsidservice: """ auto-generated. don't touch. """ @staticmethod def _get_methods(): return (('animalsid_get', ''),) def __init__(self, client): self.client = client def animalsid_get(self, id, headers=None, query_params=None, content_type='application/json'): ...
class Person: "This is a person class" age = 10 def greet(self): print("Hello") # Output: 10 print(Person.age) # Output: <function Person.greet> print(Person.greet) # Output: "This is a person class" print(Person.__doc__)
class Person: """This is a person class""" age = 10 def greet(self): print('Hello') print(Person.age) print(Person.greet) print(Person.__doc__)
positive_words = { "a+", "abound", "abounds", "abundance", "abundant", "accessable", "accessible", "acclaim", "acclaimed", "acclamation", "accolade", "accolades", "accommodative", "accomodative", "accomplish", "accomplished", "accomplishment", "acc...
positive_words = {'a+', 'abound', 'abounds', 'abundance', 'abundant', 'accessable', 'accessible', 'acclaim', 'acclaimed', 'acclamation', 'accolade', 'accolades', 'accommodative', 'accomodative', 'accomplish', 'accomplished', 'accomplishment', 'accomplishments', 'accurate', 'accurately', 'achievable', 'achievement', 'ac...
class Device: def __init__(self, name, ise_id, address, device_type): self.name = name self.ise_id = ise_id self.address = address self.device_type = device_type def get_name(self): return self.name def get_ise_id(self): return self.ise_id def get_addre...
class Device: def __init__(self, name, ise_id, address, device_type): self.name = name self.ise_id = ise_id self.address = address self.device_type = device_type def get_name(self): return self.name def get_ise_id(self): return self.ise_id def get_addr...
c.TemplateExporter.exclude_input = True c.Exporter.preprocessors = ['literacy.Execute'] #c.Exporter.preprocessors = ['literacy.template.Execute']
c.TemplateExporter.exclude_input = True c.Exporter.preprocessors = ['literacy.Execute']
class Crc8: def __init__(s): s.crc=255 def hash(s,int_list): for i in int_list: s.addVal(i) return s.crc def addVal(s,n): crc = s.crc for bit in range(0,8): if ( n ^ crc ) & 0x80: crc = ( crc << 1 ) ^ 0x31 else: ...
class Crc8: def __init__(s): s.crc = 255 def hash(s, int_list): for i in int_list: s.addVal(i) return s.crc def add_val(s, n): crc = s.crc for bit in range(0, 8): if (n ^ crc) & 128: crc = crc << 1 ^ 49 else: ...
class Service: @staticmethod def ulr_identification(user_data): url = user_data["url"] return url @staticmethod def location(user_data): lat = user_data["lat"] lon = user_data["lon"] return lat, lon
class Service: @staticmethod def ulr_identification(user_data): url = user_data['url'] return url @staticmethod def location(user_data): lat = user_data['lat'] lon = user_data['lon'] return (lat, lon)
# Chapter05_01 # Python Function # Python Function and lambda # How to defeine Function # def function_name(parameter): # code # Ex1 def first_func(w): print('Hello, ', w) word = 'Goodboy' first_func(word) # Ex2 def return_func(w1): value = 'Hello, ' + str(w1) return value x = return_func('Goodb...
def first_func(w): print('Hello, ', w) word = 'Goodboy' first_func(word) def return_func(w1): value = 'Hello, ' + str(w1) return value x = return_func('Goodboy2') print(x) def func_mul(x): y1 = x * 10 y2 = x * 20 y3 = x * 30 return (y1, y2, y3) (x, y, z) = func_mul(10) print(x, y, z) def ...
class DistcoveryException(Exception): def __init__(self, **kwargs): super(DistcoveryException, self). \ __init__(self.template % kwargs) class NoMoreAttempts(DistcoveryException): template = 'Coudn\'t create unique name with %(length)d ' \ 'digit%(length_suffix)s in %(limit)d...
class Distcoveryexception(Exception): def __init__(self, **kwargs): super(DistcoveryException, self).__init__(self.template % kwargs) class Nomoreattempts(DistcoveryException): template = "Coudn't create unique name with %(length)d digit%(length_suffix)s in %(limit)d attemt%(limit_suffix)s." def ...
__all__ = ["COMPRESSIONS"] COMPRESSIONS = { # gz ".gz": "gz", ".tgz": "gz", # xz ".xz": "xz", ".txz": "xz", # bz2 ".bz2": "bz2", ".tbz": "bz2", ".tbz2": "bz2", ".tb2": "bz2", # zst ".zst": "zst", ".tzst": "zst", }
__all__ = ['COMPRESSIONS'] compressions = {'.gz': 'gz', '.tgz': 'gz', '.xz': 'xz', '.txz': 'xz', '.bz2': 'bz2', '.tbz': 'bz2', '.tbz2': 'bz2', '.tb2': 'bz2', '.zst': 'zst', '.tzst': 'zst'}
def count_1478(digits, output): sum = 0 if len(digits) == 10 and len(output) == 4: digit_sets = [set()] * 10 for digit in digits: if len(digit) == 2: digit_sets[1] = set(digit) elif len(digit) == 3: digit_sets[7] = set(digit) el...
def count_1478(digits, output): sum = 0 if len(digits) == 10 and len(output) == 4: digit_sets = [set()] * 10 for digit in digits: if len(digit) == 2: digit_sets[1] = set(digit) elif len(digit) == 3: digit_sets[7] = set(digit) el...
# # This file is part of pysnmp software. # # Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com> # License: http://snmplabs.com/pysnmp/license.html # # PySNMP MIB module SNMP-NOTIFICATION-MIB (http://snmplabs.com/pysnmp) # ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-NOTIFICATION-MIB # Produced by pysmi-0....
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint, constraints_union) ...
input = """ c num blocks = 1 c num vars = 180 c minblockids[0] = 1 c maxblockids[0] = 180 p cnf 180 785 -119 50 -67 0 -114 -178 170 0 100 81 119 0 -8 37 77 0 60 -10 164 0 4 -120 -175 0 -134 40 -165 0 178 -135 1 0 -7 -175 -9 0 107 -24 -92 0 -24 -171 133 0 135 -10 -63 0 -121 -165 108 0 83 -173 168 0 14 171 89 0 -55 82 13...
input = '\nc num blocks = 1\nc num vars = 180\nc minblockids[0] = 1\nc maxblockids[0] = 180\np cnf 180 785\n-119 50 -67 0\n-114 -178 170 0\n100 81 119 0\n-8 37 77 0\n60 -10 164 0\n4 -120 -175 0\n-134 40 -165 0\n178 -135 1 0\n-7 -175 -9 0\n107 -24 -92 0\n-24 -171 133 0\n135 -10 -63 0\n-121 -165 108 0\n83 -173 168 0\n14 ...
# Created by MechAviv # Map ID :: 620100043 # Ballroom : Lobby sm.curNodeEventEnd(True) sm.setTemporarySkillSet(0) sm.setInGameDirectionMode(True, True, False, False) sm.sendDelay(3000) sm.showEffect("Effect/DirectionNewPirate.img/newPirate/balloonMsg2/6", 2000, 130, 0, 10, -2, True, 0) sm.sendDelay(1000) sm.setSp...
sm.curNodeEventEnd(True) sm.setTemporarySkillSet(0) sm.setInGameDirectionMode(True, True, False, False) sm.sendDelay(3000) sm.showEffect('Effect/DirectionNewPirate.img/newPirate/balloonMsg2/6', 2000, 130, 0, 10, -2, True, 0) sm.sendDelay(1000) sm.setSpeakerID(9270088) sm.removeEscapeButton() sm.setPlayerAsSpeaker() sm....
"""Reshape layer""" class ReshapeLayer(): def __init__(self, input_shape, output_shape): """ Apply the reshape operation to the incoming data Args: num_input: size of each input sample num_output: size of each output sample """ self.input_shape = input_shape self.output_shape = output_sha...
"""Reshape layer""" class Reshapelayer: def __init__(self, input_shape, output_shape): """ Apply the reshape operation to the incoming data Args: num_input: size of each input sample num_output: size of each output sample """ self.input_shape = input_shape self.output_shape = o...
# # PySNMP MIB module RUCKUS-SZ-EVENT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RUCKUS-SZ-EVENT-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:59:01 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, constraints_union, value_size_constraint, single_value_constraint) ...
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: def tmpCount(sumN, l): digit, i = 0, 0 while l: ...
class Listnode: def __init__(self, x): self.val = x self.next = None class Solution: def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode: def tmp_count(sumN, l): (digit, i) = (0, 0) while l: v = l.val l = l.next ...
def f(c): for i in [1, 2, 3]: if c: x = 0 break else: x = 1 return x #pass
def f(c): for i in [1, 2, 3]: if c: x = 0 break else: x = 1 return x
__author__ = 'rolandh' ENTITYATTRIBUTES = "urn:oasis:names:tc:SAML:metadata:attribute&EntityAttributes" def entity_categories(md): res = [] if "extensions" in md: for elem in md["extensions"]["extension_elements"]: if elem["__class__"] == ENTITYATTRIBUTES: for attr in elem...
__author__ = 'rolandh' entityattributes = 'urn:oasis:names:tc:SAML:metadata:attribute&EntityAttributes' def entity_categories(md): res = [] if 'extensions' in md: for elem in md['extensions']['extension_elements']: if elem['__class__'] == ENTITYATTRIBUTES: for attr in elem['...
def convert(text, mappings): """ Convert the text using the mapping given """ if hasattr(mappings, 'items'): return _convert(text, mappings) else: for mapping in mappings: text = _convert(text, mapping) return text def _convert(text, mapping): ...
def convert(text, mappings): """ Convert the text using the mapping given """ if hasattr(mappings, 'items'): return _convert(text, mappings) else: for mapping in mappings: text = _convert(text, mapping) return text def _convert(text, mapping): """ Convert the text us...
#!usr/bin/python3 # Filename: break.py while True: # Fakes R's repeat loop s = (input('Enter something: ')) if s == 'quit': # Provide condition to end the loop break print('Length of the string is ', len(s)) print('Done')
while True: s = input('Enter something: ') if s == 'quit': break print('Length of the string is ', len(s)) print('Done')
task_definition = """ {{ "family":"{queue_name}", "executionRoleArn":"{EXECUTION_ROLE_ARN}", "networkMode":"awsvpc", "containerDefinitions":[ {{ "name": "{container_name}", "image": "{WORKER_IMAGE}", "essential": True, "environment": [ ...
task_definition = '\n{{\n "family":"{queue_name}",\n "executionRoleArn":"{EXECUTION_ROLE_ARN}",\n "networkMode":"awsvpc",\n "containerDefinitions":[\n {{\n "name": "{container_name}",\n "image": "{WORKER_IMAGE}",\n "essential": True,\n "environment": [\n ...
class ICloneable: """ Supports cloning,which creates a new instance of a class with the same value as an existing instance. """ def Clone(self): """ Clone(self: ICloneable) -> object Creates a new object that is a copy of the current instance. Returns: A new object that is a copy of this ins...
class Icloneable: """ Supports cloning,which creates a new instance of a class with the same value as an existing instance. """ def clone(self): """ Clone(self: ICloneable) -> object Creates a new object that is a copy of the current instance. Returns: A new object that is a copy of this ...
class Collection: def __init__(self, **kwargs): self.__dict__.update(kwargs) ber_over_snr = Collection( bits_per_slot=440, slot_per_frame=1, give_up_value=1e-6, # How many bits to aim for at give_up_value certainty=20, # Stop early at x number of errors. Make sure to scale togethe...
class Collection: def __init__(self, **kwargs): self.__dict__.update(kwargs) ber_over_snr = collection(bits_per_slot=440, slot_per_frame=1, give_up_value=1e-06, certainty=20, stop_at_errors=100000, snr_stop=100, snr_step=2.5, branches=5)
# Copyright 2019 Google LLC. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
""" Dependencies needed to compile and test the PJC library """ load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def pjc_deps(): """Loads dependencies need to compile and test the PJC library.""" if 'com_github_google_glo...
class Solution: # Max Sum LC (Accepted), O(m * n) time, O(m) space def maximumWealth(self, accounts: List[List[int]]) -> int: return max(sum(row) for row in accounts) # Max Map Sum (Top Voted), O(m * n) time, O(m) space def maximumWealth(self, accounts: List[List[int]]) -> int: return m...
class Solution: def maximum_wealth(self, accounts: List[List[int]]) -> int: return max((sum(row) for row in accounts)) def maximum_wealth(self, accounts: List[List[int]]) -> int: return max(map(sum, accounts))
GSTR_APPFOLDER = 1 GSTR_CONFOLDER = 2 GSTR_LANFOLDER = 3 GSTR_TEMFOLDER = 4 GSTR_CE_FILE = 5 GSTR_CONF_FILE = 6 GSTR_LOC_FILE = 7 GSTR_SSET_FILE = 8 GSTR_LOCX_FILE = 9 GSTR_CEX_FILE = 10 GSTR_CONFX_FILE = 11 GSTR_TZ_FILE = 12 GSTR_COUNTRY_FILE = 13 GSTR_TEXT_FILE = 14 GSTR_TIPS_FILE = 15 GSTR_HELP_FILE = 16
gstr_appfolder = 1 gstr_confolder = 2 gstr_lanfolder = 3 gstr_temfolder = 4 gstr_ce_file = 5 gstr_conf_file = 6 gstr_loc_file = 7 gstr_sset_file = 8 gstr_locx_file = 9 gstr_cex_file = 10 gstr_confx_file = 11 gstr_tz_file = 12 gstr_country_file = 13 gstr_text_file = 14 gstr_tips_file = 15 gstr_help_file = 16
""" https://leetcode.com/problems/container-with-most-water Examples: >>> Solution().maxArea([]) 0 See Also: - pytudes/_2021/leetcode/hard/_42__trapping_rain_water.py """ class Solution: def maxArea(self, height: list[int]) -> int: return compute_max_area(height) def compute_max_area(heig...
""" https://leetcode.com/problems/container-with-most-water Examples: >>> Solution().maxArea([]) 0 See Also: - pytudes/_2021/leetcode/hard/_42__trapping_rain_water.py """ class Solution: def max_area(self, height: list[int]) -> int: return compute_max_area(height) def compute_max_area(heig...
bind_to = 'localhost' port = 8001 client_id = 'INSERT GOOGLE CLIENT ID'
bind_to = 'localhost' port = 8001 client_id = 'INSERT GOOGLE CLIENT ID'
# like a version, touched for the very first time version = '0.2.10' # definitions for coin types / chains supported # selected by sqc.cfg['cointype'] ADDR_CHAR = 0 ADDR_PREFIX = 1 P2SH_CHAR = 2 P2SH_PREFIX = 3 BECH_HRP = 4 BLKDAT_MAGIC = 5 BLKDAT_NEAR_SYNC = 6 BLK_REWARD = 7 HALF_BLKS = 8 coin_cfg = { 'bitcoin...
version = '0.2.10' addr_char = 0 addr_prefix = 1 p2_sh_char = 2 p2_sh_prefix = 3 bech_hrp = 4 blkdat_magic = 5 blkdat_near_sync = 6 blk_reward = 7 half_blks = 8 coin_cfg = {'bitcoin': ['1', 0, '3', 5, 'bc', 3652501241, 500, 50 * 100000000.0, 210000], 'testnet': ['mn', 111, '2', 196, 'tb', 118034699, 8000, 50 * 10000000...
#!/usr/bin/python3 # https://practice.geeksforgeeks.org/problems/pairs-of-prime-number/0 def getPrimes(n): primes = [True]*(n+1) primes[0] = False primes[1] = False i=2 while i*i<=n: if primes[i]: for j in range(2*i, n+1, i): primes[j] = False i+=1 ...
def get_primes(n): primes = [True] * (n + 1) primes[0] = False primes[1] = False i = 2 while i * i <= n: if primes[i]: for j in range(2 * i, n + 1, i): primes[j] = False i += 1 return primes def sol(n): p = [] i = 2 while i <= n // 2: ...
class Solution: def wordBreak(self, s: str, wordDict: List[str]) -> List[str]: if not s or not wordDict or len(wordDict) == 0: return [] return self.dfs(s, wordDict, {}) def dfs(self, s: str, wordDict: List[str], memo: dict[str, List[str]]) -> None: if s in memo: ...
class Solution: def word_break(self, s: str, wordDict: List[str]) -> List[str]: if not s or not wordDict or len(wordDict) == 0: return [] return self.dfs(s, wordDict, {}) def dfs(self, s: str, wordDict: List[str], memo: dict[str, List[str]]) -> None: if s in memo: ...
class Coordenada: def __init__(self, x, y): self.x = x self.y = y def distancia(self, otro_cordenada): x_diff = (self.x - otro_cordenada.x)**2 y_diff = (self.y - otro_cordenada.y)**2 return (x_diff + y_diff)**0.5 if __name__ == '__main__': coord1 = Coordenada(...
class Coordenada: def __init__(self, x, y): self.x = x self.y = y def distancia(self, otro_cordenada): x_diff = (self.x - otro_cordenada.x) ** 2 y_diff = (self.y - otro_cordenada.y) ** 2 return (x_diff + y_diff) ** 0.5 if __name__ == '__main__': coord1 = coordenada(...
ENV = "BipedalWalker-v2" LOAD = True DISPLAY = True DISCOUNT = 0.99 FRAME_SKIP = 4 EPSILON_START = 0.1 EPSILON_STOP = 0.05 EPSILON_STEPS = 25000 ACTOR_LEARNING_RATE = 1e-3 CRITIC_LEARNING_RATE = 1e-3 # Memory size BUFFER_SIZE = 100000 BATCH_SIZE = 1024 # Number of episodes of game environment to train with TRA...
env = 'BipedalWalker-v2' load = True display = True discount = 0.99 frame_skip = 4 epsilon_start = 0.1 epsilon_stop = 0.05 epsilon_steps = 25000 actor_learning_rate = 0.001 critic_learning_rate = 0.001 buffer_size = 100000 batch_size = 1024 training_steps = 1500000 max_episode_steps = 125 training_freq = 4 update_targe...
class MessageTooLong(Exception): pass class MissingAttributes(Exception): def __init__(self, attrs): msg = 'Required attribute(s) missing: {}'.format(attrs) super().__init__(msg) class MustBeBytes(Exception): pass class NoLineEnding(Exception): pass class StrayLineEnding(Exceptio...
class Messagetoolong(Exception): pass class Missingattributes(Exception): def __init__(self, attrs): msg = 'Required attribute(s) missing: {}'.format(attrs) super().__init__(msg) class Mustbebytes(Exception): pass class Nolineending(Exception): pass class Straylineending(Exception):...
deg, dis = map(int, input().split()) dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"] wps = [2, 15, 33, 54, 79, 107, 138, 171, 207, 244, 284, 326] w = 0 for n in wps: if int(dis/6 + 0.5) > n: w += 1 dir = dirs[(deg * 10 + 1125) % 36000 // 2250] ...
(deg, dis) = map(int, input().split()) dirs = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW'] wps = [2, 15, 33, 54, 79, 107, 138, 171, 207, 244, 284, 326] w = 0 for n in wps: if int(dis / 6 + 0.5) > n: w += 1 dir = dirs[(deg * 10 + 1125) % 36000 // 2250] ...
class SearchRunsIterator: """ Usage: runs = SearchRunsIterator(client, exp.experiment_id, max_results) for run in runs: print(run) """ def __init__(self, client, experiment_id, max_results=1000, query=""): self.client = client self.experiment_id = experiment_...
class Searchrunsiterator: """ Usage: runs = SearchRunsIterator(client, exp.experiment_id, max_results) for run in runs: print(run) """ def __init__(self, client, experiment_id, max_results=1000, query=''): self.client = client self.experiment_id = experiment_...
class Node: def __init__(self, data) -> None: self.data = data self.next = None class LinkedList: def __init__(self) -> None: self.head = None def push(self, data): New_node = Node(data) New_node.next = self.head self.head = New_node...
class Node: def __init__(self, data) -> None: self.data = data self.next = None class Linkedlist: def __init__(self) -> None: self.head = None def push(self, data): new_node = node(data) New_node.next = self.head self.head = New_node def get_count(sel...
# -*- coding: utf-8 -*- """ >>> from pycm import * >>> from matplotlib import pyplot as plt >>> import seaborn as sns >>> y_act = [0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2] >>> y_pre = [0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,2,0,1,2,2,2,2] >>> cm = ConfusionMatrix(y_act,y_pre) >>> ax = cm.plot() >>> ax.ge...
""" >>> from pycm import * >>> from matplotlib import pyplot as plt >>> import seaborn as sns >>> y_act = [0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2] >>> y_pre = [0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,2,0,1,2,2,2,2] >>> cm = ConfusionMatrix(y_act,y_pre) >>> ax = cm.plot() >>> ax.get_title() 'Confusion Mat...
class StakeHolderDetails: def __init__(self, blockchain_id, staker, amount_staked, reward_amount, claimable_amount, refund_amount, auto_renewal, block_no_created): self.__blockchain_id = blockchain_id self.__staker = staker self.__amount_staked = amount_staked self._...
class Stakeholderdetails: def __init__(self, blockchain_id, staker, amount_staked, reward_amount, claimable_amount, refund_amount, auto_renewal, block_no_created): self.__blockchain_id = blockchain_id self.__staker = staker self.__amount_staked = amount_staked self.__reward_amount =...
expected_output = { 'active_query': { 'periodicity_mins': 30, 'status': 'Enabled' }, 'mdns_gateway': 'Enabled', 'mdns_query_type': 'ALL', 'mdns_service_policy': 'default-mdns-service-policy', 'sdg_agent_ip': '10.1.1.2', 'service_instance_suffix': 'N...
expected_output = {'active_query': {'periodicity_mins': 30, 'status': 'Enabled'}, 'mdns_gateway': 'Enabled', 'mdns_query_type': 'ALL', 'mdns_service_policy': 'default-mdns-service-policy', 'sdg_agent_ip': '10.1.1.2', 'service_instance_suffix': 'Not-Configured', 'source_interface': 'Vlan4025', 'transport_type': 'IPv4', ...
n=[] t=[] nome="" while(nome!="fim"): nome=input("Digite um nome: ") if(nome!="fim"): n.append(nome) t.append(input("Digite o telefone: ")) tamanhoDaLista=len(n) print(n) print(t) print(tamanhoDaLista) print(n[-1]) #de tras pra frente
n = [] t = [] nome = '' while nome != 'fim': nome = input('Digite um nome: ') if nome != 'fim': n.append(nome) t.append(input('Digite o telefone: ')) tamanho_da_lista = len(n) print(n) print(t) print(tamanhoDaLista) print(n[-1])
class Solution: def isValid(self, pos): if(pos[0] >= self.matrix_row or pos[1] >= self.matrix_col): return False return True def get_all_path_to_goal(self, matrix, st): self.matrix_row = len(matrix) self.matrix_col = len(matrix[0]) self.matrix = matrix ...
class Solution: def is_valid(self, pos): if pos[0] >= self.matrix_row or pos[1] >= self.matrix_col: return False return True def get_all_path_to_goal(self, matrix, st): self.matrix_row = len(matrix) self.matrix_col = len(matrix[0]) self.matrix = matrix ...
""" author : Ali Emre SAVAS Link : https://www.hackerrank.com/challenges/py-set-add/problem """ if __name__ == "__main__": counter = int(input()) countries = set() for _ in range(counter): countries.add(input()) print(len(countries))
""" author : Ali Emre SAVAS Link : https://www.hackerrank.com/challenges/py-set-add/problem """ if __name__ == '__main__': counter = int(input()) countries = set() for _ in range(counter): countries.add(input()) print(len(countries))
class ListNode: def __init__(self, val: int, prev_node=None, next_node=None): self.val = val self.prev_node = prev_node if self.prev_node: self.prev_node.next_node = self self.next_node = next_node if self.next_node: self.next_node.prev_node = self ...
class Listnode: def __init__(self, val: int, prev_node=None, next_node=None): self.val = val self.prev_node = prev_node if self.prev_node: self.prev_node.next_node = self self.next_node = next_node if self.next_node: self.next_node.prev_node = self ...
class VerificationModel(object): def __init__(self, password, mail, code): self.Password = password self.Mail = mail self.CodeUtilisateur = code
class Verificationmodel(object): def __init__(self, password, mail, code): self.Password = password self.Mail = mail self.CodeUtilisateur = code
#!/usr/bin/env python3.6 #Author: Vishwas K Singh #Email: vishwasks32@gmail.com # Program: A Simple module with some problematic test code # Listing10.3 # hello3.py def hello(): print('Hello, world!') # A test: hello()
def hello(): print('Hello, world!') hello()
def extractAnonanemoneWordpressCom(item): ''' Parser for 'anonanemone.wordpress.com' ''' vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title']) if not (chp or vol) or "preview" in item['title'].lower(): return None tagmap = [ ('tmpw', 'The Man\'s Perfect Wife', ...
def extract_anonanemone_wordpress_com(item): """ Parser for 'anonanemone.wordpress.com' """ (vol, chp, frag, postfix) = extract_vol_chapter_fragment_postfix(item['title']) if not (chp or vol) or 'preview' in item['title'].lower(): return None tagmap = [('tmpw', "The Man's Perfect Wife", 'trans...
def square(n): print("Square of ",n,"is",(n*n)) def cude(n): print("Cube of ",n,"is",(n*n*n)) cude(3) square(4)
def square(n): print('Square of ', n, 'is', n * n) def cude(n): print('Cube of ', n, 'is', n * n * n) cude(3) square(4)
# -*- coding: utf-8 -*- # # Copyright (C) 2021 GEO Secretariat. # # geo-knowledge-hub-ext is free software; you can redistribute it and/or # modify it under the terms of the MIT License; see LICENSE file for more # details. """GEO Knowledge Hub Record Service"""
"""GEO Knowledge Hub Record Service"""
#!/usr/bin/env python def pie_percent(n): """ :param n: int :return: int precodition: n >0 """ return int(100 / n ) print(pie_percent(3)) print(pie_percent(2)) print(pie_percent(5))
def pie_percent(n): """ :param n: int :return: int precodition: n >0 """ return int(100 / n) print(pie_percent(3)) print(pie_percent(2)) print(pie_percent(5))
name_and_hp = '''SELECT name, hp FROM charactercreator_character;''' # More queries to go here below
name_and_hp = 'SELECT name, hp \n FROM charactercreator_character;'
dummy_papers = [ { "abstract": "This is an abstract.", "authors": ["Yi Zhu", "Shawn Newsam"], "category": "cs.CV", "comment": "WACV 2017 camera ready, minor updates about test time efficiency", "img": "/static/thumbs/1612.07403v2.pdf.jpg", "link": "http://arxiv.org/ab...
dummy_papers = [{'abstract': 'This is an abstract.', 'authors': ['Yi Zhu', 'Shawn Newsam'], 'category': 'cs.CV', 'comment': 'WACV 2017 camera ready, minor updates about test time efficiency', 'img': '/static/thumbs/1612.07403v2.pdf.jpg', 'link': 'http://arxiv.org/abs/1612.07403v2', 'originally_published_time': '12/22/2...
"""Ceaser Cipher This is a fun little module that implements encryption/decryption using the Ceaser cipher. The purpose of which is to Example: First import the ceasercipher module, then... ceaser = CeaserCipher() cipher = ceaser.ceaser(>0, plain) plain = ceaser.ceaser(<0, cipher) ...
"""Ceaser Cipher This is a fun little module that implements encryption/decryption using the Ceaser cipher. The purpose of which is to Example: First import the ceasercipher module, then... ceaser = CeaserCipher() cipher = ceaser.ceaser(>0, plain) plain = ceaser.ceaser(<0, cipher) ...
#!/usr/bin/python3 count = 0 i = 2 while i < 100: k = i/2 j = 2 while j <= k: k = i % j if k == 0: count = count - 1 break k = i/2 j = j + 1 count = count + 1 i = i + 1 print(count)
count = 0 i = 2 while i < 100: k = i / 2 j = 2 while j <= k: k = i % j if k == 0: count = count - 1 break k = i / 2 j = j + 1 count = count + 1 i = i + 1 print(count)
""" A module for storing utility math functions. """ def mean(data): """ Calculate the average value in a numeric list """ _data = list(data) length = len(_data) if length > 0: return sum(_data)/length else: return 0
""" A module for storing utility math functions. """ def mean(data): """ Calculate the average value in a numeric list """ _data = list(data) length = len(_data) if length > 0: return sum(_data) / length else: return 0
class IAMUsers(): def __init__(self, iam): self.client = iam # User methods def _users_marker_handler(self, marker=None): if marker: response = self.client.list_users(Marker=marker) else: response = self.client.list_users() return response def _...
class Iamusers: def __init__(self, iam): self.client = iam def _users_marker_handler(self, marker=None): if marker: response = self.client.list_users(Marker=marker) else: response = self.client.list_users() return response def _attached_policies_mar...
""" Dictionaries are Python's implementation of associative arrays. There's not much different with Python's version compared to what you'll find in other languages (though you can also initialize and populate dictionaries using comprehensions just like you can with lists!). The docs can be found here: https:/...
""" Dictionaries are Python's implementation of associative arrays. There's not much different with Python's version compared to what you'll find in other languages (though you can also initialize and populate dictionaries using comprehensions just like you can with lists!). The docs can be found here: https://docs.py...
""" File: transformation.py Purpose: Base class for tranformation classes. """ class Transformation(object): def __init__(self): pass
""" File: transformation.py Purpose: Base class for tranformation classes. """ class Transformation(object): def __init__(self): pass
{ "targets": [ { "target_name": "SpatialHashing", "sources": ["src/SpatialHashing/SpatialHashing.cc"] } ] }
{'targets': [{'target_name': 'SpatialHashing', 'sources': ['src/SpatialHashing/SpatialHashing.cc']}]}
def is_prime(n): cnt=2 if n<=1 : return 0 if n==2 or n==3: return 1 if n%2==0 or n%3==0: return 0 if n<9: return 1 counter=5 while(counter*counter<=n): if n%counter==0: return 0 if n%(counter+2)==0: return...
def is_prime(n): cnt = 2 if n <= 1: return 0 if n == 2 or n == 3: return 1 if n % 2 == 0 or n % 3 == 0: return 0 if n < 9: return 1 counter = 5 while counter * counter <= n: if n % counter == 0: return 0 if n % (counter + 2) == 0: ...
class Question: def __init__(self, text, category): self.__question_text = text self.__question_category = category @property def question_text(self): return self.__question_text @question_text.setter def question_text(self, value): self.__question_text = value ...
class Question: def __init__(self, text, category): self.__question_text = text self.__question_category = category @property def question_text(self): return self.__question_text @question_text.setter def question_text(self, value): self.__question_text = value ...
class FailureSummary(object): def __init__(self, protocol, ctx, failed_method, reason): self.__protocol = protocol self.is_success = False self.is_failure = True self.ctx = ctx self.__failed_method = failed_method self.__failure_reason = reason def failed_on(self...
class Failuresummary(object): def __init__(self, protocol, ctx, failed_method, reason): self.__protocol = protocol self.is_success = False self.is_failure = True self.ctx = ctx self.__failed_method = failed_method self.__failure_reason = reason def failed_on(sel...
class Solution: def generate(self, numRows: int) -> List[List[int]]: triangle = [] for row_num in range(numRows): row=[None for _ in range(row_num+1)] row[0],row[-1]=1,1 for j in range(1,len(row)-1): row[j]=triangle[r...
class Solution: def generate(self, numRows: int) -> List[List[int]]: triangle = [] for row_num in range(numRows): row = [None for _ in range(row_num + 1)] (row[0], row[-1]) = (1, 1) for j in range(1, len(row) - 1): row[j] = triangle[row_num - 1][j...
print("Hello World!!") print() print('-----------------------') print() print(note := 'python supports break and continue') print(note := 'Below loop will stop when i = 5') for i in range(1, 11): # we can do comparison like below if i % 5 == 0: print(note := 'we have found a multiple of 5') print(i) print(no...
print('Hello World!!') print() print('-----------------------') print() print((note := 'python supports break and continue')) print((note := 'Below loop will stop when i = 5')) for i in range(1, 11): if i % 5 == 0: print((note := 'we have found a multiple of 5')) print(i) print((note := 'we ...
# -*- coding: utf-8 -*- def info_path(owner_id): return 'data/photos_{}.csv'.format(owner_id)
def info_path(owner_id): return 'data/photos_{}.csv'.format(owner_id)
WORKING_DIR_PATH_FULL = '/Users/hitesh/Documents/workspace/JARVIS/' SAVED_FILES_DIR_FULL_PATH = WORKING_DIR_PATH_FULL + 'saved_files/' NER_DIR_FULL_PATH = SAVED_FILES_DIR_FULL_PATH + 'ner/' NER_TRAINING_FILE_PATH_FULL = NER_DIR_FULL_PATH + 'NER_token_training.tsv' NER_PROPERTY_FILE_PATH_FULL = NER_DIR_FULL_PATH + 'NE...
working_dir_path_full = '/Users/hitesh/Documents/workspace/JARVIS/' saved_files_dir_full_path = WORKING_DIR_PATH_FULL + 'saved_files/' ner_dir_full_path = SAVED_FILES_DIR_FULL_PATH + 'ner/' ner_training_file_path_full = NER_DIR_FULL_PATH + 'NER_token_training.tsv' ner_property_file_path_full = NER_DIR_FULL_PATH + 'NERP...
#! /usr/bin/python3 param_list = [ { 'task': 'train', 'boosting_type': 'gbdt', 'objective': 'binary', 'metric': {'auc'}, 'train_metric': True, 'num_leaves': 63, 'lambda_l1': 0, 'lambda_l2': 1, # 'min_data_in_leaf': 100, 'min_child_weight': 50, 'learning_rate': 0.1, 'feat...
param_list = [{'task': 'train', 'boosting_type': 'gbdt', 'objective': 'binary', 'metric': {'auc'}, 'train_metric': True, 'num_leaves': 63, 'lambda_l1': 0, 'lambda_l2': 1, 'min_child_weight': 50, 'learning_rate': 0.1, 'feature_fraction': 0.6, 'bagging_fraction': 0.7, 'bagging_freq': 1, 'verbose': 1, 'num_iterations': 30...
# -*- coding: utf-8 -*- """ The UI for opalescence is implemented in this package. Currently, only a cli is provided. """
""" The UI for opalescence is implemented in this package. Currently, only a cli is provided. """
""" You are going to be given an array of integers. Your job is to take that array and find an index N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no index that would make this happen, return -1. For example: Let's say you are g...
""" You are going to be given an array of integers. Your job is to take that array and find an index N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no index that would make this happen, return -1. For example: Let's say you are g...
def prime_num(n,prime): while(True): for a in range(2,n): if n%a==0: n+=1 prime_num(n,prime); else: print(n) prime.append(n) if len(prime)==10: break n=2 prime=[] prime_num(n,prime);
def prime_num(n, prime): while True: for a in range(2, n): if n % a == 0: n += 1 prime_num(n, prime) else: print(n) prime.append(n) if len(prime) == 10: break n = 2 prime = [] prime_num(n, prime)
expected_output = { "svl_info": { 1: { "link_status": "U", "ports": "HundredGigE1/0/26", "protocol_status": "R", "svl": 1, "switch": 1, } } }
expected_output = {'svl_info': {1: {'link_status': 'U', 'ports': 'HundredGigE1/0/26', 'protocol_status': 'R', 'svl': 1, 'switch': 1}}}
#CvModName.py modName = "BUG Mod" displayName = "BUG Mod" modVersion = "4.4 [Build 2220]" civName = "BtS" civVersion = "3.13-3.19" def getName(): return modName def getDisplayName(): return displayName def getVersion(): return modVersion def getNameAndVersion(): return modName + " " + modVe...
mod_name = 'BUG Mod' display_name = 'BUG Mod' mod_version = '4.4 [Build 2220]' civ_name = 'BtS' civ_version = '3.13-3.19' def get_name(): return modName def get_display_name(): return displayName def get_version(): return modVersion def get_name_and_version(): return modName + ' ' + modVersion def ...
# # PySNMP MIB module CISCO-CCM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-CCM-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:35:23 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, value_size_constraint, constraints_intersection) ...
#!/usr/bin/env python ''' Event class and enums for Mission Editor Michael Day June 2014 ''' #MissionEditorEvents come FROM the GUI (with a few exceptions where the Mission Editor Module sends a message to itself, e.g., MEE_TIME_TO_QUIT) #MissionEditorGUIEvents go TO the GUI #enum for MissionEditorEvent types MEE_READ_...
""" Event class and enums for Mission Editor Michael Day June 2014 """ mee_read_wps = 0 mee_write_wps = 1 mee_time_to_quit = 2 mee_get_wp_rad = 3 mee_get_loit_rad = 4 mee_get_wp_default_alt = 5 mee_write_wp_num = 6 mee_load_wp_file = 7 mee_save_wp_file = 8 mee_set_wp_rad = 9 mee_set_loit_rad = 10 mee_set_wp_default_alt...
l = int(input("Enter number of lines: ")) for i in range (1, l+1): for z in range(1, i + 1): print(z, end = " ") print()
l = int(input('Enter number of lines: ')) for i in range(1, l + 1): for z in range(1, i + 1): print(z, end=' ') print()
def simple_operations(a1: torch.Tensor, a2: torch.Tensor, a3: torch.Tensor): # multiplication of tensor a1 with tensor a2 and then add it with tensor a3 answer = a1 @ a2 + a3 return answer # add timing to airtable atform.add_event('Coding Exercise 2.2 : Simple tensor operations-simple_operations') # Computing ...
def simple_operations(a1: torch.Tensor, a2: torch.Tensor, a3: torch.Tensor): answer = a1 @ a2 + a3 return answer atform.add_event('Coding Exercise 2.2 : Simple tensor operations-simple_operations') a1 = torch.tensor([[2, 4], [5, 7]]) a2 = torch.tensor([[1, 1], [2, 3]]) a3 = torch.tensor([[10, 10], [12, 1]]) a =...
# automatically generated by the FlatBuffers compiler, do not modify # namespace: flat class BoostOption(object): Normal_Boost = 0 Unlimited_Boost = 1 Slow_Recharge = 2 Rapid_Recharge = 3 No_Boost = 4
class Boostoption(object): normal__boost = 0 unlimited__boost = 1 slow__recharge = 2 rapid__recharge = 3 no__boost = 4
#!/usr/bin/python3 """ Define a Square class """ class Square: """ A class that defines a square. """ def __init__(self, size=0): """ Initializes the square. Args: size (int): The size of the square. """ self.size = size @property def ...
""" Define a Square class """ class Square: """ A class that defines a square. """ def __init__(self, size=0): """ Initializes the square. Args: size (int): The size of the square. """ self.size = size @property def size(self): ...
# # PySNMP MIB module CISCOSB-TRAPS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-TRAPS-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:23:52 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint) ...
_base_ = [ '../../_base_/default_runtime.py', '../../_base_/schedules/schedule_adam_600e.py', '../../_base_/det_models/panet_r50_fpem_ffm.py', '../../_base_/det_datasets/icdar2017.py', '../../_base_/det_pipelines/panet_pipeline.py' ] train_list = {{_base_.train_list}} test_list = {{_base_.test_list...
_base_ = ['../../_base_/default_runtime.py', '../../_base_/schedules/schedule_adam_600e.py', '../../_base_/det_models/panet_r50_fpem_ffm.py', '../../_base_/det_datasets/icdar2017.py', '../../_base_/det_pipelines/panet_pipeline.py'] train_list = {{_base_.train_list}} test_list = {{_base_.test_list}} train_pipeline_icdar...
#Write a program that prompts for a file name, then opens that file and reads through the file, #and print the contents of the file in upper case. #Use the file words.txt to produce the output below. #You can download the sample data at http://www.py4e.com/code3/words.txt # Use words.txt as the file name fname = input...
fname = input('Enter file name: ') fh = open(fname) print('fh___', fh) book = fh.read() print('book___', book) book_capital = book.upper() book_capita_lrstrip = bookCAPITAL.rstrip() print(bookCAPITALrstrip)
class Player: def __init__(self, name: str): self.name = name self.wins = 0 def add_win(self): self.wins += 1 class Player_War(Player): def __init__(self, name: str): super().__init__(name) self.card = None
class Player: def __init__(self, name: str): self.name = name self.wins = 0 def add_win(self): self.wins += 1 class Player_War(Player): def __init__(self, name: str): super().__init__(name) self.card = None
# The MIT License (MIT) # Copyright (c) 2015 Yanzheng Li # 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,...
const_str_slice = __call_cls_builtin(str, 'slice(') const_str_comma = __call_cls_builtin(str, ', ') const_str_close_paren = __call_cls_builtin(str, ')') const_int_zero = __call_cls_builtin(int, 0) class Slice(object): def __init__(self, start, stop, step): self.start = start self.stop = stop ...
car_lot = ["Ford", "Dodge", "Toyota", "Ford", "Toyota", "Chevrolet", "Ford"] print(car_lot.count("Ford"))
car_lot = ['Ford', 'Dodge', 'Toyota', 'Ford', 'Toyota', 'Chevrolet', 'Ford'] print(car_lot.count('Ford'))
""" Module containing Client and Clients class. """ class Client(object): """ Class representing single client connecting to the server. """ def __init__(self, *args): """Constructor. Can be called with various amount of arguments. There are two main options: either provide a ...
""" Module containing Client and Clients class. """ class Client(object): """ Class representing single client connecting to the server. """ def __init__(self, *args): """Constructor. Can be called with various amount of arguments. There are two main options: either provide a ...
class Board(): WINNERS = [ set([(0, 0), (0, 1), (0, 2), (0, 3), (0, 4)]), set([(1, 0), (1, 1), (1, 2), (1, 3), (1, 4)]), set([(2, 0), (2, 1), (2, 2), (2, 3), (2, 4)]), set([(3, 0), (3, 1), (3, 2), (3, 3), (3, 4)]), set([(4, 0), (4, 1), (4, 2), (4, 3), (4, 4)]), set([(...
class Board: winners = [set([(0, 0), (0, 1), (0, 2), (0, 3), (0, 4)]), set([(1, 0), (1, 1), (1, 2), (1, 3), (1, 4)]), set([(2, 0), (2, 1), (2, 2), (2, 3), (2, 4)]), set([(3, 0), (3, 1), (3, 2), (3, 3), (3, 4)]), set([(4, 0), (4, 1), (4, 2), (4, 3), (4, 4)]), set([(0, 0), (1, 0), (2, 0), (3, 0), (4, 0)]), set([(0, 1...
# Copyright 2018 The GamePad 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 applicable...
""" [Note] Convert "tokens" in dataset into unique integers for embeddings. """ class Embedtokens(object): """ Collect all tokens in the data-set. """ def __init__(self, f_mid=False): self.unique_sort = set() self.unique_const = set() self.unique_ind = set() self.uniqu...
class Solution: def nextGreaterElement(self, n: int) -> int: num = list(str(n)) # Start from the right most digit and find the first # digit that is smaller than the digit next to it i = len(num)-1 while i-1 >= 0 and num[i] <= num[i-1]: i -= 1 if...
class Solution: def next_greater_element(self, n: int) -> int: num = list(str(n)) i = len(num) - 1 while i - 1 >= 0 and num[i] <= num[i - 1]: i -= 1 if i == 0: return -1 smallest = i while smallest + 1 < len(num) and num[smallest + 1] > num[i ...
"""HTTP specific constants.""" KEY_AUTHENTICATED = "op_authenticated" KEY_OPP = "opp" KEY_OPP_USER = "opp_user" KEY_REAL_IP = "op_real_ip"
"""HTTP specific constants.""" key_authenticated = 'op_authenticated' key_opp = 'opp' key_opp_user = 'opp_user' key_real_ip = 'op_real_ip'
# Base class class SchemaError(Exception): pass class SchemaBaseError(SchemaError): pass class SchemaAttributeError(SchemaError): pass # Don't catch these exceptions class SchemaBaseUnknownAttribute(SchemaBaseError): pass class SchemaBaseLinkTypeNotSupported(SchemaBaseError): pass class Sc...
class Schemaerror(Exception): pass class Schemabaseerror(SchemaError): pass class Schemaattributeerror(SchemaError): pass class Schemabaseunknownattribute(SchemaBaseError): pass class Schemabaselinktypenotsupported(SchemaBaseError): pass class Schemabaseunknownobjecttype(SchemaBaseError): p...
class FoxProgression: def theCount(self, seq): if len(seq) == 1: return -1 a, m = seq[1]-seq[0], seq[1]/float(seq[0]) af, mf = True, m == int(m) c = sum((af, mf)) for i, j in zip(seq[1:], seq[2:]): if af and j-i != a: af = False ...
class Foxprogression: def the_count(self, seq): if len(seq) == 1: return -1 (a, m) = (seq[1] - seq[0], seq[1] / float(seq[0])) (af, mf) = (True, m == int(m)) c = sum((af, mf)) for (i, j) in zip(seq[1:], seq[2:]): if af and j - i != a: ...