content
stringlengths
7
1.05M
class MaxSubArrayBottomUp: def __init__(self, prices): self.prices = prices self.sub_solutions = [None] * len(prices) for i in range(len(self.prices)): if i == 0: self.sub_solutions[i] = self.prices[0] else: self.sub_solutions[i] = max(...
#!/usr/bin/env python # -*- coding: utf-8 -*- class HadoopUtil(object): def __init__(self,console): self.console = console; pass def cp(self,src,dest): #复制 self.console.cmd("hadoop fs -cp -p %s %s" % (src,dest)) def mkdir(self,path):#创建目录 self.console.cmd("hadoop fs -mkdir -...
def lowest_product(input): if len(input)<4: return "Number is too small" if "0" in input: return 0 total=9**4 for i in range(len(input)-3): total=min(total, (int(input[i])*int(input[i+1])*int(input[i+2])*int(input[i+3]))) return total
class Solution: def countAndSay(self, n): """ :type n: int :rtype: str """ if n == 1: return "1" if n == 2: return "11" s = "11" for i in range(3, n + 1): s += "*" len_str = len(s) count = 1 ...
class UnbError(Exception): pass class ResponseError(UnbError): pass class BadRequest(ResponseError): pass class Unauthorized(ResponseError): pass class Forbidden(ResponseError): pass class NotFound(ResponseError): pass class TooManyRequests(ResponseError): pass class InternalS...
#usando matriz matriz = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] contador = maior = soma = 0 for l in range(0, 3): for c in range (0, 3): matriz[l][c] = int(input(f'Digite o valor para [{l}, {c}]: ')) print('-='*30) for l in range(0, 3): for c in range(0, 3): print(f'[{matriz[l][c]:^5}]', end='') ...
""" Session: 8 Topic: String functions: split, join """ str = 'This is a long string' print (str) """ splint = str.split() print ('split length is {} of word {} ' .format(len(splint), splint) ) splintn = str.split('n') print ('splitn length is {} of word {} ' .format(len(splintn), splintn) ) """ str1 = (':'.join(...
# # @lc app=leetcode id=401 lang=python # # [401] Binary Watch # # https://leetcode.com/problems/binary-watch/description/ # # algorithms # Easy (45.07%) # Total Accepted: 61.8K # Total Submissions: 136.8K # Testcase Example: '0' # # A binary watch has 4 LEDs on the top which represent the hours (0-11), and # the 6...
def barra(n=10, c="*"): print(c*n) L = [ [5, "-"], [10, "*"], [5] ] for e in L: barra(*e) # barra(5, "-") barra(10, "*")
class DataPorter: def __init__(self, model, **kwargs): self.model = model self.computing_device = kwargs.get('computing_device', 'cpu') @staticmethod def get_direct_parameters(module): # TODO: Don't access protected attribute (check if name contains dot?) return module._para...
#! /usr/bin/python3 class Entity: def __init__(self, id): self._id = id self._tags = [] self._componentids =[] def get_id(self) -> int: return self._id def add(self, parameter): if isinstance(parameter, str): self._tags.append(parameter) elif is...
"""Rules for generating capnproto files. """ CapnpInfo = provider( "Dependency info for generating capnp files", fields = [ "includes", "sources", ], ) def _path_concat(*args): path = "" for arg in args: if path == "": path = arg elif arg == "": ...
pokusy = 3,1,2,3,1,3,2,9 soucet = 0 pocet = 0 for cislo in pokusy: soucet = soucet + cislo pocet = pocet + 1 prumer = soucet / pocet print('průměrný počet hodů:', prumer)
class Person: def __init__(self, name): self.name = name self._id = name.lower() # underscore prefix = "private" but only by convention # when methods are defined in a class, it adds them as attributes to any instance of that class. # when a method is called on an object, it automatically a...
# 使用f字符串拼接字符串 s1 = input('字符串s1:') s2 = input('字符串s2:') no = int(input('整数no:')) print(f'{s1}{s2}') # 字符串 + 字符串 print(f'{s1}{no}{s2}') # 字符串 + 整数 + 字符串
def solution(s: str): return "".join(sorted(s, reverse=True)) if __name__ == "__main__": i = "Zbcdefg" print(solution(i))
def eh_primo(x): if (x==3) or (x==2): return True if (x<2) or (x%2==0): return False for i in range(3, int(x**0.5)+1, 2): if x%i==0: return False return True n = int(input()) for i in range(0,n): num = int(input()) out = eh_primo(num) if out == True: ...
class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for i in nums: j = target - i tmp_nums_start_index = nums.index(i) + 1 tmp_nums = nums[tmp_nums_start_index:] ...
DEBUG = True UPLOADS_DEFAULT_DEST = 'uploads' UPLOADED_RESUMES_ALLOW = ('pdf', 'PDF') # can't just use 'pdf' or ['pdf'] MAX_CONTENT_LENGTH = 32 * 1024 * 1024 MAX_CONTENT_LENGTH = 32 * 1024 * 1024 DB_USERNAME = 'vagrant' DB_PASSWORD = 'vagrant' DB_DATABASE = 'connect' DB_HOST = '127.0.0.1' TABLES = {} TABLES['submis...
class Solution: # O(4^n) time | O(4^n) space def letterCombinations(self, digits: str) -> List[str]: dic = {'2': 'abc', '3': 'def', '4': 'ghi', '5': 'jkl', '6': 'mno', '7': 'pqrs', '8': 'tuv', "9": 'wxyz'} n = len(digits) if n < 1: return [] lst = [ch f...
orthogonal_similarity_input_address=snakemake.input.orthogonal_similarity_input_address metlin_inchikey_address=snakemake.input.metlin_inchikey_address orthogonal_similarity_output_address=snakemake.output.orthogonal_similarity_output_address def get_set_of_firstblock_from_list(inchikey_list_address): inchike...
print('=='*20) print('{:^40}'.format('Banco CEV')) print('=='*20) saque = int(input('Que valor você quer sacar? R$ ')) if saque >= 50: cedulas50 = int(saque / 50) saque = saque - (cedulas50 * 50) print(f'Total de {cedulas50} cédulas de R$ 50') if saque >= 20: cedulas20 = int(saque / 20) saque = sa...
ADJECTIVE_CITATION_FORMS = [ ((r"ος, α, ον$", r"^a-1a\(1\)$", r"^A$"), "", []), ((r"ος, α, ον$", r"^a-3b\(1\)$", r"^A$"), "", []), ((r"ος, α, ον$", r"^a-1a\(1\)$", r"^A,"), "", []), # @@@ ((r"ος, α, ον$", r"^a-1a\(1\)$", r"^$"), "", []), # @@@...
#!/usr/bin/env python # -*- coding: utf8 -*- server = "irc.freenode.net" port = 6667 botname = "b0tsec" chan = "#n0sec"
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def __init__(self): self.path = [] self.res = [] def make_tree(self, val, left, right): ...
class Solution: def countRoutes(self, locations: List[int], start: int, finish: int, fuel: int) -> int: @lru_cache(None) def routes(start, fuel): if fuel<0: return 0 answer=0 #print('start:'+str(start)+', fuel:'+str(fuel)+', answer: '+str(an...
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : mp = dict ( ) Sum = 0 count = 0 for i in range ( n ) : if ( arr [ i ] == 0 ) : ...
def divisors(num): divisors = [] for i in range(1, num + 1): if num % i == 0: divisors.append(i) return divisors def run(): num = input("Ingresa un número: ") assert num.isnumeric(), "Debes ingresar un número que además se encuentre dentro de los números enteros positivos" ...
# # SPDX-FileCopyrightText: 2020 Amerlyq <amerlyq@gmail.com> # # SPDX-License-Identifier: CC0-1.0 # """ Main app """ __appname__ = 'flatmod' __version__ = '0.1.0'
# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. class Progression: def __init__(self, start=0): self._current = start def _advance(self): self._c...
#input = '389125467' # example input = '952316487' # my puzzle input input = [int(n) for n in input] next = {} numcups = len(input) for j in range(numcups): next.update({input[j]: input[(j + 1) % numcups]}) steps = 100 # this is needed only in part 2 start = len(input) + 1 until = 1000000 next.update({input[-1]...
#两个列表[1,5,7,9]和[2,2,6,8]合并为[1,2,2,3,6,7,8,9] a = [1,5,7,9] b = [3] a.extend(b) print(a)
# Time: O(n) # Space: O(1) class Solution(object): def shuffle(self, nums, n): """ :type nums: List[int] :type n: int :rtype: List[int] """ def index(i): return 2*i if i < n else 2*(i-n)+1 for i in xrange(len(nums)): j = i ...
def egcd(a, b): x1, x2 = 1, 0 y1, y2 = 0, 1 while b > 0: tmp = a // b x1, x2 = x2, x1 - tmp * x2 y1, y2 = y2, y1 - tmp * y2 a, b = b, a % b return a, x1, y1 def modinv(a, b): return egcd(a, b)[1] % b
class Config(): def __init__(self, koji_host, koji_storage_host, arch, result_dir): self.koji_host = koji_host self.koji_storage_host = koji_storage_host self.arch = arch self.result_dir = result_dir
# two-finger pointer method. It is tedious to set the correct indices, conditions and extreme cases anyway class Solution: def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: len1 = len(nums1) len2 = len(nums2) if len1 + len2 <= 1: if len1 == 1: ...
# Class ini digunakan untuk menyimpan data Post dari database travelnesia class Post: # Constructor ini digunakan untuk inisialiasi data dari class Post def __init__(self, post_id, title, username, location, location_rating, transport, vote, budget, content): self.post_id = post_id self.title = ...
''' Simulation of signal propagation in the DWDM network Optical signals, as defined via :class:`.info.SpectralInformation`, enter :py:mod:`.elements` which compute how these signals are affected as they travel through the :py:mod:`.network`. The simulation is controlled via :py:mod:`.parameters` and implemented mainl...
def fact(n): if(n==1): return 1 else: return n*fact(n-1) a=int(input("ENTER A NUMBER")) print(fact(a))
class BaseTest(object): def make_rpc_client(self): err_msg = "make_rpc_client must be overridden in a subclass." raise NotImplementedError(err_msg) def test_send_rpc(self): rpc_client = self.make_rpc_client() result = rpc_client.send('eth_coinbase') assert isinstance(re...
class TrieNode: def __init__(self): self.children = {} self.is_word = False class Trie: def __init__(self): self.root = TrieNode() def insert(self, word): cur = self.root for c in word: if c not in cur.children: cur.children[c] = TrieNo...
""" @Project : DuReader @Module : __init__.py.py @Author : Deco [deco@cubee.com] @Created : 8/13/18 10:48 AM @Desc : sentence embedding nonparametric parametric """
################ ''' { "e": "kline", // Event type "E": 123456789, // Event time "s": "BNBBTC", // Symbol "k": { "t": 123400000, // Kline start time "T": 123460000, // Kline close time "s": "BNBBTC", // Symbol "i": "1m", // Interval ...
def aportecooperativa (INGRESOMENSUAL): pregunta=INGRESOMENSUAL.isdigit() if(pregunta): pregunta1=int(INGRESOMENSUAL) if (pregunta1<=2): gasto=(pregunta1*0.01) return gasto elif ((pregunta1>2) and (pregunta1<=6)): gasto=(pregunta1*0.02) ret...
# Demo Python Strings - Escape Character ''' Escape Character To insert characters that are illegal in a string, use an escape character. An escape character is a backslash \ followed by the character you want to insert. An example of an illegal character is a double quote inside a string that is surrounded by doubl...
# CPU: 0.05 s universities = set() for _ in range(int(input())): university, name = input().split() if len(universities) >= 12: break elif university not in universities: print(university, name) universities.add(university)
""" Date : Avril 2020 Projet : MOOC Python 3 - France Université Numérique Objectif: Écrire une fonction wc(nomFichier) qui ouvre le fichier en question et renvoie un tuple de trois nombres : le nombre de caractères (y compris les caractères de retour à la ligne) le nombre de mots le no...
def menu(): x = 1 while x !=0 : print (" Menu'") print(" Descrizione Menu") print(" VOCE MENU.....digita 1 --> ") print(" VOCE MENU.... digita 2 --> ") x = input("scegli cosa vuoi fare digita 0 per uscire............... --> ") if x == "1": return 1 ...
class Team: def __init__(self): self.workers = [] # list of Worker objects def hire(self, worker): self.workers.append(worker) def fire(self, pos): self.workers.pop(pos)
# # PySNMP MIB module HUAWEI-SWITCH-SRV-RES-TRAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-SWITCH-SRV-RES-TRAP-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:37:05 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python ...
INGREDIENTS = [ "bone", "undead eyeball", "spider", "fish tail", "adamantine", "tentacle of giant octopus or giant squid", "ice", "coal", "food morsel", "bitumen (a drop)", "giant slug bile", "jade dust", "rotten egg", "silver powder", "artistic representatio...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Aug 11 10:42:59 2020 @author: juanfe """ def sum2(a,b): """ :param a: (float) Primer variable a sumar :param b: (float) Segunda varaible a sumar :return c: (float) c=a+b """ c = a + b return c def sums(a,b,c): """ ...
# This function returns pointer to LCA of two given # values n1 and n2 # This function assumes that n1 and n2 are present in # Binary Tree def findLCA(root, n1, n2): # Base Case if root is None: return None # If either n1 or n2 matches with root's key, report # the presence by returning root ...
# %% [114. Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list/) class Solution: def flatten(self, root: TreeNode) -> None: """ Do not return anything, modify root in-place instead. """ lst = list(to_list(p := root, True)) if r...
class PWM: def __enter__(self): raise NotImplementedError() def __exit__(self, exc_type, exc_value, traceback): raise NotImplementedError() def set_frequency(self, freq): raise NotImplementedError() def set_period(self, period_us): raise NotImplementedError() d...
maior = 0 menor = 0 for c in range(1, 16): p = int(input(f'Digite o {c}° numero: ')) if p == 1: p = maior = menor else: if p > maior: maior = p if p < menor: menor = p print(f'O maior numero é {maior}') print(f'O menor é {menor}')
def solve(n, l): l_len = len(l) missing = ((l_len + 1) * (l_len + 2) // 2) - sum(l) print(missing) if __name__ == "__main__": inp_n = [int(x) for x in input().split()] inp_l = [int(x) for x in input().split()] solve(n=inp_n[0], l=inp_l)
def neighbors(matrix,i,j,row,col): mine = 0 if not ((i < 1) or (j < 1)): if matrix[i - 1][j - 1]: mine+=1 if not (i < 1): if matrix[i - 1][j]: mine+=1 if not ((i < 1) or (j >= col-1)): if matrix[i - 1][j + 1]: mine+=1 if not (j >= col-1): ...
# https://leetcode.com/problems/unique-email-addresses/ class Solution: def numUniqueEmails(self, emails): """ :type emails: List[str] :rtype: int """ def create_unique_email(email): local, domain = email.split('@') built_local = [] for c...
def removeDuplicates(nums): prev = None current = None new_list = [] for i in nums: current = i if current != prev: new_list.append(current) prev = current return new_list
num = list() for i in range(0, 5): num.append(int(input(f'Digite um número para a posição {i}: '))) print('=-='*30) print(f'Você digitou os valores {num}.') print(f'O maior valor digitado foi {max(num)} na posição', end=' ') for c, v in enumerate(num): if v == max(num): print('{:.<3}'.format(c),end=' ')...
# -*- coding: utf-8 -*- """ 演習5 ■ 仕様 以下のアスキーアートを表示するコンソールプログラムを作成してください。 ■ 実行画面 ○○○ ○○ ○ ○ ○○ ○○○ """ # 変数 ball = "〇" # 何個ボールを印刷する変数です ball_cnt = 3 # カウンター変数 counter = 0 # 7行を印刷する為  while counter <= 7: # ボールかける ボールカウンター変数を印刷するする print(ball * ball_cnt) # ボールカウンタを ー=1 ball_cnt -= 1 #  カウンター変数...
d = str(input("Digite uma data no formato 'DD/MM/AAAA': ")) data = (d.split("/")) resp = [data[0]+" de "] if data[1] == "01": data[1] = "Janeiro de " elif data[1] == "02": data[1] = "Fevereiro de " elif data[1] == "03": data[1] = "Março de " elif data[1] == "04": data[1] = "Abril de " elif data[1] == "05": data[1]...
base_directional_light = { 'type': 'directional', 'direction': [[10.0, 10.0, 10.0]], 'ambient_color': [[0.5, 0.5, 0.5]], 'diffuse_color': [[0.5, 0.5, 0.5]], 'specular_color': [[0.5, 0.5, 0.5]], } base_point_light = { 'type': 'point', 'ambient_color': [[0.5, 0.5, 0.5]], 'diffuse_color': ...
class Profile: def __init__(self,n,f,t): self.name = n.title() # ensures that both passwords have both upper and lower case letters self.food = f.title() self.time = t self.Sentence = self.sentence() def sentence(self): if self.time == 0: return (f'{self....
class InjectException(Exception): """Base class for all exceptions.""" pass class NonInjectableTypeError(InjectException): """Raised when a type could not be injected (i.e. they are no corresponding bindings).""" pass class NoBindingFound(NonInjectableTypeError): """Raised when no binding was fo...
# Below are implementations of some standard RL agents class RandomAgent(): """Random agent""" def __init__(self, env): self.env = env def act(self, state): return self.env.action_space.sample() def reset(self): pass def learn(self, state, action, reward, next_state, done...
##Ejercicio 11 # Cual es la complejidad del codigo? # # Entrada: # - # Salida: ''' si n 10 o 16 primer while 2 primer while 4 primer while 8 primer while 16 segundo while 16 segundo while 16 ------------- ''' # # # la complejidad resultante es de O log(log(n)) # ya que es un efecto ...
# Desenvolva uma lógica que leia o peso e a altura de uma pessoa, # calcule seu Índice de Massa Corporal (IMC) e mostre seu status, de acordo com a tabela abaixo: # # – IMC abaixo de 18,5: Abaixo do Peso # # – Entre 18,5 e 25: Peso Ideal # # – 25 até 30: Sobrepeso # # – 30 até 40: Obesidade # # – Acima de 40: Obesidade...
class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: def bruteforce(): for i in range(9): for j in range(9): boxr, boxc = i//3 , j//3 num = board[i][j] if num=='.': continue ...
#!/usr/bin/env python # -*- coding: utf-8 -*- # vi: set expandtab shiftwidth=4 : # auther: shun kawai # =============================== # function.py # =============================== def func(a, b): print(a, "+", b, "=", a+b) for x in range(1, 11): func(x, x*x)
# Kabupaten Bandung kecamatan = { 'Ciwidey': { 'pusat': 'Lebakmuncang', 'luas': 48.47 }, 'Rancabali': { 'pusat': 'Patengan', 'luas': 148.37 }, 'Pasirjambu': { 'pusat': 'Pasirjambu', 'luas': 239.58 }, 'Cimaung': { 'pusat': 'Cipinang', 'luas': 55 }, 'Pengalengan': { 'pusat': 'Pangalengan', 'luas': 195.41 }, ...
HAVE_RUN_INIT = "False" def on_init(server): global HAVE_RUN_INIT HAVE_RUN_INIT = "True" def on_message(msg, server): if msg["text"] == u"test_init": return HAVE_RUN_INIT
class Solution: def arrangeCoins(self, n: int) -> int: lo, hi = 0, n + 1 while lo < hi: mi = (hi - lo) // 2 + lo if mi * (mi + 1) // 2 <= n: lo = mi + 1 else: hi = mi return lo-1
# Copyright 2018 Databricks, Inc. VERSION = '1.2.1.dev0'
#!/usr/bin/python2.7 # -*- coding: utf-8 -*- class A: pass class B: pass # 新式类 统一了 type(x) 和 x.__class__, python3所有类默认继承object class C(object): pass a = A() b = B() c = C() print(type(A)) print(type(B)) print(type(C)) print("-------------- ") print(type(a)) print(type(b)) print(type(c)) print("----...
# Create a style for the shadow label_style = lv.style_t() lv.style_copy(label_style, lv.style_plain) label_style.text.opa = lv.OPA._50 # Create a label for the shadow first (it's in the background) shadow_label = lv.label(lv.scr_act()) shadow_label.set_style(lv.label.STYLE.MAIN, label_style) # Create the main label ...
def main(): f = open("Bridge_5000000.txt", "r") lines = f.readlines() f.close() idx = 0 parsed_len = 0 with open("Bridge_5000000_parsed.txt", 'w') as g: g.write(lines[0]) g.write(lines[1]) g.write(lines[2]) idx += 3 valid_cards_list = [set(list(range(13*0, 13*1))), set(list(range(13*1, 13*2))),...
def strStr(haystack, needle): if len(needle) == 0: return 0 if needle in haystack: return haystack.index(needle) else: return -1
def utility(countryId, numOfRemainingTeams): if(storedValues[numOfRemainingTeams][countryId] != -1): return storedValues[numOfRemainingTeams][countryId] max = 0; for i in range(numOfRemainingTeams + 1): value = livesPerTeam[i][countryId] + utility(countryId - 1, numOfRemainingTeams - i) if(value > max): ...
def test_read_main(test_client): response = test_client.get("/") assert response.status_code == 200 assert response.json() == {"Hello": "World"}
class Set(): def __init__(self): self.items = {} def has(self, value): if self.items.get(value): return True return False def add(self, value): if not self.has(value): self.items[value] = value return True return False ...
class Produto: def __init__(self, nome, descricao, preco): self.nome = nome self.descricao = descricao self.preco = preco self.quantidade = 0 def aumentar_quantidade(self, quantidade_a_somar): if quantidade_a_somar > 0: self.quantidade += quantidade_a_somar ...
### The following code implements the Convolutional Neural Network on MNIST dataset in pytorch. """ Step 1: Load the data """ train_dataset = dsets.MNIST(root = './data', train = True, transform = transforms.ToTensor(), download = True ...
num1 = float ( input ('Digite o número ? ')) num2 = float ( input ('Digite outro número ? ')) tipo = int ( input ('Escolha 1,2,3 ou 4 ? ')) if ( tipo == 1 ): m = ( num1 + num2 ) / 2 print ('Média é {}'.format(m)) elif ( tipo == 2) and ( num1 > num2 ): print ('Diferença >>> {:.0f}-{:.0f} = {:.0f}'.format(num1,...
results = [] for x in data: y = delayed(inc)(x) results.append(y) total = delayed(sum)(results) total.compute()
# -*- coding: utf-8 -*- """ Created on Thu Jun 3 19:34:03 2021 @author: Dhiman """ def countingValleys(steps, path): # Write your code here depth = 0 n = 0 for i in range(len(path)): if(path[i] == 'U'): depth +=1 ...
#Crie um programa que tenha uma função fatorial() que receba dois parâmetros: o primeiro que indique o #número a calcular e outro chamado show, que será um valor lógico (opcional) indicando se será mostrado ou #não na tela o processo de cálculo do fatorial. def fatorial(num,show=False): """Fazer o fatorial do num...
# Python Program for Merge Sort # Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the two sorted halves. # The merge() function is used for merging two halves. The merge(arr, l, m, r) is key process that assumes that arr[l..m] and ...
#Guess Number Higher or Lower 猜数字大小 ''' 猜数字大小: 对手已经作为函数给我们了,只要调用然后比较就可以,很简单 ''' # The guess API is already defined for you. # @param num, your guess # @return -1 if my number is lower, 1 if my number is higher, otherwise return 0 # def guess(num: int) -> int: class Solution: def guessNumber(self, n: int) -> int:...
#!/usr/bin/python def main(): try: a = int(input("Input number: ")) b = int(input("Input number: ")) CubeSum = a**3 + b**3 print("The Cube sum is equal to " + str(CubeSum)) main() except: raise SystemExit def message(): print("Press any non-number key to ter...
# blockgen.py # Functions for generating Scratch JSON def procedure(name, args, atomic, body): argnames, argtypes = zip(*args) return [0, 0, [["procDef", name + " " + " ".join(argtypes), list(argnames), [""]*len(argnames), atomic], body]] def getparam(name): return ["getparam", nam...
out=[0,0,0] x=int(input()) for i in range(x): d=int(input()) g=d%3 out[g]+=1 print(" ".join([str(i)for i in out]))
# WRITE YOUR SOLUTION HERE: class LotteryNumbers : def __init__(self, week_number: int, correct_numbers: list): self.correct_numbers = correct_numbers self.week_number = week_number def number_of_hits(self,numbers: list): return len([number for number in numbers if number in self.co...
numbers = int(input()) res_num = 0 for i in range (1, numbers + 1): i = str(i) res_num = 0 for num in range (len(i)): res_num += int(i[num]) if res_num in(5, 7, 11): print(f'{i} -> True') else: print(f'{i} -> False')
# This largely mimics the AST of Python 2.7 with additional nodes # to support Cython specific constructs. #------------------------------------------------------------------------------ # AST validation #------------------------------------------------------------------------------ def assert_mod(node, var_name): ...
# Python program to find largest # number in a list # list of numbers list1 = [10, 20, 4, 45, 99] # sorting the list list1.sort() # printing the last element print("Largest element is:", list1[-1])
class Roles(object): Admin = 'ur:admin' ApiKeyUser = 'apikey-user' SessionUser = 'session-user' class Permissions(object): List = 'list' View = 'view' Edit = 'edit' Create = 'create' Delete = 'delete' Import = 'import' ListSupporters = 'listsupporters' AdminPetition = ...
__version__ = "0.6.0" __author__ = "Nico Schlömer" __author_email__ = "nico.schloemer@gmail.com" __copyright__ = "Copyright (C) 2018-2019 {} <{}>".format(__author__, __author_email__) __website__ = "https://github.com/nschloe/optimesh" __status__ = "Development Status :: 4 - Beta" __license__ = "License :: OSI Approved...
######################################################### # # Just scratch space, this won't execute or import properly. # ######################################################### name = "All executive parent domains" compliance_stats(name, parents_only, utils.executive_only) name = "All executive CFO Act parent do...