content
stringlengths
7
1.05M
'''Faça um programa que leia a altura e a largura de uma parede em metros. Calcule a sua área e a quantidade de tinta necessária para pintá-la. Sabendo que cada litro de tinta pinta uma área de 2m².''' ''' altura = float(input('Digite o valor em metros para a altura da parede : ')) largura = float(input('Digite o valo...
def bisection(f, x0, x1, error=1e-15): if f(x0) * f(x1) > 0: print("No root found.") else: while True: mid = 0.5 * (x0 + x1) if abs(f(mid)) < error: return mid elif f(x0) * f(mid) > 0: x0 = mid else: ...
lista = [[],[]] for c in range(1,8): num = int(input(f'Digite o {c}º número: ')) if num % 2 == 0: lista[0].append(num) else: lista[1].append(num) print(sorted(lista[0])) print(sorted(lista[1])) #da pra fazer tbm lista[0].sort() e lista[1].sort()
field_english_to_french_dic = { "id": "id", "name": "Nom", "description": "Description", "ministry_interior": "Ministère de l'intérieur ?", "geo_localizable": "Géolocalisable ?", "application_name": "Application", "family_name": "Famille", "tag_name": "Tag", "reutilization_name": "Ré...
# Longest Substring Without Repeating Characters class Solution: def lengthOfLongestSubstring(self, s: str) -> int: window = set() # pointer of sliding window, if find the char in window, then need to move pointer to right to remove all chars until remove this char left =...
# -*- coding: utf-8 -*- countries = { 'china': 1380, 'india': 1331, 'estados unidos': 325, 'indonesia': 260, 'brasil': 207, 'pakistan': 201, 'nigeria': 191, 'blanglades': 162 } if __name__ == '__main__': while True: country = str(input('Escribe el nombre de un país del que quieras saber su población: ')...
"""Constants.""" MAX_CONCURRENCY = 30 MAX_RETRY_ATTEMPTS = 5 DEFAULT_URL = "https://api.redbrickai.com" ORG_API_HAS_CHANGED = ( "this api has changed recently, try running help(redbrick.get_org)" + " or visiting https://redbrick-sdk.readthedocs.io/en/stable/#redbrick.get_org" ) PROJECT_API_HAS_CHANGED = ( ...
{ "targets": [ { # OpenSSL has a lot of config options, with some default options # enabling known insecure algorithms. What's a good combinations # of openssl config options? # ./config no-asm no-shared no-ssl2 no-ssl3 no-hw no-zlib no-threads #...
class PGSSException(Exception): """Base exception class""" class PGSSInvalidOperation(PGSSException): """Invalid operation""" class PGSSLookupError(PGSSException): """Invalid GoGraph lookup (ex. missing node or edge)"""
# Copyright 2018 Inria Damien.Saucez@inria.fr # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUT...
class FixedWidthRecord(object): fields = () LEFT = 'ljust' RIGHT = 'rjust' encoding = 'utf-8' lineterminator = '\r\n' def __init__(self): self.data = {} def __setitem__(self, key, value): self.data[key] = value def __getitem__(self, key): return self.data[key...
month = input() nights = int(input()) total_price_apartment = 0 total_price_studio = 0 discount_studio = 0 discount_apartment = 0 if month == 'May' or month == 'October': total_price_studio = nights * 50 total_price_apartment = nights * 65 if nights > 14: discount_studio = 0.30 ...
#Pseudo-testo dell'esercizio: scrivere pretty(f, n) che, data una lambda #(f) e il numero dei suoi argomenti (n), printi la tabella di verità della #lambda (tutte le lambda sono infatti funzioni booleane, pertanto tutti gli #argomenti possono assumere come valore solo 1 e 0, cioè True e False) '''def pretty(lamb, ar...
price_history_2015="$413,268 $371,473 $336,311 $239,010 $227,809 $398,996 $403,729 $353,405 $220,980 $203,186 $459,297 $461,085 $1,078,036 $551,382 $503,344 $364,826 $399,342 $430,636 $644,972 $554,170 $275,601 $849,539 $396,181 $410,221 $381,013 $272,015 $457,796 $472,744 $229,586 $217,508 $287,573 $284,288 $266,932 $...
def main(): n = int(input()) a = list(map(int, input().split())) minValue = 10 ** 9 maxValue = - (10 ** 9) for i in range(n): if a[i] > maxValue: maxValue = a[i] if a[i] < minValue: minValue = a[i] print(maxValue - minValue) if __name__=="__mai...
""" URL: https://codeforces.com/problemset/problem/136/A Author: Safiul Kabir [safiulanik at gmail.com] """ n = int(input()) inp = list(map(int, input().split())) outp = [0] * n for i in range(n): outp[inp[i] - 1] = i + 1 print(' '.join(map(str, outp)))
# WEIGHING THE STONES for _ in range(int(input())): N = int(input()) DictR = {} DictA = {} Rupam = [int(a) for a in input().split()] Ankit = [int(a) for a in input().split()] for i in range(N): DictR[Rupam[i]] = Rupam.count(Rupam[i]) DictA[Ankit[i]] = Ankit.count(Ankit[i]) #...
def formatacao_real(numero: float) -> str: return f"R${numero:,.2f}"
class NullMailerErrorPool(Exception): pass class NullMailerErrorPipe(Exception): pass class NullMailerErrorQueue(Exception): pass class RabbitMQError(Exception): pass
class State: def __init__(self, charge, time_of_day, day_of_year, rounds_remaining, cost): self.battery = Battery(charge) self.time_of_day = time_of_day self.day_of_year = day_of_year self.rounds_remaining = rounds_remaining self.cost = cost class Battery: def __init__(s...
def encontra_impares(lista): x = [] if len(lista) > 0: n = lista.pop(0) if n % 2 != 0: x.append(n) x = x + encontra_impares(lista) return x if __name__=='__main__': print (encontra_impares([1,2,3,4,5,5]))
# Crie um script Python que leia dois números e tente mostrar a soma entre eles. numero_1 = int(input('Digite o 1° número: ')) numero_2 = int(input('Digite o 2° número: ')) soma_dos_numeros = numero_1 + numero_2 print(f'A soma é {soma_dos_numeros}.')
"""1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, re...
# Beispielprogramm für das Buch "Python Challenge" # # Copyright 2020 by Michael Inden def gcd(a, b): # rekursiver Abbruch if b == 0: return a # rekursiver Abstieg return gcd(b, a % b) def gcd_iterative(a, b): while b != 0: remainder = a % b a = b b = remainder ...
seat_ids = [] def binary_partition(start, end, identifier, lower_id, upper_id): if start == end: return start half_range = int((end - start + 1) / 2) if identifier[0] == lower_id: new_start = start new_end = end - half_range elif identifier[0] == upper_id: new_start =...
def skyhook_calculator(upper_vel,delta_vel): Cmax = 4000 Cmin = 300 epsilon = 0.0001 alpha = 0.5 sat_limit = 800 if upper_vel * delta_vel >= 0: C = (alpha * Cmax * upper_vel + (1 - alpha) * Cmax * upper_vel)/(delta_vel + epsilon) C = min(C,Cmax) u = C * del...
email = input("E-mail: ") username, domain = email.split('@') domain = domain.split('.')[0] print(f"Usuário: {username}") print(f"Domínio: {domain}")
def printmove(fr,to): print("Moved from " + str(fr)+" to "+str(to)) def TowerOfHanoi(n,fr,to,spare): if n==1: printmove(fr,to) else: TowerOfHanoi(n-1,fr,spare,to) TowerOfHanoi(1,fr,to,spare) TowerOfHanoi(n-1,spare,to,fr) TowerOfHanoi(int(input("Enter the number of rings in the source peg\n")),'A','B','C')
# Enter your code here. Read input from STDIN. Print output to STDOUT n = input() a = set(raw_input().strip().split(" ")) m = input() b = set(raw_input().strip().split(" ")) print(len(a.intersection(b)))
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def lowestCommonAncestor( self, root: "TreeNode", p: "TreeNode", q: "TreeNode" ) -> "TreeNode": level = ...
""" day6b - https://adventofcode.com/2020/day/6 * Part 2 Example: 6 Identify the questions to which everyone answered "yes"! 3520 """ def load_data(): answers = {} answer_id = 1 answers[1] = [] datafile = 'input-day6' with open(datafile, 'r') as input: for line in input: cle...
# how to copy a list months = ['jan', 'feb', 'march', 'apr', 'may'] months_copy = months[:] print(months_copy) print(months)
data = ( 'nzup', # 0x00 'nzurx', # 0x01 'nzur', # 0x02 'nzyt', # 0x03 'nzyx', # 0x04 'nzy', # 0x05 'nzyp', # 0x06 'nzyrx', # 0x07 'nzyr', # 0x08 'sit', # 0x09 'six', # 0x0a 'si', # 0x0b 'sip', # 0x0c 'siex', # 0x0d 'sie', # 0x0e 'siep', # 0x0f 'sat', # 0x10 'sax', #...
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/6/4 10:25 # @Author : Li Yingping # @Site : # @File : test_docsAutoGen.py # @Software: PyCharm class Docs(object): """ 类功能说明:Sphinx文档自动生成规范样例类 .. _NumPy Documentation HOWTO: https://numpydoc.readthedocs.io/en/latest/format.html#d...
""" @Author:lichunhui @Time: @Description: 爬虫配置文件,与scrapy 配置文件settings区分开来,对爬虫的一些个性化设置在此文件中,scrapy设置在settings文件中; """ # mysql database settings db_host = '127.0.0.1' db_port = 3306 db_user = 'root' db_pwd = '' db_name = 'test' db_charset = 'utf8mb4' db_type = 'mysql' # redis settings redis_host = '127.0.0.1' redis...
print('Digite os três lados de um triângulo') l1 = int(input()) l2 = int(input()) l3 = int(input()) x = 0 if (l1 + l2) <= l3: print('Esse não é um triângulo válido') x = 5 else: if (l1 + l3) <= l2: print('Esse não é um triângulo válido') x = 5 else: if (l2 + l3) <= l1: ...
''' import requests import copy host = "http://172.30.1.8" uri = "/changeuser.ghp" org_headers = { "User-Agent": "Mozilla/4.0", "Host": host.split("://")[1], "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "en-us", "Accept-Encoding": "gzip, deflate",...
def create_matrix(rows): matrix = [[int(x) for x in input().split()] for _ in range(rows)] return matrix def valid_cell(row, col, size): return 0 <= row < size and 0 <= col < size def print_matrix(matrix): [print(' '.join([str(x) for x in row])) for row in matrix] # did this for the sake of using c...
#Leia uma temperatura em graus Celsius e apresente-a convertida em Kelvin. # A formula da conversao eh: K=C+273.15, # sendo K a temperatura em Kelvin e c a temperatura em celsius. C=float(input("Informe a temperatura em Celsius: ")) K=C+273.15 print(f"A temperatura em Kelvin eh {round(K,1)}")
def operate(operator, *args): result = 1 for x in args: if operator == "+": return sum(args) elif operator == "*": result *= x elif operator == "/": result /= x return result print(operate("+", 1, 2, 3)) print(operate("*", 3, 4)) print(operate("/"...
class MonoBasicPackage (GitHubTarballPackage): def __init__(self): GitHubTarballPackage.__init__(self, 'mono', 'mono-basic', '4.8', 'e31cb702937a0adcc853250a0989c5f43565f9b8', configure='./configure --prefix="%{staged_profile}"') def install(self): self.s...
# We start our program by informing the user that this program is for a calculator. print("Welcome to the calculator program!") # Our program will run until the user chooses to exit, so we define a variable to # hold the text that a user must enter to exit the program. Since we intend that # this variable be constant ...
# Copyright 2020 Keren Ye, University of Pittsburgh # # 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...
################################################## ## ## Auto generate the simple WAT unit tests for ## wrap, trunc, extend, convert, demote, promote ## and reinterpret operators. ## ################################################## tyi32 = "i32"; tyi64 = "i64"; tyf32 = "f32"; tyf64 = "f64"; tests =...
# -*- coding: utf-8 -*- # !/bin/env python __all__ = ['Driver'] """ This script defines objects representing the drivers """ class Driver(object): """ Represent a Driver. 3 properties are mandatory: starting time, starting and ending nodes. For continuous solution, a traffic weight can be specified: be...
# M0_C5 - Mean, Median def mean(scores): # Write your code here return "not implemented" def median(scores): # Write your code here return "not implemented" if __name__ == '__main__': scores = input("Input list of test scores, space-separated: ") scores_list = [int(i) for i in scores.split()]...
entradas = int(input()) def cesar_cifra(frase, deslocamento): frase_codificada = "" for letra in frase: ascii_value = ord(letra)-deslocamento if ascii_value < 65: ascii_value = 91 - (65-ascii_value) frase_codificada += chr(ascii_value) return frase_codificada for i in...
all_cells = input().split("#") water = int(input()) effort = 0 fire = 0 cells_value = [] total_fire = 0 for cell in all_cells: current_cell = cell.split(" = ") type_of_fire = current_cell[0] cell_value = int(current_cell[1]) if type_of_fire == "High": if not 81 <= cell_value <= 125:...
def body_mass_index(weight, height): return round(weight/(height ** 2), 1) def shape_of(weight, height): result = body_mass_index(weight, height) if result <= 15: return 'тежко недохранване' elif 15 < result <= 16: return 'средно недохранване' elif 16 < result <= 18.5: ret...
""" Contains Template class """ class Template(object): ''' Represents a Template and all its data ''' def __init__(self): self.name = None self.keyval = [] self.context = None def __repr__(self): return "{}".format(self.keyval)
class NextcloudRequestException(Exception): def __init__(self, request=None, message=None): self.request = request message = message or f"Error {request.status_code}: {request.get_error_message()}" super().__init__(message) class NextcloudDoesNotExist(NextcloudRequest...
def generate_game_stats(sheets): games = 0 wins = [0, 0, 0] #Re, Contra, Tie for sheet in sheets: for row_int in range(1, len(sheet)): row = sheet[row_int] # print(row) if len(row) == 5: games += 1 if int(row[4]) >= 1: ...
rf_commands = { 'light/off': '2600500000012b9312131337131312131213131213121338133713131238133713131238133713131312133714371337143713121312131214371312131214111411143713371436140005610001294813000d050000000000000000', 'aircon/off': '2600d6007f3d110e112c110f112c110e112c110f112c110e112c110f112c112c110e112c110f112c112c11...
#L01EX06 topo = int(input()) carta = int(input()) if (topo % 13) == (carta % 13) or carta % 13 == 11: print("True") elif (-12 <= (topo - carta)) and ((topo - carta) <= 12): print("True") else: print("False")
testcases = int(input()) for _ in range(0, testcases): pc, pr = list(map(int, input().split())) nnm_of_9_pc = pc if pc % 9 == 0 else pc + 9 - (pc % 9) nnm_of_9_pr = pr if pr % 9 == 0 else pr + 9 - (pr % 9) digits_pc = nnm_of_9_pc // 9 digits_pr = nnm_of_9_pr // 9 who_wins = '1' if digits_pc...
FACTORY_IGNORE_FIELDS = ['id', 'created', 'modified', 'archived'] FACTORY_INTEGER_FIELDS = [ 'BigIntegerField', 'IntegerField', 'PositiveIntegerField', 'PositiveSmallIntegerField', 'SmallIntegerField', ] FACTORY_FLOAT_FIELDS = [ 'FloatField', 'MoneyField', ] FACTORY_TEXT_FIELDS = [ 'Text...
elements = { 'login_page': { 'input_email': '//*[@id="ap_email"]', 'btn_continue': '//*[@id="continue"]', 'input_password': '//*[@id="ap_password"]', 'btn_login': '//*[@id="signInSubmit"]' }, 'header_confirm': '/html/body/div[1]/header/div/div[1]/div[3]/div/a[1]/div/span', ...
""" Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front of queue. peek() -- Get the front element. empty() -- Return whether the queue is empty. Notes: You must use only standard operations of a stack...
# Código Original # altura = float(input('Digite a altura da parede em metros: ')) # largura = float(input('Digite a largura da parede em metros: ')) # metro_quadrado = altura*largura # print(f'Você precisará de {metro_quadrado/2}l de tinta') # Desafio da aula 11 altura = float(input('\033[33mDigite a altura da pared...
valor_real = float(input("\033[1;30mDigite o valor na carteira?\033[m \033[1;32mR$\033[m")) dolares = valor_real / 3.27 print("\033[1;37mO valor\033[m \033[1;32mR$: {0:.2f} reais\033[m \033[1;37mpode comprar\033[m \033[1;32mUSD$: {1:.2f} dolares\033[m \033[1;37m!\033[m".format(valor_real, dolares))
# Problem 026 - Reciprocal cycles """ Note: This task could be solved faster by looping over a list of all cyclic prime numbers. But then cycle_length would be easier to write """ def generate_decimal_iterator(denominator): numerator = 10 while numerator != 0: yield numerator // denominator n...
class Node: def __init__(self,val=None,nxt=None,prev=None): self.val = val self.nxt = nxt self.prev = prev class LL: def __init__(self): self.head = Node() self.tail = Node() self.head.nxt = self.tail self.tail.prev = self.head def find(s...
class Solution: def findUnsortedSubarray(self, nums): """ :type nums: List[int] :rtype: int """ sorted_nums = sorted(nums) start = 0 end = len(nums) - 1 while start <= end and nums[start] == sorted_nums[start]: start += 1 while e...
# Letter Combinations of a Phone Number # ttungl@gmail.com class Solution(object): def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ # sol 1 d = {'2': 'abc', '3':'def', '4':'ghi', '5':'jkl', '6': 'mno', '7':'pqrs', '8':'tuv', '...
p1 = 0.49 p2 = 0.38 p3 = 0.1 p4 = 0.03 p = p1 * p1 + p1 * p2 + p1 * p3 + p1 * p4 + p2 * p2 + p2 * p4 + p3 * p3 + p3 * p4 + p4 * p4 print(p) print(10 * 0.2 * 0.8 ** 9)
class Developer: DUNDY = 321730481903370240 ADM = 600443374587346989 TEMPLAR = 108281077319077888 GHOSTRIDER = 846009958062358548
def computeParameterValue(sources): mapping = {} for idx, source in enumerate(sources): for kv in source: k, v = kv.split(":") mapping[k] = v results = [] for key in mapping: results.append(mapping[key]) return results
#coding=utf-8 ''' Created on 2014-1-5 @author: zhangtiande '''
for _ in range(int(input())): n = int(input()) temp = list(map(int, input().split())) c = 0 for i in range(n-1): temp2 = list(map(int, input().split())) if c==0: for j in range(n-1): if temp[j]==1 and (temp[j+1]==1 or temp2[j]==1): c=1 ...
class OperatingSystemNotSupported(Exception): def __init__(self, operating_system: str) -> None: self._operating_system = operating_system message = f"operating system not supported - {operating_system}" super().__init__(message) @property def operating_system(self) -> str: ...
"""restructuredtext (rst) documentation support """ __import__("pkg_resources").declare_namespace(__name__) __version__ = "1.8.1"
money = int(input()) cake = money * 0.2 drinks = cake - 0.45 * cake animator = 1/3 * money price = money + cake + drinks + animator print (price)
class Solution: def closeStrings(self, word1: str, word2: str) -> bool: if len(word1)!=len(word2): return False show1=[0]*26 show2=[0]*26 for i in range(len(word1)): show1[ord(word1[i])-ord('a')]+=1 show2[ord(word2[i])-ord('a')]+=1 ...
""" File: largest_digit.py Name: ---------------------------------- This file recursively prints the biggest digit in 5 different integers, 12345, 281, 6, -111, -9453 If your implementation is correct, you should see 5, 8, 6, 1, 9 on Console. """ def main(): print(find_largest_digit(12345)) # 5 print(find_la...
n = int(input()) c = [] for i in range(n - 1):#h:高さ c.append([int(m) - 1 for m in input().split()]) for i in range(n - 1): c[i].append(1) def DFS(K, w,edges,N): cnt = 0 roots=[ [] for i in range(N)] for a,b,c in edges: roots[a]+=[(b,c)] roots[b]+=[(a,c)] dist=[-1]*N stack=[] stack.append(K)...
# file grafo.py class Grafo: def __init__(self, es_dirigido = False, vertices_init = []): self.vertices = {} for v in vertices_init: self.vertices[v] = {} self.es_dirigido = es_dirigido def __contains__(self, v): return v in self.vertices def __len__(self): return len(self.vertices) def __iter__(sel...
# # PySNMP MIB module NBS-SIGCOND-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NBS-SIGCOND-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:17:38 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
""" Write a program that takes two strings from the user and checks if they represent a valid user name. Valid users and passwords: apple => red lettuce => green lemon => yellow orange => orange When valid credentials are entered print: Welcome Master And when invalid credentials are entered print...
def dayOfProgrammer(year): s=0 if 1700 <= year <= 1917: if year % 4==0: for i in range(1, 9): if i % 2 == 0: s += 30 else: s += 31 print(256 - s, ".09", ".", year, sep='') else: for i in r...
#Escreva um programa em Python que leia um número inteiro qualquer e peça para o usuário # escolher qual será a base de conversão: # 1 para binário, 2 para octal e 3 para hexadecimal. num = int(input('Digite um número inteiro qualquer: ')) op = int(input('Digite a opção: 1 - Binário 2 - Octal 3 - Hexadecimal: ')) res =...
class Solution: def generateMatrix(self, n: int) -> List[List[int]]: res = [[0] * n for _ in range(n)] xi,yi,dx,dy = 0,0,1,0 for i in range(1,n*n+1): res[yi][xi]=i if not 0 <= yi+dy < n or not 0 <= xi+dx < n or res[yi+dy][xi+dx]: dy,dx = dx,-dy ...
# Merge Two Sorted Lists # # Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing # together the nodes of the first two lists. # # Example: # # Input: 1->2->4, 1->3->4 # Output: 1->1->2->3->4->4 # Definition for singly-linked list. class ListNode: def __init__(s...
#bitwise or operator a=24 b=10 print(bin(a)) print(bin(b)) print(a|b)
#CNN Config File batchsize = 3 numberOfGenres = 4 learningRate = 0.001 numberOfSteps = 10000 dropoutProbability = 0.5
''' 09 - Subsetting lists of lists You saw before that a Python list can contain practically anything; even other lists! To subset lists of lists, you can use the same technique as before: square brackets. Try out the commands in the following code sample in the IPython Shell: x = [["a", "b", "c"], ["d", "e", "f...
class DjangoeventsError(Exception): pass class AlreadyExists(DjangoeventsError): pass
# Remove a exclamation mark from the end of string. For a beginner kata, you can assume # that the input data is always a string, no need to verify it. # Examples # remove("Hi!") === "Hi" # remove("Hi!!!") === "Hi!!" # remove("!Hi") === "!Hi" # remove("!Hi!") === "!Hi" # remove("Hi! Hi!") === "Hi! Hi" # rem...
class Solution: def maxPower(self, s: str) -> int: best_answer = 1 current_answer = 1 last_char = None for char in s: if last_char == char: current_answer += 1 else: if current_answer > best_answer: best_answ...
class Reporter(): def __init__(self, checker): pass def doReport(self): pass def appendMsg(self): pass def export(self): pass
def evenNumbersGenerator(x): while True: x += 1 yield x # yield 1 # yield 2 # yield 3 # yield 4 # yield 5 # yield 6 # yield 7 gen=evenNumbersGenerator(5) print( next(gen) ) print( next(gen) ) print( next(gen) ) print( next(gen) )
class Optimizer: def __init__(self, parameters): pass def step(self, **kwargs): raise NotImplementedError
# Copyright 2018 Kai Groner # # 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 i...
spike = { 'kind': 'bulldog', 'owner': 'tom', } garfield = { 'kind': 'cat', 'owner': 'mark', } tom = { 'kind': 'cat', 'owner': 'will', } pets = [spike, garfield, tom] for pet in pets: print(pet)
# MenuTitle: Print master models # -*- coding: utf-8 -*- __doc__ = """ Prints a tab with all Kern On models for each master. """ for i, master in enumerate(Font.masters): if master.userData["KernOnIsInterpolated"]: continue negativeModels = [] zeroModels = [] positiveModels = [] for model in master.userData[...
# # PySNMP MIB module CISCO-FABRIC-MCAST-APPL-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-FABRIC-MCAST-APPL-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:40:35 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python versio...
class Stack(): def __init__(self): self.arr = [] self.length = 0 def __str__(self): return str(self.__dict__) def push(self, data): self.arr.append(data) self.length += 1 def peek(self): return self.arr[self.length - 1] def pop(self): popped_item = self.arr[self.length - 1] del self.arr[self.le...
""" Some module ----------- Just a dummy module with some class definition """ class MyClass(object): """Some class With some description""" def do_something(self): """Do something""" pass #: Any instance attribute some_attr = None #: Any other instance attribute some_...
class TrafficLightClassifier(object): def __init__(self): PATH_TO_MODEL = 'frozen_inference_graph.pb' self.detection_graph = tf.Graph() with self.detection_graph.as_default(): od_graph_def = tf.GraphDef() # Works up to here. with tf.gfile.GFile(PATH_TO_MOD...
a = 1 b = 2 d = 4 c = 3 e = 6 e = 5 f = 7 g = 8
t = int(input().strip()) for a0 in range(t): b,w = input().strip().split(' ') b,w = [int(b),int(w)] x,y,z = input().strip().split(' ') x,y,z = [int(x),int(y),int(z)] cost = b*x + w*y x_cost = b*(y+z) + w*y y_cost = b*x + w*(x+z) new_cost = min(cost, x_cost, y_cost) print (new...