content
stringlengths
7
1.05M
class ScriptBase(type): def __init__(cls, name, bases, attrs): if cls is None: return if not hasattr(cls, "plugins"): cls.plugins = [] else: cls.plugins.append(cls) class ServerBase: __metaclass__ = ScriptBase def __init__(self): su...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None # Find the max and then break the array in two parts. # Then recursively class Solution(object): def constructMaximumBinaryTree(self, nums): ...
class BuildProducts(object): '''A class to help keep track of build products in the build. Really this is just a wrapper around a dict stored at the key 'BUILD_TOOL' in an environment. This class doesn't worry about what stored in that dict, though it's generally things like SharedLib configurators...
lista = [] pares = [] ímpar = [] while True: n = int(input('Digite um valor ou ZERO para SAIR: ')) if n == 0: break lista.append(n) lista.sort() if n % 2 == 0: pares.append(n) pares.sort() else: ímpar.append(n) ímpar.sort() print(f'LISTA DIGITADA -> {list...
"""Meta Content presentation""" amendment_header = [ "Amendment of Directive 85/611/EEC", "Amendment of Directive 93/6/EEC", "Amendment of Directive 2000/12/EC" ] test_presentations = [ "Article 8 is replaced by the following:", "In Article 7, paragraphs 1 and 2 are " "replaced by the followin...
class ResourceObject: def __init__(self, resource_type, resource_name, mem_limit_threshold, mem_request_threshold, cpu_limit_threshold, cpu_request_threshold, max_hit): self.resource_type ...
M = [] size1 = int(input()) for i in range(size1): row = [] for j in range(size1): row.append(int(input())) M.append(row) M2 = [] for i in range(size1): row = [] for j in range(size1): row.append(int(input())) M2.append(row) result = [ [ 0 for i in range(size1) ] for j in r...
def currencyCodes(): """ This function returns a list of currency codes. It looks simple, but it can be improved without affecting other components. """ currency_codes = ['USD', 'EUR', 'AUD'] return currency_codes
MYSQL_HOST = 'localhost' MYSQL_DBNAME = 'spider' MYSQL_USER = 'root' MYSQL_PASSWD = '123456' MYSQL_PORT = 3306 MYSQL_CHARSET = 'utf8' MYSQL_UNICODE = True
class Concrete: x: int @require(lambda x: x > 0) def __init__(self, x: int) -> None: self.x = x @require(lambda self: self.x > 2) @require(lambda number: number > 0) def some_func(self, number: int) -> int: """Do something.""" class Reference: pass __book_url__ = "dummy...
#! /usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2019/3/9 1:30 PM # @Author : xiaoliji # @Email : yutian9527@gmail.com """ 在从左到右从上到下递增的矩阵中,判断目标数是否存在 >>> m = [[1, 2, 8, 9], [2, 4, 9, 12], [4, 7, 10, 13], [6, 8, 11, 15]] >>> search_in_matrix(7, m) True >>> search_in_matrix(5, m) Fa...
squares = [1, 4, 9, 16, 25] i = 0 while i < len(squares): print(i, squares[i]) i = i + 1 words = ['cat', 'window', 'defenestrate'] for w in words: print(w, len(w)) for i in range(len(words)): print(i, words[i], len(words[i]))
print('Sequencia de Fibonacci') n = int(input('Quantos termos você quer mostrar: ')) t1 = 0#os dois primeiros termos sempre serão esses t2 = 1 print('{} {}'.format(t1, t2), end=' ') cont = 3 while cont <= n: t3 = t1 + t2#aqui ele vai somar o primeior + segundo termo e da o terceiro termo print('{}'.form...
def ov_range(a_1,a_2,b_1,b_2): big_a=a_1 small_a=a_2 big_b=b_1 small_b=b_1 if a_1<a_2: big_a=a_2 small_a=a_1 elif a_1>a_2: big_a=a_1 small_a=a_2 if b_1>b_2: big_b=b_1 small_b=b_2 elif b_1<b_2: big_b=b_2 small_b=b_1 #print(big_a, '\n', small_a, '\n', big_b, '\n', small_b) interval_1=b...
#!/usr/bin/env python """ _Agent_t_ Agent test methods """ __all__ = []
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])""" def include_third_party_repositories(): http_archive( name = "com_github_libevent", build_file_content = all_cont...
class ContactInformation(object): def __init__(self, name, weight=100, *args, **kwargs): self.name = name self.weight = weight def __str__(self): return "Unusable Contact: {:s} ({:d})".format(self.name, self.weight) class EmailAddress(ContactInformation): def __init__(self, name, ...
# # Copyright 2019 FMR LLC <opensource@fmr.com> # # SPDX-License-Identifier: MIT # """CLI and library to concurrently execute user-defined commands across AWS accounts. ## Overview `awsrun` is both a CLI and library to execute commands over one or more AWS accounts concurrently. Commands are user-defined Python modul...
py_ignore = """ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are...
def nome_cidade_pais(cidade, pais, populacao=''): """[Junta o nome de uma cidade e o de um país de forma elegante] """ if populacao: cidade_pais = f'{cidade.title()}, {pais.title()} - população {populacao}' else: cidade_pais = f'{cidade.title()}, {pais.title()}' return cidade_pais
class train_test_setup(): def __init__(self, device, net_type, save_dir, voc, prerocess, training_epoch=100, latent_k=32, batch_size=40, hidden_size=300, clip=50, num_of_reviews = 5, intra_method='dualFC', inter_method='dualFC', learning_rate=0.00001, dropout=0, setence_max_len=50...
"""Provides HTML tags wrappers for pretty printing.""" def bold(s): return '<b>'+s+'</b>' def italic(s): return '<i>'+s+'</i>' def b(s): return bold(s) def i(s): return italic(s) def red(s): return '<font color="red">'+s+'</font>' def green(s): return '<font color="green">'+s+'</font...
class Solution(object): def threeSumClosest(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ nums.sort() triplate = [] prevSum = float("-inf") prevDiff = target - prevSum for i in range(len(nums) - 2): ...
MODELS = { "pwc": ( 'configs/pwcnet/pwcnet_ft_4x1_300k_sintel_final_384x768.py', 'checkpoints/pwcnet_ft_4x1_300k_sintel_final_384x768.pth' ), "flownetc": ( 'configs/flownet/flownetc_8x1_sfine_sintel_384x448.py', 'checkpoints/flownetc_8x1_sfine_sintel_384x448.pth' ), ...
''' Implementation of exponential search Time Complexity: O(logn) Space Complexity: Depends on implementation of binary_search {O(logn): recursive, O(1):iterative} Used for unbounded search, when the length of array is infinite or not known ''' #iterative implementation of binary search def binary_search(arr, s, e, x...
# Copyright (c) 2016, The Regents of the University of California, # through Lawrence Berkeley National Laboratory (subject to receipt # of any required approvals from the U.S. Dept. of Energy). # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the ...
""" Searching lists. """ toys = ["blocks", "slinky", "fidget spinner", "cards", "doll house", "legos", "blocks", "teddy bear"] # Finding items in a list print(toys.index("legos")) print(toys.index("blocks")) #print(toys.index("video game")) print("") # Checking if items are in a list print("legos" in toys) print("b...
class VaderStreamsConstants(object): __slots__ = [] BASE_URL = 'http://vapi.vaders.tv/' CATEGORIES_JSON_FILE_NAME = 'categories.json' CATEGORIES_PATH = 'epg/categories' CHANNELS_JSON_FILE_NAME = 'channels.json' CHANNELS_PATH = 'epg/channels' DB_FILE_NAME = 'vaderstreams.db' DEFAULT_EPG_...
class Vector: def __init__(self, inputs: list): self.inputs = inputs def dot(self, weigths): dot_product = 0 for index in range(len(self.inputs)): dot_product = dot_product + (self.inputs[index] * weigths.inputs[index]) return dot_product
dependency_matcher_patterns = { "pattern_parameter_adverbial_clause": [ {"RIGHT_ID": "action_head", "RIGHT_ATTRS": {"POS": "VERB"}}, { "LEFT_ID": "action_head", "REL_OP": ">", "RIGHT_ID": "condition_head", "RIGHT_ATTRS": {"DEP": "advcl"}, }, ...
PAGE_ITEM_LIMIT = 10 RSS_ITEM_LIMIT = 10 OUTPUT_DIRECTORY = ""
"""Provides a macro to import all TensorFlow Serving dependencies. Some of the external dependencies need to be initialized. To do this, duplicate the initialization code from TensorFlow Serving's WORKSPACE file. """ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def tf_serving_workspace(): ...
""" git igualdad e identidad excepciones operadores binarios """ # excepcionew # out of bounds exception # keyerror # excepcion para mejor validación de entrada # excepcion para continuar en un error (keyerror en mi piano) """ << (bit shift) (desplazamiento de bit a la izquierda) 011011 110110 101100 011000 >> (ri...
# %% ####################################### def match_str_len_with_padding( string1: str, string2: str, padding="#", align=("left", "center", "right")[1] ): """Returns a list containing the original longer string, and the smaller string with padding. Examples: >>> mystring = "Complex is better tha...
class Blacklist: def __init__(self): """ Initializes a set of blaclisted words """ self.bl = set() self.words = """ janvier février mars avril mai juin juillet août septembre octobre novembre notamment décembre ai accueil ad ads adsense ainsi alors amp après au aujourd auquel aurait auraient auss...
''' EASY 203. Remove Linked List Elements You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes. Given a number K, we would want to reformat the strings such that each group contains exactly K characters, exce...
""" 4101 : 크냐? URL : https://www.acmicpc.net/problem/4101 Input : 1 19 4 4 23 14 0 0 Output : No No Yes """ while True: a, b = map(int, input().split()) if (a == 0) and (b == 0): break if a > b: print('Yes') else:...
cities = [ 'Vilnius', 'Kaunas', 'Klaipeda', 'Siauliai', 'Panevezys', 'Alytus', 'Dainava (Kaunas)', 'Eiguliai', 'Marijampole', 'Mazeikiai', 'Silainiai', 'Fabijoniskes', 'Jonava', 'Utena', 'Pasilaiciai', 'Kedainiai', 'Seskine', 'Lazdynai', 'Telsi...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Codec: def serialize(self, root): """Encodes a tree to a single string. :type root: TreeNode :rtype: str """ result = []...
def add_numbers(num1, num2): return num1 + num2 def subtract_numbers(num1, num2): return num1 - num2 def multiply_numbers(num1, num2): return num1 * num2 def divide_numbers(num1, num2): return num1 / num2
REQUEST_DELETE_CONTENT_RANGE = 'deleteContentRange' REQUEST_DELETE_TABLE_ROW = 'deleteTableRow' REQUEST_INSERT_TABLE = 'insertTable' REQUEST_INSERT_TABLE_ROW = 'insertTableRow' REQUEST_INSERT_TEXT = 'insertText' REQUEST_MERGE_TABLE_CELLS = 'mergeTableCells' REQUEST_UPDATE_TEXT_STYLE = 'updateTextStyle' BODY = 'body' ...
sum = lambda a,b : a + b print("suma: "+ str(sum(1,2))) # Map lambdas names = ["Christian", "yamile", "Anddy", "Lucero", "Evelyn"] names = map(lambda name:name.upper(),names) print(list(names)) def decrement_list (*vargs): return list(map(lambda number: number - 1,vargs)) print(decrement_list(1,2,3)) #all ...
#Escreva um programa que leia dois números inteiros e compare-os, mostrando na tela uma mensagem: #O primeiro valor é maior, O segundo valor é menor , Não existe valor maior, os dois são iguais. # Fazendo a leitura de dois números n1 = float(input('Digite o primeiro valor: ')) n2 = float(input('Digite o segundo valor:...
""" This file is create and managed by Tahir Iqbal ---------------------------------------------- It can be use only for education purpose """ # List Modification mix_list = [1, 'Programmer', 5.0, True] print(mix_list) # Mutable : Because re-assign value mix_list[0] = 2 print(mix_list) # Adding item in li...
""" ED Data imports exception types """ class FieldsValidationError(Exception): """ Exception type for validation errors related to DataModel instances. """ pass class UnexpectedQueryResult(Exception): """ Exception for unexpected database results. """ pass class NoResultsError(Un...
def author_picture(): author_picture_list = [ "https://edu-test-1255999742.file.myqcloud.com/portrait/20190524/" "2ca50ff2ca024a75a893b80257458104.jpg", "https://edu-test-1255999742.file.myqcloud.com/portrait/20190524/" "f3b24a5e1d534ba49b36f4ac36ce4f09.jpg", "https://edu-tes...
s = 'pvkq{m164675262033l4m49lnp7p9mnk28k75}' flag = '' for i in range(1,27): # 凯撒密码 t = '' for c in s: if c.islower(): t += chr(ord('a') + ((ord(c) - ord('a')) + i) % 26) elif c.isupper(): t += chr(ord('A') + ((ord(c) - ord('A')) + i) % 26) else: t += ...
# python3 theory/conditionals.py def plus(a, b): if type(a) is int or type(a) is float: if type(b) is int or type(b) is float: return a + b else: return None else: return None print(plus(1, '10')) def can_drink(age): print(f"You are {age} years old.") if age < 18: print("You ca...
def os_return(distro): if distro == 'rhel': return_value = { 'distribution': 'centos', 'version': '7.5', 'dist_name': 'CentOS Linux', 'based_on': 'rhel' } elif distro == 'ubuntu': return_value = { 'distribution': 'ec2', ...
"""Return list of values that are multiplies of x.""" def count_by(x, n): """Return a sequence of numbers counting by `x` `n` times.""" return [i * x for i in range(1, n + 1)]
class NoGloveValueError(Exception): """ Raised if no value can be found in GloVe for a user's text. """ pass
class Config: @staticmethod def get(repo, config_key): splitted_keys = config_key.split('.') splitted_keys_in_byte = [key.encode() for key in splitted_keys] if splitted_keys.__len__() > 2: section = tuple(splitted_keys_in_byte[:-1]) arg = splitted_keys_in_byte[-1] else: se...
path = 'home/sample.mp4' akhil = [] akhil = path.split(".") video = akhil[0].split("/") print(video[len(video)-1])
def converteHora(hora): # Se a hora for 00: if int(hora[:2]) == 0: return f"12{hora[2:]} AM" # Se for 12 if int(hora[:2]) == 12: return f"12{hora[2:]} PM" # Se for de tarde if int(hora[:2]) > 12: return f"0{int(hora[:2]) - 12 }{hora[2:]} PM" return f"{hora} AM" print(converteHora(...
# Copyright (c) 2009 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. { 'includes': [ '../../build/common.gypi', ], 'targets': [ { 'target_name': 'libpng', 'type': '<(library)', 'dependencies...
# # PySNMP MIB module HPN-ICF-FC-PSM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-FC-PSM-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:38:51 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
print('=-'*25) print(f'{"Sequencia de fibonacci": ^50}') print('=-'*25, '\n') termos = int(input('Quantos termos voce quer mostrar: ')) controle = 0 fibonacci = 0 n1 = 0 n2 = 1 print(n1, '->', n2, end=' -> ') while controle != termos - 2: controle += 1 fibonacci = n1 + n2 n1 = n2 n2 = fibonacci p...
def count_and_say(palavra): dicionario = {} palavra = palavra.replace(' ', '') for letra in palavra: if not letra in dicionario.keys(): dicionario[letra] = 1 else: dicionario[letra] += 1 retorno = '' for letra, quantidade in dicionario.items(...
# https://www.hackerrank.com/challenges/recursive-digit-sum def super_digit(n, k): def _compute(num): num_str = str(num) total = sum(map(int, num_str)) if len(str(total)) == 1: return total else: return _compute(total) # n, k = [int(x) for x in ra...
# Copyright 2018 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
def remove_char(str,n): first_part = str[:n] last_part = str[n+1:] return first_part + last_part def unify(E1, E2): E1_Variable = E1[0].isupper() E2_Variable = E2[0].isupper() SUBSET = "" if not E1_Variable and not E2_Variable or(len(E1) == 0 and len(E2) == 0): if E1[0] == E2[0]: ...
# Create a script that has: #a function accept a list of grades (i.e. [99, 88, 77]) #and returns a grading report for that list. # Data # List of Integers # blank_list = [] # grades = [99, 75, 89, 45, 68, 94, 87, 86, 80] # Conditional logic # A >= 90 # B < 90 and B >= 80 # C < 80 and C >= 70 # D < 70 and D >= 60 ...
def titulo(txt): print('-' * 35) print(f'{txt:^35}') print('-' * 35)
def make_shirt(size='Large', message='I love Python'): print(f"The size of the shirt is {size} and the message is {message}") make_shirt() make_shirt('m') make_shirt('xs', "I'm okay")
def fib(n): '''Takes in a number n, and returns the nth fibonacci number, starting with: 1, 1, 2, 3, 5,...''' if n<=1: return n else: f = [0, 1] for i in range(2,n+1): f.append(f[i-1] + f[i-2]) return f[n]
# Created by MechAviv # Map ID :: 940011080 # Western Region of Pantheon : Heliseum Hideout # [SET_DRESS_CHANGED] [00 00 ] sm.curNodeEventEnd(True) sm.setTemporarySkillSet(0) sm.setInGameDirectionMode(True, True, False, False) sm.forcedInput(0) sm.forcedInput(2) sm.sendDelay(60) sm.forcedInput(0) sm.setSpeakerID(0) ...
class Solution: # @param root, a tree link node # @return nothing def connect(self, root): if not root or (not root.left and not root.right): return root strut = dict() level_0 = [root] lv = 0 strut[lv] = level_0 is_last_level = False ...
# -*- coding:utf8- ''' #温度转换 c=float(input(">>")) f=(9/5)*c+32 print(f) ''' ''' #圆柱体体积 from math import * r,h=eval(input(">>")) a=pow(r,2)*3.141 v=a*h print(a,'\n',v) ''' ''' #长度转换 feet=float(input(">>")) meter=feet*0.305 print(meter) ''' ''' #计算能量 m=float(input(">>")) i=float(input(">>")) f=float(input(">>")) q=m*...
class Solution: def partition(self, s: str) -> List[List[str]]: res=[] self.helper(res,s,[]) return res def helper(self,res,s,path): if not s: res.append(path) return for i in range(1,len(s)+1): if self.check(s[:i])==True: ...
#entrada nFuncionarios = int(input()) qEventos = int(input()) #processamento mesas = [] for i in range(1, nFuncionarios + 1): #inserindo funcionarios nas mesas mesas.append(i) for i in range(0, qEventos): entrada = str(input()).split() eTipo = int(entrada[0]) a = int(entrada[1]) if eTipo == 1: #up...
#58: Next Day a=input("Enter the date:") b=[1,3,5,7,8,10,12] c=[4,6,9,11] d=a.split('-') year=int(d[0]) month=int(d[1]) date=int(d[2]) if year%400==0: x=True elif year%100==0: x=False elif year%4==0: x=True else: x=False if 1<=month<=12 and 1<=date<=31: if month in b: date+...
class Solution(object): def checkSubarraySum(self, nums, k): """ :type nums: List[int] :type k: int :rtype: bool """ remainders = {0:-1} subSum = 0 for i, ni in enumerate(nums): subSum += ni if k != 0: subSum %= ...
def get_soundex(token): temp='' token=token.upper() temp+=token[0] dic={'BFPV':1,'CGJKQSXZ':2,'DT':3,'L':4,'MN':5,'R':6,'AEIOUYHW':''} for char in token[1:]: for key in dic.keys(): if char in key: code=str(dic[key]) break if...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def minDepth(self, root: TreeNode) -> int: def depth(node, x): if node == None: ...
def longest_palin_substring(str1): """ dp[size][i] = dp[size-2][i+1] if str[i] == str[j] else dp[size][i] = False where dp[size][i] = If substring of size `size` starting at index `i` is palindrome or not. Answer = max of all (j-i+1) where dp[i][j] is True. """ str_len = len(str1) is...
#!/usr/bin/env python3 # Import data with open('/home/agaspari/aoc2021/dec_8/dec8_input.txt') as f: signal_list = f.read().split('\n') unique_signals_one = {'c', 'f'} unique_signals_four = {'b', 'c', 'd', 'f'} unique_signals_seven = {'a', 'c', 'f'} unique_signals_eight = {'a', 'b', 'c', 'd', 'e', 'f', 'g'} uniqu...
x = 1 + 2 * 3 - 3 ** 5 / 2 y = 3 ** 5 - 2 z = x / y zz = x // y z -= z zz += zz xx = -x xx %= 10 if type(x) is int: print(x and y)
""" bender_mc.utils ~~~~~~~~~~~~~~~ Utility tools for bender-mc. """ # :copyright: (c) 2020 by Nicholas Repole. # :license: MIT - See LICENSE for more details. def deformat_title(formatted_title): return formatted_title.replace( "__COLON__", ":").replace( "__DOT__", ".").replace( ...
class Queue: qu = [] size = 0 front = 0 rear = 0 def __init__(self, size): self.size = size def en_queue(self, data): self.qu.append(data) self.size = self.size + 1 self.rear = self.rear + 1 def de_queue(self): temp = self.qu[self.front] del...
class parser(object): def __call__(self, line): self.rank = 0 self.in_garbage = False # if False, then we're in garbage self.ignore = False self.points = [] self.garbage_count = 0 for char in line: self._inc(char) return self.points ...
# -*- coding: utf-8 -*- """ >>> import os >>> import json >>> from samila import * >>> from pytest import warns >>> g = GenerativeImage(lambda x,y: 0, lambda x,y: 0) >>> g.generate(step=0.1) >>> result = g.save_data() >>> g_ = GenerativeImage(data=open('data.json', 'r')) >>> g_.data1 == g.data1 True >>> g_.data2 == g.d...
"""Various functions to help deal with exceptions. Released under the MIT license (https://opensource.org/licenses/MIT). """ def raises(callable, args=(), kwargs={}): """Check if `callable(*args, **kwargs)` raises an exception. Returns `True` if an exception is raised, else `False`. Arguments: - call...
""" This demonstrates the use of object properties as a way to give the illusion of private members and getters/setters per object oriented programming. Variables prefixed by underscore are a signal to other programmers that they should be changing them directly, but there really isn't any enforcement. There are still...
class Text(): '''text to write to console''' def __init__(self, text, fg='black', bg='white'): self.text = text self.fg = fg self.bg = bg class Value(): '''a value for the status bar''' def __init__(self, name, text, row=0, fg='black', bg='white'): self.name = name ...
""" * * Author: Juarez Paulino(coderemite) * Email: juarez.paulino@gmail.com * """ n=int(input()) a=*map(int,input()), a,b=sorted(a[:n]),sorted(a[n:]) d=[1,-1][a[0]>b[0]] print('NYOE S'[all(d*x<d*y for x,y in zip(a,b))::2])
# *********************************************************************************** # * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved * # * * # * Redistribution and use in source and binary forms, with or...
"""django-solo helps working with singletons: things like global settings that you want to edit from the admin site. """ __version__ = '1.0.5'
m = int(input()) n = int(input()) + 1 for i in range(m, n, ): if (i % 17 == 0) or (i % 10 == 9) or (i % 3 == 0 and i % 5 == 0): print(i)
edad=input("¿Que edad tienes?") edad=int(edad) while True: if edad < 3: print("Su boleto es gratis") break elif edad >= 3 and edad <=12: print("Su boleto tiene un valor de $10") break else: print("Su boleto tiene un valor de $15") break
def print_formatted(number): binlen = len(str(bin(number))) - 2 for i in range(1, number+1): print("{0} {1} {2} {3}".format(str(i).rjust(binlen), str(oct(i))[1:].rjust(binlen), format(i, 'x').upper().rjust(binlen), bin(i)[2:].rjust(binlen)))
""" 程式設計練習題 2.2-2.10 2.12 列印表格. 請撰寫一程式,顯示以下這個表格: ``` a b a ** b 1 2 1 2 3 8 3 4 81 4 5 1024 5 6 15625 ``` """ A_PRINT = 1 B_PRINT = 2 AB = A_PRINT ** B_PRINT print("a", "b", "a ** b") print(A_PRINT, B_PRINT, AB) A_PRINT += 1 B_PRINT += 1 AB = A_PRINT ** B_PRINT print(...
class RequestHandler: def __init__ (self, logger): self.logger = logger def log (self, message, type = "info"): self.logger.log ("%s - %s" % (self.request.uri, message), type) def log_info (self, message, type='info'): self.log (message, type) def trace (self): self.logger.trace (self.request.uri) ...
# # PySNMP MIB module HH3C-LOCAL-AAA-SERVER-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-LOCAL-AAA-SERVER-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:15:00 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3....
__version__ = '1.0.1' default_app_config = ( 'django_selectel_storage.apps.' 'DjangoSelectelStorageAppConfig' )
soma = 0 for c in range(0, 6): x = int(input('Digite 6 números número')) if x % 2 != 0: soma = x + soma print(x) print(soma)
# perguntado os números e os coloocando nas listas numeros = [] repetidos = [] c = 0 while c < 5: while True: n1 = int(input(f'Digíte o {c + 1}° número- ')) if n1 in numeros: print('Numero duplicado, não sera inserido') repetidos.append(n1) break if n1 n...
class Solution(object): def findWords(self, words): """ :type words: List[str] :rtype: List[str] """ result = [] keyb = {'a': '2', 'b': '3', 'c': '3', 'd': '2', 'e': '1', 'f': '2', 'g': '2', 'h': '2', 'i': '1', 'j': '2', 'k': '2', 'l': '2', 'm': '3', 'n': '3', 'o': '1...
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) 2016 JiNong Inc. # """ Reference * http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python """ def enum(*sequential, **named): """ a function to generate enum type """ enums = dict(zip(sequential, ran...
XMajor = [[15, 13.333333333333334, 26.666666666666668, 46.666666666666664, 13.333333333333334, 0.0, 0.0, 0.0],[13, 15.384615384615385, 38.46153846153846, 7.6923076923076925, 15.384615384615385, 15.384615384615385, 0.0, 7.6923076923076925],[4, 25.0, 0.0, 25.0, 50.0, 0.0, 0.0, 0.0],[10, 20.0, 30.0, 0.0, 0.0, 0.0, 20.0, 3...
# Define Functions # Function that handles all litre conversions def litreconv(): print("you have selected Litres") conversion = int(input("input Litres to convert: ")) print(str(conversion) + " Litres") converted = 0.21997 * conversion print(str(round(converted, 4)) + " UK Gallons") converted...