content
stringlengths
7
1.05M
# Create a file phonebook.det that stores the details in following format: # Name Phone # Jiving 8666000 # Kriti 1010101 # Obtain the details from the user. fileObj = open("phonebook.det","w") fileObj.write("Name \t") fileObj.write("Phone \t") fileObj.write("\n") while True : name = input("Ente...
class XacException(Exception): """ Generic exception """ def __init__(self, original_exc, msg=None): msg = 'An exception occurred in the Xac service' if msg is None else msg super(XacException, self).__init__( msg=msg + ': {}'.format(original_exc)) self.original_exc =...
def readBinaryDataSet(metaFilePath,binaryFilePath): dfmeta = pd.read_csv(metaFilePath) binaryFile = open(binaryFilePath,'rb') # print binaryFile.seek() FileVars={} for ind in dfmeta.index: binaryFile.seek(dfmeta.loc[ind,'startBytePosition']) typenum = None if dfmeta.loc[ind,'internalVartype'] == 'int': ...
def hello_world(event): return f"Hello, World!" def hello_bucket(event, context): return f"A new file was uploaded to the bucket"
# Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each # Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers. # Let's remember how Fibonacci numbers can be calculated. F0 = 0, F1 = 1, and all the next numbers are # Fi...
def solve(): for n in range(1, 1001): for m in range(n + 1, 1001): a, b, c = (m**2 - n**2, 2 * m * n, m**2 + n**2) if a + b + c == 1000: return a * b * c if __name__ == "__main__": print(solve())
def matrixElementsSum(matrix): sum = 0 for i in range(0,len(matrix)-1): for j in range(0,len(matrix[i])): if matrix[i][j] == 0: matrix[i+1][j] = 0 for row in matrix: for element in row: sum = sum + element return sum
"""SECCOMP policy. This policy is based on the default Docker SECCOMP policy profile. It allows several syscalls, which are most commonly used. We make one major change regarding the network-related ``socket`` syscall in that we only allow AF_INET/AF_INET6 SOCK_DGRAM/SOCK_STREAM sockets for TCP and UDP protocols. """ ...
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def opentelemetry_cpp_deps(): """Loads dependencies need to compile the opentelemetry-cpp library.""" # Google Benchmark library. # Only needed for benchmarks, not to build t...
"""" Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? """ # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def hasCycle(self, head): ...
# 28. Write a Python program to print all even numbers from a given numbers list in the same order and stop the printing if any numbers that come after 237 in the sequence. # Question: # Input: """ numbers = [ 386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978, 328, 615, 953, 345, 399, 162, 758, 219, 918, 237,...
# Douglas Vieira # @ansattz # 1 - Não delete nem modifique esta linha def abss(x): """ Retornar o valor absoluto de inteiros e de números complexos; int -> float complex -> float """ md=(x**2)**0.5 return md print(abss(complex(-3,-4))) #2 - Não delete nem modifique esta linha def qrreal(a,b,c...
class MapPiece(object): name = "" tiles = "" symbolic_links = {} spawn_ratios = tuple() spawners = tuple() connectors = {} @classmethod def write_tiles_level(cls, level, left_x, top_y): local_x = 0 local_y = 0 for line in cls.tiles: for char in line: ...
# Copyright 2010-2021, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and ...
class Solution: def __init__(self, w: List[int]): self.length = sum(w) self.n = len(w) self.w_pool = [0] for i in range(self.n): self.w_pool.append(self.w_pool[-1] + w[i]) def pickIndex(self) -> int: picked_val = random.uniform(0, self.length) i = 0 ...
def montana_getEnhancedLocation(location): """Add Montana to the location if not there already.""" return add_state(location, "Montana") def montana_cleanPrice(price): return price_quantity_us_number(price) def montana_getCurrency(price): return price_currency(price)
class WordDictionary(object): def __init__(self): """ initialize your data structure here. """ self.root = {} def addWord(self, word): """ Adds a word into the data structure. :type word: str :rtype: void """ node = self.root ...
class TrainTaskConfig(object): use_gpu = False # the epoch number to train. pass_num = 2 # the number of sequences contained in a mini-batch. batch_size = 64 # the hyper parameters for Adam optimizer. learning_rate = 0.001 beta1 = 0.9 beta2 = 0.98 eps = 1e-9 # the paramete...
INSTALLED_APPS = [ "django_event_sourcing", "django.contrib.auth", "django.contrib.contenttypes", ] DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:", } } SECRET_KEY = "This is a SECRET_KEY" EVENT_TYPES = [ "tests.event_types.DummyEventType"...
#! python2.7 ## -*- coding: utf-8 -*- ## kun for Apk View Tracing ## TreeType.py #=============================================================================== # # data structures #=============================================================================== class CRect(object): mLeft = 0 mRigh...
grades = { "English": 97, "Math": 93, "Art": 74, "Music": 86 } grades.setdefault("Art", 87) # Art key exists. No change. print("Art grade:", grades["Art"]) grades.setdefault("Gym", 97) # Gym key is new. Added and set. print("Gym grade:", grades["Gym"])
# Utility functions for viterbi-trellis. # # argmin is defined here to avoid dependence on e.g., numpy. def argmin(list_obj): """Returns the index of the min value in the list.""" min = None best_idx = None for idx, val in enumerate(list_obj): if min is None or val < min: min = val...
strategy_type = "learning" config = { "strategy_id": "svm", "name": "Support Vector Machine Classifier", "parameters": [ { "parameter_id": "C", "label": "C - Error term weight", "type": "float", "default_value": 2.6, }, { "p...
# is_learning = True # while is_learning: # print('Learning...') # ask = input('Are you still learning? ') # is_learning = ask == 'yes' # if not is_learning: # print('You finally mastered it') people = ['Alice', 'Bob', 'Charlie'] for person in people: print(person) indices = [0, 1, 2, 3, 4] for _ i...
# <<BEGIN-copyright>> # Copyright 2021, Lawrence Livermore National Security, LLC. # See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: BSD-3-Clause # <<END-copyright>> """ This module contains miscellaneous functions used by the modules that convert a GNDS reactionSuite into an ACE file. """ ...
def height(root): if root is None: return -1 left_height = height(root.left) right_height = height(root.right) return 1 + max(left_height, right_height)
class Solution: """ @param M: a matrix @return: the total number of friend circles among all the students """ def findCircleNum(self, M): # Write your code here res, queue = 0, [] visited = [False for _ in range(len(M))] for i in range(len(M)): if...
NumeroEntrada = int(input("Digite um número inteiro: ")) RestoDivisao = NumeroEntrada % 3 if RestoDivisao == 0: print("Fizz") else: print(NumeroEntrada)
# # PySNMP MIB module LIEBERT-GP-REGISTRATION-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/LIEBERT-GP-REGISTRATION-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:56:06 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python versio...
class BadRequest(Exception): pass class ParamError(BadRequest): pass class Unauthorized(Exception): pass class Forbidden(Exception): pass class NotFound(Exception): pass class IDNotFoundError(NotFound): pass class Conflict(Exception): pass class ParamConflict(Conflict): pass cla...
# Copyright (c) 2017 Mark D. Hill and David A. Wood # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: redistributions of source code must retain the above copyright # notice, this list of conditio...
a= "goat" def animal(): global a b = "pakka" a = a * 6 print(a) print(b) animal()
def selection_sort(alist): for i in range(0, len(alist) - 1): smallest = i for j in range(i + 1, len(alist)): if alist[j] < alist[smallest]: smallest = j alist[i], alist[smallest] = alist[smallest], alist[i] alist = input('Enter the list of numbers: ').split()...
# Idenpotant # Closure def outer_function(tag): pass def add(x, y): return x + y def deco(orig_func): def wrapper(*args, **kwargs): print("That is to know that I ran the deco func") return orig_func(*args, **kwargs) return wrapper add = deco(add) print(add(3, 5))
skills = [ { "id" : "0001", "name" : "Liver of Steel", "type" : "Passive", "isPermable" : False, "effects" : { "maximumInebriety" : "+5", }, }, { "id" : "0002", "name" : "Chronic Indigestion", "type" : "Combat", ...
for cat1 in range(1, 21): for cat2 in range(1, 21): hypo = (cat1 ** 2 + cat2 ** 2) ** 0.5 if hypo.is_integer(): print(cat1, cat2, hypo)
# Copyright 2021 Canonical Ltd. # See LICENSE file for licensing details. """Module testing the Legend Studio Operator."""
# # Copyright 2018-2019 IBM Corp. All Rights Reserved. # # 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...
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def hasCycle(self, head: ListNode) -> bool: h = set() while head and head not in h: h.add(head) head = head.next retu...
class Default(): """Single repository for default values.""" EXEC_DIRECTORY = '' # Unit Test defaults GOOD_CONFIG = 'null.cfg' BAD_CONFIG = 'none.cfg' TEST_DIR = './test_directory' TEST_FILE_NAME = 'test.zip' TEST_FILE_SIZE = 4 * 1024 * 1024 TEST_FILE_NULL_COUNT = 4 * 1024 * 1024 *...
class ServiceModel: @property def short_name(self): return self.__service_short_name @property def count(self): return self.__count_slot @count.setter def count(self, value): self.__count_slot = int(value) def object_factory(name, base_class, argnames): ...
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"main": "00_beproductive.ipynb", "parse_arguments": "00_beproductive.ipynb", "in_notebook": "00_beproductive.ipynb", "APP_NAME": "01_blocker.ipynb", "REDIRECT": "01...
def sumar(a, b): return a + b def restar(a, b): return a - b def multiplicador(a, b): return a * b def dividir(numerador, denominador): return float(numerador)/denominador
class MockOpenedFile(object): def __init__(self, value='value'): self.seek_values = [] self.buf_values = [] self.value = value def seek(self, offset): self.seek_values.append(offset) def read(self, buf): self.buf_values.append(buf) return self.value def...
"""Write a function that checks whether an element occurs in a list.""" def check_existence_of_element(a,b): if a in b: print ("the item in list") else: print ("the item is not in the list") item = 1 mylist = [1, 4, 5, 100, 2, 1, -1, -7] check_existence_of_element(item,mylist) #index = -1
""" Binary Search Given a sorted array arr[] of n elements, write a function to search a given element x in arr[]. A simple approach is to do linear search.The time complexity of above algorithm is O(n). Another approach to perform the same task is using Binary Search. Binary Search: Search a sorted array by repeate...
""" extended GCD algorithm return s,t,g such that a s + b t = GCD(a, b) and s and t are coprime """ def extended_gcd(a,b): old_s, s = 1, 0 old_t, t = 0, 1 old_r, r = a, b while r != 0: quotient = old_r / r old_r, r = r, old_r - quotient * r old_s, s = s, old_s - qu...
# CountFirstCharaters # -------------------------------------- # It counts how many times a character appears at the beginning of a line def CountFirstCharacters (Line, Character): n = 0 for letter in Line: if letter == Character: n = n + 1 else: return n # Remove all the Character characters from the li...
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def deleteDuplicates(self, head): """ :type head: ListNode :rtype: ListNode """ # Runtime: 32...
# -*- encoding: utf-8 -*- # # [graph.py] # # A clone of @holman's Spark program to allow graphing of simple data in the terminal. # # Copyright (C) 2017, Liam Schumm. Licensed under the MIT License, included in LICENSE.rst. # ticks = ["▁", "▂", "▃", "▄", "▅", "▆ ", "▇ ", "█"] def graph(*numbers_s): """graph: Gra...
print ("hola mundo/jhon") a=45 b=5 print("Suma:",a+b) print("Resta:",a-b) print("Division:",a/b) print("Multiplicacion:",a*b)
class Interfaces: def __init__(self, interface: dict): self.screen = interface['screen'] self.account_linking = interface['account_linking'] class MetaData: def __init__(self, meta: dict): self.locale = meta['locale'] self.timezone = meta['timezone'] self.interfaces = I...
#!/usr/bin/env python3 # https://codeforces.com/problemset/problem/4/A n = int(input()) print('YES' if (n>2 and n%2==0) else 'NO')
class Submissions: def __init__(self, client): self.client = client def list(self, groupId, assignmentId): url = self.client.api_url + '/groups/' + groupId + '/assignments/' + assignmentId + '/submissions' method = 'get' return self.client.api_handler(url=url, method=method) ...
class NQ: def __init__(self, size): self.n = size self.board = self.generateBoard() def solve(self): if self.__util(0) == False: print("Solution does not exist") self.printBoard() def __util(self, col): if col >= self.n: return ...
# %% [139. Word Break](https://leetcode.com/problems/word-break/) class Solution: def wordBreak(self, s: str, wordDict: List[str]) -> bool: @functools.lru_cache(None) def check(s): if not s: return True for word in wordDict: if s.startswith(wor...
def wrapper(f): def fun(l): decorated_numbers = [] for number in l: decorated_numbers.append("+91 " + number[-10:-5] + " " + number[-5:]) return f(decorated_numbers) return fun @wrapper def sort_phone(l): print(*sorted(l), sep='\n') if __name__ == '__main__': l =...
def reverse_text(string): return (x for x in string[::-1]) # for x in string[::-1]: # yield x # idx = len(string) - 1 # while idx >= 0: # yield string[idx] # idx -= 1 for char in reverse_text("step"): print(char, end='')
class Ticket: def __init__(self, payload, yt_api, gh_api, users_dict): self.payload = payload self.action = payload["action"] self.yt_api = yt_api self.gh_api = gh_api self.users_dict = users_dict self.pr = payload["pull_request"] self.url = self.pr["html_ur...
MULTI_SIGNAL_CSV_DATA = """ symbol,date,signal ibm,1/1/06,1 ibm,2/1/06,0 ibm,3/1/06,0 ibm,4/1/06,0 ibm,5/1/06,1 ibm,6/1/06,1 ibm,7/1/06,1 ibm,8/1/06,1 ibm,9/1/06,0 ibm,10/1/06,1 ibm,11/1/06,1 ibm,12/1/06,5 ibm,1/1/07,1 ibm,2/1/07,0 ibm,3/1/07,1 ibm,4/1/07,0 ibm,5/1/07,1 dell,1/1/06,1 dell,2/1/06,0 dell,3/1/06,0 dell,4/...
dna_seq1 = 'ACCTGATC' gc_count = 0 for nucl in dna_seq1: if nucl == 'G' or nucl == 'C': gc_count += 1 print(gc_count / len(dna_seq1))
class BaseLoadTester(object): def __init__(self, config): self.config = config def before(self): raise NotImplementedError() def on_result(self): raise NotImplementedError()
description = 'POLI monochromator devices' group = 'lowlevel' tango_base = 'tango://phys.poli.frm2:10000/poli/' s7_motor = tango_base + 's7_motor/' devices = dict( chi_m = device('nicos.devices.tango.Motor', description = 'monochromator tilt (chi axis)', tangodevice = s7_motor + 'chi_m', ...
# Advent of code 2021 : Day 1 | Part 1 # Author = Abhinav # Date = 1st of December 2021 # Source = [Advent Of Code](https://adventofcode.com/2021/day/1) # Solution : inputs = open("input.txt", "rt") inputs = list(map(int, inputs.read().splitlines())) print(sum([1 for _ in range(1, len(inputs)) if inputs[_-1] < in...
# hello.py """ This is an demo of a python script in the `py` package. """ #import api # cythonized max c api # basic examples a = 10 b = 1.5 c = "HELLO WORLD!!!" d = [1,2,3,4] e = ['a','b', 'c'] f = lambda: "hello func" g = lambda x: x+10 h = '"a"' e = '"double-quoted"' f = "'single-quoted'"
# coding=utf-8 # sum = 0 # i = 1 # while i < 100: # sum += i # i += 1 # print(sum) # while True: # n = int(input('请输入一个数字: ')) # print('你输入的数字是: %d' % n) # edge = 10 # n = int(input('请输入一个大于%d的整数: ' % edge)) # while n < 10: # print('输入错误,%d小于%d' % (n, edge)) # n = int(input('请输入一个大于%d的整数: '...
class Charge: def __init__(self, vehicle): self._vehicle = vehicle self._api_client = vehicle._api_client async def get_state(self): return await self._api_client.get( "vehicles/{}/data_request/charge_state".format(self._vehicle.id)) async def start_charging(self): ...
test = { 'name': 'q3_1_2', 'points': 1, 'suites': [ { 'cases': [ { 'code': ">>> #It looks like you didn't give anything the name;\n" ">>> # seconds_in_a_decade. Maybe there's a typo, or maybe you ;\n" '>>> # ...
# generated from catkin/cmake/template/pkg.context.pc.in CATKIN_PACKAGE_PREFIX = "" PROJECT_PKG_CONFIG_INCLUDE_DIRS = "/home/ros/lidar_ws/src/geometry/kdl_conversions/include;/opt/ros/kinetic/share/orocos_kdl/../../include;/usr/include/eigen3".split(';') if "/home/ros/lidar_ws/src/geometry/kdl_conversions/include;/opt/...
if __name__ == '__main__': n = int(input()) answer = '' for i in range(n): answer += str(i + 1) print(answer)
def reset_io(buff): buff.seek(0) buff.truncate(0) return buff def truncate_io(buff, size): # get the remainder value buff.seek(size) leftover = buff.read() # remove the remainder buff.seek(0) buff.truncate(size) return leftover # def diesattheend(pool): # import atexit # ...
# This file is part of BenchExec, a framework for reliable benchmarking: # https://github.com/sosy-lab/benchexec # # SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> # # SPDX-License-Identifier: Apache-2.0 """Main package of BenchExec. The following modules are the public entry points: - benche...
''' APDT: Ploting -------------------------- Provide useful data visualizaton tools. Check https://github.com/Zhiyuan-Wu/apdt for more information. '''
dead_emcal = [128, 129, 131, 134, 139, 140, 182, 184, 188, 189, 385, 394, 397, 398, 399, 432, 434, 436, 440, 442, 5024, 5025, 5026, 5027, 5028, 5030, 5032, 5033, 5035, 5036, 5037, 5038, 5039, 5121, 5122, 5123, 5124, 5125, 5126, 5128, 5129, 5130, 5132, 5133, 5134, 5135, 5170, 5172, 5173, 5174, 5178, 5181, 6641, 6647, 66...
#!/usr/bin/python3 #---------------------- Begin Serializer Boilerplate for GAPS ------------------------ HHEAD='''#ifndef GMA_HEADER_FILE #define GMA_HEADER_FILE #pragma pack(1) #include <stdio.h> #include <stdint.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <inttypes.h> #include <arpa/in...
#!/usr/bin/env python def add_multiply(x, y, z=1): return (x + y) * z add_multiply(1, 2) # x=1, y=2, z=1
print("Bem Vindo ao jogo de Adivinhação") print("################################") print("DICA: Obter, para si, vantagem ilícita, em prejuízo alheio, induzindo ou mantendo alguém em erro, mediante artifício, ardil, ou qualquer outro meio fraudulento:") print("################################") numero_secreto = 71 tot...
"""Errand gofers module """ class Gofers(object): """Errand gofers class """ def __init__(self, *sizes): self._norm_sizes(*sizes) def _norm_sizes(self, *sizes): def _n(s): if isinstance(s, int): return ((s,1,1)) elif isinstance(s, ...
''' Write a function called my_func that takes two arguments---a list and a substring---and returns a new list, containing only words that start with the chosen substring. Make sure that your function is not case sensitive: meaning that if you want to filter by words that start with 'a', both 'apple' and 'Apple' wo...
# Copyright (c) 2015 Microsoft Corporation """ >>> from z3 import * >>> x = Int('x') >>> s = MCSatCore() >>> s.add_tactic('solve-eqs') >>> s.freeze(x) >>> s.add(x == 1) >>> s.push() >>> s [x == 1] >>> s = MCSatCore() >>> s.add_tactic('solve-eqs') >>> s.add(x == 1) >>> s.push() >>> s [] >>> y = Int('y') >>> s = MCSatCo...
def transpose_grid(grid): grid_t = [] grid_line = [] for i in range(len(grid[0])): for row in grid: grid_line.append(row[i]) grid_t.append(grid_line) grid_line = [] return grid_t def verify_row(row, necessary_length): if len(row) < necessary_length: ret...
font = CurrentFont() for glyph in font.selection: glyph = font[name] glyph.prepareUndo() glyph.rotate(-5) glyph.skew(5) glyph.performUndo()
""" A reimplementation of some useful python utilities missing from RPython """ def zip(list1, list2): """ expects two lists of equal length """ assert len(list1) == len(list2) for i in xrange(len(list1)): yield list1[i], list2[i] raise StopIteration def all(ls): """ expects l...
load("//elm/private:test.bzl", _elm_test = "elm_test") elm_test = _elm_test def _elm_make_impl(ctx): elm_compiler = ctx.toolchains["@rules_elm//elm:toolchain"].elm output_file = ctx.actions.declare_file(ctx.attr.output) env = {} inputs = [elm_compiler, ctx.file.elm_json] + ctx.files.srcs if ctx.f...
x = [2,3,5,6,8] y = [1,6,22,33,61] x_2 = list() x_3 = list() x_4 = list() x_carpi_y = list() x_2_carpi_y = list() for i in x: x_2.append(int(pow(i,2))) x_3.append(int(pow(i,3))) x_4.append(int(pow(i,4))) print("xi : ", x, sum(x)) print("xi^2 : ", x_2, sum(x_2)) print("xi^3 : ", x_3, sum(x_3)) print("xi^...
# Escreva um programa que leia um valor em metros e o exiba convertido em centímetros e milímetros medida = float(input('Digite o valor em metros: ')) cent = int(medida * 100) mili = int(medida * 1000) print('{} metros, equivalem a {} centímetros e {} milímetros'.format(medida, cent, mili))
# coding=utf8 # Copyright 2018 JDCLOUD.COM # # 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 ...
print('=-'*50) print('-----------\033[33mLEITOR DE NÚMEROS INTEIROS:\033[m------------') print('O PROGRAMA VAI SOMAR TODOS OS NÚMEROS DIGITADOS E SÓ VAI PARAR QUANDO O USUÁRIO DIGITAR O VALOR 999.') print('=-'*50) n = 0 soma = 0 cont = -1 while n != 999: soma = soma + n cont = cont + 1 n = int(input('Digite...
############################################################################# # Copyright 2016 Mass KonFuzion # # 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/l...
class Virus(object): '''Properties and attributes of the virus used in Simulation.''' def __init__(self, name, repro_rate, mortality_rate): self.name = name self.repro_rate = repro_rate self.mortality_rate = mortality_rate def test_virus_instantiation(): #TODO: Create your own tes...
def tail(sequence, n): """Returns the last n items of a given sequence.""" if n <= 0: return [] return list(sequence[-n:])
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: Pieter Huycke email: pieter.huycke@ugent.be GitHub: phuycke """ #%% def message_check(message = str): if len(message) < 160: return message else: return message[:160] longer = message_check("In certain chat programs or ...
def getInnerBlocks(string, begin, end, sep = [","]): ret_list = [] if not isinstance(string, str): return None # read a name until depth 1. Store until depth 0, and append it along with # the contents. # at depth 0, ignore separators cname = "" depth = 0 last_name = "" cstr = "" clist = [] for char in ...
# A lista a seguir possui mais uma lista interna, a lista de preços. # A lista de preços possui 3 sublistas dentro dela com os preços dos produtos. # para exemplificar, o preço do mamão é de 10.00 - alface crespa é de 2.99 e o feijão 9.0 # Será solicitado o preço de alguns produtos. para imprimir deve ser por f-string ...
def solve(n): a = [] for _ in range(n): name, h = input().split() h = float(h) a.append((name, h)) a.sort(key = lambda t: t[1], reverse=True) m = a[0][1] for n, h in a: if h != m: break print(n, end = " ") print() while True: n = int(input()) if ...
#Curso Python #06 - Condições Aninhadas #Primeiro Exemplo #nome = str(input('Qual é seu Nome: ')) #if nome == 'Jefferson': # print('Que Nome Bonito') #else: # print('Seu nome é bem normal.') #print('Tenha um bom dia, {}'.format(nome)) #Segundo Exemplo nome = str(input('Qual é seu Nome: ')) if nome == 'Jeffers...
# IDLE (Python 3.8.0) # module_for_lists_of_terms def termal_generator(lict): length_of_termal_generator = 16 padding = length_of_termal_generator - len(lict) count = padding while count != 0: lict.append(['']) count = count - 1 termal_lict = [] for first_inner in lict[0]: ...
"""Implementation for yq rule""" _yq_attrs = { "srcs": attr.label_list( allow_files = [".yaml", ".json", ".xml"], mandatory = True, allow_empty = True, ), "expression": attr.string(mandatory = False), "args": attr.string_list(), "outs": attr.output_list(mandatory = True), } ...
# ------------------------------ # 331. Verify Preorder Serialization of a Binary Tree # # Description: # One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #. # # _9_ # ...
class HsvFilter: def __init__(self, hMin=None, sMin=None, vMin=None, hMax=None, sMax=None, vMax=None, sAdd=None, sSub=None, vAdd=None, vSub=None): self.hMin = hMin self.sMin = sMin self.vMin = vMin self.hMax = hMax self.sMax = sMax self.vMax = vM...