content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def estadistica (nombre_archivo): archivo = open (nombre_archivo) resultado = {} porcentajes = {} total = 0 for linea in archivo: for c in linea.lower().strip(): #c=cada caracter no cada palabra if c in resultado: resultado[c]= resultado[c]+1 ...
def estadistica(nombre_archivo): archivo = open(nombre_archivo) resultado = {} porcentajes = {} total = 0 for linea in archivo: for c in linea.lower().strip(): if c in resultado: resultado[c] = resultado[c] + 1 else: resultado[c] = 1 ...
class BaseWSGI: def __init__(self, *a, **kw): pass
class Basewsgi: def __init__(self, *a, **kw): pass
# # PySNMP MIB module CABH-CAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CABH-CAP-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:43:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019,...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, constraints_union, constraints_intersection, value_range_constraint) ...
WHITE = (255, 255, 255) LIGHT_GREY = (220, 220, 220) DARK_GREY = (100,100,100) GREY = (100, 100, 100) BLACK = (0, 0, 0) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255)
white = (255, 255, 255) light_grey = (220, 220, 220) dark_grey = (100, 100, 100) grey = (100, 100, 100) black = (0, 0, 0) red = (255, 0, 0) green = (0, 255, 0) blue = (0, 0, 255)
# experiment.py if __name__ == '__main__': loc = 0 frames = 1000 for exp in ['decnash','idm','cnash']: for track in range(5): # run command = 'python experiments/experiment.py --loc %i --track %i --exp %s --frames %i' %(loc, track, exp, frames) os.system(command) ...
if __name__ == '__main__': loc = 0 frames = 1000 for exp in ['decnash', 'idm', 'cnash']: for track in range(5): command = 'python experiments/experiment.py --loc %i --track %i --exp %s --frames %i' % (loc, track, exp, frames) os.system(command)
class DataProcJob(object): def __init__(self, client, project, region, response): self.client = client self.project = project self.region = region self.response = response @classmethod def from_id(cls, client, project, job_id, region="global"): return DataProcJob(cli...
class Dataprocjob(object): def __init__(self, client, project, region, response): self.client = client self.project = project self.region = region self.response = response @classmethod def from_id(cls, client, project, job_id, region='global'): return data_proc_job(...
class Season: def __init__(self, name, start): self._name = name # Assumption: name is unique. eg. LeagueName_Summer_2018 self._start = start def getName(self): return self._name def getStartingTime(self): # TODO: time formatting return self._start
class Season: def __init__(self, name, start): self._name = name self._start = start def get_name(self): return self._name def get_starting_time(self): return self._start
def solution(): mod = 10**9+7 T = int(input()) for t in range(T): V, S = map(int, input().split(' ')) # hash vocabulary vocabulary = {} for v in range(V): word = input() lst = [0] * 26 for letter in word: lst[ord(letter) - o...
def solution(): mod = 10 ** 9 + 7 t = int(input()) for t in range(T): (v, s) = map(int, input().split(' ')) vocabulary = {} for v in range(V): word = input() lst = [0] * 26 for letter in word: lst[ord(letter) - ord('a')] += 1 ...
# URI Online Judge 1146 X = int(input()) while X != 0: for x in range(1,X+1): if x == 1: String = "{}".format(x) else: String += " {}".format(x) print(String) String = "" X = int(input())
x = int(input()) while X != 0: for x in range(1, X + 1): if x == 1: string = '{}'.format(x) else: string += ' {}'.format(x) print(String) string = '' x = int(input())
vogais = ('abacate', 'pau', 'cimento', 'ana', 'kassinda', 'ar', 'luis',) for nome in vogais: print(f'\nDentro da palavra {nome.lower()} temos:', end='') for v in nome: if v in 'aeiou': print(f'{v}', end=' ')
vogais = ('abacate', 'pau', 'cimento', 'ana', 'kassinda', 'ar', 'luis') for nome in vogais: print(f'\nDentro da palavra {nome.lower()} temos:', end='') for v in nome: if v in 'aeiou': print(f'{v}', end=' ')
R, G, B = map(int, input().split()) a = [R, G, B] def is_ok(n): m = 0 p = 0 for x in a: if x - n >= 0: p += (x - n) // 2 else: m += n - x return p >= m for i in range(min(a), max(a) + 2): if is_ok(i): continue print(i - 1) break
(r, g, b) = map(int, input().split()) a = [R, G, B] def is_ok(n): m = 0 p = 0 for x in a: if x - n >= 0: p += (x - n) // 2 else: m += n - x return p >= m for i in range(min(a), max(a) + 2): if is_ok(i): continue print(i - 1) break
def calcula_media(A: float, B: float, C: float): if (not isinstance(A, float) or not isinstance(B, float) or not isinstance(C, float)): raise TypeError M = (2 * A + 3 * B + 5 * C) / 10 return f'MEDIA = {M}'
def calcula_media(A: float, B: float, C: float): if not isinstance(A, float) or not isinstance(B, float) or (not isinstance(C, float)): raise TypeError m = (2 * A + 3 * B + 5 * C) / 10 return f'MEDIA = {M}'
# Symmetric Tree # Complexity:: Time:O(n), Space:O(n) # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isSymmetric(self, root: TreeNode) -> bool: return self.isMirror(root, ...
class Solution: def is_symmetric(self, root: TreeNode) -> bool: return self.isMirror(root, root) def is_mirror(self, t1, t2): if t1 is None and t2 is None: return True elif t1 is None or t2 is None: return False return t1.val == t2.val and self.isMirror(...
# CHECK-TREE: { hello <- #unit; goodbye <- #unit; #record { hello: hello, goodbye: goodbye }} # CHECK-RESULT hello: #unit hello = () goodbye = ()
hello = () goodbye = ()
class DnsRecord(object): def __init__(self, id, type, name, content, ttl): self.id = id self.type = type self.name = name self.content = content self.ttl = ttl
class Dnsrecord(object): def __init__(self, id, type, name, content, ttl): self.id = id self.type = type self.name = name self.content = content self.ttl = ttl
# Se ingresan tres notas de un alumno, si el promedio # es mayor o igual a siete mostrar un mensaje "Promocionado". print('ingresar notas del alumno') nota1, nota2, nota3, nota4 = float(input('nota1: ')),float(input('nota2: ')),float(input('nota3: ')),float(input('nota4: ')) promedio = (nota1 + nota2 + nota3 + ...
print('ingresar notas del alumno') (nota1, nota2, nota3, nota4) = (float(input('nota1: ')), float(input('nota2: ')), float(input('nota3: ')), float(input('nota4: '))) promedio = (nota1 + nota2 + nota3 + nota4) / 4 if promedio >= 7: print('Nota: ', promedio, '\n', 'Promocionado') else: print('repitente del curso...
# -*- coding: utf-8 -*- __author__ = 'Rishiraj Pravahan' __email__ = 'rpravahan@gmail.com' __version__ = '0.1.0'
__author__ = 'Rishiraj Pravahan' __email__ = 'rpravahan@gmail.com' __version__ = '0.1.0'
# This is the class of the input root. Do not edit it. class BinaryTree: def __init__(self, value): self.value = value self.left = None self.right = None def branch_sum(root, curr_sum): if not root.left and not root.right: return [curr_sum + root.value] if root.left and r...
class Binarytree: def __init__(self, value): self.value = value self.left = None self.right = None def branch_sum(root, curr_sum): if not root.left and (not root.right): return [curr_sum + root.value] if root.left and root.right: return branch_sum(root.left, curr_su...
epsilon = 0.5 def scale(y, a, b): return a*(1-y) + (b-a)*y def G(y): return 2*y - 1 if x < epsilon * G(X[0]): rho = scale(X[1], 0.3, 1.2) ux = X[2] p = scale(X[3], 0.9, 4.1) else: rho = scale(X[4], 0.1, 0.7) ux = 0 p = scale(X[5], 0.05, 0.7)
epsilon = 0.5 def scale(y, a, b): return a * (1 - y) + (b - a) * y def g(y): return 2 * y - 1 if x < epsilon * g(X[0]): rho = scale(X[1], 0.3, 1.2) ux = X[2] p = scale(X[3], 0.9, 4.1) else: rho = scale(X[4], 0.1, 0.7) ux = 0 p = scale(X[5], 0.05, 0.7)
song = "O Sakis Rouvas toy Peiraia" split_song = song.split() # argument of split specifies the delimiter # in case of no arguments, delimiter is single space print(split_song) glue = "/" s = glue.join(["users","sdi1700115","myWork"]) print(s)
song = 'O Sakis Rouvas toy Peiraia' split_song = song.split() print(split_song) glue = '/' s = glue.join(['users', 'sdi1700115', 'myWork']) print(s)
class Solution: def alienOrder(self, words: List[str]) -> str: # step 0: unique letters reverse_adj_list = { c: [] for word in words for c in word } # step 1: edges for first_w, second_w in zip(words, words[1:]): for f, s in zip( first_w, second_w ): ...
class Solution: def alien_order(self, words: List[str]) -> str: reverse_adj_list = {c: [] for word in words for c in word} for (first_w, second_w) in zip(words, words[1:]): for (f, s) in zip(first_w, second_w): if f != s: reverse_adj_list[s].append(f)...
section = 'Common Other Libraries' robotdocs = { 'other.other.Other': {'docformat': 'rest', 'synopsis': 'Local other library synopsis'}}
section = 'Common Other Libraries' robotdocs = {'other.other.Other': {'docformat': 'rest', 'synopsis': 'Local other library synopsis'}}
def listToString(s): str1 = "" for ele in s: str1 += ele return str1 s = ['wow', 'cool', 'damm'] print(listToString(s))
def list_to_string(s): str1 = '' for ele in s: str1 += ele return str1 s = ['wow', 'cool', 'damm'] print(list_to_string(s))
def main(): h = int(input()) ahs = list(map(int, input().split())) Ambiguous = list(map(lambda h1h2 : (h1h2[0] > 1) and (h1h2[1] > 1), zip(ahs, ahs[1:]))) Ambiguous.insert(0, False) isPerfect = not(any(Ambiguous)) if isPerfect: print('perfect') else: czyTrzebaAmbigowac = Tru...
def main(): h = int(input()) ahs = list(map(int, input().split())) ambiguous = list(map(lambda h1h2: h1h2[0] > 1 and h1h2[1] > 1, zip(ahs, ahs[1:]))) Ambiguous.insert(0, False) is_perfect = not any(Ambiguous) if isPerfect: print('perfect') else: czy_trzeba_ambigowac = True ...
n,m,k = map(int,input().split()) data = list(map(int, input().split())) data.sort() first = data[n-1] second = data[n-2] count = int(m/(k+1))*k count += m % (k+1) result = 0 result += (count) * first result += (m-count) * second print(result)
(n, m, k) = map(int, input().split()) data = list(map(int, input().split())) data.sort() first = data[n - 1] second = data[n - 2] count = int(m / (k + 1)) * k count += m % (k + 1) result = 0 result += count * first result += (m - count) * second print(result)
#CONFIG YOUR_API_KEY = "AIzaSyXXXXXXXXXXXXXXXXXXXXXX" pollid = 1 # GET chat ID: # insert id here [STREAM_URL_ID] # https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/list?apix=true&apix_params=%7B%22part%22%3A%5B%22snippet%22%5D%2C%22id%22%3A%5B%22STREAM_URL_ID%22%5D%7D LIVECHATID = "XXXXXXXXXXXXXXXXXXXX...
your_api_key = 'AIzaSyXXXXXXXXXXXXXXXXXXXXXX' pollid = 1 livechatid = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX4ZxILejl2OVIzdkVMNlk'
def DivisorSumTwice401(): LIMIT=10**15 MOD=10**9 splitCount=int(LIMIT**0.5) splitAt=LIMIT//(splitCount+1) #SIGMA=sum(FLOOR(N/i)*(i^2)) #after splitat FLOOR(N/i) is always going to be 1 #so directly found def sumOfSquares(s,e): #(s+1)^2+(s+2)^2...+(e-1)^2+e^2 re...
def divisor_sum_twice401(): limit = 10 ** 15 mod = 10 ** 9 split_count = int(LIMIT ** 0.5) split_at = LIMIT // (splitCount + 1) def sum_of_squares(s, e): return (e * (e + 1) * (2 * e + 1) - s * (s + 1) * (2 * s + 1)) // 6 ans = 0 for i in range(1, splitAt + 1): ans += i * i ...
mainurl = "https://api.koreanbots.dev" PostURL = { 'dbkrpostguild': f'{mainurl}/bots/servers', 'dbkrsearch': f'{mainurl}/bots/search', 'dbkrget': f'{mainurl}/bots/get/', 'dbkrvote': f'{mainurl}/bots/voted/', 'dbkrcategories': f'{mainurl}/bots/category/' }
mainurl = 'https://api.koreanbots.dev' post_url = {'dbkrpostguild': f'{mainurl}/bots/servers', 'dbkrsearch': f'{mainurl}/bots/search', 'dbkrget': f'{mainurl}/bots/get/', 'dbkrvote': f'{mainurl}/bots/voted/', 'dbkrcategories': f'{mainurl}/bots/category/'}
map_server = 'my.imap.server' mail = imaplib.IMAP4_SSL(imap_server) mail.login(imap_user, imap_password) start_message_uid = 169 if start_message_uid: command = "UID {}:*".format(start_message_uid) result, data = mail.uid('search', None, "UID", start_message_uid + ':*') else: result, data = mail.uid('searc...
map_server = 'my.imap.server' mail = imaplib.IMAP4_SSL(imap_server) mail.login(imap_user, imap_password) start_message_uid = 169 if start_message_uid: command = 'UID {}:*'.format(start_message_uid) (result, data) = mail.uid('search', None, 'UID', start_message_uid + ':*') else: (result, data) = mail.uid('se...
class Card: def __init__(self, rank, suit): assert rank in ('2', '3', '4', '5', '6', '7', '8', '9', 'T','J', 'Q', 'K', 'A'),'Invalid Rank' #assertion checks assert suit in ('H', 'C', 'D', 'S'),'Invalid Suit' self.__rank = rank self.__suit = suit def convert_rank(self,rank): if rank == 'T': ...
class Card: def __init__(self, rank, suit): assert rank in ('2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'), 'Invalid Rank' assert suit in ('H', 'C', 'D', 'S'), 'Invalid Suit' self.__rank = rank self.__suit = suit def convert_rank(self, rank): if rank =...
# setup configuration for DumpsterDiver CONFIG = { "logfile": "./errors.log", "base64_chars": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", "archive_types": [".zip", ".tar.gz", ".tgz", ".tar.bz2", ".tbz"], "excluded_files": [ ".jpg", ".jpeg", ".png", ...
config = {'logfile': './errors.log', 'base64_chars': 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', 'archive_types': ['.zip', '.tar.gz', '.tgz', '.tar.bz2', '.tbz'], 'excluded_files': ['.jpg', '.jpeg', '.png', '.gif', '.svg', '.mp4', '.mp3', '.webm', '.ttf', '.woff', '.eot', '.css', '.DS_Store', '...
#!/usr/bin/python # This script takes in a VCF file and outputs a matrix # as expected by the qqman package in R if __name__ == "__main__": parser = argparse.ArgumentParser(description='Commands for launch script.') parser.add_argument('ip', help='The IP address of the server, in format xxx.xxx.xxx.xxx. Thi...
if __name__ == '__main__': parser = argparse.ArgumentParser(description='Commands for launch script.') parser.add_argument('ip', help='The IP address of the server, in format xxx.xxx.xxx.xxx. This is required.') parser.add_argument('--base_dir', '-b', dest='base_dir', default='/home/torcivia/tcga/', help='...
def selectionSort(list): for i in range(len(list)-1): min = i for j in range(i+1,len(list)): if list[min] > list[j]: min = j if min != i: list[min] = list[min] + list[i] list[i] = list[min] - list[i] list[min] = list[min] - list[i] return list number = int(input("\nEnte...
def selection_sort(list): for i in range(len(list) - 1): min = i for j in range(i + 1, len(list)): if list[min] > list[j]: min = j if min != i: list[min] = list[min] + list[i] list[i] = list[min] - list[i] list[min] = list[min] ...
def xml_clean_soup(soup): # here is a list of tags that i want to remove before i extract the text # these include links, scripts, supplemnetal tags, references, tables, authors tag_remove_list = ['ref-list', 'supplementary-material', 'bibliography', ...
def xml_clean_soup(soup): tag_remove_list = ['ref-list', 'supplementary-material', 'bibliography', 'tex-math', 'inline-formula', 'table', 'tbody', 'table-wrap', 'ack', 'fig', 'table-wrap-foot', 'surname', 'given-names', 'name', 'xref', 'element-citation', 'sup', 'td', 'tr', 'string-name', 'familyname', 'givennames'...
N = int(input()) for _ in range(N): n = int(input()) A = input() B = input() hm = [] for i in range(n): if B[i] == A[i]: pass else: if B[i] in hm: continue hm.append(B[i]) print(len(hm))
n = int(input()) for _ in range(N): n = int(input()) a = input() b = input() hm = [] for i in range(n): if B[i] == A[i]: pass else: if B[i] in hm: continue hm.append(B[i]) print(len(hm))
vals = [0, 1, 2] vals.insert(0, 1) print ("vals after insert: ", vals) #output: 1,0,1,2 del vals[1] print ("vals after del: ", vals) #output: 1,1,2
vals = [0, 1, 2] vals.insert(0, 1) print('vals after insert: ', vals) del vals[1] print('vals after del: ', vals)
# coding=utf-8 class ModelState(object): MUTABLE_STATE = 'mutable_state' IMMUTABLE_STATE = 'immutable_state'
class Modelstate(object): mutable_state = 'mutable_state' immutable_state = 'immutable_state'
CURRENT_ENVIRONMENT = "CURRENT_ENV" ENVIRONMENTS = "ENVIRONMENTS" API_KEY_SETTING = "API_KEY" API_AUTH_TOKEN_SETTING = "API_AUTH_TOKEN" API_ENDPOINT_SETTING = "API_ENDPOINT" PACKAGE_NAME = "robo-ai" DEFAULT_SETTINGS = { CURRENT_ENVIRONMENT: "", "production": { API_KEY_SETTING: "", API_AUTH_TOKE...
current_environment = 'CURRENT_ENV' environments = 'ENVIRONMENTS' api_key_setting = 'API_KEY' api_auth_token_setting = 'API_AUTH_TOKEN' api_endpoint_setting = 'API_ENDPOINT' package_name = 'robo-ai' default_settings = {CURRENT_ENVIRONMENT: '', 'production': {API_KEY_SETTING: '', API_AUTH_TOKEN_SETTING: '', API_ENDPOINT...
class UIObject: def getElement(self): return self.element def setElement(self, element): self.element = element
class Uiobject: def get_element(self): return self.element def set_element(self, element): self.element = element
# # PySNMP MIB module ASCEND-MIBSTATICCONTROLLER-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBSTATICCONTROLLER-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:28:28 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python ...
(configuration,) = mibBuilder.importSymbols('ASCEND-MIB', 'configuration') (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_interse...
expected_output = { 'asic': { '0': { 'table': { 'cts_cell_matrix_vpn_label': { 'subtype': { 'em': { 'dir': { 'o': { 'max': 32768, ...
expected_output = {'asic': {'0': {'table': {'cts_cell_matrix_vpn_label': {'subtype': {'em': {'dir': {'o': {'max': 32768, 'mpls': 0, 'other': 0, 'used': 0, 'used_percent': '0.00%', 'v4': 0, 'v6': 0}}}, 'tcam': {'dir': {'o': {'max': 768, 'mpls': 0, 'other': 1, 'used': 1, 'used_percent': '0.13%', 'v4': 0, 'v6': 0}}}}}, 'c...
class Model(object): def __init__(self, time_step): self._time = 0.0 self._units = [] self._time_step = time_step @property def time(self): return self._time @property def units(self): return self._units @property def time_step(self): retur...
class Model(object): def __init__(self, time_step): self._time = 0.0 self._units = [] self._time_step = time_step @property def time(self): return self._time @property def units(self): return self._units @property def time_step(self): retur...
#! /usr/bin/env python3 guilds = {} with open("${funguild.baseName}",'w') as handle: with open("$funguild") as f: for line in f: if not line.startswith('SequenceID'): line = line.split('\\t') try: guilds[line[5]] = guilds[line[5]] + 1 ...
guilds = {} with open('${funguild.baseName}', 'w') as handle: with open('$funguild') as f: for line in f: if not line.startswith('SequenceID'): line = line.split('\\t') try: guilds[line[5]] = guilds[line[5]] + 1 except: ...
def has_unique_words(passwd): words = passwd.split() return len(set(words)) == len(words) def has_unique_anagrams(passwd): words = [''.join(sorted(word)) for word in passwd.split()] return len(set(words)) == len(words) with open('input-4.txt') as f: print(sum(has_unique_words(passwd) for passwd in...
def has_unique_words(passwd): words = passwd.split() return len(set(words)) == len(words) def has_unique_anagrams(passwd): words = [''.join(sorted(word)) for word in passwd.split()] return len(set(words)) == len(words) with open('input-4.txt') as f: print(sum((has_unique_words(passwd) for passwd in...
def _GET(request,args): ini=request.find('?') print (ini) final=request.find('HTTP') print(final) variables=(request[ini+1:final]).split('&') print("variables=",(request[ini+1:final]).split('&')) for m in variables: k,v= m.split('=') if k==args: print("var es",k,...
def _get(request, args): ini = request.find('?') print(ini) final = request.find('HTTP') print(final) variables = request[ini + 1:final].split('&') print('variables=', request[ini + 1:final].split('&')) for m in variables: (k, v) = m.split('=') if k == args: print...
class Config: SECRET_KEY = 'YOUR_SECRET_KEY' ENCRYPTION_KEY = 'YOUR_ENCRYPTION_KEY' MONGODB_SETTINGS = { 'host': '127.0.0.1', 'db': 'YOUR_DB_NAME', 'port': 27017, 'username': 'YOUR_DB_USERNAME', 'password': 'YOUR_DB_PASSWORD', } DEPLOY_HOSTS = ['admin@example...
class Config: secret_key = 'YOUR_SECRET_KEY' encryption_key = 'YOUR_ENCRYPTION_KEY' mongodb_settings = {'host': '127.0.0.1', 'db': 'YOUR_DB_NAME', 'port': 27017, 'username': 'YOUR_DB_USERNAME', 'password': 'YOUR_DB_PASSWORD'} deploy_hosts = ['admin@example.com:22'] deploy_passwords = {'admin@example...
N = int(input()) m = 1000000007 dp = [0] * 10 dp[0] = 1 for _ in range(N): t = [0] * 10 for i in range(10): for j in range(i, 10): t[j] += dp[i] t[j] %= m dp = t print(sum(dp) % m)
n = int(input()) m = 1000000007 dp = [0] * 10 dp[0] = 1 for _ in range(N): t = [0] * 10 for i in range(10): for j in range(i, 10): t[j] += dp[i] t[j] %= m dp = t print(sum(dp) % m)
stop = 10 start = 0 step = 1 while start != stop: print(start) start = start + step print("Start", start) print("Stop", stop) print("Step", step) start = 0 while start < stop: print(start) start = start + step start = 0 stop = 100 while True: print("Maris ir super!") if start == stop: ...
stop = 10 start = 0 step = 1 while start != stop: print(start) start = start + step print('Start', start) print('Stop', stop) print('Step', step) start = 0 while start < stop: print(start) start = start + step start = 0 stop = 100 while True: print('Maris ir super!') if start == stop: br...
#!/usr/bin/env python # coding: utf-8 # In[1]: n = int(input()) m = int(input()) print(n-m)
n = int(input()) m = int(input()) print(n - m)
class Solution: def reverseString(self, s: List[str]) -> None: l=len(s) for i in range(int(len(s)/2)): s[i],s[l-i-1]=s[l-i-1],s[i] print(s)
class Solution: def reverse_string(self, s: List[str]) -> None: l = len(s) for i in range(int(len(s) / 2)): (s[i], s[l - i - 1]) = (s[l - i - 1], s[i]) print(s)
line = input() split = line.split(" ") A = int(split[0]) B = int(split[1]) C = int(split[2]) D = int(split[3]) if B > C and D > A and (C+D) > (A+B) and C > 0 and D > 0 and A % 2 == 0: print("Valores aceitos") else: print("Valores nao aceitos")
line = input() split = line.split(' ') a = int(split[0]) b = int(split[1]) c = int(split[2]) d = int(split[3]) if B > C and D > A and (C + D > A + B) and (C > 0) and (D > 0) and (A % 2 == 0): print('Valores aceitos') else: print('Valores nao aceitos')
#!/usr/bin/env python # coding=utf-8 ''' Author: John Email: johnjim0816@gmail.com Date: 2020-08-06 09:34:46 LastEditor: John LastEditTime: 2020-08-06 09:35:03 Discription: Environment: ''' # Source : https://leetcode.com/problems/divide-two-integers/ # Author : JohnJim0816 # Date : 2020-08-06 ####################...
""" Author: John Email: johnjim0816@gmail.com Date: 2020-08-06 09:34:46 LastEditor: John LastEditTime: 2020-08-06 09:35:03 Discription: Environment: """ class Solution: def divide(self, dividend, divisor): (i, a, b) = (0, abs(dividend), abs(divisor)) if a == 0 or a < b: return 0 ...
# # PySNMP MIB module HUAWEI-FR-QOS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-FR-QOS-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:32:48 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') (value_range_constraint, value_size_constraint, single_value_constraint, constraints_union, constraints_intersection) ...
def gcd(a, b): if b: return gcd(b, a%b) else: return a n, m = map(int, input().split(' ')) n = n + 1 m = m + 1 nm = n * m c = [[1, 0, 0, 0] for i in range(nm+1)] for i in range(nm): for j in range(3): c[i+1][j+1] = c[i][j] + c[i][j+1] ans = c[nm][3]-n*c[m][3]-m*c[n][3] for i in range(1, n): for j in range...
def gcd(a, b): if b: return gcd(b, a % b) else: return a (n, m) = map(int, input().split(' ')) n = n + 1 m = m + 1 nm = n * m c = [[1, 0, 0, 0] for i in range(nm + 1)] for i in range(nm): for j in range(3): c[i + 1][j + 1] = c[i][j] + c[i][j + 1] ans = c[nm][3] - n * c[m][3] - m * c[...
# Desafio que retorna a quantidade de vogais que uma string possui def get_count(input_str): num_vowels = 0 for i in range(len(input_str)): if input_str[i] in 'aeiouAEIOU': # print(input_str[i]) num_vowels += 1 return num_vowels print(get_count("abracadabra"))
def get_count(input_str): num_vowels = 0 for i in range(len(input_str)): if input_str[i] in 'aeiouAEIOU': num_vowels += 1 return num_vowels print(get_count('abracadabra'))
# https://stackoverflow.com/questions/458550/standard-way-to-embed-version-into-python-package __version__ = '0.3.1' release_notes = { '0.3.1': ''' - Working directory is now set once with a command. # NicEastvillage - Added a fetch command that fetches a ladder from Google Sheets. # NicEastvillag...
__version__ = '0.3.1' release_notes = {'0.3.1': '\n - Working directory is now set once with a command. # NicEastvillage\n - Added a fetch command that fetches a ladder from Google Sheets. # NicEastvillage\n - Added a test command and option that checks for missing bots. # NicEastvillage\n ', '0...
#!/usr/bin/env python3 def calculate(): def find_minimum_multiple(n): feasible = [[1] + [0] * (n - 1)] i = 0 while feasible[i][0] != 2: assert i == len(feasible) - 1 prev = feasible[i] cur = list(prev) digitmod = pow(10, i, n) fo...
def calculate(): def find_minimum_multiple(n): feasible = [[1] + [0] * (n - 1)] i = 0 while feasible[i][0] != 2: assert i == len(feasible) - 1 prev = feasible[i] cur = list(prev) digitmod = pow(10, i, n) for j in range(n): ...
# Problem description: http://www.geeksforgeeks.org/partition-a-set-into-two-subsets-such-that-the-difference-of-subset-sums-is-minimum/ def find_minimum_partition(array, set1, total_sum): # construct all possible values for set 1 from array if not array: sum_set1 = sum(set1) sum_set2 = total...
def find_minimum_partition(array, set1, total_sum): if not array: sum_set1 = sum(set1) sum_set2 = total_sum - sum_set1 return abs(sum_set1 - sum_set2) else: return min(find_minimum_partition(array[:-1], set1 + [array[-1]], total_sum), find_minimum_partition(array[:-1], set1, tota...
RULETYPE_EQUAL = 1 RULETYPE_REGEXP = 2 RULETYPE_FIND = 3 RULETYPE_WORD = 4 ACTION_MATCH = 1 ACTION_IGNORE = 2 ACTION_FOLLOW = 3
ruletype_equal = 1 ruletype_regexp = 2 ruletype_find = 3 ruletype_word = 4 action_match = 1 action_ignore = 2 action_follow = 3
#!/usr/bin/env python3 # Day 7: Cousins in Binary Tree # # In a binary tree, the root node is at depth 0, and children of each depth k # node are at depth k+1. # Two nodes of a binary tree are cousins if they have the same depth, but have # different parents. # We are given the root of a binary tree with unique values...
class Treenode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def enumerate(self, root: TreeNode, depth=0, parent=None) -> dict: if root is None: return {} else: elems = {roo...
def greeting(): return 'GREETING from Lambda Layer!' def get_real(): return 'REAL'
def greeting(): return 'GREETING from Lambda Layer!' def get_real(): return 'REAL'
# Initize 1D array arr = [1, 2, 3] # Initize 1D array to x n = 5 x = 3 arr1 = [x] * n # Expect[3, 3, 3, 3, 3] # Initize 2D array to x m = n arr2 = [[x] * n for i in range(m)] # Expect [3,3,3,3,3] * 5 # # Initize 3D array to x k = m arr3 = [[[x] * n for i in range(m)] for j in range(k)] # Expect [3,3,3,3,3...
arr = [1, 2, 3] n = 5 x = 3 arr1 = [x] * n m = n arr2 = [[x] * n for i in range(m)] k = m arr3 = [[[x] * n for i in range(m)] for j in range(k)]
def on_button_pressed_a(): paddle.change(LedSpriteProperty.X, -1) input.on_button_pressed(Button.A, on_button_pressed_a) def on_button_pressed_b(): paddle.change(LedSpriteProperty.X, 1) input.on_button_pressed(Button.B, on_button_pressed_b) paddle: game.LedSprite = None ball = game.create_sprite(2, 1) paddle ...
def on_button_pressed_a(): paddle.change(LedSpriteProperty.X, -1) input.on_button_pressed(Button.A, on_button_pressed_a) def on_button_pressed_b(): paddle.change(LedSpriteProperty.X, 1) input.on_button_pressed(Button.B, on_button_pressed_b) paddle: game.LedSprite = None ball = game.create_sprite(2, 1) paddle =...
l = [1,2,3,4,5,1,2,3,4,5,7,1,1,2,4,3,8] * 10 ht = {} print("Building hash table:") #By building the hashtable we reduce the time complexity in the is_in_list function for x in l: #O(n) ht[x] = True def is_in_list(n): '''for x in l: if n == x: return True return False''' return n in h...
l = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 7, 1, 1, 2, 4, 3, 8] * 10 ht = {} print('Building hash table:') for x in l: ht[x] = True def is_in_list(n): """for x in l: if n == x: return True return False""" return n in ht print(is_in_list(3)) for i in range(10): print(is_in_list(i))
b =[] def test(): global b #print("Hi Rita") b = [] b = 6 b = 9 return b test()
b = [] def test(): global b b = [] b = 6 b = 9 return b test()
def capitalize_title(title): return title.title() def check_sentence_ending(sentence): return sentence.endswith(".") def clean_up_spacing(sentence): clean_sentence = sentence.strip() return clean_sentence def replace_word_choice(sentence, new_word, old_word): better_sentence = sentence.replace(ne...
def capitalize_title(title): return title.title() def check_sentence_ending(sentence): return sentence.endswith('.') def clean_up_spacing(sentence): clean_sentence = sentence.strip() return clean_sentence def replace_word_choice(sentence, new_word, old_word): better_sentence = sentence.replace(ne...
'''class ThisIsAnAnimal: # class is an object pass animal = ThisIsAnAnimal() class Animal: property_1 = "Something" the_animal = Animal() print(the_animal.property_1) # Something ''' class Animal: this_is_a_property = "Something" the_animal = Animal() print(the_animal.this_is_a_property) # Somet...
"""class ThisIsAnAnimal: # class is an object pass animal = ThisIsAnAnimal() class Animal: property_1 = "Something" the_animal = Animal() print(the_animal.property_1) # Something """ class Animal: this_is_a_property = 'Something' the_animal = animal() print(the_animal.this_is_a_property)
__author__ = 'mlaptev' class Vertex(object): def __init__(self, _n): self._name = _n self._adjacency_list = set() self._color = 0 @property def name(self): return self._name def add_adjacent_vertex_id(self, _v): self._adjacency_list.add(_v) def is_adjace...
__author__ = 'mlaptev' class Vertex(object): def __init__(self, _n): self._name = _n self._adjacency_list = set() self._color = 0 @property def name(self): return self._name def add_adjacent_vertex_id(self, _v): self._adjacency_list.add(_v) def is_adjacen...
#https://atcoder.jp/contests/abc148/tasks/abc148_c def gcd(a,b): if a%b==0: return b return gcd(b,a%b) A,B = map(int,input().split()) print((A*B)//gcd(A,B))
def gcd(a, b): if a % b == 0: return b return gcd(b, a % b) (a, b) = map(int, input().split()) print(A * B // gcd(A, B))
# Copyright 2014 The Bazel 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 la...
load('@io_bazel_rules_go//go/private:mode.bzl', 'get_mode') load('@io_bazel_rules_go//go/private:actions/action.bzl', 'add_go_env') load('@io_bazel_rules_go//go/private:common.bzl', 'declare_file') def _go_info_script_impl(ctx): go_toolchain = ctx.toolchains['@io_bazel_rules_go//go:toolchain'] mode = get_mode(...
# -*- coding: utf-8 -*- ''' Abstract Factory for create meny diffrents objects '''
""" Abstract Factory for create meny diffrents objects """
# # PySNMP MIB module SYNSO-ENMIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SYNSO-ENMIB # Produced by pysmi-0.3.4 at Wed May 1 15:14: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 2019, 0...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, value_size_constraint, constraints_union, constraints_intersection) ...
class BaseException(Exception): MESSAGE_TEMPLATE = "Exception {}: {}" def __init__(self, name: str, value, *args, **kwargs): self.message = self.MESSAGE_TEMPLATE.format(name, value) super(BaseException, self).__init__(*args) def __str__(self): return "{}".format(self.message) ...
class Baseexception(Exception): message_template = 'Exception {}: {}' def __init__(self, name: str, value, *args, **kwargs): self.message = self.MESSAGE_TEMPLATE.format(name, value) super(BaseException, self).__init__(*args) def __str__(self): return '{}'.format(self.message) ...
def findDecision(obj): #obj[0]: Coupon, obj[1]: Education, obj[2]: Occupation, obj[3]: Restaurant20to50, obj[4]: Distance # {"feature": "Coupon", "instances": 51, "metric_value": 0.9864, "depth": 1} if obj[0]>0: # {"feature": "Occupation", "instances": 44, "metric_value": 0.9457, "depth": 2} if obj[2]<=14: # {...
def find_decision(obj): if obj[0] > 0: if obj[2] <= 14: if obj[1] <= 3: if obj[4] <= 2: if obj[3] <= 1.0: return 'True' elif obj[3] > 1.0: return 'False' else: ...
# # PySNMP MIB module Nortel-MsCarrier-MscPassport-VirtualRouterMIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-MsCarrier-MscPassport-VirtualRouterMIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:19:57 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_union, value_size_constraint, constraints_intersection) ...
# Author: Mujib Ansari # Date: Jan 23, 2021 # Problem Statement: WAP to reverse a number def reverse_number(num): reverse = 0 while num > 0: reminder = num % 10 reverse = reverse * 10 + reminder num = num // 10 return reverse n = int(input("Enter a number : ")) pri...
def reverse_number(num): reverse = 0 while num > 0: reminder = num % 10 reverse = reverse * 10 + reminder num = num // 10 return reverse n = int(input('Enter a number : ')) print('Original number : ', n) print('Reverse number : ', reverse_number(n))
562143 564321 214563 453261 134562 243561 543621 315264 354621 342516 231456 124635 123546 312546 413256 451632 325614 215643 213465 135426 452163 245631 234165 261543 615432 532614 123654 231564 152436 356142 345216 234156 413265 326154 142635 416532 621543 341652 432561 263154 241365 325164 235164 154632 415326 42513...
562143 564321 214563 453261 134562 243561 543621 315264 354621 342516 231456 124635 123546 312546 413256 451632 325614 215643 213465 135426 452163 245631 234165 261543 615432 532614 123654 231564 152436 356142 345216 234156 413265 326154 142635 416532 621543 341652 432561 263154 241365 325164 235164 154632 415326 42513...
#!/usr/bin/python3 MAJOR = 0 MINOR = 5 PATCH = 0 STRING = "{}.{}.{}".format(MAJOR, MINOR, PATCH)
major = 0 minor = 5 patch = 0 string = '{}.{}.{}'.format(MAJOR, MINOR, PATCH)
''' Utils used for testing in biothings_client tests ''' def descore(hit): ''' Pops the _score from a hit or hit list - _score can vary slightly between runs causing tests to fail. ''' if isinstance(hit, list): res = [] for o in hit: o.pop('_score', None) res.ap...
""" Utils used for testing in biothings_client tests """ def descore(hit): """ Pops the _score from a hit or hit list - _score can vary slightly between runs causing tests to fail. """ if isinstance(hit, list): res = [] for o in hit: o.pop('_score', None) res.ap...
class Operations: def __init__ (self, min_value, max_value, *params): #length1, min_value1, max_value1, #length2, min_value2, max_value2): #lengths, min_values, max_values = map (list, zip (*params)) min_values, max_values = map (list, zip (*params)) #lengths, min_values, max_values = zip (*params) #asse...
class Operations: def __init__(self, min_value, max_value, *params): (min_values, max_values) = map(list, zip(*params)) assert isinstance(min_values, list) assert isinstance(max_values, list) if min_value > max_value: raise exception('min:%s > max:%s' % (min_value, max_v...
def listimp(filename): with open(filename,'r') as file: list = [] for line in file: line = line.rstrip('\n') list.append(line) return list def cleanlist(list): returnlist = [] string = "" for i in list: if i == '': returnlist.append(string...
def listimp(filename): with open(filename, 'r') as file: list = [] for line in file: line = line.rstrip('\n') list.append(line) return list def cleanlist(list): returnlist = [] string = '' for i in list: if i == '': returnlist.append(strin...
# Configure these tables to taste. # NOTE: Adding or removing any entry will change which responses are picked # for a particular song title. # Describes the song. descriptors = [ 'That song is great!', 'That song is _amazing_.', 'That song is terrible!', 'That song isn\'t very good.', 'I hate that...
descriptors = ['That song is great!', 'That song is _amazing_.', 'That song is terrible!', "That song isn't very good.", 'I hate that song.', 'That was my favorite as a kid.', 'That was my favorite in high school.', 'That was my favorite in college.', "That's one of my favorite songs!", "It's got a great beat!", "Here'...
def __chooseObjectFromList(ctx, objects, attribute): # TODO: use entropy random = ctx.random temperature = ctx.temperature weights = [ temperature.getAdjustedValue( getattr(o, attribute) ) for o in objects ] return random.weighted_choice(objects, weights) d...
def __choose_object_from_list(ctx, objects, attribute): random = ctx.random temperature = ctx.temperature weights = [temperature.getAdjustedValue(getattr(o, attribute)) for o in objects] return random.weighted_choice(objects, weights) def choose_unmodified_object(ctx, attribute, inObjects): workspa...
message_hub_creds = { "instance_id": "XXXXX", "mqlight_lookup_url": "https://mqlight-lookup-prod02.messagehub.services.us-south.bluemix.net/Lookup?serviceId=XXXX", "api_key": "XXXX", "kafka_admin_url": "https://kafka-admin-prod02.messagehub.services.us-south.bluemix.net:443", "kafka_rest_url": "https://kafka-...
message_hub_creds = {'instance_id': 'XXXXX', 'mqlight_lookup_url': 'https://mqlight-lookup-prod02.messagehub.services.us-south.bluemix.net/Lookup?serviceId=XXXX', 'api_key': 'XXXX', 'kafka_admin_url': 'https://kafka-admin-prod02.messagehub.services.us-south.bluemix.net:443', 'kafka_rest_url': 'https://kafka-rest-prod02...
def distance_line_to_point(line,point): ((x0,y0),(x1,y1)) = line (x2,y2) = point nom = abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1) denom = ((y2 - y1)**2 + (x2 - x1) ** 2) ** 0.5 result = nom / denom return result
def distance_line_to_point(line, point): ((x0, y0), (x1, y1)) = line (x2, y2) = point nom = abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1) denom = ((y2 - y1) ** 2 + (x2 - x1) ** 2) ** 0.5 result = nom / denom return result
##Dictionary basics. Similar to objects in data structure birthdays = {'Alice': 'Apr 1', 'Bob': 'Dec 12', 'Carol': 'Mar 4'} def birthdayInfo (birthdays): while True: print('Enter a name: (blank to quit)') name = input() if name == '': break if name in birthdays: ...
birthdays = {'Alice': 'Apr 1', 'Bob': 'Dec 12', 'Carol': 'Mar 4'} def birthday_info(birthdays): while True: print('Enter a name: (blank to quit)') name = input() if name == '': break if name in birthdays: print(birthdays[name] + ' is the birthday of ' + name)...
class GenericFunctions: @classmethod def folder_to_table(cls, name): return name.replace("__", ".") @classmethod def table_to_folder(cls, name): return name.replace(".", "__")
class Genericfunctions: @classmethod def folder_to_table(cls, name): return name.replace('__', '.') @classmethod def table_to_folder(cls, name): return name.replace('.', '__')
class TextColors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' BLACK = u'\u001b[30m' RED = u'\u001b[31m' GREEN = u'\u001b[32m' YELLOW = u'\u001b[33m' BL...
class Textcolors: header = '\x1b[95m' okblue = '\x1b[94m' okgreen = '\x1b[92m' warning = '\x1b[93m' fail = '\x1b[91m' endc = '\x1b[0m' bold = '\x1b[1m' underline = '\x1b[4m' black = u'\x1b[30m' red = u'\x1b[31m' green = u'\x1b[32m' yellow = u'\x1b[33m' blue = u'\x1b[3...
class Node: def __init__(self, val=None): self.val = val self.left = None self.right = None def __str__(self): return str(self.val) class BST: def __init__(self): self.root = None def add(self, val): new_node = Node(val) if self.root == None: ...
class Node: def __init__(self, val=None): self.val = val self.left = None self.right = None def __str__(self): return str(self.val) class Bst: def __init__(self): self.root = None def add(self, val): new_node = node(val) if self.root == None: ...
def interpret(value, commands, args): v = value for i,j in zip(commands,args): if i=='+': v += j elif i=='*': v *= j elif i=='-': v -= j else : return -1 return v def main(): print("Enter the initial value : ", end="") ...
def interpret(value, commands, args): v = value for (i, j) in zip(commands, args): if i == '+': v += j elif i == '*': v *= j elif i == '-': v -= j else: return -1 return v def main(): print('Enter the initial value : ', end...
d = {"A": 4 ,"K": 3, "Q": 2, "J": 1, "X": 0} s = 0 for i in range(int(input())): a = input() for j in a: s += d[j] print(s)
d = {'A': 4, 'K': 3, 'Q': 2, 'J': 1, 'X': 0} s = 0 for i in range(int(input())): a = input() for j in a: s += d[j] print(s)
def run_length_encoding(text): assert 1 < len(text) char = text[0] count = 1 output = '' for c in text[1:]: if c == char: count += 1 else: output = f'{output}{char}{str(count)}' count = 1 char = c output = f'{output}{char}{str(co...
def run_length_encoding(text): assert 1 < len(text) char = text[0] count = 1 output = '' for c in text[1:]: if c == char: count += 1 else: output = f'{output}{char}{str(count)}' count = 1 char = c output = f'{output}{char}{str(count...
# Returns a valid response when request's |referrer| matches # |expected_referrer|. def main(request, response): # We want |referrer| to be the referrer header with no query params, # because |expected_referrer| will not contain any query params, and # thus cannot be compared with the actual referrer header...
def main(request, response): referrer = request.headers.get('referer', '').split('?')[0] referrer_policy = request.GET.first('referrer_policy') expected_referrer = request.GET.first('expected_referrer', '') response_headers = [('Content-Type', 'text/javascript'), ('Access-Control-Allow-Origin', '*')] ...
expected_output = { "vrfs": { "default": { "groups_count": 2, "interface": { "Ethernet2/2": { "query_max_response_time": 10, "vrf_name": "default", "statistics": { "...
expected_output = {'vrfs': {'default': {'groups_count': 2, 'interface': {'Ethernet2/2': {'query_max_response_time': 10, 'vrf_name': 'default', 'statistics': {'general': {'sent': {'v2_reports': 0, 'v2_queries': 16, 'v2_leaves': 0}, 'received': {'v2_reports': 0, 'v2_queries': 16, 'v2_leaves': 0}}}, 'configured_query_max_...
#py_nested_dict.py "how to use nested dicts" names=['Snarky', 'Fang', 'Sara'] toys=['bone', 'squrrel', 'squeaker'] weights=[23,30,40] mydict={} index=0 for name, toy, weight in zip(names, toys, weights): mydict["dog_"+str(index)] = {'name': name, 'toy': toy, ...
"""how to use nested dicts""" names = ['Snarky', 'Fang', 'Sara'] toys = ['bone', 'squrrel', 'squeaker'] weights = [23, 30, 40] mydict = {} index = 0 for (name, toy, weight) in zip(names, toys, weights): mydict['dog_' + str(index)] = {'name': name, 'toy': toy, 'weight': weight} index += 1 for (key, value) in myd...
# Updated to match RK's mapping on 20180715 - GN # # def get_sntypes(): # sntypes_map = {1: 'SN1a', 2: 'CC-II', 3: 'CC-Ibc', 6: 'SNII', 12: 'IIpca', 13: 'SNIbc', 14: 'IIn', # 41: 'Ia-91bg', 42: 'Ia-91bg-Jones', 43: 'Iax', 45: 'pointIa', # 50: 'Kilonova-GW170817', 51: 'Kilonova-...
def get_sntypes(): sntypes_map = {11: 'SNIa-Normal', 2: 'SNCC-II', 12: 'SNCC-II', 14: 'SNCC-II', 3: 'SNCC-Ibc', 13: 'SNCC-Ibc', 41: 'Ia-91bg', 43: 'SNIa-x', 51: 'Kilonova', 60: 'SLSN-I', 61: 'PISN', 62: 'ILOT', 63: 'CART', 64: 'TDE', 70: 'AGN', 80: 'RRLyrae', 81: 'Mdwarf', 83: 'EBE', 84: 'Mira', 90: 'uLens-binary',...
class CleverbotError(Exception): pass class NoCredentials(CleverbotError): pass class InvalidCredentials(CleverbotError): pass class APIError(CleverbotError): pass class OutOfRequests(CleverbotError): pass
class Cleverboterror(Exception): pass class Nocredentials(CleverbotError): pass class Invalidcredentials(CleverbotError): pass class Apierror(CleverbotError): pass class Outofrequests(CleverbotError): pass
name=input("Enter your name\n") if name: print(f"your name is {name}") else: print("not entered your name")
name = input('Enter your name\n') if name: print(f'your name is {name}') else: print('not entered your name')
#!/usr/bin/env python reader = vtk.vtkImageReader() reader.ReleaseDataFlagOff() reader.SetDataByteOrderToLittleEndian() reader.SetDataExtent(0,63,0,63,1,93) reader.SetFilePrefix("" + str(VTK_DATA_ROOT) + "/Data/headsq/quarter") reader.SetDataMask(0x7fff) rangeStart = 0.0 rangeEnd = 0.2 LUT = vtk.vtkLookupTable() LUT.S...
reader = vtk.vtkImageReader() reader.ReleaseDataFlagOff() reader.SetDataByteOrderToLittleEndian() reader.SetDataExtent(0, 63, 0, 63, 1, 93) reader.SetFilePrefix('' + str(VTK_DATA_ROOT) + '/Data/headsq/quarter') reader.SetDataMask(32767) range_start = 0.0 range_end = 0.2 lut = vtk.vtkLookupTable() LUT.SetTableRange(0, 1...
def main(): # Use height to build pyramid height = get_height() for i in range(height): for j in range(height - i - 1, 0, -1): print(" ", end="") for k in range(i + 1): print("#", end="") print(" ", end="") for l in range(i + 1): print("#"...
def main(): height = get_height() for i in range(height): for j in range(height - i - 1, 0, -1): print(' ', end='') for k in range(i + 1): print('#', end='') print(' ', end='') for l in range(i + 1): print('#', end='') print() def get...