content
stringlengths
7
1.05M
Z = [[0,0,0,0,0,0], [0,0,0,1,0,0], [0,1,0,1,0,0], [0,0,1,1,0,0], [0,0,0,0,0,0], [0,0,0,0,0,0]] def compute_neighbours(Z): rows,cols = len(Z), len(Z[0]) N = [[0,]*(cols) for i in range(rows)] for x in range(1,cols-1): for y in range(1,rows-1): N[y][x] = Z[y-1][...
#Exercício025 name = str(input('Qual seu nome completo?: ')).strip().upper() print('Seu nome tem a palavra SILVA?: {}'.format('SILVA'in name)) print('xD')
"""comics_download By IaninaK susie@example.com Downloads multiple comics from xkcd.com""" __version__ = '0.1.0'
print('\nVerificando as primeiras letras de um texto\n') cid = str(input('Que cidade você nasceu ? ')).strip() print(cid[:5].lower() == 'santo') fim = input('\nCurso de Python no YouTube, canal CURSO EM VIDEO.')
def foo(): pass def bar(*args, kwonly_arg: str = None): pass
# DATA UNIT CLASS class _Unit: def __init__(self, name, con_2_si, con_unit, si_unit): self._name = name self._con_2_si = con_2_si self._con_unit = con_unit self._si_unit = si_unit def get_name(self): return self._name def get_con_2_si(self): return self._con...
def missing_number(nums): arr = [0 for _ in range(len(nums))] for i in range(len(nums)): if nums[i] < len(nums): arr[nums[i]] = -1 for i in range(len(nums)): if arr[i] != -1: return i return len(nums)
#!/usr/bin/env python # -*- encoding: utf-8 -*- # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache...
__title__ = "mathy_envs" __version__ = "0.11.0" __summary__ = "Learning environments for solving math problems step-by-step" __uri__ = "https://mathy.ai" __author__ = "Justin DuJardin" __email__ = "justin@dujardinconsulting.com" __license__ = "All rights reserved"
class HostInitiators(object): def read_get(self, name, idx_name, unity_client): return unity_client.get_host_initiators(idx_name) class HostInitiatorsColumn(object): def get_idx(self, name, idx, unity_client): return unity_client.get_hosts()
def check_password_hash(hash,password): if hash == password: return True else: return False def get_cards_summary_model(): data = dict() data["used_on_amazon"] = 0 data['used_on_google'] = 0 data['total_used'] = 0 data['expired'] = 0 data['total'] = 0 data['in_progre...
def extractOneManArmy(item): """ """ vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title']) if not (chp or vol) or 'preview' in item['title'].lower(): return None if 'DBWG – Chapter' in item['title'] or 'Dragon-Blooded War God' in item['tags']: return buildReleaseMessageWithType(item, 'Drag...
# decorator.py def deco(func): print('ok') return func @deco def foo(): print('foo') foo() # ---------等价于----------- print("-"*10 , '等价于', '-'*10) def deco1(func): print('ok') return func def foo(): print('foo') deco1(foo) foo()
KABUM_PAGES = { "https://www.kabum.com.br/hardware/placas-mae?page_number=1&page_size=100&facet_filters=eyJwcmljZSI6eyJtaW4iOjM2NS45OCwibWF4IjoxMTE3NS4yOX19&sort=price": "placa-mae", "https://www.kabum.com.br/hardware/processadores?page_number=1&page_size=100&facet_filters=eyJwcmljZSI6eyJtaW4iOjM1MC42OSwibWF4I...
"""Misc utility functions""" def is_netcdf_asset(asset, strict): """ Determine if an asset is netcdf4-python compatible. netcdf4-python currently supports HDF5, NetCDF3, and NetCDF4. Determination is currently done through MIME if strict mode is enabled. If strict mode is not enabled, determination is...
#!/usr/bin/env python ''' you can use this command to run specific Python code: ..code-block:: python py.test example1.py ''' def f(x): return x + 1 def test_f(): assert f(0) == 1
# -*- coding: utf-8 -*- ''' Module takes a series of showimes and first filters them and then prompts the user to select times. Currently the only filter is automatically applied and filters sceances during work hours. Currently the program is not intelligent enough to optimize times or ensure that sceances do not ove...
"""Whole-slide image file reader for TensorFlow. The histomics_stream.ds.init module supports transformations at the beginning of a tensorflow.data.Dataset workflow. This module defines objects that can be supplied to the tensorflow.data.Dataset.from_tensor_slices() method. """ class Header: """A class used to...
with open("lfw-gender-0.80.txt") as lfwgender, \ open("manual-gender.txt") as manual, \ open("lfw-gender-final.txt", "w") as final: nextline = lfwgender.readline() while nextline: firstname, gender = nextline.split() if gender != "?": final.write(nextline) else...
class Person: def __init__(self, name, age): self.name = name self.age = age def __repr__(self): return f'Hello, my name is {self.name} and im {self.age}' class Student(Person): def __init__(self, name, age, grade): super().__init__(name, age) # super(Student, self...
N, M = [int(n) for n in input().split()] L, R = (1, N) for i in range(M): l, r = [int(n) for n in input().split()] L, R = (max(l, L), min(r, R)) print(max(0, R-L+1))
"""Fake Motor Speed Control for use in CI environments w/o real hardware""" class MotorSpeedControl(object): def __init__(self): self._fail_safe = False self.foundChip = True pass def Init(self): pass def SetCommsFailsafe(self, state): self._fail_safe = state ...
n = int(input()) integer_list = map(int, input().split()) integer_list = tuple(integer_list) print(hash(integer_list))
# This file is used to store password secrets which are not to be committed # to git. The key has to match one of the sources in the ocd_backend/sources # directory. If there a secret is required but not supplied in this file, the # program will fail. A secret like gegevensmagazijn will also match postfixes # like gege...
""" 257. Longest String Chain https://www.lintcode.com/problem/longest-string-chain/description?_from=contest&&fromId=93 dp[i] longest string chian ending in i dp[i] = max(dp[i], dp[j] + 1) if distance between words[j] and word[i] is 1 for j in range [0, i) max(dp[i]) dp[i] = 1 longest increasing subsequence变形 """...
VERBOSITY = 1 SAMPLE_RATE = 16000 DURATION_MS = 1000 FEATURES_COUNT = 64 DESIRED_SAMPLES = int(SAMPLE_RATE * DURATION_MS / 1000) DROPOUT_RATE = 0.5 TESING_PERCENTAGE = 15 VALIDATION_PERCENTAGE = 15 VALIDATION_FREQUENCY = 10 SAVE_PERIOD = 10 EPOCHS = 100 BATCH_SIZE = 512 DATASET_URL = 'http://download.tensorflow.org/d...
# https://www.hackerrank.com/challenges/common-child/problem def longestCommonSubsequence(s1, s2): remove_element = set(s1) - set(s2) new_s1 = "" for element in s1: if element not in remove_element: new_s1 += element s1 = new_s1 memory = [[0] * (len(s2) + 1) for _ in range((le...
# License: MIT """ https://github.com/automl/fanova """ __version__ = "2.0.20.dev"
class Defines(object): PROTOCOL_ID = b'BitTorrent protocol' RM_CLIENT_ID = b'RM' RM_CLIENT_VERSION = b'0100'
{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# lists are used to store a list of things; similar to arrays in java \n", "# note the use of square brackets and\n", "\n", "a = [3, 10, -1]" ] }, { "cell_type": "code", "...
def find_opposites(seq): check=set() res=set() for i in seq: if -i in check: res.add(abs(i)) check.add(i) return sorted(res)
num = int(input('Digite um número:')) u = num // 1 % 10 d = num // 10 % 10 c = num // 100 % 10 m = num // 1000 % 10 print('Analisando o número {}'.format(num)) print('A quantidade de unidade é {} \n a de dezena é {}'.format(u,d)) print('de centena é {} \n a de milhar é {}'.format(c,m))
class Player(object): """Klasa obsługująca poszczególnych graczy.""" def __init__(self, name, x, y): """Domyślne ustawienia klasy Args: name (string): Nazwa gracza x (int): Pozycja x gracza y (int): Pozycja y gracza """ self...
""" (Effective) core (aka one-electron) Hamiltonian """ core_wavefunction = {} # core hamiltonian core_wavefunction["h_core_a"] = { "type": "array", "description": "Alpha-spin core (one-electron) Hamiltonian in the AO basis.", "items": {"type": "number"}, "shape": {"nao", "nao"} } core_wavefunction[...
# Copyright (c) 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Generates new baselines for Blink layout tests that need rebaselining. Intended to be called periodically. Syncs to the Blink repo and runs 'webkit-p...
_base_ = './kd_resnet18_resnet50_cifar100_equal.py' # model settings model = dict( adaptive=True, adaptation = dict(out_channels=[256, 512, 1024, 2048], in_channels=[64, 128, 256, 512]), distill_losses=[ dict(type='NST', mode='feature', loss_weight=1.0), dict(type='Logits', mode='logits', lo...
""" 对文件描述的注释 """ class Foo(object): def __init__(self, a1, a2): self.a1 = a1 self.a2 = a2 # def __call__(self, *args, **kwargs): # print(11111, args, kwargs) # return 123 # def __getitem__(self, item): # print(item) # return 8 # # def __setitem__(sel...
# configs COMBINE_FACE_WEIGHT = 10 COMBINE_FEATURE_WEIGHT = 10 FEATURE_DETECT_MAX_CORNERS = 50 FEATURE_DETECT_QUALITY_LEVEL = 0.1 FEATURE_DETECT_MIN_DISTANCE = 10 FACE_DETECT_REJECT_LEVELS = 1.3 FACE_DETECT_LEVEL_WEIGHTS = 5 HAARCASCADE_PROFILEFACE = 'haarcascade_profileface.xml' HAARCASCADE_FRONTALFACE = 'haarcascade...
n, m = [int(i) for i in input().split()] a = [["*" if (i + j) % 2 != 0 else "." for j in range(m)] for i in range(n)] for row in a: print(' '.join(row))
# Copyright (c) 2011 Mitch Garnaat http://garnaat.org/ # Copyright (c) 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved # # 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 ...
############################################################################### __author__ = "ICHEC" __copyright__ = 'Copyright 2020, QNLP' __credits__ = ['{credit_list}'] __license__ = '{license}' __version__ = '{mayor}.{minor}.{rel}' __maintainer__ = '{maintainer}' __email__ = 'lee.oriordan@ichec.ie' __status__ = 'al...
#! python3 print("Task 6.1") persons = { 'first_name': 'john', 'last_name' : 'dog', 'age' : '40', 'city' : 'chicago', } print('All information about person:') print(persons['first_name']) print(persons['last_name']) print(persons['age']) print(persons['city']) print("Task 6.2") persons = { '...
def counting(): y = 1 while y<500: yield y #This is a great way to iterate through one number at a time. It will go forever if needed. y += 1 for y in counting(): print(y)
""" pycraigslist.tests.test_unit ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A suite of modules to unit test the pycraigslist module. """
def update_weights(weights, error, l_rate, vector): """Takes in a given weight, error, learning rate, and vector element Retuns updated weight """ return [weight + (elem * l_rate * error) for elem, weight in zip(vector, weights)] if __name__ == '__main__': print(update_weights((.1, .1, .2), -6, .1, (.5, .5, .5)))...
class StringCalculator: def __init__(self): self.string = '' self.list_of_numbers = [] self.delimiter = ',' def add(self, string_of_numbers): self.validate_input(string_of_numbers) self.process_delimiter() self.generate_list_of_numbers() retur...
class Airplane: def __init__(self, x=0, y=0, gravity=2, jump=50): self.x = x self.y = y self.defaultX = x self.defaultY = y self.gravity = gravity self.jump = jump self.width = 60 self.height = 35 def init(self): self.x = self.defaultX ...
#!/usr/bin/env python3 def readint(): return int(input()) def readints(): return map(int, input().split()) def readline(): return str(input()) T = readint() for case in range(T): N = readint() if N == 0: result = "INSOMNIA" else: k = 0 s = set() while len(s) <...
# Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. # Note: # The solution set must not contain duplicate triplets. # Example: # Given array nums = [-1, 0, 1, 2, -1, -4], # A solution set is: # [ # [-1...
# Each new term in the Fibonacci sequence is generated by adding the # previous two terms. By starting with 1 and 2, the first 10 terms will # be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # By considering the terms in the Fibonacci sequence whose values do not # exceed four million, find the sum of the even-valued term...
"""Module with different tools to facilitate data operations in ESTAMPES This module provides different simple tools, by submodules to facilitate common operations like conversions, transformations... The tools are gathered by submodules based on their intended use: `atom` Atom-specific tools. `comp` Related...
class Solution: def fourSumCount(self, nums1: List[int], nums2: List[int], nums3: List[int], nums4: List[int]) -> int: pass ####################################################################################################################### """ num1 => [1,2] num2 => [-2,-1] num3 => [-1,2]...
dias = int(input('Por quantos dias o carro ficou alugado? ')) km = float(input('Quantos quilometros o carro percorreu? ')) preco = (dias * 60) + (km * 0.15) print ('O valor a ser pago eh de R${:.2f}!'.format(preco))
# fisrt we get the number of people from the user people = input("enter number of guests \n") # we use the try methord to prevent the program from crashing if the user puts a string try: people = int(people) if(people > 0 and people <= 50): price = 4000 elif(people >50 and people <= 100): pr...
# coding: utf-8 class Person: number_of_people = 0 # Specific to the class GRAVITY = 9.8 # we define constants in the generic class def __init__(self, name): self.name = name Person.add_person() # Decorator @classmethod def number_of_people_(cls): return cls.nu...
seq=input() def SortList(sequence): k=0; list1=[] while k<len(sequence): num="" if sequence[k]!=" ": for j in range(k,len(sequence)): if sequence[k]!=" ": num+=sequence[k] k+=1 else: ...
n = int(input()) for i in range(n): for j in range(i): print(' ', end="") for j in range((n - i) * 2 - 1): print('*', end="") print() for i in range (n - 1): for j in range(n - i - 2): print(' ', end="") for j in range((i + 1) * 2 + 1): print('*', end="") print()
class Config: STATE_SHAPE = [84, 84, 3] SPEED = 20 # cm/step GOAL_DIRECTION_REWARD = 1 CRASH_REWARD = -10 SIM_DIR = '/home/mate/ucv-pkg-outdoor-8-lite/LinuxNoEditor/outdoor_lite/Binaries/Linux/' SIM_NAME = 'outdoor_lite' RANDOM_SPAWN_LOCATIONS = True MAP_X_MIN = -4000 MAP_X_MAX = ...
""" PASSENGERS """ numPassengers = 22784 passenger_arriving = ( (7, 5, 3, 9, 2, 1, 2, 2, 4, 0, 1, 0, 0, 7, 6, 3, 5, 4, 1, 3, 2, 3, 2, 1, 0, 0), # 0 (6, 11, 5, 8, 5, 3, 0, 2, 0, 0, 2, 0, 0, 6, 9, 8, 4, 3, 4, 2, 0, 2, 3, 0, 3, 0), # 1 (4, 8, 4, 5, 8, 5, 4, 1, 2, 3, 1, 0, 0, 7, 10, 6, 2, 9, 4, 1, 0, 4, 3, 0, 1, 0)...
class Rectangle: def __init__(self, width, height): self.width = width self.height = height def __str__(self): return "Rectangle(width=" + str(self.width) + \ ", height=" + str(self.height) + ")" def set_width(self, width): self.width = width def set_hei...
frogs = input().split(' ') while True: token = input().split(' ') length = len(frogs) - 1 command = token[0] if command == 'Join': name = token[1] frogs.append(name) elif command == 'Jump': name = token[1] index = int(token[2]) if length >= index: ...
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': '', # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '...
# -*- coding: utf-8 -*- model = { u'en ': 0, u' de': 1, u'et ': 2, u'er ': 3, u'tt ': 4, u'om ': 5, u'för': 6, u'ar ': 7, u'de ': 8, u'att': 9, u' fö': 10, u'ing': 11, u' in': 12, u' at': 13, u' i ': 14, u'det': 15, u'ch ': 16, u'an ': 17, u'gen': 18, u' an': 19, u't s': 20, u'som': 21, u'te ': 2...
print('{}\n {:^25}\n {}\n'.format('='*25, '10 TERMOS DE UMA PA', '='*25), end=' ') primeiro = int(input('Primeiro Termo: ')) razao = int(input(' Razão: ')) acumulador = 0 for c in range(0, 10): print(primeiro + acumulador, '=> ', end='') acumulador += razao print('ACABOU')
# # @lc app=leetcode id=485 lang=python3 # # [485] Max Consecutive Ones # # https://leetcode.com/problems/max-consecutive-ones/description/ # # algorithms # Easy (55.77%) # Likes: 464 # Dislikes: 342 # Total Accepted: 164K # Total Submissions: 293.3K # Testcase Example: '[1,0,1,1,0,1]' # # Given a binary array, ...
# 02. Count substring occurrences text, key = input(), input() counter = 0 for index in range(0, len(text) - len(key) + 1): if key.lower() == text[index:index + len(key)].lower(): counter += 1 print(counter)
# def func(a): # return a + 5 func = lambda a: a+5 square = lambda s: s*s sum = lambda x,y,z: x+y+z x = 10 print (func(x)) print (square(x)) print (sum(x,4,5))
# Numeric Pattern 6 """ 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 """ i = 0 nums = list(range(1, 50, 2)) for _ in range(5): j = i + 5 row = " ".join(map(str, nums[i:j])) print(row) i = j
class ServiceTypes(): MachineLearning = "ml" Vision = "vision" ChatBot = "bot" Speech = "speech" LangIntent = "intent" LangEntity = "entity"
class Solution(object): def maxSubArray(self, nums): idx, sumVal = 0, 0 ans = -float('INF') while idx < len(nums): sumVal += nums[idx] ans = max(ans, sumVal) if sumVal < 0: sumVal = 0 idx += 1 return ans
# -*- coding: utf-8 -*- """ Created on Sat Jul 20 09:42:33 2019 @author: aksha """ #printing examples #print("Hello World") # #print("The Lion King") #print ("was released in 1996") #print("by Disney.") # #print("4*8 is", 4*8) #print("2**2**2 is", 2**2**2) #print("1+2+3+4+5 is", 1+2+3+4+5) #input a...
class Document: def __init__(self, docID, docTitle, docContent, docAll): self.docID = docID self.docTitle = docTitle self.docContent = docContent self.docAll = docAll def get_docID(self): return self.docID def get_docTitle(self): return self.docTitle def get_docContent(self): return self.docConten...
class Solution: def findTilt(self, root: TreeNode) -> int: def traverse(node, res): if not node: return 0 left_sum = traverse(node.left, res) right_sum = traverse(node.right, res) res[0] += abs(left_sum-right_sum) ...
x = 9 y = 3 #integers #arithmetic operators print(x+y) #addition print(x-y) #subtraction print(x*y) #multiplication print(x/y) #division print(x%y) #modulus print(x**y) #exponentiation x = 9.1918123 print(x//y) #floor division # Assignment operators x = 9 #sets x to equal 9 x += 3 # x = x +3 print(x) x = 9 x -=...
class Terminal(object): check = u'\u2714' error = u'\u2715' broken = u'\u2718' arrow = u'\u21D2' broken_arrow = u'\u21CF' under_arrow = u'\u21AA' class tcolors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '...
expected_output = { "instance": { "master": { "areas": { "0.0.0.1": { "interfaces": { "ge-0/0/2.0": { "state": "BDR", "dr_id": "10.16.2.2", "bdr_id": "1...
""" LINK: https://leetcode.com/problems/sqrtx/ Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned. Example 1: Input: x = 4 Output: 2 Example 2: Input: x = 8 Output: 2 Exp...
full_dataset = [ {'name': 'Peach', 'items': ['green shell', 'banana', 'green shell',], 'finish': 3}, {'name': 'Peach', 'items': ['green shell', 'banana', 'green shell',], 'finish': 1}, {'name': 'Bowser', 'items': ['green shell',], 'finish': 1}, {'name': None, 'items': ['green shell',], 'finish': 2}, ...
""" Using nested loops to iterate over all the items in a matrix list """ #Defining a matrix list matrix = [ [1,2,3], [4,5,6], [7,8,9] ] #This loop will iterate over all the items inside the matrix list for row in matrix: for index in row: print(index)
nome = str(input('Qual é o seu nome? ')).strip().upper() if nome == 'GABRIEL': print('Que lindo nome você tem!') else: print('Seu nome é tão normal!') print('Bom dia, {}'.format(nome))
def Contract_scalar_1x5(\ t0_6,t1_6,t2_6,\ t0_5,t1_5,t2_5,\ t0_4,t1_4,t2_4,\ t0_3,t1_3,t2_3,\ t0_2,t1_2,t2_2,\ t0_1,t1_1,t2_1,\ t0_0,t1_0,t2_0,\ o1_5,\ o1_4,\ o1_3,\ o1_2,\ o1_1\ ): ############################## # ./input/input_Lx1Ly5.dat ################...
def read_matrix_lines(): return [int(x) for x in input().split(", ")] def create_matrix(size): result = [read_matrix_lines() for _ in range(size)] return result def get_first_diagonal(matrix, size): return [matrix[i][i]for i in range(size)] def get_second_diagonal(matrix, size): result = [] f...
""" Summary ------- The summary is a brief intro. You can put raw HTML into this field. """ summary = '<p> A seasoned Software professional with over 7 years of rich experience in Artificial Intelligence, Machine Learning and Robotics Automation. Responsible for Continous Improvement and Business Digital Trasnformation...
# Crie um programa que simule o funcionamento de um caixa eletrônico. No início, pergunte ao usuário qual será o # valor a ser sacado (número inteiro) e o programa vai informar quantas cédulas de cada valor serão entregues. # OBS: considere que o caixa possui cédulas de R$50, R$20, R$10 e R$1. print('*' * 30) print('{...
#!/usr/bin/python def param_gui(self): param_gui = [ self.K1, self.P1, self.e1, self.om1, self.ma1, self.incl1, self.Omega1, self.K2, self.P2, self.e2, self.om2, self.ma2, self.incl2, self.Omega2, self.K3, self.P3, self.e3, self.om3, self.ma3, self.incl3, self.Omega3, ...
class HaltListener: def stream_read_halted(self, chunk: int, _time: int) -> None: pass def stream_read_resumed(self, chunk: int, _time: int): pass
class Solution: def solve(self, words): bitmasks = [] for j,word in enumerate(words): bitmask = [0]*26 distincts = 0 for char in word: i = ord(char) - ord('a') if bitmask[i] == 0: distincts += 1 bitmask[i] = 1 ...
n = {1:0,2:0,3:0,4:0,'nulo':0,'branco':0} while True: op = int(input(''' ------faça seu voto------ 1 - Jose 2 - Pedro 3 - Antoinho 4 - Adelson 5 - Voto Nulo 6 - Voto em Branco : ''')) if op == 0: break elif op ==1: n[1] +=1 elif op ==2: n[2] +=1 elif op ==3: n[3] +=1 ...
# print(range(5)) # a = range(1,10,5) # for x in a: # print(x) # num =1 # rem = num%2 # if rem==0: # print('The number is even') # else: # print('The number is odd') # print("I am not inside if statement") # num = -2 # if num>0: # print("Number is positive") # if (num % 2) == 0: # prin...
# 함수로 가장 작은 값 리턴하기 count = int(input()) lst = [0]*count elements = map(int, input().split()) times = 0 for i in elements: lst[times] = i times += 1 def f(): min_num = lst[0] for i in range(count): if min_num < lst[i]: max_num = lst[i] print(min_num) f()
def entrada_notas(): notas = input().split(' ') nota1 = float(notas[0]) nota2 = float(notas[1]) nota3 = float(notas[2]) nota4 = float(notas[3]) return nota1, nota2, nota3, nota4 def media(n1, n2, n3, n4): med = (2 * n1 + 3 * n2 + 4 * n3 + n4)/10 print(f'Media: {med:.1f}') if med >=...
""" Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should return minimum element from the SpecialStack. All these operations of SpecialStack must be O(1). To implement SpecialStack, you should only use standa...
"""Lambda Expressions @see: https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions Small anonymous functions can be created with the lambda keyword. Lambda functions can be used wherever function objects are required. They are syntactically restricted to a single expression. Semantically, they are jus...
#! /usr/bin/env python ''' (This question is super complicated and artificial.) (Refer Sumita Arora: Strings Q5) ''' A = int(input("Enter the integer: ")) S = input("Enter the string: ") # extract digits D = int(''.join( e for e in S if e.isdigit() )) R = A + D print("{} + {} = {}".format(A, D, R))
#!/usr/bin/env python population = input("Please enter population value: ") print("You have entered: ", population)
class HttpServerHTMLGenerator: """ Generates the HTML for the debug_http_server. """ def __init__(self): pass @staticmethod def generate_main_table(url_records): ret_html = '<html><head><meta charset="utf-8"/></head><table border=\'1\'>{0}</table></html>' main_table = "<...
op_str = 'acc +7' def parse_operation(operation_str): op_list = operation_str.strip().split() operation = op_list[0] op_sign = op_list[1][0] steps = op_list[1][1:] return {'operation': operation, 'sign': op_sign, 'steps': int(steps), 'visited': False} #print(parse_operation(op_str)) #operations_...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ============================================================================ # ReMorse - Morse code encode/decode module for Python # Copyright (C) 2018 by Ralf Kilian # Distributed under the MIT License (https://opensource.org/licenses/MIT) # # GitHub: https://github.c...
SOC_IRAM_LOW = 0x40020000 SOC_IRAM_HIGH = 0x40070000 SOC_DRAM_LOW = 0x3ffb0000 SOC_DRAM_HIGH = 0x40000000 SOC_RTC_DRAM_LOW = 0x3ff9e000 SOC_RTC_DRAM_HIGH = 0x3ffa0000 SOC_RTC_DATA_LOW = 0x50000000 SOC_RTC_DATA_HIGH = 0x50002000
""" problem: 1018 - Banknotes url: https://www.urionlinejudge.com.br/judge/en/problems/view/1018 """ valor = int(input()) notas = [100,50,20,10,5,2,1] resto = valor print(valor) for n in notas: qtd = resto // n resto = resto % n print('{:d} nota(s) de R$ {:d},00'.format(qtd, n))