content
stringlengths
7
1.05M
#todos os is #exemplo isnumeric,isalpha,islower etc a= input ('digite algo') print('o tipo primitivo desse valor é:',type(a)) print('é nuumerico?',a.isnumeric()) print('é alfa numerico?',a.isalnum()) print('é alfa?',a.isalpha()) #...a.islower() #...a.istitle() #...a.isdecimal()
class RequestManipulator: ''' This class can be used to inspect or manipulate output created by the sdc client. Output creation is done in three steps: first a pysdc.pysoap.soapenvelope.Soap12Envelope is created, then a (libxml) etree is created from its content, anf finally a bytestring is gene...
# https://leetcode.com/problems/single-element-in-a-sorted-array/ # You are given a sorted array consisting of only integers where every element # appears exactly twice, except for one element which appears exactly once. Find # this single element that appears only once. # Follow up: Your solution should run in O(log...
class Solution: def findDuplicates(self, nums: List[int]) -> List[int]: if not len(nums): return nums l = [0 for i in range(len(nums)+1)] for i in range(len(nums)): n = nums[i] if l[n]==0: l[n]= 1 else: l[n]+=1 ...
# terrascript/resource/at-wat/ucodecov.py # Automatically generated by tools/makecode.py (24-Sep-2021 15:29:37 UTC) __all__ = []
#Guess my number #Week 2 Finger Exercise 3 print ("Please think of a number between 0 and 100!") print ("Is your secret number 50?") s=[x for x in range (100)] i=input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly.") j=0 k=len(s) m=50...
soma = 0 cont = 1 while cont <= 5: x = float(input("Digite a {} nota: ".format(cont))) soma = soma + x cont = cont + 1 media = soma / 5 print('A media final {}'.format(media))
#A program to count the words "to" and "the" present in a text file "poem.txt". countTo = 0 countThe = 0 file = open("poem.txt", "r") listObj = file.readlines() for index in listObj: word = index.split() for search in word: if search == "to": countTo += 1 elif search == "the": ...
FirstLetter = "Hello" SecondLetter = "World" print(f"{FirstLetter} {SecondLetter}!")
# -*- coding: utf-8 -*- # The union() method returns a new set with all items from both sets: set1 = {"a", "b" , "c"} set2 = {1, 2, 3} set3 = set1.union(set2) print(set3) # Return a set that contains the items that exist in both set x, and set y: x = {"apple", "banana", "cherry"} y = {"google", "microsoft", "apple"} z ...
nums1 = {1, 2, 7, 3, 4, 5} nums2 = {4, 5, 6, 8} nums3 = {9, 10} distinct_nums = nums1.union(nums2, nums3) print( distinct_nums)
class Descriptor(object): """.""" def __init__(self, name=None): """.""" self.name = name def __get__(self, instance, owner): """.""" return instance.__dict__[self.name] def __set__(self, instance, value): """.""" instance.__dict__[self.name] = value...
class Solution: def maxAreaOfIsland(self, grid): """ :type grid: List[List[int]] :rtype: int """ maxArea = 0 for i in range(len(grid)): for j in range(len(grid[0])): if grid[i][j] == 1: maxArea = max(maxArea, self.dfs(g...
"""This script demonstrates the bubble sort algorithm in Python 3.""" AGES = [19, 20, 13, 1, 15, 7, 11, 3, 16, 10] def display(): """Prints all the items in the list.""" print("The ages are: ") for i in range(len(AGES)): print(AGES[i]) print("\n") def bubble_sort(array): """Repeatedly s...
# fmt: off print(2.2j.real) print(2.2j.imag) print(1.1+0.5j.real) print(1.1+0.5j.imag)
#!/usr/bin/env python # # Decoder for Texecom Connect API/Protocol # # Copyright (C) 2018 Joseph Heenan # Updates Jul 2020 Charly Anderson # # 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 Licens...
def test_get_work_film(work_object_film): details = work_object_film.get_details() if not isinstance(details, dict): raise AssertionError() if not len(details) == 17: print(len(details)) raise AssertionError() def test_rating_work_film(work_object_film): main_rating = work_obj...
numbers_1 = [1, 2, 3, 4] numbers_2 = [3, 4, 5, 6] answer = [number for number in numbers_1 if number in numbers_2] print(answer) friends = ['Elie', 'Colt', 'Matt'] answer2 = [friend.lower()[::-1] for friend in friends] print(answer2)
# -*- coding: utf-8 -*- def GetCookie(raw_cookies): """Get raw_cookies with Chrome or Fiddler.""" COOKIE = {} for line in raw_cookies.split(';'): key, value = line.split("=", 1) COOKIE[key] = value return(COOKIE)
""" After years of study, scientists have discovered an alien language transmitted from a faraway planet. The alien language is very unique in that every word consists of exactly L lowercase letters. Also, there are exactly D words in this language. Once the dictionary of all the words in the alien language was built,...
#!/usr/bin/python # Examples of function in Python 3.x # When you need a function? # When you want to perform a set of specific tasks and want to reuse that code whenever required # Also, for better modularity, readability and troubleshooting # How to write a function (Syntax)? '''def function_name(): { ...
#!/usr/bin/python3 """ 1-main """ FIFOCache = __import__('1-fifo_cache').FIFOCache my_cache = FIFOCache() my_cache.put("A", "Hello") my_cache.put("B", "World") my_cache.put("C", "Holberton") my_cache.put("D", "School") my_cache.print_cache() my_cache.put("E", "Battery") my_cache.print_cache() my_cache.put("C", "Street...
print("Welcome!") is_able_to_ride = "" first_rider_age = int(input("What is the age of the first rider? ")) first_rider_height = float(input("What is the height of the first rider? ")) is_a_second_rider = input("Is there a second rider (yes/no)? ") if is_a_second_rider == "yes": second_rider_age = int(input("Wha...
def main(): pass # Run this when called from CLI if __name__ == "__main__": main()
# test for for x in range(10): print(x) for x in range(3, 10): print(x) for x in range(1, 10, 3): print(x) for i, v in enumerate(["a", "b", "c"]): print(i, v) for x in [1,2,3,4]: print(x) for k, v in d.items(): print(x) for a, b, c in [(1,2,3), (4,5,6)]: a = a + 1 b = b * 2 c ...
class ErrorMessage: @staticmethod def inline_link_uid_not_exist(uid): return ( "error: DocumentIndex: " "the inline link references an " "object with an UID " "that does not exist: " f"{uid}." )
_logger = None def set_logger(logger): global _logger _logger = logger def get_logger(): return _logger class cached_property: """ Descriptor (non-data) for building an attribute on-demand on first use. ref: http://stackoverflow.com/a/4037979/3886899 """ __slots__ = ('_factory',...
''' You are given an array (which will have a length of at least 3, but could be very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer N. Write a method that takes the array as an argument and returns this "outlier" N. ...
class Plugin: max = 1 min = 0 def __init__(self, name): self.name = name
def load(): data = [] targets = [] f = open('sonar.data', 'r+') line = f.readline() while line: s = line.strip().split(',') d = s[0:len(s)-1] t = 1 if s[len(s)-1] == 'M' else 0 for i in range(len(d)): d[i] = float(d[i]) data.append(d) ta...
class InstrumentStatus(object): def __init__(self, actuatorCommands, commandCounter): self._actuatorCommands= actuatorCommands self._commandCounter= commandCounter def commandCounter(self): return self._commandCounter def actuatorCommands(self...
pkgname = "startup-notification" pkgver = "0.12" pkgrel = 0 build_style = "gnu_configure" configure_args = ["lf_cv_sane_realloc=yes", "lf_cv_sane_malloc=yes"] hostmakedepends = ["pkgconf"] makedepends = ["libx11-devel", "libsm-devel", "xcb-util-devel"] pkgdesc = "Library for tracking application startup" maintainer = "...
# the defined voltage response from a type K thermocouple # from https://srdata.nist.gov/its90/download/type_k.tab ktype = { #temp in C: millivolt response -270: -6.458, -269: -6.457, -268: -6.456, -267: -6.455, -266: -6.453, -265: -6.452, -264: -6.450, -263: -6.448, ...
""" 5.3 – Cores de alienígenas #1: Suponha que um alienígena acabou de ser atingido em um jogo. Crie uma variável chamada alien_color e atribua-lhe um alor igual a 'green', 'yellow' ou 'red'. • Escreva uma instrução if para testar se a cor do alienígena é verde. Se for, mostre uma mensagem informando que o jogador aca...
''' author : https://github.com/Harnek Prim's algorithm is a minimum-spanning-tree algorithm (for weighted undirected graph) Complexity: Performance:: Adjacency matrix = O(|V|^2) Adjacency list with heap = O(|E| log|V|) ''' def prim(s, edges, n): wt = 0 V = set(range(1,n+1)) A = set() A.add(s...
''' Problem Statement : GCD Choice Link : https://www.hackerearth.com/challenges/competitive/october-easy-20/algorithm/gcd-choice-f04433f3/ Score : partially accepted - 43 pts ''' def find_gcd(x, y): while(y): x, y = y, x % y return x n = int(input()) numbers = list(map(int,input().spl...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # author: Tang Zhuangkun class OperateTargetVo: ''' 对标的物进行操作,支持更新,创建 所需用到的参数 ''' def __init__(self, target_type, operation, target_code, target_name, index_company, valuation_method, trigger_value, trigger_percent, buy_and_hold_strate...
teacher = "Mr. Zhang" print(teacher) print("53+28") print(53+28) first = 5 second = 3 print(first + second) third = first + second print(third) teacher_a="Mr. Zhang" teacher_b=teacher_a print(teacher_a) print(teacher_b) teacher_a="Mr.Yu" print(teacher_a) print(teacher_b) score=7 score = score + 1 print(score)...
__all__ = [ "utils", "ascii_table", "astronomy", "data_plot", "h5T", "mesa", "nugridse", "ppn", "selftest", ]
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2021, Cisco Systems # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) DOCUMENTATION = r""" --- module: enterprise_ssid short_description: Manage EnterpriseSsid objects of Wireless description: - Gets either one or al...
## https://leetcode.com/problems/implement-strstr/ ## problem is to find where the needle occurs in the haystack. ## do this in O(n) by looping over the characters in the haystack ## and checking if the string started by that index (and as long ## as the needle) is equal to the needle. ## return -1 if we get to the ...
# 4из20 + Результаты последнего тиража def test_4x20_results_last_draw(app): app.ResultAndPrizes.open_page_results_and_prizes() app.ResultAndPrizes.click_game_4x20() app.ResultAndPrizes.click_results_of_the_last_draw() app.ResultAndPrizes.button_get_report_winners() app.ResultAndPrizes.parser_rep...
text = """ //------------------------------------------------------------------------------ // Explicit instantiation. //------------------------------------------------------------------------------ #include "Geometry/Dimension.hh" #include "FSISPH/FSISpecificThermalEnergyPolicy.cc" namespace Spheral { template cla...
value = '16b87ecc17e3568c83d2d55d8c0d7260' # https://md5.gromweb.com/?md5=16b87ecc17e3568c83d2d55d8c0d7260 print('flippit')
class Storage(dict): """ A Storage object is like a dictionary except `obj.foo` can be used in addition to `obj['foo']`, and setting obj.foo = None deletes item foo. >>> o = Storage(a=1) >>> print o.a 1 >>> o['a'] 1 >>> o.a = 2 >>> print o['a'] ...
def paint(x, y): global a global pic if not (0 <= x < a and 0 <= y < a): return if pic[x][y] == '+': return pic[x][y] = '+' paint(x+1, y) paint(x-1, y) paint(x, y+1) paint(x, y-1) output = [] a = int(input()) pic = [] for i in range(a): pic.append(list(input()))...
""" TODO: - QualifiedName visitability.. somewhere - CreateOrReplaceTable (w/ prefixes) - batching for snowflake... - helper against sqla inserts with nonexisting columns :/ """
#!/usr/bin/python3 # -*- coding: utf-8 -*- # Created by Ross on 19-3-18 """ 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 问总共有多少条不同的路径? 输入: m = 3, n = 2 输出: 3 解释: 从左上角开始,总共有 3 条路径可以到达右下角。 1. 向右 -> 向右 -> 向下 2. 向右 -> 向下 -> 向右 3. 向下 -> 向右 -> 向右 """ def solve(m: int, n:...
OCTICON_MARK_GITHUB = """ <svg class="octicon octicon-mark-github" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.2...
COMMANDS = [ # OP Level 0-2 "placefeature" "advancement", "attribute", "bossbar", "clear", "clone", "data", "datapack", "debug", "defaultgamemode", "difficulty", "effect", "enchant", "execute", "experience", "fill", "forceload", "function", ...
# -*- coding: utf-8 -*- invoice_info = """ 购方名称:甘肃省水利水电勘测设计研究院 购方纳税人识别号:620102438002318 购方地址、电话:甘肃省兰州市城关区平凉路284号 0931-8806331 开户行及账号:农行兰州东方红广场支行 27-011101040003710 """ invoice_notice = """ 1.增值税发票不可折叠、涂抹 2.发票购方名称务必准确、发票纳税人识别号务必准确 """ hotel_expense = """ 以下费用为上限 省级城市:500 地市级城市:400 XXXX """ question_dict = { '开票信息...
str1 = input("Enter the postfix expression:") list1 = str1.split() stack = list() print(list1) # 2 3 1 * + 9 - here the ans is -4 def isOperator(a): if a == '+' or a == '-' or a == '/' or a == '*': return 1 else: return 0 def evaluate(a, b, c): if a == '+': return b + c elif...
# fruits = {} # # fruits["apple"] = "A sweet red fruit" # # fruits["mango"] = "King of all" # # print(fruits["apple"]) line = input() letter = {} for ch in line: if ch in letter: letter[ch] += 1 else: letter[ch] = 1 print(letter) print(letter.keys())
###Titulo: Exibe número ###Função: Este programa exibe os numeros de 50 a 100 ###Autor: Valmor Mantelli Jr. ###Data: 09/12/20148 ###Versão: 0.0.1 # Declaração de variáve x = 50 # Processamento while x <=100: # Saída print(x) x = x + 1
# from .initial_values import initial_values #----------STATE VARIABLE Genesis DICTIONARY--------------------------- genesis_states = { 'player_200' : False, 'player_250' : False, 'player_300' : False, 'player_350' : False, 'player_400' : False, 'game_200' : False, 'game_250' : F...
#!/usr/bin/env vpython3 def onefile(fname): data = open(fname, 'rt').read() data = data.replace('FPDF_EXPORT', 'extern') data = data.replace('FPDF_CALLCONV', '') open(fname, 'wt').write(data) onefile('pdfium/include/fpdf_annot.h') onefile('pdfium/include/fpdf_attachment.h') onefile('pdfium/include/fpd...
def inequality(value): # Complete the if statement on the next line using value, the inequality operator (!=), and the number 13. if value != 13: ### Your code goes above this line ### return "Not Equal to 13" else: return "Equal to 13" print(inequality(100))
# -*- Mode: Python; test-case-name: test.test_pychecker_CodeChecks -*- # vi:si:et:sw=4:sts=4:ts=4 # trigger opcode 99, DUP_TOPX def duptopx(): d = {} for i in range(0, 9): d[i] = i for k in d: # the += on a dict member triggers DUP_TOPX d[k] += 1
####################################################### # # track.py # Python implementation of the Class track # Generated by Enterprise Architect # Created on: 11-Feb-2020 11:08:09 AM # Original author: Corvo # ####################################################### class track: # default constructor d...
mylist=['hello',[2,3,4],[40,50,60],['hi'],'how',"bye"] print(mylist) print(mylist[1][1]) mylist=['hello',[2,3,4]] print(mylist[1][0]) num1=[0,32,444,4453,[23,43,54,12,3]] print(num1) num2=[0,32,444,4453] num2.extend([23,43,54,12,3]) print(num2)
nascido = 0 contador = 1 total = 0 while contador <= 10: contador += 1 nascido = int(input('Em que ano você nasceu: ')) demaior = (nascido - 2021) *-1 if demaior >= 18: total += 1 print ('{} São maiores de idade'.format (total))
def test(x, y): x + y test( 11111111, test(11111111, 1111111), test(11111111, 1111111), 222, 222, test(11111111, 1111111), test(11111111, 1111111), 222, test(11111111, 1111111), test(11111111, 1111111), test(11111111, 1111111), test(11111111, 1111111), test(1111...
"""Define library wise constants""" __version__: str = '0.0.7' __author__: str = 'Igor Morgado' __author_email__: str = 'morgado.igor@gmail.com'
# dfs # Runtime: 52 ms, faster than 100.00% of Python3 online submissions for Path Sum III. # Memory Usage: 13.3 MB, less than 100.00% of Python3 online submissions for Path Sum III. # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # ...
# # PySNMP MIB module CISCOTRAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOTRAP-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:24:33 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
data_s3_path = "riskified-research-files/research analysts/DO/representment/win_rate_prediction/exploration" data_file_name = "disputed_chbs_targil_6.csv" cat_features = [ # 'dispute_status', 'domestic_international', 'order_submission_type', 'bill_ship_mismatch', 'is_proxy', 'order_external_st...
# # PySNMP MIB module GMS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/GMS-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:06:21 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)...
# Copyright (c) 2015 Vivaldi Technologies AS. All rights reserved { 'targets': [ { 'target_name': 'vivaldi_api_registration', 'type': 'static_library', 'msvs_disabled_warnings': [ 4267 ], 'includes': [ '../../chromium/build/json_schema_bundle_registration_compile.gypi', '....
class Solution: def solve(self, nums, a, b, c): q = lambda x: a*(x**2)+b*x+c if not nums: return [] if len(nums) == 1: return list(map(q,nums)) if a == 0: if b > 0: return list(map(q,nums)) else: return list(map(q,re...
# -*- coding: utf-8 -*- """ Created on Sat Mar 21 12:03:38 2020 @author: Ravi """ def CountSort(arr,n): count = [0]*100 for i in arr: count[i]+=1 i=0 for a in range(100): for c in range(count[a]): arr[i] = a i+=1 return arr
def Vertical_Concatenation(Test_list): Result = [] n = 0 while n != len(Test_list): temp = '' for indexes in Test_list: try: temp += indexes[n] except IndexError: pass n += 1 Result.append(temp) return Re...
#!/usr/bin/env python3 class UserError(Exception): pass
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def createList(self, list): h = head = ListNode(None) for l in list: head.next = ListNode(l) head = head.next return h.next ...
self.description = "check file type without mtree" self.filesystem = [ "bar/", "foo -> bar/" ] pkg = pmpkg("dummy") pkg.files = [ "foo/" ] self.addpkg2db("local",pkg) self.args = "-Qk" self.addrule("PACMAN_RETCODE=1") self.addrule("PACMAN_OUTPUT=warning.*(File type mismatch)")
#Solution-7 Lisa Murray # User needs to input number that they want to calculate the square root of: num = float(input("Please enter a positive number: ")) #square root is found by raising the number to the power of a half sqroot = num**(1/2) # round the square root number to one decimal place and cast as a string a...
# MadLib.py adjective = input("Please enter an adjective: ") noun = input("Please enter a noun: ") verb = input("Please enter a verb ending in -ed: ") print("Your MadLib:") print("The", adjective, noun, verb, "over the lazy brown dog.")
""" None """ class SnakeGame: def __init__(self, width: int, height: int, food: List[List[int]]): """ Initialize your data structure here. @param width - screen width @param height - screen height @param food - A list of food positions E.g food = [[1,1], [1,0]] m...
""" Handling of options passed to the decorator to generate more rows of data. """ def _copy_rows(data, num_rows, base_row_index=0): """ Copies one list from a list of lists and adds it to the same list n times. Parameters ---------- data: [][] Dataset to apply the function to. This will ...
class Node: def __init__(self,cargo,left=None,right=None): self.cargo = cargo self.left = left self.right = right def __str__(self) -> str: return str(self.cargo) def insert(root,key): if root is None: return Node(key) if root.cargo>key: if root.left is ...
num1 = 1 num2 = 2 num3 = 3 num4 = 33 num6 = 66
class input_format(): def __init__(self,format_tag): self.tag = format_tag def print_sample_input(self): if self.tag =='FCC_BCC_Edge_Ternary': print(''' Sample JSON for using pseudo-ternary predictions of solid solution strength by Curtin edge dislocation model. --...
'''l = ['cão', 'gato', 'peixe'] for c in l: print(c)''' cont = 0 palavra = input('digite a palavra: ') for c in palavra: if c in 'aeiou': print(c, end=' ') cont += 1 print(cont)
def main(): a = float(input("Number a: ")) b = float(input("Number b: ")) if a > b: print("A > b") elif a < b: print("A < B") else: print("A = B") if __name__ == '__main__': main()
# A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase and lowercase English letters (no punctuation). # For example, "Hello World", "HELLO", and "hello world hello world" are all sentences. # You are given a sentence s​​​​​...
class AuthSigner(object): """Signer for use with authenticated ADB, introduced in 4.4.x/KitKat.""" def sign(self, data): """Signs given data using a private key.""" raise NotImplementedError() def get_public_key(self): """Returns the public key in PEM format without headers or newl...
# MYSQL CREDENTIALS mysql_user = "root" mysql_pass = "clickhouse" # MYSQL8 CREDENTIALS mysql8_user = "root" mysql8_pass = "clickhouse" # POSTGRES CREDENTIALS pg_user = "postgres" pg_pass = "mysecretpassword" pg_db = "postgres" # MINIO CREDENTIALS minio_access_key = "minio" minio_secret_key = "minio123" # MONGODB ...
#! python3 """√ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... In the first one-thousand expansions, how many fractions contain a numerator with more digits than denominator?""" answer = 0 n, d = 3, 2 for _ in range(1000): if len(str(n)) > len(str(d)): answer += 1 n, d = n + d + d, n + d print(answ...
# Find cure root using bisection search num = 43 eps = 1e-6 iteration = 0 croot = num/2 _high = num _low = 1 while abs(croot**3-num)>eps: iteration+=1 cube = croot**3 if cube==num: print(f'At Iteration {iteration} : Found It!, the cube root for {num} is {croot}') break elif cube>num: ...
level = 3 name = 'Kertasari' capital = 'Cibeureum' area = 152.07
#!/bin/python3 """ If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ def multiples_of_3_5(stop): """Compute sum numbers in range(1, stop) if numbers are divided by 3 or 5.""...
class IllegalValueException(Exception): def __init__(self, message): super().__init__(message) class IllegalCurrencyException(Exception): def __init__(self, message): super().__init__(message) class IllegalCoinException(Exception): def __init__(self, message): super().__init__(m...
n1 = float(input('Informe a nota 1: ')) n2 = float(input('Informe a nota 2: ')) m = (n1+n2)/2 print('A média é {}'.format(m))
class Solution(object): def maxProfit(self, k, prices): """ :type k: int :type prices: List[int] :rtype: int """ n = len(prices) if k >= n/2: ret = 0 for i in xrange(1, n): ret += max(prices[i]-prices[i-1], 0) ...
class Solution: @lru_cache(None) def numRollsToTarget(self, d: int, f: int, target: int) -> int: if d==1: if f>=target:return 1 return 0 count=0 for i in range(1,f+1): if i<target: count += self.numRollsToTarget(d-1,f,target-i) ...
# Tags: Implementation # Difficulty: 1.5 # Priority: 5 # Date: 08-06-2017 hh, mm = map(int, input().split(':')) a = int( input() ) % ( 60 * 24 ) mm += a hh += mm // 60 mm %= 60 hh %= 24 print('%0.2d:%0.2d' %(hh, mm))
# # PySNMP MIB module HUAWEI-BRAS-SRVCFG-DEVICE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-BRAS-SRVCFG-DEVICE-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:43:28 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python ve...
class Solution: def findOrder(self, numCourses: int, prerequisites: List[List[int]]) -> List[int]: child = collections.defaultdict(set) parent = collections.defaultdict(int) for c, p in prerequisites: child[p].add(c) parent[c] +=1 q = collections.dequ...
''' URL: https://leetcode.com/problems/monotonic-array/ Difficulty: Easy Title: Monotonic Array ''' ################### Code ################### class Solution: def isMonotonic(self, A: List[int]) -> bool: if len(A) in [1, 2]: return True cmp = None ...
#NUMBERS 10 #Numero Entero (integer) 10.4 #Numero Flotante (float) print(type(10)) print(type(10.4)) #INPUT age = input('Coloque su edad: ') print(type(age)) new_age = int(age) + 5 print(new_age)
''' In this problem, we should define dummy and cur as a listNode(0). Let dummy points to the start of cur. Everytime when we update cur.next, cur will move to cur.next. And if the length of l1 and l2 is not equal, cur.next points to the left list l1 or l2. Tips: It is like two pointers. But it is done with node. '...