content
stringlengths
7
1.05M
#!/usr/bin/env python one_kb = 1024 def to_mega_byte(data_size): return (data_size * one_kb) * 1024 def calculate_symbol_size(generation_size, data_size): return data_size / generation_size def encoding_calculate(generation_size, symbols_size): return generation_size * symbol_size
length = 21 for i in range(length): for j in range(length): if (i == j): print('*', end="") elif (i == length-1-j): print('*', end="") elif (j == length//2 and i > length//10 and i < 0.9*length ): print('*', end="") else: print(' ', e...
def max_window_sum(arr,w_size): if len(arr) < w_size: return None running_sum = run_index = 0 max_val = float("-inf") for item in range(w_size): running_sum += arr[item] for item in range (w_size , len(arr)): if running_sum > max_val: max_val = running_sum running_sum -= arr[run_index] running_sum ...
v = float(input("Digite em Km/h velocidade em que o carro estava: ")) if v > 80: print("Você foi multado.") m = (v - 80) * 7 print("Deve pagar uma multa no valor de R${:.2f}".format(m)) print("Dirija com cuidado!")
# # PySNMP MIB module RADLAN-PIM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RADLAN-PIM-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:39:06 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2...
class TagAdditionsEnum: TAG_NAME = "name" TAG_SMILES = "smiles" TAG_ORIGINAL_SMILES = "original_smiles" TAG_LIGAND_ID = "ligand_id" # try to find the internal value and return def __getattr__(self, name): if name in self: return name raise AttributeError # pro...
def helper(memo, nums, i, j): if i > j: return 0 if j == i: return nums[i] if (i, j) in memo: return memo[(i, j)] ans1 = nums[i] + min(helper(memo, nums, i + 2, j), helper(memo, nums, i + 1, j - 1)) ans2 = nums[j] + min(helper(memo, nums, i + 1, j - 1), helper(memo, nums, i, j - 2)) memo...
# O(n) time with caching, O(n) space def count_steps(n, cache = {}): if n <= 0: return 0 if n == 1: return 1 if n == 2: return 2 if n == 3: return 4 if n in cache: return cache[n] cache[n] = count_steps(n - 1) + count_steps(n - 2) + count_steps(n - 3) ...
""" project-scoped settings """ LOGGING_LEVEL = 'INFO' CSV_MAX_FILE_SIZE_MB = 1024 S3_BUCKET_NAME = 'migrations-redshift-123' S3_TARGET_DIR = 'files_to_copy_to_redshift' REDSHIFT_DB = 'dev'
class Paren: def __init__(self, paren): if paren == '(': LParen() @staticmethod def getParen(paren): if paren == '(': return LParen() elif paren == ')': return RParen() elif paren == '{': return LBrace() elif paren == '}': return RBrace() def __str__...
# Escreva um algoritmo para ler um valor (do teclado) e escrever (na tela) o seu antecessor. (SOMENTE NUMERO INTEIRO) num = int(input('Digite um valor na tela: ')) res = num - 1 print(res)
class Wotd(): def __init__( self, definition: str, englishExample: str, foreignExample: str, language: str, transliteration: str, word: str ): if definition is None or len(definition) == 0 or definition.isspace(): raise ValueError( ...
""" 63. Unique Paths II A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). Now consider if some obst...
"""Submodule for the `Namespace` class, which tracks `Named` objects to detect conflicts.""" class Namespace: """Managed set of uniquely named `Named` and nested `Namespace` objects. This is used to check uniqueness of the `name` and `mnemonic` values.""" def __init__(self, name, check_mnemonics=True): ...
n = int(input("Enter n: ")) x = 2 y = 2 x1 = 0 flag = False ''' Gives false at 2 and 3 because powers start from 2''' if n == 1: print("Output: True\n" + str(n) + " can be expressed as " + str(1) + "^(0, 1, 2, 3, 4, 5, ......)") else: while x <= n: #print(x) while x1 < n: ...
SECRET_KEY = 'Software_Fellowship_Day_4' DEBUG = True ENV = 'development' API_KEY = "API_KEY_GOES_HERE"
#-*- coding:utf-8 -*- USER_STATE_UNACTIVE = 0 USER_STATE_ACTIVE = 1 USER_STATE_DELETE = -1 SUPER_USER = 'admin' SUPER_USER_PWD = '123456' class LimitType: TYPE_URL = 0 TYPE_MENU = 1 TYPE_PAGE = 2 TYPE_TAB = 3 class LimitGroupType: TYPE_WELCOME = 1 TYPE_USER = 2 TYPE_GROUP = 3 TYPE_ROLE = 4 TYPE_LIMIT = 5 T...
def output(): test_case = int(input()) if 2 <= test_case <= 99: for i in range(test_case): i_put = input() print('gzuz') if __name__ == '__main__': output()
# DFS class Solution: def findCircleNum(self, M: List[List[int]]) -> int: res = 0 visited = [0]*len(M) for i in range(len(M)): if visited[i] == 0: res += 1 visited[i] = 1 self.dfs(M, i, visited) return res ...
# Python type a = 'Python is a great language.' b = 10 c = 2.5 d = {a, b, c} e = [a, b, c] f = (a, b, c) g = {"a":b, "a":c} h = b > c i = 3 + 4j ''' print('a =',a,type(a)) print('b =',b,type(b)) print('c =',c,type(c)) print('d =',d,type(d)) print('e =',e,type(e)) print('f =',f,type(f)) print('g =',g,type(g)) print('h...
#!/usr/bin/python3 #https://practice.geeksforgeeks.org/problems/rearrange-characters/0 def sol(s): """ If a character frequency is 4 then it requires atleast 3 other characters so that the characters are not adjacent. We only need to check the character with highest frequency because if those are not ...
class ValidationError(Exception): def __init__(self, message, errors): super().__init__(message) self.message = message self.errors = errors def __errPrint__(self, foo, space=' '): ''' Function to petty print the error from cerberus. ''' error = '' ...
class TestInstitutionsSearch: def test_institutions_search(self, client): res = client.get("/institutions?search=university") json_data = res.get_json() assert "university" in json_data["results"][0]["display_name"].lower() for result in json_data["results"][:25]: assert ...
''' Distinct Numbers in Window Asked in: Amazon https://www.interviewbit.com/problems/distinct-numbers-in-window/ You are given an array of N integers, A1, A2 ,…, AN and an integer K. Return the of count of distinct numbers in all windows of size K. Formally, return an array of size N-K+1 where i’th element in this ...
#TabuadaLoop numero=int(input("Qual é o número que você quer que apareça sua tabuada: ")) for i in range(0,11): print(numero, ' * ', i, ' = ', numero*i)
print("Enter the number of frames: ", end="") capacity = int(input()) f, st, fault, pf = [], [], 0, "No" print("Enter the reference string: ", end="") s = list(map(int, input().strip().split())) print("\nString|Frame →\t", end="") for i in range(capacity): print(i, end=" ") print("Fault\n ↓\n") for i in s: i...
start_year = int(input()) current_year = start_year + 1 found = False while True: not_found = False for fi in range(len(str(current_year))): for si in range(fi + 1, len(str(current_year))): fd = str(current_year)[fi] sd = str(current_year)[si] if fd == sd: ...
""" common.py provides constant values to be used throughout the app """ EXCHANGE_BINANCE = 'BINANCE' SIDE_HODL = "hodl" SIDE_SELL = "sell" SIDE_BUY = "buy"
def fat (n): fat = 1 while (n > 1): fat = fat * n n -= 1 return fat def test_fat0 (): assert fat (0)==1
# --------------------------------------------------------------------------------> Rotation class Rotation: def __init__(self, start_line, end_line, rotation_center=None): self.type = "Rotation" self.start_line = start_line self.end_line = end_line self.rotation_center = rotation_ce...
# todo: make this configurable EXCHANGE_CRONOS_BLOCKCHAIN = "Cronos" CUR_CRONOS = "CRO" MILLION = 100000000.0 CURRENCIES = { "ibc/14F9BC3E44B8A9C1BE1FB08980FAB87034C9905EF17CF2F5008FC085218811CC": "OSMO", "ibc/EB2CED20AB0466F18BE49285E56B31306D4C60438A022EA995BA65D5E3CF7E09": "SCRT", "ibc/FA0006F056DB6719B8...
with plt.xkcd(): plt.figure(figsize=(8,6)) ##################################### ## determine which variables you want to look at, replace question marks # determine which variables you want to look at, replace question marks plt.hist(s_ves, label='a', alpha=0.5) # set the first argument here plt.hist(s_o...
""" Codebay site-wide default configuration. The format of this file is normal Python syntax where configuration values are directly modified in the 'conf' object. Example: >>> conf.conftest_test1 = 5 >>> conf.conftest_test2 = 'test' >>> conf.conftest_test3 = True Use the '.codebayrc.py' file in home directory to ad...
OCTICON_CHECK = """ <svg class="octicon octicon-check" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg> """
# Create a new class level variable called person_counter # Create a property called person_id and return a unique ID for each person object class Person: def __init__(self, first_name: str, last_name: str): self.__first_name = first_name self.__last_name = last_name @property def full_na...
class Stack: def __init__(self): self.stack = [] def empty(self): return len(self.stack) == 0 def peek(self): return self.stack[-1] def push(self, x): self.stack.append(x) def pop(self): del self.stack[-1] class Queue: def __ini...
print("{:f}".format(123.5)) # 123.500000 print("{:.2f}".format(123.5)) # 123.50 print("{:7.2f}".format(123.5)) # 123.50 print("{:07.2f}".format(123.5)) # 0123.50 print("{:d}".format(123)) # 0123 print(f"Eu sei contar até {1234}")
class Player(): """ This player class initializes a player with a unique ID and exposes functions to play a card and assign/add cards to the player's deck. """ def __init__(self, player_id): self.player_id = player_id self.player_deck = [] def assign_cards(self, cards): ...
class Solution: def tree2str(self, t): """ :type t: TreeNode :rtype: str """ if not t: return '' ans = str(t.val) if t.left or t.right: ans += '(' + self.tree2str(t.left) + ')' if t.right: ans += '(' + self.tree2str...
class Solution: def hasAllCodes(self, s: str, k: int) -> bool: sub_s = set() for i in range(0, len(s) - k + 1): sub_s.add(s[i:i+k]) return True if len(sub_s) == 2**k else False
""" CNGI Package Module functions with blank descriptions have not been completed yet. As each function is completed, its description will be populated. """ #__init__.py
# region Deprecated_code """notes = [] is_generating = threading.Event() is_throwing = threading.Event() notes_count = 0 portion_iter = 0 notes_amount = 0 portion_iters_amount = 0 out_path = "" # DEPRECATED CODE!!! def setup(): global notes_amount, portion_iters_amount, out_path notes_amount = gen...
# Let's just use the local mongod instance. Edit as needed. # Please note that MONGO_HOST and MONGO_PORT could very well be left # out as they already default to a bare bones local 'mongod' instance. #MONGO_HOST = 'localhost' #MONGO_PORT = 27017 # Skip these if your db has no auth. But it really should. #MONG...
#! /usr/bin/python # -*- coding: utf-8 -*- def compose_char(char): return NotImplementedError def compose(string): return NotImplementedError def decompose_char(char): return NotImplementedError def decompose(string, aslist=False): l = (decompose_char(c) for c in string) if aslist: ...
n=int(input()); res="" for _ in range(n): car=int(input()) opt=int(input()) for _ in range(opt): a,b=map(int, input().split()) car+=a*b res+=str(car)+"\n" print(res)
class dotSolid_t(object): """ dotSolid_t(Size: int) """ @staticmethod def __new__(self, Size): """ __new__[dotSolid_t]() -> dotSolid_t __new__(cls: type,Size: int) """ pass CreationType = None EdgeIndex = None Edges = None FaceIndex = None F...
''' The squirrels in Palo Alto spend most of the day playing. In particular, they play if the temperature is between 60 and 90 (inclusive). Unless it is summer, then the upper limit is 100 instead of 90. Given an int temperature and a boolean is_summer, return True if the squirrels play and False otherwise. ''' def s...
HEADER = '''<!doctype html> <html class="no-js" lang=""> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title></title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="manifest" href...
# A recursive implementation of Binary Search def recBinarySearch(target, theValues, first, last): # If the sequence of values cannot be subdivided further, # we are done if last <= first: # BASE CASE #1 return False else: # Find the midpoint of the sequence mid = (first + las...
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Custom exceptions used in the astroquery query classes """ __all__ = ['TimeoutError', 'InvalidQueryError', 'RemoteServiceError', 'TableParseError'] class TimeoutError(Exception): """ Raised on failure to establish connection with server ...
# # PySNMP MIB module ZYXEL-XGS4728F-MIB (http://pysnmp.sf.net) # ASN.1 source file:///usr/local/share/snmp/ZYXEL-XGS-4728F.my # Produced by pysmi-0.0.7 at Fri Feb 17 12:27:14 2017 # On host e0f449e7a145 platform Linux version 4.4.0-62-generic by user root # Using Python version 3.5.3 (default, Feb 10 2017, 02:09:54) ...
def validate(number): if not 0 < number <= 64: raise ValueError("Invalid input!") def square(number): validate(number) return 2 ** (number - 1) def total(number): validate(number) return sum(square(i + 1) for i in range(number))
""" Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. Example : Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. Rain water trapped: Example 1 The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In ...
DB_NAME = "defaultdb" DB_USER = "postgres" SESSIONSDB_HOST = '127.0.0.1' SESSIONSDB_PORT = 6379 SESSIONSDB_PASSWD = None SESSIONSDB_NO = 1 # SMTP MD_HOST = '127.0.0.1' MD_PORT = 10000 MD_USERNAME = None MD_KEY = '' class API_LOGGER: ENABLED = False
inpt = [] while True: try: inpt.append(int(input())) except EOFError: break even = lambda x: True if x % 2 == 0 else False l = lambda lst: list(map(even, inpt)) print(l(inpt))
#/usr/bin/python3 class Car() : def __init__(self) : print("This is class named car") car = Car() class ChinaCar(Car) : def __init__(self, name) : self.__name__ = name print("China car named ", name) china_car = ChinaCar("byd") class FlyCar(Car) : def __init__(self) : ...
# # PySNMP MIB module CISCO-UNIFIED-COMPUTING-FC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-UNIFIED-COMPUTING-FC-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:59:25 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python ...
def heapSort(self): heap = hp.Heap() heap.createHeap(*self.arr) i = 0 while(heap.size > 0): self.arr[i] = heap.delete() i += 1
text = input() new = "@" dash = "-" save = [] command = input() while command != "Complete": conversion = command.split(" ") if conversion[0] == "Make": if conversion[1] == "Upper": conv = text.upper() text = conv print(conv) elif conversion[1...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None LOW = float('-inf') class Solution: def largestValues(self, root): """ :type root: TreeNode :rtype: List[int] """ ...
class Solution(object): def romanToInt(self, s): """ :type s: str :rtype: int """ roman_dict1 = {'I':1, 'V':5, 'X':10, 'L':50, 'C':100, 'D':500, 'M':1000} roman_dict2 = {'IV':4, 'IX':9, 'XL':40, 'XC':90, 'CD':400, 'CM':900} sum_var = 0 i = 0 wh...
# 一:元祖练习题:判断是否可以实现,如果可以请写代码实现。 # li = ["alex",[11,22,(88,99,100,),33] "WuSir", ("ritian", "barry",), "wenzhou"] li = ["alex", [11, 22, (88, 99, 100,), 33], "WuSir", ("ritian", "barry",), "wenzhou"] # 1:请将 "WuSir" 修改成 "吴彦祖" li[2] = "吴彦祖" print(li) # 2:请将 ("ritian", "barry",) 修改为 ['日天','日地'] li[3] = ['日天', '日...
L3_attention_mse=[{"layer_T":4, "layer_S":1, "feature":"attention", "loss":"attention_mse", "weight":1}, {"layer_T":8, "layer_S":2, "feature":"attention", "loss":"attention_mse", "weight":1}, {"layer_T":12, "layer_S":3, "feature":"attention", "loss":"attention_mse", "weight":1}] L...
class TableEntryPJC: def __init__(self, rli, wi, rlj, wj, rlij, wij): self.rli = rli self.rlj = rlj self.rlij = rlij self.wi = wi self.wj = wj self.wij = wij def __str__(self): res = "" res = res + " " + str(self.rli) + " : " + str(self.wi) + "\n"...
""" The Datatable app is responsible for generating and returning visualization data for specific configurations of dimensions and filters. """
def pagesNumberingWithInk(current, numberOfDigits): currentNumberOfDigits = len(str(current)) while numberOfDigits >= currentNumberOfDigits: numberOfDigits -= currentNumberOfDigits current += 1 currentNumberOfDigits = len(str(current)) return current-1 if __name__ == '__main__': input0 = [1, 21, 8, 21, 76, 8...
class PrintHelper: @staticmethod def PrintBanner(printStr, sep='='): bannerStr = sep * len(printStr) print(bannerStr) print(printStr) print(bannerStr)
#!/usr/bin/env python # -*- coding: utf-8 -*- # This script allows to split an input tf.data.TFRecords dataset # to training and test dataset using the input split proportions. # Optionally, the user can request to get a validation dataset # by passing a float value to the variable `valid_chunk`. # # Author: Davide Lo...
bridgelist = [] with open('input.txt') as infile: for line in infile.readlines(): i, o = line.strip().split('/') i, o = int(i), int(o) bridgelist.append((i,o,)) maxlen = 0 maxstrength = 0 def build_bridge(bridgelist, already_used=None, current_value=0, connector_used=0, current_length=0): ...
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def findSecondMinimumValue(self, root): """ :type root: TreeNode :rtype: int """ f, s = se...
choice = int(input()) if choice == 1: # Código final 2 param opcional class Conta: def __init__(self, titular, saldo, numero, limite = 1000): self.titular = titular self.saldo = saldo self.numero = numero self.limite = limite def...
__author__ = 'lrebuffi' """ ========= Associate ========= Widgets for association rules. """ # Category description for the widget registry NAME = "Wavepy - Diagnostic" DESCRIPTION = "Widgets for WavePy - Diagnostic" BACKGROUND = "#01DFA5" #"#A9F5BC" ICON = "icons/wavepy.png" PRIORITY = 0.2
class UsernameConverters: regex= '[a-zA-Z0-9]{5,20}' def to_python(self,value): return str(value) def to_url(self,value): return str(value) class MobileConverter: regex = '1[3-9]\d{9}' def to_python(self,value): return str(value) def to_url(self,value): retu...
c, d = None, None def setup(): size(800, 800) global c, d c= color(random(255), random(255), random(255)) d= color(random(255), random(255), random(255)) def draw(): global c, d for x in range(width): # loop through every x p = lerpColor(c, d, 1.0 * x/width) stroke(p) line(x, 0, x, height) ...
n,c = map(int,raw_input().split()) i = 0 while i<c : if [char for char in str(n)][-1] == "0" : n=n/10 else : n-=1 i+=1 print(n)
""" We are given a list schedule of employees, which represents the working time for each employee. Each employee has a list of non-overlapping Intervals, and these intervals are in sorted order. Return the list of finite intervals representing common, positive-length free time for all employees, also in ...
num = (int (input ('Digite um número: ')), int (input ('Digite outro número: ')), int (input ('Digite mais um número: ')), int (input ('Digite o último número: '))) print (f'O número 9 apareceu {num.count(9)}.') if 3 in num: print (f'O número 3 apareceu na {num.index(3)+1}ª posição.') else: print ('...
def factorial(n) -> int: if n == 0: return 1 return n * factorial(n - 1) if __name__ == "__main__": print(factorial(0)) print(factorial(1)) print(factorial(2)) print(factorial(3)) print(factorial(4)) print(factorial(5)) print(factorial(9)) print(factorial(20))
""" Python script made/used by Sean Klein (smklein). Used to quickly navigate between multiple repositories. """ home = "~" prefix_dir = home + "/path/prefix" dir_info =\ ["CATEGORY:", {"directory": prefix_dir + "/dirname", "build": """ # Updates DEPS make deps # Actually builds sources. Default...
# CPU: 0.06 s for _ in range(int(input())): tc_no, num = input().split() try: oct_num = int(num, 8) except ValueError: oct_num = 0 # Idk why but you have to convert num to int before printing (or else 'Wrong answer') print(tc_no, oct_num, int(num), int(num, 16))
# -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect connect-cli. # Copyright (c) 2019-2021 Ingram Micro. All Rights Reserved. ITEMS_COLS_HEADERS = { 'A': 'ID', 'B': 'MPN', 'C': 'Action', 'D': 'Name', 'E': 'Description', 'F': 'Type', 'G': 'Precision', 'H':...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def maxDepth(root: TreeNode) -> int: if not root: return 0 height = 0 queue = [root] while queue: size = len(queue) height += 1 stack = [] while siz...
#Classe mãe class Inseto: class_name = "" desc = "" objects = {} def __init__(self,name): self.name = name Inseto.objects[self.class_name] = self def get_desc(self): return self.class_name + "\n" + self.desc #Classe filha class Aranha(Inseto): def __init__(self, name): self.class_name = "aranha" s...
"""EduuRobot Core!""" # SPDX-License-Identifier: MIT # Copyright (c) 2018-2021 Amano Team __version__ = "2.0.0-beta"
class PublishedEvent(object): def __init__(self, draft, public): self.draft = draft self.public = public
""" The Sims 4 Community Library is licensed under the Creative Commons Attribution 4.0 International public license (CC BY 4.0). https://creativecommons.org/licenses/by/4.0/ https://creativecommons.org/licenses/by/4.0/legalcode Copyright (c) COLONOLNUTTY """ class CommonDialogNavigationButtonTag: """ Tags appli...
#this function receives an msp file and reads through it and isolates individual spectra based on blank lines in the file #it sends a spectrum to parse_spectrum for parsing and writing to the csv file def isolate_spectra(library_headers): #declare empty list for lines from file current_spectrum_text_chunk=[] ...
# Carson (2111000) | Zenumist Society (261000010) experiment = 3310 closedLab = 926120100 if sm.hasQuest(experiment): control = sm.sendAskYesNo("Do you want to go to the closed laboratory and try controlling the Homun?") if control: sm.sendNext("Concentrate...! It won't be an easy task trying to cont...
t=int(input()) for i in range(0,t): str=input() c=0 for j in range(0,len(str)): ch=str[j] if(ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u' or ch=='A' or ch=='E' or ch=='I' or ch=='O' or ch=='U'): c=c+(len(str)-j)*(j+1) print(c)
#correção profs = MUITO MELHOR num = int(input('Digite um número: ')) c = num fatorial = 1 print(f'{num}! = ', end='') while c > 0: print(f'{c}', end='') print(f' x ' if c > 1 else ' = ', end='') fatorial *= c c -= 1 print(fatorial) n = int(input('Digite um número: ')) i = n f = 1 print(f'{n}! = ', en...
class Solution: def largestUniqueNumber(self, A: List[int]) -> int: counter = Counter(A) for num, freq in sorted(counter.items(), reverse = True): if freq == 1: return num return -1
class Solution: def totalMoney(self, n: int) -> int: # ind = 1 amount = 0 prevmon = 0 while n: coin = prevmon + 1 for i in range(7): amount += coin coin += 1 n-=1 if n==0: r...
'''Receba um número inteiro positivo na entrada e imprima os nn primeiros números ímpares naturais. Para a saída, siga o formato do exemplo abaixo. Digite o valor de n: 5 1 3 5 7 9 ''' quant = int(input('Digite o valor de n: ')) cont = 0 num = 1 while quant > cont: print(num) num += 2 quant -= 1
class Node: def __init__(self, data): self.data= data self.left= None self.right= None """ 4 / \ 5 6 / \ / \ 7 None None None / \ None None """ root= Node(4) root.left=5 root.rig...
# ------------------------------ # # # Description: # # # Version: 1.0 # 01/19/20 by Jianfa # ------------------------------ # Used for testing if __name__ == "__main__": test = Solution() # ------------------------------ # Summary: #
#ERROR MESSAGES ARGUMENTS_TYPE_LIST_OR_STRING_ERROR_MESSAGE= "Arguments should be of type List or String" ARGUMENTS_TYPE_STRING_ERROR_MESSAGE = "Arguments should be of type String" LABEL_ALREADY_PRESENT_ERROR_MESSAGE = "Class/Label: {} already present." NO_LABEL_PRESENT_ERROR_MESSAGE = "Please add Class/Labels to the o...
class Bacteria: def __init__(self, id, type, age, life_counter, power, x, y): self.id = id self.type = type self.age = age self.life_counter = life_counter self.power = power self.x = x self.y = y # Create 3 instances of Bacteria b1 = Bacteria(1, "Cocci", ...
#To add two numbers a=int(input("Enter the 1st number")) b=int(input("Enter the 2nd number")) c=a+b print("The sum of the two numbers:",c)
# configure the dm text def generate_dm_text(name): return '''Hey {}, It great to connect with you on twitter'''.format(name) scheduler_time = 15 #in minutes tw_username = "signosdazueira" #change this to yours
#!/usr/bin/env python3 def parse(line): bound, char, password = line.split(' ') low, high = bound.split('-') low, high = int(low), int(high) char = char[0] return (low, high, char, password) def is_valid(low, high, char, password): low, high = low - 1, high - 1 low, high = password[low] ...