content
stringlengths
7
1.05M
# """ # This is the interface that allows for creating nested lists. # You should not implement it, or speculate about its implementation # """ #class NestedInteger: # def __init__(self, value=None): # """ # If value is not specified, initializes an empty list. # Otherwise initializes a single i...
def compare_extraction(extractor, examples, counter_examples, lwrap="", rwrap=""): for example in examples: wrapped = lwrap + example + rwrap # print(extractor.process(wrapped), example) assert extractor.process(wrapped) == [example] assert extractor.process...
list = ["2,4,6,8,10","1,3,7,9,10"] listA = list[0].split(sep=',') listB = list[1].split(sep=',') print("\n::: INTERSECCIÓN ::: \n") i=0 counter=0 while i < len(listA) : j=0 while j < len(listB) : if listA[i] == listB[j] : print ("lista A",listA[i]) counter+=1 j+=1 i+=1 if counter == 0 : ...
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def addTwoNumbers(self, l1, l2): out = l1 out_root = out flag = 0 while l1 is not None or l2 is not None or flag: ...
class Solution: def min_steps(self, piles): piles.sort(reverse=True) res = 0 for i in range(1, len(piles)): if piles[i] != piles[i - 1]: res += i return res
def solve(f, a, b, c): m = (a + b) / 2.0 while a != m and m != b: if f(m) < c: a = m else: b = m m = (a + b) / 2.0 return a a = 0 b = 10 print(solve(lambda x: x ** 3 + x + 1, a, b, 5.0000000000000001))
# # Copyright (c) 2018 Joy Diamond. All rights reserved. # @gem('Crystal.ChessBishop') def gem(): require_gem('Crystal.CardRoot') @export class ChessBishop(CardRoot): ally_abbreviation = 'WB' enemy_abbreviation = 'BB' initial_attack = 1 initial_health = 3 ...
''' Demo_2 sums up all the input number collected from the input and gives the average value of the inputs ''' number = 0 i = 0 sum = 0 average = 0 n=0 print('please enter the numbers, if it equals to 0 or be less than 0, the input will end') while True: n = int(input('please enter a number: ')) if n <= 0: ...
""" procon library by bayashi-cl github repository: https://github.com/bayashi-cl/byslib-python This library can be expanded with expander. - https://github.com/bayashi-cl/expander """ __version__ = "0.1.0"
input = open('input.txt').readlines() input = map(lambda s: s.replace('\n', ''), input) depth = 0 horizontal = 0 for string in input: replaced = string.replace('down ', '') if 'down' in string else string.replace('up ', '-') if replaced != string: depth += int(replaced) else: horizontal +=...
# visa full time master's ph.D question def number_of_pair(a, k): # a = [1,1,3,3,9,46] # k = 47 # answer = 1 -> (1,46) # a.sort() d = {} pair = 0 i = 0 if not a: return 0 try: while i <= len(a): value = a[i] complement = k - value...
# -*- coding: utf-8 -*- """ @description: @author: LiuXin @contact: xinliu1996@163.com @Created on: 2020/11/20 上午11:41 """
#!/usr/env/bin python3 class BaseError(Exception): def __init__(self, value): self.value = value def __str__(self): return self.value class MissingParameters(BaseError): pass class ApiError(BaseError): pass class IDNotFound(BaseError): pass class NameNotFound(BaseError): ...
####Aula 64 Curso em Vídeo###### n = cont = soma = 0 n = int(input('Digite um número : ')) while n != 999: soma += n cont += 1 n = int(input('Digite um número : ')) print('você digitou {} números e a soma foi {} '.format(cont,soma))
class DataReader(): """ Get dataset from files Examples: train, dev, test = DataReader("data/train.txt","data/dev.txt","data/test.txt").read() """ def __init__(self, train_file, dev_file, test_file): """ Init dataset information. Inputs: train_file: trai...
class Solution(object): # Use inbuilt functions def hammingWeightBuiltin(self, n): """ :type n: int :rtype: int """ return bin(n).count('1') # Using bit operation to cancel a 1 in each round # Think of a number in binary `n = XXXXXX1000, n - 1 is XXXXXX0111`. ...
"""Top-level package for COVID Traffic Controller Demonstrator.""" __author__ = """Aadam Abrahams""" __email__ = 'aadam1999@gmail.com' __version__ = '0.1.0'
"""This is another example for function""" def print_names(first_name, last_name): print("this firstname is:" + first_name) print("The second name is" + last_name) print_names('Vamsi', 'Mandapati')
class LoggingConfigEnum: """This "Enum" serves to store all paths and keywords used to configure the loggers.""" # set levels (for now, they match to the "logging" default ones) DEBUG = "debug" INFO = "info" WARNING = "warning" ERROR = "error" EXCEPTION = "exception" # paths to the co...
n, k = list(map(int, input().split())) prices = sorted([int(input()) for _ in range(n)]) count = 0 for price in reversed(prices): if k // price > 0: count += k // price k %= price print(count)
# Operadores lógicos OR a = 1 == 1 or 1 < 0 # True a = 2 != 2 or 1 == 0 or 45 > 90 # False a = 56 != 23 or 1 > 0 or 45 > 90 # True a = 23 > 2 or 1 > 0 or 45 > 90 or 45 > 78 # True a = 1 > 2 or 1 < 0 or 45 > 90 or 45 > 78 # False print("Final")
# ------------------------------ # 427. Construct Quad Tree # # Description: # We want to use quad trees to store an N x N boolean grid. Each cell in the grid can only # be true or false. The root node represents the whole grid. For each node, it will be # subdivided into four children nodes until the values in the ...
# basic function definition def hello_world(): print('hello world') print('I\'m a print statement inside the hello_world() function') # calling the function will execute it hello_world() hello_world() # function with inputs and return value def sum(a, b): return a + b print(sum(3, 7)) print(sum('hello', ...
# 235. Lowest Common Ancestor of a Binary Search Tree # 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 lowestCommonAncestor(self, root, p, q): """ :type root: T...
# -*- coding: utf-8 -*- class ResourceManager: OP_ID_DETECT = 0 OP_ID_COMMS = 1 OP_ID_TRAIN = 2 OP_ID_EVAL = 3 def __init__(self): return def operation(self, op_id): # determine whether to run an operation based on # system workload and priority # not yet impl...
class HistoryRecord(object,IDisposable): """ HistoryRecord(command: Command,version: int) """ def Dispose(self): """ Dispose(self: HistoryRecord) Actively reclaims unmanaged resources that this instance uses. """ pass def SetBool(self,id,value): """ SetBool(self: HistoryRecord,id: int,value: ...
def display1(flight_number, seating_capacity): print("Flight Number:", flight_number) print("Seating Capacity:", seating_capacity) print("code-1: positional arguments") display1("AI789", 200) # Uncomment and execute the below function call statement and observe the output # display1(300,"BA123") def display...
swaps_222 = { "B": (0, 14, 16, 3, 4, 2, 6, 1, 8, 9, 10, 11, 12, 13, 24, 15, 23, 19, 17, 20, 18, 21, 22, 5, 7), "B'": (0, 7, 5, 3, 4, 23, 6, 24, 8, 9, 10, 11, 12, 13, 1, 15, 2, 18, 20, 17, 19, 21, 22, 16, 14), "B2": (0, 24, 23, 3, 4, 16, 6, 14, 8, 9, 10, 11, 12, 13, 7, 15, 5, 20, 19, 18, 17, 21, 22, 2, 1), ...
""" Put .txt files for custom reference spectra in here ( each line should contain a wavelength, reflectance pair) and they will be loaded automatically as global variables. For example *MySpectra.txt* would become accessible as *hylite.reference.spectra.MySpectra*. """
""" ___NOMEATRIBUTO Simboliza FORTEMENTE que o atributo ou método não deve ser acessado ou modificado fora da classe Neste caso, o simbolismo é tamanho que para conseguir se acessar tal atributo ou método, é necessário usar: instancia._NOMECLASSE__nomeatributo/metodo """ class Carro: def __init__(self): ...
# # PySNMP MIB module FSM7326-POWER-ETHERNET-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/FSM7326-POWER-ETHERNET-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:02:42 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version ...
#!/usr/bin/env python # -*- coding: utf-8 -*- """Python Cursor on Target Module Tests.""" __author__ = 'Greg Albrecht W2GMD <oss@undef.net>' __copyright__ = 'Copyright 2020 Orion Labs, Inc.' __license__ = 'Apache License, Version 2.0'
""" *WATER BALLOON Once a water balloon pops, is soaks the area around it. The ground gets drier the further away you travel from the balloon. The effect of a water balloon popping can be modeled using a list. Create a function that takes a list which takes the pre-pop state and returns the state af...
""" - start with 1 map to verify - 100 epochs for training - make the POD size 80% (tile changes) of map size - randomize the steps amongst the file so it doesnt overfit - shuffle the sequences - env always gvies 2D int array - """
""" On a 2-dimensional grid, there are 4 types of squares: 1 represents the starting square. There is exactly one starting square. 2 represents the ending square. There is exactly one ending square. 0 represents empty squares we can walk over. -1 represents obstacles that we cannot walk over. Return the number of 4-...
# -*- coding: utf-8 -*- """ Created on Thu Nov 19 21:13:47 2020 """ class Fahrzeug: #1. Erstellen Sie eine Klasse Fahrzeug, die die Attribute bezeichnung, # neupreis, alter, und den Wertverlust pro Jahr wertverlust übergeben bekommt. # wertverlust soll dabei als privates Attribut gespeichert we...
name_list = ["鈴木", "佐藤", "山田"] position = ["部長", "課長", "係長"] # name_listに藤田、positionに大統領を追加してみよう! print("====要素追加===") name_list.append("藤田") position.append("大統領") # 要素番号 1に追加してみよう name_list.insert(1,"藤田") print(name_list) print(position) print("====要素削除(末尾)===") # name_listの最後の要素番号を削除しよう! name_list.pop() # positi...
ATOMICLONG_APPLY = 0x0a01 ATOMICLONG_ALTER = 0x0a02 ATOMICLONG_ALTERANDGET = 0x0a03 ATOMICLONG_GETANDALTER = 0x0a04 ATOMICLONG_ADDANDGET = 0x0a05 ATOMICLONG_COMPAREANDSET = 0x0a06 ATOMICLONG_DECREMENTANDGET = 0x0a07 ATOMICLONG_GET = 0x0a08 ATOMICLONG_GETANDADD = 0x0a09 ATOMICLONG_GETANDSET = 0x0a0a ATOMICLONG_INCREMEN...
# Copyright (c) 2021 Works Applications Co., Ltd. # # 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 law or a...
class Solution: """ 633.平方数之和 | 难度:中等 | 标签:数学 给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a^2 + b^2 = c 。 <p> 示例 1: 输入:c = 5 输出:true 解释:1 * 1 + 2 * 2 = 5 <p> 示例 2: 输入:c = 3 输出:false <p> 示例 3: 输入:c = 4 输出:true <p> 示例 4: 输入:c = 2 输出:true <p> 示例...
# -*- coding: utf-8 -*- qntCasos = int(input()) for caso in range(qntCasos): strDieta = input() strCafeDaManha = input() strAlmoco = input() EhCheater = False for indice in range(len(strCafeDaManha)): if strCafeDaManha[indice] in strDieta: strDieta = strDieta.replace(strCafeDaManha[indice]...
def skipbigrams(text): bigrams = list() for i in range(0, len(text)-2): bigrams.append((text[i], text[i+2])) return bigrams
## \file OutputFormat.py # \author Naveen Ganesh Muralidharan # \brief Provides the function for writing outputs ## \brief Writes the output values to output.txt # \param y_t Process Variable: The output value from the power plant def write_output(y_t): outputfile = open("output.txt", "w") print("y_t = ", end="...
class Solution: def lengthOfLongestSubstring(self, s: str) -> int: bInx, mLan, sMap = 0, 0, {} for i, v in enumerate(s): if v in sMap and sMap[v] >= bInx: if mLan < i - bInx: mLan = i - bInx bInx = sMap[v] + 1 elif i == len(...
# https://app.codesignal.com/arcade/code-arcade/lab-of-transformations/ngQTG9kra7GE9pnnK def newNumeralSystem(az_digit): # The system effectively is a base-26 numeric system in which the letters # from A to Z are the az_digits. # # Create a mapping from a uppercase letter to its index. system = { i ...
n = int(input('Digite um número:')) s = n + 1 a = n - 1 print('Seu sucessor é {} e seu antecessor é {}.'.format(s, a))
class REPL_STATE: NONE = 0 CONNECT = 1 CONNECTING = 2 RECEIVE_PING_REPLY = 3 SEND_HANDSHAKE = 4 RECEIVE_AUTH_REPLY = 5 RECEIVE_PORT_REPLY = 6 RECEIVE_IP_REPLY = 7 RECEIVE_CAPA_REPLY = 8 SEND_PSYNC = 9 RECEIVE_PSYNC_REPLY = 10 TRANSFER = 11 CONNECTED = 12 class REPL...
# The new config inherits a base config to highlight the necessary modification _base_ = '../retinanet/retinanet_r50_fpn_1x_coco.py' # We also need to change the num_classes in head to match the dataset's annotation model = dict( bbox_head=dict( num_classes=1)) # dataset settings dataset_type = '...
def lucas(n): if(n==0): return 2 if(n==1): return 1 return lucas(n-1)+lucas(n-2) n=9 print(lucas(n))
# -*- coding: utf-8 -*- """ Build a program to print a graph like: * *** ***** ******* Try to code as easy as you can. """ for i in range(1, 5): print(' ' * (4 - (i - 1)) + '*' * (2 * i - 1))
def isPandigital(string): check = "".join(sorted(string)) if check == "123456789": return True return False def check_pandigital_Product(num): i = 1 while i*i <= num: if num%i == 0 and isPandigital(str(num) + str(i) + str(num//i)): return True i+=1 return Fal...
class Persona: def __init__(self,id,nombre,apellido,fechan,sexo,nombre_us,contraseña,especialidad,telefono,tipo): self.id = id self.nombre = nombre self.apellido = apellido self.fechan = fechan self.sexo = sexo self.nombre_us = nombre_us self.contraseña = con...
# -*- coding: utf-8 -*- class InstanceLimitReached(Exception): pass class InstanceCreationError(Exception): pass
# Numero perfeito def perfeito(): print("Determina se um número n é perfeito\n") lista = [] while len(lista) != 5: soma = 0 if len(lista) == 5: break n = int(input("Digite o valor de n: ")) for c in range(1,n): if n % c == 0: soma += c...
# Copyright 2017 Workiva # 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 law or agreed to in writing, software #...
# generated from genmsg/cmake/pkg-genmsg.context.in messages_str = "/home/venom/ros/demo2_ws/src/ROS_Gazebo_Tutorial/pal_person_detector_opencv/msg/Detection2d.msg;/home/venom/ros/demo2_ws/src/ROS_Gazebo_Tutorial/pal_person_detector_opencv/msg/Detections2d.msg" services_str = "" pkg_name = "pal_person_detector_opencv"...
# Desenvolva um programa que leia seis números inteiros e mostre a soma apenas # daqueles que forem pares. Se o valor digitado for ímpar, desconsidere-o. s = 0 cont = 0 for c in range(1, 7): num = int(input(f'Digite o {c}° valor: ')) if c % 2 == 0: s += c cont += 1 print(f'Você informou {cont} n...
with open('./results.txt') as f: lines = f.readlines() f.close() goSnakeWins = 0 antiBlobWins = 0 for i in range(0, len(lines)): #if len(lines[i]) < 100: #print(lines[i], end = "") if "DONE" in lines[i]: #print(lines[i], end = "") if "20blobby2" in lines[i]: goSnakeWin...
# Problem 136: Single Number class Solution: # Approach 1 - Sort def singleNumber1(self, nums) -> int: if nums == []: return None nums.sort() index = 0 while index != len(nums)-1 and nums[index] == nums[index+1]: index += 2 return nums[ind...
def metade(p): return p / 2 def dobro(p): return p * 2 def aumentar(p, au): jur = au / 100 return p + (p * jur) def diminuir(p, di): jur = di / 100 return p - (p * jur)
# -*- coding: utf-8 -*- """ Created on Tue Jun 09 19:02:15 2015 @author: Shamir """ for i in range(1, num_rows): euclidean_distance = [] for j in range(1, num_columns): prev_column = j - 1 distance = euclidean(file.values[i, prev_column], file.values[i, j]) euclidean_distance...
# # @lc app=leetcode id=146 lang=python3 # # [146] LRU Cache # class ListNode: def __init__(self, key, val, next=None, prev=None): self.key = key self.val = val self.next = next self.prev = prev class LRUCache: def __init__(self, capacity: int): self.cache_history = ...
km = float(input('Quantidade de KM percorridos? ')) dia = int(input('Quantidade de dias alugados? ')) Qtdkm = km * 0.15 Qtddia = dia * 60 resfinal = Qtdkm + Qtddia print('O total a pagar é de R${:.2f}'.format(resfinal))
"""Cycle(atoms) -> cycle object for a ring. cycle.atoms -> atoms around a ring cycle.bonds -> bonds aroung a ring cycle.rotate(atom) -> rotate the ring so that atom is in front """ class CycleError(Exception): pass class Cycle: def __init__(self, atoms, bonds, aromatic=0): """(atoms)->create...
class Switches: """ Abstract class providing common interface to the set of switches """ def num_switches(self): raise NotImplementedError def switch_state(self, idx): raise NotImplementedError
# Quiz, Problem 6 def flatten(aList): ''' aList: a list Returns a copy of aList, which is a flattened version of aList ''' aNewList = [] for elt in aList: if type(elt) == list: aNewList.extend(flatten(elt)) else: aNewList.append(elt) retu...
""" This program uses the reverse method to change a list such that it is in the reverse order that it was in. Note that it does NOT put it in reverse sorted order (unless the list was ALREADY in sorted order). """ my_list = [1, 4, 2, -4, 10, 0] print(my_list) my_list.reverse() print(my_list)
# -*- coding: utf-8 -*- """ @author: Victor Kohler @since: date 18/12/2016 @version: 0.1 """ class MockOpen(object): """Simulate the builtin open function""" def __init__(self): pass def close(self): return True
def fractional_knapsack_greedy(value, weight, capacity): # index = [0, 1, 2, ..., n - 1] for n items index = list(range(len(value))) # contains ratios of values to weight ratio = [v / w for v, w in zip(value, weight)] # index is sorted according to value-to-weight ratio in decreasing order index...
class Meta(type): def __new__(msc, nome, bases, namespace): if nome == 'A': return type.__new__(msc, nome, bases, namespace) """" Garante que um metodo seja implementado em uma classe. if 'fala_oi' not in namespace: print('O metodo fala_oi deve...
# 1964 오각형, 오각형, 오각형.... n = int(input()) five = sum([(4 + 3 * i) if i != 0 else 5 for i in range(n)]) print(five % 45678)
#!/usr/bin/env python3 # --------------------------------------------------------------------------- # # The MIT License (MIT) # # # # Copyright (c) 2021 Eliud Cabrera Castillo <e.cabrera-ca...
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def detectCycle(self, head): """ :type head: ListNode :rtype: ListNode """ if head is None: retu...
class GenResult(object): """Wraps the result of a batch generator. See the comments for BatchExecutor.execute. """ # Private attributes: # mixed _value - The result. def __init__(self, value): self._value = value
class FindElements: def __init__(self, root: TreeNode): self.values = set() q = deque([root]) root.val = 0 while q: n = q.popleft() self.values.add(n.val) if n.left: n.left.val = n.val * 2 + 1 q.append(n.left) ...
class Scene: def __init__(self): super().__init__() self.Home_Team_Logo_Image = None self.Away_Team_Logo_Image = None self.Home_Team_Score = "0" self.Away_Team_Score = "0" self.MainText = None self.AdditionalText = []
##addition_str is a string with a list of numbers separated by the + sign. Write code that uses the accumulation pattern to take the sum of all of the numbers and assigns it to sum_val (an integer). (You should use the .split("+") function to split by "+" and int() to cast to an integer). addition_str = "2+5+10+20" ...
# -*- coding: utf-8 -*- # Copyright © 2017 Artyom Goncharov # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, mod...
km = int(input('Digite o Km: ')) m = km * 1000 cm = km * 100_000 print('{0}km em metros são: {1}m \n{0}km em centímetros são: {2}cm'.format(km, m, cm))
values = [int(e) for e in input("Please insert value:").split()] print(values) previousValue = values[0] for value in values : if value < previousValue : previousValue = value print("False") exit(0) print("True")
### #while문 ### ja = 4 #ja=분자 mo = 2 #mo=분모 pi = 3+(ja/(mo*(mo+1)*(mo+2))) #pi=파이값 re = 300 #re=반복횟수 while re>0: ja *= -1 mo += 2 pi = pi+(ja/(mo*(mo+1)*(mo+2))) re -= 1 print(f"pi={pi}") ### #for문 ### ja = 4 #ja=분자 mo = 2 #mo=분모 pi = 3+(ja/(mo*(mo+1)*(mo+2))) #pi=파이값 for i in range(300): ja *=...
ls=list(map(int,input('Enter the list of numbers: ').split())) for i in range(len(ls)-1,0,-1): for j in range(i): if ls[j]>ls[j+1]: ls[j],ls[j+1] = ls[j+1],ls[j] print('Sorted list:',ls)
# MEDIUM # input => [3,2,4,1] # Max index, boundary index # 2 4 # 1st [4, 2, 3, 1] # 2 [1, 3, 2, 4] # 1 3 # 1st [3, 1, 2, 4] # 2 [2, 1, 3, 4] # 0 2 # 1st [2, 1, 3, 4] # ...
class Configurations: class Settings: autoclose_squarebrackets= True autoclose_parentheses= True autoclose_curlybraces= True autoclose_doublequotes= True autoclose_singlequotes= True current_line_indicator= True current_line_indicator_symbol= ':' font_...
''' Copyright (C) 2020, Sathira Silva. Approach: Union by path compression algorithm is used. During a single find call or a union call, reattach all the nodes we're following to the root. Therefore, the height of each subtree will be as minimal as possible. Before the kruskal a...
# Digite algum nome nome = str(input('Digite o nome completo: ')) # Variáveis nomelist = nome.split() nome2 = nome.rfind(max(' ')) nome2C = nome[nome2:].lstrip() # Prints Formatadas print(f'O nome completo que você digitou: {nome}') print(f'O seu Primeiro nome: {nomelist[0]}') print(f'O seu último nome: {nome2C}')
''' lanche = ('Hamburger','Suco','Pizza','Pudim','Batata Frita') print('{:^30}'.format('# jeito 1 #')) for cont in range(0, len(lanche)): print(f'Eu vou comer {lanche[cont]} na posição {cont}') print('Vou comer para caramba!') print('{:^30}'.format('# jeito 2 #')) for pos, comida in enumerate(lanche): print(f'E...
# 407.加一 / plus-one # http://www.lintcode.com/zh-cn/problem/plus-one/ # 给定一个非负数,表示一个数字数组,在该数的基础上+1,返回一个新的数组。 # 该数字按照大小进行排列,最大的数在列表的最前面。 # 样例 # 给定 [1,2,3] 表示 123, 返回 [1,2,4]. # 给定 [9,9,9] 表示 999, 返回 [1,0,0,0]. class Solution: # @param {int[]} digits a number represented as an array of digits # @return {in...
class SensorPack(dict): ''' Fun fact, you can slice using np.s_. E.g. sensors.at(np.s_[:2]) ''' def at(self, val): return SensorPack({k: v[val] for k, v in self.items()}) def apply(self, lambda_fn): return SensorPack({k: lambda_fn(k, v) for k, v in self.items()}) ...
# Mostre a tabudada de algum número soliticatado, várias vezes, até o user digitar algum valor negativo while True: num = int(input('\nQual número você quer a tabuada? ')) if num <= 0: break for count in range(1, 11): print(f'{num} * {count} = {num*count}') print('Acabou')
# -*- coding: utf-8 -*- """ Created on Mon Apr 23 9:50:00 2019 @author: jercas """ """ leetcode-704: 二分查找 EASY '数组' '二分查找' 给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target , 写一个函数搜索 nums 中的 target,如果目标值存在返回下标,否则返回 -1。 """ class Solution(object): def BinarySearch(self, nums, target): """ :type nums: List[int] :type...
s = 1 while s: a = int(input("Input number a: ")) b = int(input("Input number b: ")) c = input("Choose an operation (+/-/*/:)") if c == "+": print(a, c, b, "=", a+b) elif c == "-": print(a, c, b, "=", a-b) elif c == "*": print(a, c, b, "=", a*b) elif c == ":": ...
def menor_a_mayor(lista): return sorted(lista) def desordenar(lista): return menor_a_mayor(lista)
""" Description Insertion sort involves finding the right place for a given element in a sorted list. So in beginning we compare the first two elements and sort them by comparing them. Then we pick the third element and find its proper position among the previous two sorted elements. This way we gradually go on addi...
class QuidMustLoginException(Exception): """ The refresh token is invalid or expired """ class QuidUnauthorizedException(Exception): """ The server responded with unauthorized 401 status code """ class QuidTooManyRetriesException(Exception): """ Request retried too many times """...
""" Application constants """ class LabelVariants: """Valid values for the `variant` field of a label_definition""" NUMERICAL = "numerical" BOOLEAN = "boolean" valid_labels = (NUMERICAL, BOOLEAN)
b11, b12, b13, b14, b15, b16, b17, b18, b19, b21, b22, b23, b24, b25, b26, b27, b28, b29, b31, b32, b33, b34, b35, b36, b37, b38, b39, b41, b42, b43, b44, b45, b46, b47, b48, b49, b51, b52, b53, b54, b55, b56, b57, b58, b59, b61, b62, b63, b64, b65, b66, b67, b68, b69, b71, b72, b73, b74, b75, b76, b77, b78, b79, b81, ...
# -*- coding: UTF-8 -*- class DataTypes: def __init__(self): self._dtypes = { 0x00: '<{0}B', # 08-bit unsigned char 0x01: '<{0}b', # 08-bit signed char 0x02: '<{0}H', # 16-bit unsigned short 0x03: '<{0}h', # 16-bit signed short 0x04: '<{0}I'...
#pirate game print('Welcome To Sharks And Pirates') print('This Game Is Licensed Under The MIT Creator License') print('If You Want The Source Code Please Vist anmoymouse89076 On Github') #gettings the name greeting = input('Hello, Possible Pirate! What Is The Password') if greeting in ('Arrr!'): print('Go ...
""" Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. Example: ...