content
stringlengths
7
1.05M
# Copyright © 2020 Hoani Bryson # License: MIT (https://mit-license.org/) # # Protocol Keys # # Global definitions of keys used in configurations # TYPE = "type" ADDR = "addr" DATA = "data"
# Bug from 3.4 threading. Bug is handling while/else def acquire(self): with self._cond: while self: rc = False else: rc = True return rc
a = input("Enter a list elements separated by space ") list = a.split() even=0; odd=0; for x in list: if x % 2 == 0: even_count += 1 else: odd_count += 1 print("number of even numbers = ", even) print("number of odd numbers = ",odd)
class Solution: def robotSim(self, commands: List[int], obstacles: List[List[int]]) -> int: obs = set(map(tuple, obstacles)) dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] maxDist = di = x = y = 0 for command in commands: if command == -2: di = (di - 1) % 4...
# Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Presubmit script for ui. See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for more details about the presubmit API built into ...
S = list(map(str, input())) S_set = set(S) if len(S) == len(S_set): print("yes") else: print("no")
class DnaAssemblyMethod(object): """General class for assembly methods. All assembly methods can store the following attributes: Parameters ---------- duration Duration required for the assembly (e.g. an estimated upper bound). The time unit is left at the choice of the user. cut...
SECTION_POSITION_MAX_DIF = 100 """# Segment class for generic segments Members: - text - offset - cleaned_text - length (optional, default to 0) """ class Segment(): def __init__(self, text, offset, length = 0): self.text = text self.offset = offset self.length = length if length == 0: ...
def frame(phrase='', ch='*') -> str: if not phrase: return f'{ch * 4}\n{ch + " " + ch}\n{ch + " " + ch}\n{ch * 4}' else: first_line = f"{ch}{ch * (len(phrase)+2)}{ch}" second_line = f"{ch}{' ' * (len(phrase)+2)}{ch}" third_line = f"{ch} {phrase} {ch}" return f'{first_l...
class Lead: def __init__(self, activity, user): self.activity = activity self.user = user
class SimpleInterpreter(object): def __init__(self): self.stack = [] self.environment = {} # instruction_map = {1: self.LOAD_VALUE, # 2: self.ADD_TWO_VALUES, # 3: self.POP_FROM_STACK } def LOAD_VALUE(self, number): s...
Result =[] scorelist = [] if __name__ == '__main__': for _ in range(int(input())): name = input() score = float(input()) Result+=[[name,score]] scorelist+=[score] b=sorted(list(set(scorelist)))[1] for a,c in sorted(Result): if c==b: print(a)
list = ['a', 'b', 'c', 'c'] # stworzenie kolekcji która ma 4 elementy print(list) setFromList = set(list) # stworzenie zbioru z kolekcji który ma 3 elementy, ponieważ zostały zignorowane dane powtarzające się print(setFromList) setFromList.add('d') print(setFromList) setFromList.remove('a') print(setFromList) # dodanie...
{ "includes": [ "../common.gypi" ], "targets": [ { "target_name": "libgdal_ogr_gpx_frmt", "type": "static_library", "sources": [ "../gdal/ogr/ogrsf_frmts/gpx/ogrgpxdatasource.cpp", "../gdal/ogr/ogrsf_frmts/gpx/ogrgpxdriver.cpp", "../gdal/ogr/ogrsf_frmts/gpx/ogrgpxlayer.cpp" ], "include...
def find_measure(name = None, tag = None, id = None, search = None): return 'do some magic!' def get_dimension(id): return 'do some magic!' def get_indicator(id): return 'do some magic!' def get_measure(id): return 'do some magic!' def get_measure_root(id): return 'do some magic!' def get_root...
#Given a string s, find the longest palindromic substring in s. You may assume # that the maximum length of s is 1000. def longestPalindrome(s: str) -> str: left, right = 0, len(s) - 1 def is_palindrome(sub): left, right = 0, len(sub) - 1 while left <= right: if sub[left] != sub[rig...
# 937. Reorder Data in Log Files class Solution: # Sorting by Keys def reorderLogFiles(self, logs: list[str]) -> list[str]: def get_key(log: list[str]) -> tuple: id, content = log.split(" ", maxsplit=1) return (0, content, id) if content[0].isalpha() else (1, None, None) ...
class Cliente: nome = str() NIF = str() def __init__(self, nome1, NIF1): self.nome = nome1 self.NIF = NIF1 def consultar(self): print(self.nome) print(self.NIF)
my_dict = {1:'Apple', 2:'Oracle',3:'Advanced Programming Practice',4:'Software Project Management', 5:'Fundamentals of mathematics'} for x in range(1,6): #print(my_dict[i]) test_str = my_dict[x] res = {i : test_str.count(i) for i in set(test_str)} print(res)
""" You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2. The Next Greater Number of a number x in nums1 is the first greater number to its right in nums2. If it does not exi...
# 二叉树遍历 # 定义节点 class Node: def __init__(self, key): self.data = key self.left = None self.right = None self.parent = None """二叉树 0 / \ 1 2 / \ / \ 3 4 5 6 """ # 递归前序遍历 根-左-右 0 1 3 4 2 5 6 def recursive_preorder_traversal...
{ "includes": [ "common.gypi", "local.gypi" ], "targets": [ { "target_name": "uv_tls", "product_name": "uv_tls", "type": "static_library", "dependencies": [ "deps/ringbuffer/ringbuffer.gyp:ringbuffer" ], ...
"""Base Attack Callback module.""" class BaseCallback: """Base Attack Callback. A callback records and/or prints specific values of each attack iteration of the `generate` method. This base class cannot be directly utilized. It must be either a function or a class implementing the `__call__`...
# https://www.hackerrank.com/challenges/mini-max-sum/problem def miniMaxSum(arr): sort = sorted(arr) large = sort.pop(len(arr)-1) small = sort.pop(0) max_sum = large min_sum = small for i in sort: max_sum += i min_sum += i print(min_sum, max_sum)
def command_ask_path(): return 'COMMAND_ASK_PATH' def command_repeat(): return 'COMMAND_REPEAT' def command_quit(): return 'COMMAND_QUIT' def command_feedback(msg): return 'COMMAND_FEEDBACK;' + msg def command_consult(): return 'COMMAND_CONSULT' def command_wait(): return 'COMMAND_WAIT...
class Solution(object): def isUgly(self, n): """ :type n: int :rtype: bool """ if n ==0: return 0 for p in [2,3,5]: while n%p==0: n=n//p if n ==1: return True return False ...
# coding=utf-8 """ Metaclass for event identifiers """ __author__ = "Sean" class EventMeta(type): """ Metaclass for events. Automatically fills in `identifier` and `identifiers` on class creation. If class does not have an `identifier` or it is set to None, one is generated from its module and ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- print("M(x1,y1)") x1 = int(input("введите x1 ")) y1 = int(input("введите y1 ")) print("M(x2,y2)") x2 = int(input("введите x2 ")) y2 = int(input("введите y2 ")) if x1==-x2 and y1==-y2: print("Точки M(",x1,",",y1,") и M(",x2,",",y2,") симметричны относительно начала координа...
""" Assignments Assigments allow you to set or clear variables, indexed variables, structure elements, functions, and general transformations. You can also get assignment and documentation information about symbols. """
"""The Translator class converts a list to HTML.""" class Translator(object): """The Translator class converts a list to HTML. Parameters ---------- input_list : list The list to translate. Returns ------- self.html_element : str The HTML translation. """ def __...
# package information. INFO = dict( name = "import_gist", description = "script to import gist script", author = "Katsuya Ogata", author_email = "cosacog@gmail.com", license = "MIT License", url = "https://github.com/cosacog/import_gist", classifiers = [ "Programming Language :...
# -*- coding: utf-8 -*- i=[1,3,5,7,9] j=[6,5,4] for I in i: for J in j: print("I=%i J=%i"%(I,I+J))
# Contains Duplicate II # find out whether there are two distinct indices i and j in the array # such that nums[i] = nums[j] and the absolute difference between i and j is at most k. class Solution(object): def containsNearbyDuplicate(self, nums, k): window = set() for i, num in enumerate(nums): ...
# -*- encoding: utf-8 -*- # Copyright: (c) 2019 H2O.ai # License: Apache License Version 2.0 (see LICENSE for details) """ :mod:`base` -- base/abstract H2O classes used internally. """ class Keyed(object): @property def key(self): """ :return: the unique key representing the object on the b...
""" LeetCode 79: Word Search https://leetcode.com/problems/word-search/ Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same...
a = int(input()) b = int(input()) if a != 1 and b != 1: print(1) if a != 2 and b != 2: print(2) if a != 3 and b != 3: print(3)
load("@rules_sphinx//sphinx:indirect_repositories.bzl", "rules_sphinx_indirect_deps") def stuff_sack_level_3_deps(): rules_sphinx_indirect_deps()
# Om t > 10 => vi kan skriva t = a*10^k, där 1<=a<10, alltså består t^n av fler än n siffror def main(): roof1 = 100 roof2 = 25 powerful = set() for n in range(1, roof1): for e in range(1, roof2): val = n ** e if len(str(val)) == e: powerful.add(val) print(len(powerful)) # print...
# -*- coding: utf-8 -*- # Copyright 2021 Cohesity Inc. class SchedulingPolicyProtoContinuousSchedule(object): """Implementation of the 'SchedulingPolicyProto_ContinuousSchedule' model. TODO: type model description here. Attributes: backup_interval_mins (long|int): If this field is set, backups ...
class IInfo: def __init__(self): # keys self.__id = None self.__parent_id = None self.__url = None self.__parent_url = None self.__create_datetime = None self.__edit_datetime = None self.__title = None self.__description = None self...
"""Internal API endpoint constant library. _______ __ _______ __ __ __ | _ .----.-----.--.--.--.--| | _ | |_.----|__| |--.-----. |. 1___| _| _ | | | | _ | 1___| _| _| | <| -__| |. |___|__| |_____|________|_____|____ |____|__| |__|__|__|_____| |: 1 | ...
class BaseMeasure: def min_feature_size(self, _query_size, _alpha): raise 'Not Implemented' def max_feature_size(self, _query_size, _alpha): raise 'Not Implemented' def minimum_common_feature_count(self, _query_size, _y_size, _alpha): raise 'Not Implemented' def similarity(sel...
""" If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ def test_find_sum_of_all_multiples(): assert find_sum_of_all_multiples(10) == 23 assert find_sum_of_all_multiples(2...
# -*- mode: python -*- # -*- coding: utf-8 -*- ''' filter_musicalbum.py - Versa pipeline rules specification to be used with versa transform command The following example, run from the Versadistribution root directory, will generate a filtered down model file in /tmp/musicalbums-trimmed.vlit versa transform demo/pipe...
class Node(): """ Class to create a node with tree-like attributes. """ def __init__(self, data): """ Initialize a node with data, left, and right attributes. """ self.data = data self.left = None self.right = None def __repr__(self): return '...
{'type':'CustomDialog', 'name':'Template', 'title':'Dialog Template', 'size':(300, 100), 'style':['resizeable'], 'components': [ {'type':'Button', 'name':'btnOK', 'position':(10, 35), 'label':'OK', 'id':5100, 'default':1, }, {'type':'Button', 'name':'btnCancel', ...
print("Input your height :") h_ft=int(input("Feet :")) h_inch=int(input("Inches :")) h_inch+=h_ft*12 h_cm=round(h_inch*2.54,1) print("Your height is : %d cm"%h_cm)
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2021, Cisco Systems # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) DOCUMENTATION = r""" --- module: pnp_settings short_description: Manage PnpSettings objects of DeviceOnboardingPnp description: - Returns global P...
class Player: def __init__(self, master): self.master = master self.choice = "UP" self.master.bind("<Left>", lambda x: self.set_choice("LEFT")) self.master.bind("<a>", lambda x: self.set_choice("LEFT")) self.master.bind("<Right>", lambda x: self.set_choice("RIGHT")) ...
VALID_QUERY_PARAMS = "query" SEARCH_TYPE = "type" SEARCH_DATABASE = "d" SEARCH_FORMULA = "f" SEARCH_TEXT = "t" SEARCH_LIMIT = 50 AUTHENTICATION_FAIL = "You must be an admin to perform database manipulation." FORMULA_CREATION_SUCCESS = "Formula creation is successful!" FORMULA_CREATION_FAIL = "Formula creation failed...
"""Trim suffix. Create string _t consisting of string _s with its suffix _w removed (if _s ends with _w). Source: programming-idioms.org """ # Implementation author: bukzor # Created on 2018-04-08T07:26:47.248912Z # Last modified on 2018-04-08T07:26:47.248912Z # Version 1 t = s.rsplit(w, 1)[0]
## PB method : # n = int(input()) # # positive = [] # negative = [] # count_positives = 0 # negative_sum = 0 # # for i in range(1, n+1): # number = int(input()) # if number >= 0: # positive.append(number) # count_positives += 1 # else: # negative.append(number) # negative_sum...
''' What are some potential efficiency disadvantages of having very shallow inheritance trees, that is, a large set of classes, A, B, C, and so on, such that all of these classes extend a single class, Z? ''' ''' does not take advantage of the benefits on an inheritance hierarchy. So a bunch of classes extending one cl...
description = 'nGI XinGI setup: Gratings' group = 'lowlevel' pvprefix = 'SQ:ICON:ngiX:' display_order = 35 excludes = ['ngi_backpack'] devices = dict( g1_rz = device('nicos_ess.devices.epics.motor.HomingProtectedEpicsMotor', description = 'nGI Interferometer Grating Rotation G1 (XinGI)', motorp...
class Keyboard: buttons = [] home_buttons = ["오늘의 식단", "내일의 식단", "식단 리뷰", "운영시간", "도서관", "버스", "지하철" ] food_buttons = ['학식', '교식', '푸드코트', '스낵코너', '더 키친'] ratable_...
vel = float(input('Velocidade do veículo: ')) velMax = 80 taxa= 7.00 if(vel > velMax): multa = (vel - velMax) * taxa print('Você ultrapassou o limite de velocidade! Pagar multa de R${:.2f}'.format(multa)) print('Dirija com Cuidado!')
class ContentAnalysis: def __init__(self): self.line_count = 0 # count the total number of lines in the file self.char_count = 0 # count the number of characters in the file self.total_word_count = 0 # count the total word count in the file self.unique_word_count = 0 # count the n...
#Função para ler um número inteiro usando tratamento de erros caso não seja digitado corretamente def ReadInt(msg): while True: try: number = int(input(msg)) except (ValueError, TypeError): print ('\033[1;31mERRO: Digite um número inteiro válido!\033[m') continue...
a=1 b=2 c=3 d=4 你是不是个沙雕 f=6
class Random: def __init__(self, *param): if len(param) == 1: self.set_seed(param[0]) elif len(param) == 4: self.set_state(*param) else: raise TypeError("Random.__init__ takes either 1 or 4 arguments") def set_seed(self, seed): multiplier = 0x6C078965 temp = seed self.state = [] ...
#return the index of the smallest value from [start:] def posMin(lst,start): n = len(lst) firstval =lst[start] pos = start for i in range(start,n): if lst[i]<firstval: first = lst[i] pos = i return pos def selectionSort(lst): n = len(lst) for sta...
max_prime = 0 number = 600851475143 factor = 2 while number != 1: if number % factor == 0: number //= factor max_prime = max(max_prime, factor) else: factor += 1 print("Max primer number is {}".format(max_prime))
class Solution(object): def int2str(self,num): return str(num) def str2int(self,st): return int(st) def plusOne(self, digits): """ :type digits: List[int] :rtype: List[int] """ digits=map(self.int2str,digits)#整数列表转为字符串列表 nums=str(int...
# # PySNMP MIB module CRESCENDO-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CRESCENDO-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:28:15 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
# Write a loop that computes # a.  The sum of all even numbers between 2 and 100 (inclusive). # b.  The sum of all squares between 1 and 100 (inclusive). # c.  The sum of all odd numbers between a and b (inclusive). # d.  The sum of all odd digits of n . (For example, if n is 32677, the sum would # ...
num1 = 1 num2 = 2 num3 = 3333 num3 = 33 num4 = 444
fin = open("TrainingData.csv") x = open("x.csv", 'w') Y = open("Y.csv", 'w') xData = [] yData = [] # read in data for dataSet in fin: d = list(map(int,dataSet.strip().split(','))) xData.append(d[0:3]) yData.append([d[-1]]) # write data index = 0 for i in xData: k = str(i[0]) for j in i[1:]: ...
i = 4 d = 4.0 s = 'HackerRank ' i2 = int(input()) d2 = float(input()) s2 = input() print(i + i2) print(d + d2) print(s + s2)
""" Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled uniquely. We use # as a separator for each node, and , as a separator for node label and each neighbor of the node. As an example, consider the serialized graph {...
items = { 'ether': { 'name': 'ether', 'icon': 'Resources//pictures//ether.png' }, 'aiguille': { 'name': 'aiguille', 'icon': 'Resources//pictures//aiguille.png', }, 'tube': { 'name': 'tube', 'icon': 'Resources//pictures//tube.png' } }
name = 'automake' version = '1.15' authors = [ 'GNU' ] description = \ ''' Automake ''' build_requires = [ 'autoconf-2.69' ] variants = [ ['platform-osx', 'arch-x86_64'] ] tools = [ ] def commands(): env.PATH.append('{root}/bin') if building: env.ACLOCAL_PATH = '{root}/s...
class Sources: ''' news source class to define sources objects ''' def __init__(self, id,name, description,url, category,language, country): self.id = id self.name = name self.description = description self.url = url self.category = category self.language ...
soma = 0 cont = 0 for c in range(1, 500, 2): if (c % 3) == 0: cont += 1 soma += c print (f'A soma de todo os {cont} valores solicitados é {soma}')
expected_output = { "interfaces": { "Loopback1": { "ipv4": {"192.168.111.2": {"ip": "192.168.111.2", "netmask": "255.255.255.0","primary": True}}, "ipv6": ["2001:db8:4:1::1/64", "2001:db8:400:1::2/112"], "vrf": "VRF1", }, }, }
"""" 1) Implemente uma aplicação que dada uma Pilha implemente funções para: a) retornar o número de elementos empilhados b) excluir todos os elementos da pilha c) inserir elementos na pilha d) retirar elementos da pilha e) retorna o elemento que está no topo da pilha f) alterar elemento que está no topo da pilha g) ve...
baum1 = False baum2 = False baum3 = False baum4 = False baum5 = False i = 1 while i <= 4: if kara.onLeaf(): if i == 1: baum1 = True kara.removeLeaf() elif i == 2: baum2 = True kara.removeLeaf() elif i == 3: baum3 = True ...
games = ['AirRaid', 'Alien', 'Amidar', 'Assault', 'Asterix', 'Asteroids', 'Atlantis', 'BankHeist', 'BattleZone', 'BeamRider', 'Berzerk', 'Bowling', 'Boxing', 'Breakout', 'Carnival', 'Centipede', 'ChopperCommand', 'CrazyClimber', 'DemonAttack', 'DoubleDunk', 'ElevatorAction', 'Enduro', 'FishingDerby', 'Freeway', 'Frostb...
class Solution: def nthMagicalNumber(self, n: int, a: int, b: int) -> int: MOD = int(1e9+7) if max(a,b)%min(a,b) == 0: return (min(a,b)*n) % MOD ans = 0 gcd_ab = gcd(a,b) for i in range(n//(a//gcd_ab + b//gcd_ab - 1)): ans = (ans + (a*b)//gcd_ab) % MOD ...
class Solution: def findLadders(self, beginWord: str, endWord: str, wordList: List[str]) -> List[List[str]]: wordSet = set(wordList) if endWord not in wordList: return [] # {"hit": ["hot"], "hot": ["dot", "lot"], ...} graph: Dict[str, List[str]] = defaultdict(list) # build graph from begin...
# # PySNMP MIB module Nortel-Magellan-Passport-TraceBaseMIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-Magellan-Passport-TraceBaseMIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:17:35 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 #...
# Copyright (C) 2022 by the nbvalx authors # # This file is part of nbvalx. # # SPDX-License-Identifier: BSD-3-Clause """nbvalx documentation configuration.""" # Project information project = "nbvalx" copyright = "2022, the nbvalx authors" author = "Francesco Ballarin (and contributors)" # General configuration exten...
def test_test(): assert False def test_2_test(): pass
''' https://leetcode.com/problems/palindromic-substrings/ 647. Palindromic Substrings Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string. ''...
""" Add Strings Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs to integers directly. Example 1: ...
#variables exc = 0 #input cod = int(input("Digite o código do funcionário: ")) horas = int(input("Digite a quantidade de horas trabalhadas: ")) #process if(horas > 50): exc = ((horas - 50) * 20) salario = (500 + exc) else: salario = (horas * 10) print("Salário TOTAL: {0}".format(salario)) print("Salário EXC...
""" 12-7 命令式编程 vs 函数式编程 """ # 命令式编程最为熟知. # 无论度复杂的业务逻辑,控制流程的几个关键点是: # 函数 # 条件判断 # 循环 # 这三大类是命令式编程最显著的特征. # 函数式编程: # 函数式编程的主要手段: # map # reduce # filter # lambda 表达式 # lambda 表达式在函数式编程里可以称作算子. # 理论上,我们可以用以上四个手段去替换所有命令式编程的复杂逻辑. # lambda 表达式是函数式编程最基本的单元,他在一定程度上可以替换命令式编程里的函数。 # map 和 reduce 可以替换循环。 # 建议:函数式编程可以结合到命令式编程里,...
def add(a,b): print("ADDING %d + %d" % (a, b)) return a+b def subtract(a, b): print("SUBTRACTING %d - %d" % (a, b)) return a-b def multiply(a, b): print("MULTIPLYING %d * %d" %(a, b)) return a*b def divide(a,b): print("DIVIDING %d / %d" %(a, b)) return a/b print("Let't do some math w...
def binary_search(haystack, needle): if len(haystack) == 0: return -1 l, r = 0, len(haystack) - 1 while l <= r: mid = (l + r) // 2 if needle < haystack[mid]: r = mid - 1 elif needle > haystack[mid]: l = mid + 1 else: return mid ...
class Config(object): JOBS = [ { 'id': 'job1', 'func': '__main__:auto_cancel', 'trigger': 'interval', # 间隔执行 'seconds': 5, } ]
class ExtractionError(Exception): '''The exception that is raised when there is an error when extracting.''' def extract_7z(path:str): '''Extract a file using 7zip. '''
def harness(p): scenario = [ 'Constructor 0', 'Constructor 1', 'Main function', 'Destructor 1', 'Destructor 0' ] for expect in scenario: line = p.readline().rstrip() assert expect == line, f'Expected: {expect}, got: {line}'
class Solution: def longestSubstring(self, s: str, k: int) -> int: c = Counter(s) for i, v in c.items(): if v < k: return max(self.longestSubstring(x, k) for x in s.split(i)) return len(s)
class BotController(object): def __init__(self,senderId,converter,processorFactory,messenger): self.senderId = senderId self.converter = converter self.processorFactory = processorFactory self.messenger = messenger def parse(self,request): seatnum = request["seatnum"] ...
# Demo Python Operators ''' Python Operators Operators are used to perform operations on variables and values. Python divides the operators in the following groups: * Arithmetic operators * Assignment operators * Comparison operators * Logical operators * Identity operators * Membership operators *...
# -*- coding: utf-8 -*- model = { 'lar': 0, 'en ': 1, 'ler': 2, 'an ': 3, 'in ': 4, ' bi': 5, ' ya': 6, 'eri': 7, 'de ': 8, ' ka': 9, 'ir ': 10, 'arı': 11, ' ba': 12, ' de': 13, ' ha': 14, 'ın ': 15, 'ara': 16, 'bir': 17, ' ve': 18, ' sa': 19, 'ile': 20, 'le ': 21, 'nde': 22, 'da ': 23, ' bu': ...
# make a list to hold onto our items shopping_list = [] def show_help(): # print out instructions on how to use the app print("What should we pick up at the store?") print(""" Enter 'DONE' to stop adding items. Enter 'HELP' for this help. Enter 'SHOW' to see your current list. """) def show_list(): ...
def getFrequencies(loadFrequencies): output = 0 for line in loadFrequencies(): operator = line[0] num = int(line[1:]) if operator == "+": output += num else: output -= num return output
def base_gate_sequence_and_macros(model, basic_gates_macros: dict = None): """ Given a pyGSTi model generate a minimal generating set of gate sequences by taking a union of the fiducials and the germs. If basic gates macros given, generate a macro for each gate sequence as well. @param model: A pyGS...
""" One Wire typing class This class includes full support for Onewire devices using the ESP32 RMT peripheral to achieve very precise timing 1-Wire is a device communications bus system designed by Dallas Semiconductor Corp. that provides low-speed data, signaling, and power over a single conductor. 1-Wire is similar...
""" Instruction class """ # Standard Library Imports # Third Party Imports # Local Imports class Instruction(object): """ The Instruction class represents a single instruction within a Gadget. """ register_families = [["rax", "eax", "ax", "al", "ah"], # 0 ["rbx", "ebx", "...