content
stringlengths
7
1.05M
# PCB.py # # # Author: Neha Karanjkar # Date: 18 Oct 2017 class PCB: creation_timestamp=0.0 def __init__(self, type_ID, serial_ID, creation_timestamp=0.0): #A PCB has the following attributes: self.type_ID=type_ID # type (used to infer dimensions, num of components etc) s...
x = object() y = object() x_list = [x] * 10 y_list = [y] * 10 big_list = x_list + y_list print("x_list contains %d objects" % len(x_list)) print("y_list contains %d objects" % len(y_list)) print("big_list contains %d objects" % len(big_list)) if x_list.count(x) == 10 and y_list.count(y) == 10: print(...
#-*- coding:utf-8 -*- class NoSuchClient(RuntimeError): def __init__(self, arg): self.args = (arg,)
with open("FBres") as f: raw = f.read() res = raw.split("\\' \\'") lst = [] for i, r in enumerate(res): if i == 0 or i == len(res) - 1: r = r.replace("\\'", "") if i % 2 == 0: dic = {} if r != "_separator_": resx, resy, aspect = r.split() resx, resy, a...
def banner(): print(""" _ _ _ _ | |_ __ _ | |_ ___ | |_ (_) | __|/ _` || __|/ _ \| __|| | | |_| (_| || |_| __/| |_ | | \__|\__,_| \__|\___| \__||_| """) def instructions(): pr...
"""Cached evaluation of coefficients for Lagrange basis polynomials on the unit simplex. """ lagrange_basis_coefficients_cache = [ # n = 1 [ # r = 1 { (0,): [1, -1], (1,): [0, 1], }, # r = 2 { (0,): [1, -3, 2], (1,): [0, 4...
registry = { "alpha_zero_service": { "grpc": 7003, }, }
def dropOnto(nodeName, mimeData, row): pass def mimeData(nodeNames): pass
def nearest(numbers, x): minimal = abs(numbers[0] - x) answer = numbers[0] for item in numbers: if abs(item - x) < minimal: minimal = abs(item - x) answer = item return answer def main(): size = int(input()) numbers = list(map(int, input().split())) x = int(...
def missing_number2(N, numbers): S = N * (N + 1) // 2 for n in numbers: S -= n return S N = int(input()) numbers = list(map(int, input().split())) print(missing_number2(N, numbers))
def main(): a = set("I am fine") b = set("I am ok") print_set(sorted(a)) print_set(sorted(b)) def print_set(o): print('{', end = ' ') for x in o: print(x, end = ' ') print('}') if __name__ == '__main__': main() # Members in set a but not b def main(): a = set("I am fine") b = s...
# solution to kata found here # https://www.codewars.com/kata/5412509bd436bd33920011bc/solutions/python def maskify(cc): s2 = '' for i in range(len(cc)): character = cc[-(i+1)] if (i+1) > 4: character = '#' s2 += character s2 = s2[::-1] return s2 ''' here's the s...
# -*- coding: utf-8 -*- # Copyright 2017 LasLabs Inc. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). { "name": "Bus Presence Override", "summary": "Adds user-defined im status (online, away, offline).", "version": "10.0.1.0.0", "category": "Social", "website": "https://github....
class Singleton(type): """ Metaclass for all singletons in the system (e.g. Kernel). The example code is taken from http://python-3-patterns-idioms-test.readthedocs.io/en/latest/Metaprogramming.html """ instance = None def __init__(cls, name, bases, attrs): super().__init__(name, ba...
class Emo: Tag = '<:Tag:931120394323251270>' Tags = '<:Tags:931091527936127006>' TagNotFound = '<:TagNotFound:931120394394566666>' TagNeutral = '<:TagNeutral:931120394117726248>' TagFound = '<:TagFound:931120394033823745>'
""" Financefeast Client Library exceptions """ class NotAuthorised(Exception): """ Raises an Not Authorised exception for a 403 HTTP response from the API """ class RateLimitExceeded(Exception): """ Rate Limit exceeded """ super(Exception) class MissingClientId(Exception): """ M...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def CSV_Parse_To_Dict(handle, column_delim = ","): """ Initializes the class. The Dictionary structure is built through the first line of the CSV data file. Line delimiter is not customizable and is "\n" by default. Args: handle (File): File handler. T...
class GW_Commands: @staticmethod def ping(slack_id=None, channel=None, params=None) : return 'pong',None
class AdaptivePointOrientationType(Enum, IComparable, IFormattable, IConvertible): """ An enumerated type containing possible orientation types for Adaptive Points. enum AdaptivePointOrientationType,values: ToGlobalXYZ (7),ToGlobalZthenHost (6),ToHost (2),ToHostAndLoopSystem (3),ToInstance (9),ToInstanc...
a="-5.54" k=list(range(-5,6)) print(k) d=10.5//1 f=5.45 print(round(f,0)) print(d) f=float(a) print(f) aux="" if len(a)>2: if a[0]=='-': aux='-' i=1 else: i=0 while a[i]!='.' or i==len(a): aux=aux+a[i] i=i+1 if a[i]=='.': if (i+1)!=len(a): i=...
def beautifulTriplets(d, arr): count = 0 for i in arr: if i+d in arr and i+2*d in arr: count += 1 return count arr = [1, 6, 7, 7, 8, 10, 12, 13, 14, 19] # arr = [1,1,1,2,4,4,4,5,7,7,7,8] print(beautifulTriplets(3, arr))
l1 = [1, 2, 3, 4, 5, 6, 7] ex1 = [val for val in l1] print('passando valor a valor para a variavel ex1 \n', ex1) ex2 = [v * 2 for v in l1] print('multiplicando usando compreensao de lista \n', ex2) ex3 = [(v, v2) for v in l1 for v2 in range(3)] print(ex3) l2 = ['Adriana', 'Luiz', 'Mauro'] ex4 = [v.replace('a', '@'...
def test_textline_repr_works(m_16_19_doc): assert repr(m_16_19_doc.pages[0][4]) == \ '<OMBTextLine with text "August 1, 2016 ">' def test_textline_is_blank_works(m_16_19_doc): assert m_16_19_doc.pages[0][0].is_blank() assert not m_16_19_doc.pages[0][4].is_blank() def test_page_numbers_work(m_16_...
class Person: number_of_people = 0 def __init__(self, name): self.name = name Person.add_people() def get_name(): return self.name @classmethod def get_number_of_people(cls): return cls.number_of_people @classmethod def add_people(cls): cls.number_...
# # PySNMP MIB module VPN-TC-STD-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/VPN-TC-STD-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:35:18 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2...
# The character class is used as a super class in the enemy and player class. class Character: def __init__(self, x=0, y=0, movementSpeed=0): # Arguments are optinal. self.x = x self.y = y self.movementSpeed = movementSpeed self.width = 32 self.height = 32 self.xVel...
data = input() city_dict = {} trans_dict = {} while data != 'ready': city = data.split(":")[0] transportation_list = data.split(":")[1].split(",") if city not in city_dict: city_dict.update({city: trans_dict}) trans_dict = {} for items in transportation_list: vehicle = ...
# -*- coding: utf-8 -*- """ .. module:: composite.visitors.base :synopsis: Base visitors classes, utils :platform: Linux, Unix, Windows .. moduleauthor:: Nickolas Fox <tarvitz@blacklibary.ru> .. sectionauthor:: Nickolas Fox <tarvitz@blacklibary.ru> """ class FieldVisitor(object): """ Field visitor, he...
def f(x): return x * x #def g(x): # return # Should be 2 SLOC
largura = float(input("Digite a largura da parede em metros que deseja pintar: ")) altura = float(input("Digite a altura da parede em metros que deseja pintar: ")) area = (largura * altura) tinta = (area / 2) print("A largura da parede é de {} metros, com uma altura de {} metros".format(largura,altura)+ "\ne...
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Author: Sword York # GitHub: https://github.com/SwordYork/sequencing # No rights reserved. # class Vocab(object): def __init__(self, tokens, embedding_dim, delimiter=' ', vocab_size=None, bos_token='SEQ_BEG', eos_token='SEQ_END', unk_token='UN...
""" Ex 34 - Create a program that reads a salary and shows on the screen the new salary with 15% increase. If the salary is highest that 1250 just give 10% increase """ s = float(input('Enter your salary: ')) # increase if s > 1250: s = (s / 100) * 10 + s else: s = (s/100) * 15 + s # shows the new salary print...
ODRL = { "@context": { "odrl": "http://www.w3.org/ns/odrl/2/", "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs": "http://www.w3.org/2000/01/rdf-schema#", "owl": "http://www.w3.org/2002/07/owl#", "skos": "http://www.w3.org/2004/02/skos/core#", "dct": "http:...
''' Problem Statement Given a sorted array of numbers, find if a given number ‘key’ is present in the array. Though we know that the array is sorted, we don’t know if it’s sorted in ascending or descending order. You should assume that the array can have duplicates. Write a function to return the index of the ‘key’...
# List Unpacking numbers = ["1","2","3","4"] one, two, *others = numbers print(one) print(others)
"""/** * @author [Jai Miles] * @email [jaimiles23@gmail.com] * @create date 2020-05-18 09:56:46 * @modify date 2020-06-16 23:43:24 * @desc [ Data module for survival mode. Contains data for: - Mode Name - Welcome - Scores - Z-score response lists - Survival Mode High Scores ] */ """...
""" Include a dump of snapshot data from the live system""" SNAPSHOTS_LIST = { u"snapshots": [ { u"duration_in_millis": 54877, u"end_time": u"2018-05-06T05:00:54.937Z", u"end_time_in_millis": 1525582854937, u"failures": [], u"indices": [ ...
#perulangan bersarang pada python list_angka = [1,2,3] list_huruf = ['a','b'] for angka in list_angka: for huruf in list_huruf: print(huruf) print(angka)
# Program make a simple calculator # This function adds two numbers def add(x, y): return x + y # This function subtracts two numbers def subtract(x, y): return x - y # This function multiplies two numbers def multiply(x, y): return x * y # This function divides two numbers def divide(x, ...
class SomeClass(object): """ Awesome class @ivar bar: great stuff @type bar: string """ def __init__(self): self.bar = None
# Задача №253. Високосный год # # Требуется определить, является ли данный год високосным. # (Напомним, что год является високосным, если его номер кратен 4, но не кратен 100, а также если он кратен 400.) # # Входные данные # Вводится единственное число - номер года (целое, положительное, не превышает 30000). # # Выход...
dogAge = 14 humanAge = int(input("Hundealter in Jahren eingeben (1-∞): ")) if humanAge == 2: dogAge = 22 elif humanAge > 2: dogAge = humanAge * 5 + 12 print("\nDer ist Hund ", dogAge, "Hundjahre alt!")
""" .. module:: project.settings.celery synopsis: Celery settings """ CELERY_BROKER_URL = "amqp://user:pwd@rabbitmq:5672/test" CELERY_RESULT_BACKEND = "redis://redis:6379/0" CELERY_WORKER_LOG_FORMAT = ( "[CELERY] $(processName)s %(levelname)s %(asctime)s " "%(module)s '%(name)s.%(funcName)s:%(lineno)s: %(mes...
def findAns(N): if (N <= 2): print ("NO") return value = (N * (N + 1)) // 2 if(value & 1): print ("NO") return v1 = [] v2 = [] if (not (N & 1)): turn = 1 start = 1 last = N while (start < last): if (turn): ...
delay = 'delays=pairs(-10us, [-10.1us, 0]+log_series(562ns, 10ms, steps_per_decade=4))' description = 'Laser Y = -4.235mm, X-ray 40um (H) x 40um (V), Laser 1443nm, 1.10mJ' finish_series = False finish_series_variable = u'Delay' basename = 'RNA-Hairpin-8BP-AU-Stem-End-1' power = '' temperature_wait = 1.0 temperature_id...
n = int(input()) f = [[c == '.' for c in input()] for _ in range(n)] r2 = 0 for xc in range(n): for yc in range(n): if not f[xc][yc]: continue closest = 2 * n ** 2 for x in range(-1, n + 1): for y in range(-1, n + 1): if 0 <= x < n and 0 <= y < n and f[x][y]: continue closest = min(closest, (...
class License: def __init__(self, license_id, name, short_name, cross_reference, comment, is_spdx_official): self.license_id = license_id self.name = name self.short_name = short_name self.cross_reference = cross_reference self.comment = comment self.is_spdx_official ...
def largestNumber(array): extval, ans = [], "" l = len(str(max(array))) + 1 for i in array: temp = str(i) * l extval.append((temp[:l:], i)) extval.sort(reverse = True) for i in extval: ans += str(i[1]) if int(ans)==0: return "0" return ans...
# Copyright 2012 Google Inc. 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 or agreed...
# # PySNMP MIB module OSPF-PRIVATE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OSPF-PRIVATE-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:26:28 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
def predict(list_items): """Returns the double of the items""" return [i*2 for i in list_items]
# ログインに必要なパラメータはここに記述 # 学籍番号;例)00aa000 username = '*******' # 共通パスワード password = '********'
# Copyright 2020 Nicole Borrelli # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
_base_ = './schedule_1x.py' # learning policy lr_config = dict(step=[30, 40]) total_epochs = 50
{ "targets": [ { "target_name": "audio", 'conditions': [ ['OS=="win"', { "sources": ["audio-napi.cc"], "cflags" : [ "-lole32", "-loleaut32"] }], ['OS=="linux"', { "sources": ["audio-napi_dummy.cc"] }], ['OS=="mac"', { ...
str = input('Enter a string:') i = len(str) - 1 while i > -1 : print(str[i]) i -= 1
#!/usr/bin/env python3 def load_input_file(path): with open(path) as input_file: return [int(line.strip()) for line in input_file] test_data = [199, 200, 208, 210, 200, 207, 240, 269, 260, 263] def count_increases(inputs, width=1): return sum( inputs[step] > inputs[step - width] for step i...
n = int(input('Digite um número: ')) total = 0 for c in range(1, n + 1): if n % c == 0: print('\033[34m', end=' ') total += 1 else: print('\033[m', end=' ') print('{}'.format(c), end=' ') print('\n\033[mO número {} foi divisivel {} vezes.'.format(n, total)) if total == 2: prin...
class Solution: def daysBetweenDates(self, date1: str, date2: str) -> int: if date1 > date2: date1, date2 = date2, date1 @lru_cache(None) def special(year: int) -> bool: return (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0) def split_date(date: str): ...
# 字符串类型 String a = "Hello" b = "Python" print(a[:6]) ''' String 运算符 + 字符串连接 a + b 输出结果: HelloPython * 重复输出字符串 a*2 输出结果:HelloHello [] 通过索引获取字符串中字符 a[1] 输出结果 e [ : ] 截取字符串中的一部分,遵循左闭右开原则,str[0,2] 是不包含第 3 个字符的。 a[1:4] 输出结果 ell in 成员运算符 - 如果字符串中包含给定的字符返回 True 'H' in a 输出结果 True ...
meal_list = [ {"name": "Grilled Greek Chicken Souvlaki", "description": "Grilled Greek Chicken Souvlaki with Sauteed Onions, Blistered Cherry Tomatoes, and Couscous Pilaf. Accompanied with a Tzatziki Sauce.", "proteins": 38, "carbs": 40, "fats": 11, "calories": 403, "large_picture_url": "https://static.wixstatic.co...
names = ['james', 'john', 'jack'] email_domains = ['gmail', 'yahoo', 'hotmail'] for i, j in zip(names, email_domains): print(i, j) print("------------")
class SimpleEquality(object): """ Helper class for the simple comparison of two objects of the same class. If their __dict__'s are equal, true is returned """ def __eq__(self, other): if isinstance(self, other.__class__): return self.__dict__ == other.__dict__ return No...
with open("texto.txt", "r") as arquivo: conteudo = arquivo.read() palavras = conteudo.split() print(palavras) print(len(palavras))
# Question: https://projecteuler.net/problem=61 P3n = lambda n: n*(n+1) // 2 P4n = lambda n: n*n P5n = lambda n: n*(3*n-1)//2 P6n = lambda n: n*(2*n-1) P7n = lambda n: n*(5*n-3)//2 P8n = lambda n: n*(3*n-2) has_four_digits = lambda n: n if (n >= 1000) and (n <= 9999) else 0 P3 = {has_four_digits(P3n(n)) for n in ran...
valor = float(input('Valor da casa: R$')) salario = float(input('Salário do comprador: R$')) anos = int(input('Quantos anos de financiamento? ')) prestacao = valor / (anos * 12) print(f'Para pagar uma casa de R${valor:.2f} em {anos} a prestação será de R${prestacao:.2f}') if prestacao > salario * 30 / 100: print('E...
__all__ = ["BaseProcess", "BaseSignalState", "BaseSimulation", "BaseEngine"] class BaseProcess: __slots__ = () def __init__(self): self.reset() def reset(self): self.runnable = False self.passive = True def run(self): raise NotImplementedError class BaseSignalStat...
class ColorRGB: def __init__(self, red, green, blue): self.red = red self.green = green self.blue = blue
class TaskError(Exception): def __init__(self, msg): self.msg = msg def print_msg(self): return ("Exception raised: ", self.msg)
# # PySNMP MIB module QOSSLA-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/QOSSLA-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:35:43 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:...
Nomod = 0 NoFail = 1 Easy = 2 NoVideo = 4 Hidden = 8 HardRock = 16 SuddenDeath = 32 DoubleTime = 64 Relax = 128 HalfTime = 256 Nightcore = 512 Flashlight = 1024 Autoplay = 2048 SpunOut = 4096 Relax2 = 8192 Perfect = 16384 Key4 = 32768 Key5 = 65536...
people = ["jack chen", "brus lee"] jackChen = people[0] brusLee = people[1] people = ["jack chen", "brus lee"] jackChen, brusLee = people print(jackChen, brusLee) # jack chen brus lee jackChen, brusLee = ["jack chen", "brus lee"] print(jackChen, brusLee) # jack chen brus lee numbers = [i for i in range(1, 20, 2)] prin...
#!/usr/bin/env python # encoding: utf-8 class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: ans = collections.defaultdict(list) for word in strs: count = [0] * 26 for c in word: count[ord(c) - ord('a')] += 1 ans[tuple(cou...
class Node(object): def __init__(self, value, children=None): if not children: children = [] self.value = value self.children = children def __str__(self, level=0): if not self.value: ret = ( "| Catalogs\t| Schemas\t| Table Names\t\n------...
def getCountyFDARestaurantsData(county): data = {"01001": {"FFRPTH14": 0.649878148, "FSRPTH14": 0.523512952}, "01003": {"FFRPTH14": 0.659633903, "FSRPTH14": 1.104387065}, "01005": {"FFRPTH14": 0.818239298, "FSRPTH14": 0.55789043}, "01007": {"FFRPTH14": 0.22216297899999998, "FSRPTH14": 0.22216297899999998}, "01009": {"...
"""This problem was asked by Flipkart. Starting from 0 on a number line, you would like to make a series of jumps that lead to the integer N. On the ith jump, you may move exactly i places to the left or right. Find a path with the fewest number of jumps required to get from 0 to N. """
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 2 18:13:35 2018 @author: tim https://docs.python.org/3/reference/datamodel.html https://docs.python.org/3.6/whatsnew/3.6.html#pep-487-simpler-customization-of-class-creation https://stackoverflow.com/a/51661030/7955763 """ class PluginBase: ...
""" IDE: PyCharm Project: semantic-match-classifier Author: Robin Filename: classify.py Date: 21.03.2020 TODO: load model and classify """
class Animal: def __init__(self, name, owner, noiseMade, furColour): self.name = name self.owner = owner self.noiseMade = noiseMade self.furColour = furColour def changeOwner(self, newOwnerName): self.owner = newOwnerName def changeName(self, newName): sel...
# -*- coding: utf-8 -*- class StudentCard: def __init__(self, name, id, major, faculty, course): self.name = name self.id = id self.major = major self.faculty = faculty self.course = course def print_StudentCard(self): dic = { 'ID': self.id, ...
INSTALLED_APPS = add_to_tuple(INSTALLED_APPS, 'filer', # cms plugins 'cmsplugin_filer_file', 'cmsplugin_filer_folder', 'cmsplugin_filer_image', ) ## django_filer #FILER_0_8_COMPATIBILITY_MODE = True
territories = {'GAU', 'RHA', 'SAM', 'VIN', 'ILL', 'LUS', 'ARM', 'GAL', 'DAM', 'ARA', 'CIR', 'SAH', 'PHA', 'MAR', 'SAG', 'TAR', 'MAS', 'ETU', 'ROM', 'NEA', 'APU', 'RAV', 'VEN', 'DAL', 'EPI', 'ATH', 'SPA', 'MAC', 'BYZ', 'DAC', 'CHE', 'SIP', 'BIT', 'MIL', 'ISA', 'CAP', 'ANT', 'SID', 'TYE', 'J...
class Node:#create a Node def __int__(self,data): self.data=data#given data self.next=None#given next to None class Linked_List: pass def insert_tail(Head,data): if(Head.next is None): Head.next = Node(data) else: insert_tail(Head.next, data)...
def run (autoTester): aList = [1, 2, 3, 'moon', 'stars'] autoTester.check (aList) aList.insert (3, 'sun') autoTester.check (aList) autoTester.check (aList [2:4:1]) autoTester.check (aList [:]) autoTester.check (aList [2:]) autoTester.check (len (aList)) aList.append ('milkyway') ...
input_data = input().split() def is_even(word): return len(word) % 2 == 0 def get_even_len_words(words): return [word for word in words if is_even(word)] def print_result(words): [print(word) for word in words] words = get_even_len_words(input_data) print_result(words)
nome = input("Digite o nome do aluno: ") qtd_aulas = 20 def verifica_nota(): erro = True while erro: nota = input("Digite a nota da prova: ") try: nota = float(nota) if nota < 0 or nota > 10: print("A nota deve ser maior que 0 e menor ou igual a 10") ...
counter_name = 'NIH:DI245.56671FE403.CH2.temperature' Size = wx.Size(695, 305) logfile = '//mx340hs/data/anfinrud_1710/Logfiles/DI-245-CH2-1.log' average_count = 1 max_value = nan min_value = nan end_fraction = 1 reject_outliers = False outlier_cutoff = 2.5 show_statistics = True time_window = 21600
# Title : Multilevel Inheritance # Author : Kiran Raj R. # Date : 08:11:2020 class Employee: def __init__(self, emp_id, name, basicSalary, position): self.emp_id = emp_id self.name = name self.basicSalary = basicSalary self.position = position def print_details(self): ...
"""Constants used across the skill """ MSG_PREFIX = "mycroft.api" MSG_TYPE = { "cache": f"{MSG_PREFIX}.cache", "internet": f"{MSG_PREFIX}.internet", "config": f"{MSG_PREFIX}.config", "info": f"{MSG_PREFIX}.info", "is_awake": f"{MSG_PREFIX}.is_awake", "skill_settings": f"{MSG_PREFIX}.skill_settin...
set1 = { "Madara", "Obito", "Itachi", "Sasuke" } set2 = { "Hashirama", "Naruto", "Sasuke", "Sai" } print(set1.intersection(set2))
""" Read the documentation ofthe dictionary method setdefault and use it to write a more concise version of invert_dict. """ def invert_dict_og(d): inverse = dict() for key in d: val = d[key] if val not in inverse: inverse[val] = [key] else: inverse[val].ap...
def alternatingCharacters(s): deletions = 0 for i in range(len(s)-1): if s[i] == s[i+1]: deletions += 1 return deletions print(alternatingCharacters('AABBCD'))
class DoAnnotator: # get the gene, disease_dataset in bulk, do_dataset @staticmethod def attach_annotations(id, dataset): return dataset[id]
t = int(input()) # Tempo de entrada v = int(input()) # Velocidade de entrada # Calcular o gasto em litros calculo = v * t/12 # Mostar a saída print("%0.3f" % calculo)
class Camera: name: str projection_type: str = None _width: int = None _height: int = None _width_rel_max = None _height_rel_max = None focal: float c_x: float = 0 c_y: float = 0 k1: float = 0 k2: float = 0 k3: float = 0 p_1: float = 0 p_2: float = 0 @propert...
def main(request, response): response.headers.set(b'Cache-Control', b'no-store') response.headers.set(b'Access-Control-Allow-Origin', request.headers.get(b'origin')) headers = b'x-custom-s,x-custom-test,x-custom-u,x-custom-ua,x-custom-v' if request.method == u'OPTIONS': ...
squares = [] for i in range(1,11): squares.append(i**2) squ = [i**2 for i in range(1,11)] print(squ) negative = [] for i in range(1,11): negative.append(-i) neg = [-i for i in range(1,11)] #imp print(neg) l = ['abc','tuv','xyz'] rev = [st[::-1] for st in l] print(rev) even = [i for i in range(1,11) if i%...
#!/usr/bin/python3 def print_sorted_dictionary(a_dictionary): sorted_dictionary = sorted(a_dictionary.items()) for k, v in sorted_dictionary: print('{0}: {1}'.format(k, v))
xs = input().strip() xs = "".join(f"{int(x, 16):04b}" for x in xs) print(xs, end="")
""" 1708. Largest Subarray Length K Easy An array A is larger than some array B if for the first index i where A[i] != B[i], A[i] > B[i]. For example, consider 0-indexing: [1,3,2,4] > [1,2,2,4], since at index 1, 3 > 2. [1,4,4,4] < [2,1,1,1], since at index 0, 1 < 2. A subarray is a contiguous subsequence of the arr...