content
stringlengths
7
1.05M
''' Fixed arguments ''' def print_fib(a, b, c): print(a, b, c) print_fib(1, 1, 2) print_fib(1, 1, 2, 3) ''' Using *args ''' def print_fib(a, *args): print(a) print(args) print_fib(1, 1, 2, 3) print_fib(1) ''' Using **kwargs ''' def print_fib(a, **kwargs): print(a) print(kwargs) print_fib(1, s...
s, t, n = map(int, input().split()) dList = input().split() bList = input().split() cList = input().split() Time = 0 for i in range(len(dList) - 1): Time += int(dList[i]) if Time % int(cList[i]) == 0: wait = abs(Time - int(cList[i])) - int(cList[i]) else: wait = abs(Time - int(cList[i])) ...
""" Pipeless / examples.py. MIT licensed. Basic functionality >>> from pipeless import pipeline >>> function, run, _ = pipeline(lambda item, e: None) >>> @function ... def up_one(_): return _+1 >>> list(run([0, 1, 3])) [1, 2, 4] >>> @function ... def twofer(_): ... yield _ ... yield _ >>> list(run([0, 1, 3])) ...
logic_registry = [] def logic(function): """A descriptor to tag a function as programmable logic, contianing migen commands.""" logic_registry.append(function) return function def is_logic(function): """Returns True if the given function was tagged using the ``@logic`` descriptor.""" return func...
n = int(input()) string = [] string = input().split(" ") string.sort() for i in range (0,n): print (string[i], end = " ")
"""外挂1""" wg1 = 5 wg2 = 0 while True: n1 = input("输入您的红包数量:") if n1 == " " or n1 == "exit": break n2=float(n1) if n2>= 5: wg2 += 1 if n2 >= 10: wg1 += 1 print(wg1, wg2)
# # @lc app=leetcode.cn id=227 lang=python3 # # [227] 基本计算器 II # # https://leetcode-cn.com/problems/basic-calculator-ii/description/ # # algorithms # Medium (38.94%) # Likes: 323 # Dislikes: 0 # Total Accepted: 51.2K # Total Submissions: 121.3K # Testcase Example: '"3+2*2"' # # 给你一个字符串表达式 s ,请你实现一个基本计算器来计算并返回它的值...
# Calculate an average value # Calculate an average value iteratively: # def average(nums): # result = 0 # for num in nums: # result += num # return result/len(nums) # Could you provide a recursive solution? # A formula for updating an average value given a new input might be handy: # @ = ( xi +...
class GlobalInfo: gui_thread = None main_window = None daemon_inst = None daemon_conn = None headless_plugin_manager = None
class MinimumBalanceAccount(BankAccount): def __init__(self, minimum_balance): BankAccount.__init__(self) self.minimum_balance = minimum_balance def withdraw(self, amount): if self.balance - amount < self.minimum_balance: print ('Sorry, minimum balance must be maintaine...
class Solution: def divide(self, dividend: int, divisor: int) -> int: if (dividend == -2147483648 and divisor == -1): return 2147483647 ans = 1 nORp = 1 if (dividend > 0) == (divisor > 0) else -1 a , b = abs(dividend) , abs(divisor) if a < b : return 0 elif a == b: re...
colors = ["red", "yellow", "green", "blue"] print(type(colors)) print(colors) numbers = (1,2,3) print(numbers) numbers_list = list(numbers) print(numbers_list) print(list("Fabio")) groceries = "eggs, milk, cheese" grocery_list = groceries.split(", ") print(grocery_list) numbers = list(range(1,10)) print(numbers) ...
# -*- coding: utf-8 -*- """ Stopwords from the nltk package Bird, Steven, Edward Loper and Ewan Klein (2009). Natural Language Processing with Python. O'Reilly Media Inc. List of stopwords useful in text mining, analyzing content of tweets, web pages, keywords, etc. Each list is accessible as part of a dictionary `...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Meta data for appveyorpy.""" __version__ = '0.0.1' def add(a: int, b: int) -> int: """Add ``a`` and ``b``.""" return a + b
class Solution: def maxArea(self, height: List[int]) -> int: n = len(height) start, end = 0, n-1 maxArea = 0 while start < end: area = (end - start)*min(height[start], height[end]) if maxArea < area: maxArea = area if height[start] ...
N = int(input()) A = int(input()) if N%500 <= A: print('Yes') else: print('No')
# puzzle3b.py def get_rating(input_data, rating_type, num_len): def rating_type_compare(rating_type, count_0, count_1): if rating_type.upper() in ["OXYGEN", "O2"]: return (count_0 > count_1) elif rating_type.upper() in ["CO2"]: return (count_0 <= count_1) # Strategy: Fo...
dado1 = 'pessego' dado2 = 'se' if dado2 in dado1: print(f'{dado2} encontrado na posição {dado1.find(dado2)} de {dado1}')
class ParticipantIdentifierTypeName(): AS_PROGRESSION_ID = 'AS_PROGRESSION_ID' BME_COVID_ID = 'BME_COVID_ID' CARDIOMET_ID = 'CARDIOMET_ID' CARMER_BREATH_ID = 'CARMER_BREATH_ID' EASY_AS_ID = 'EASY_AS_ID' EDEN_ID = 'EDEN_ID' EDIFY_ID = 'EDIFY_ID' ELASTIC_AS_ID = 'ELASTIC_AS_ID' EPIGENE...
def D2old(): n = int(input()) bricks = input().split() bricks = [int(x) for x in bricks] m = min(bricks) M = max(bricks) while(m!=M): for idx in range(n): if(bricks[idx] != m): continue m_count = 0 while( idx+m_count < n and bricks[idx+m_count]== m): bricks[idx+m_count] +=1 m_count+=1 ...
# -*- coding: utf-8 -*- """ Created on Sat Aug 17 13:18:39 2019 @author: solis https://opendata.aemet.es/centrodedescargas/inicio """ MYAPIKEY = 'facilitadoPorAEMET'
''' 9. Faça um programa que imprima na tela apenas os números ímpares entre 1 e 50. ''' for j in range(1, 50): if j % 2 == 1: print(j, end=' ')
class LoginError(Exception): """ An error occurred when logging in. """ pass class ParseError(Exception): """ An error occurred when trying to parse the message. """ pass class ParserNotFoundError(Exception): """ Parser for the given destto name was not registered with the ...
# Copyright (c) 2015, 2014 Computational Molecular Biology Group, Free University # Berlin, 14195 Berlin, Germany. # 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 ...
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 """ Stubs for testing organization.py """ describe_organization = { 'Organization': { 'Id': 'some_org_id', 'Arn': 'string', 'FeatureSet': 'ALL', 'MasterAccountArn': 'string', ...
""" Python program using class sructure for calculating a dining bill and diners' shares on any percentages of sales tax or tip, and on any given number of diners sharing the bill, as given per the user input """ class Tip_Calculator(): """define a Tip_Calculator class""" def __init__(self): """initia...
list = [] def list_(times): for x in range(times): number = int(input('Ingrese numero(s) a incluir ')) list.append(number) return list times = int(input('Cantidad de elementos?: ')) list = list_(times) print(list)
class Helmet: name = "" info = "" level = 0 visibility = 0 _type = "" heaviness = 0 loudness = 0 hit_points = 10000 cut_damage_reduction = 0 # 1 - 10(%) stab_damage_reduction = 0 # 1 - 10(%) smash_damage_reduction = 0 # 1 - 10(%) special_abilities = [] occupied = F...
#Patterns to detect accommodation related queries pattern_details1 = { "LABEL" : "PICKUP_REG", "pattern" : [ { "TEXT" : { "REGEX" : "\bpickup\b|\bpick-up\b|\bdeliver*\b|\bgrab*\b" } } ] } pattern_details2 = { "LABEL" : "PICKUP_LEMM", "pattern" : [ { "TEXT" : { "REGEX" : "delive...
#remove all the digits from given string inp="test1254ab995drgdc10108done" inp=inp.replace("0","") inp=inp.replace("1","") inp=inp.replace("2","") inp=inp.replace("3","") inp=inp.replace("4","") inp=inp.replace("5","") inp=inp.replace("6","") inp=inp.replace("7","") inp=inp.replace("8","") inp=inp.replace("9...
n = int(input()) if n%2!=0: print("Weird") else: if (n>=2 and n<=5): print("Not Weird") elif (n>=6 and n<=20): print("Weird") elif(n>20): print("Not Weird")
#!/usr/bin/env python """Temp GGBweb python formating functions""" __author__ = "Aaron Brooks" __copyright__ = "Copyright 2014, cMonkey2" __credits__ = ["Aaron Brooks"] __license__ = "GPL" __version__ = "0.0.1" __maintainer__ = "Aaron Brooks" __email__ = "brooksan@uw.edu" __status__ = "Development"
n = int(input()) d = len(str(n)) - 1 k = str(n) j = int(k[0]) count = 1 co = 0 for i9 in range(3, 8, 2): for i8 in range(3, 8, 2): for i7 in range(3, 8, 2): for i6 in range(3, 8, 2): for i5 in range(3, 8, 2): for i4 in range(3, 8, 2): f...
n1 = int(input('Digite um número: ')) dob = n1 * 2 tri = n1 * 3 raiz = n1 ** (1/2) print(f'O dobro de {n1} é {dob}') print(f'O triplo de {n1} vale {tri}') print(f'A raiz quadrada de {n1} é igual a {raiz:.6f}')
""" @author: David Lei @since: 21/08/2016 @modified: Common problem with many variations - minimum number of coins - how many ways can we give change - each coin only used once - each coin can be used as many times as you want etc """ """ Minimum number of coins variation Given coins of d...
""" Test routes for routes for authorizing users, app/main/routes """ # pylint: disable=redefined-outer-name,unused-argument def test_index_route_to_login(client): """ Test redirect to login when go to index and not authorized """ response = client.get("/", follow_redirects=True) assert response.st...
# coding: utf-8 """ Heapsort implementation https://en.wikipedia.org/wiki/Heapsort Worst-case performance O(n * log(n)) Best-case performance O(n) Average performance O(n * log(n)) """ def heapsort(lst): """ Implementation of heap sort algorithm """ lenght = len(lst) heapstart = int(lenght / 2) - 1 ...
#!/usr/bin/python3 # -*- coding: utf-8 -*- # # Run inside python3 shell. # def gen_gray(n): """ A generator that yields the elements of a gray sequence (as lists) with `n` bits. """ k = 0 even = True seq = [False]*n while k < 2**n: yield seq if even: seq[n - 1] = not s...
def convert_and_sum_list_kwargs(usd_list, **kwargs): total = 0 for amount in usd_list: total += convert_usd_to_aud(amount, **kwargs) return total print(convert_and_sum_list_kwargs([1, 3], rate=0.8))
class SimpleGraph: def __init__(self): self.edges = {} @property def nodes(self): return self.edges.keys() def neighbors(self, id): return self.edges[id] class DFS(object): ''' Implementation of recursive depth-first search algorithm Note for status 0=not visited, ...
#link: https://leetcode.com/problems/island-perimeter/submissions/ """ Go through every cell on the grid and whenever you are at cell 1 (land cell), look for surrounding (UP, RIGHT, DOWN, LEFT) cells. A land cell without any surrounding land cell will have a perimeter of 4. Subtract 1 for each surrounding land cell. ...
#check if it is a multiple subject def is_multiple_subject_linked_to_subject(subject): for child in subject.children: if child.dep_ == "conj": return True return False def is_multiple_subject_linked_to_predicate(predicate): #this case is for personal pronoun, and not only, but much more nsubj subjects = [] ...
def test_getitem_fetches_delayed_array_from_index(): """ spec['a'] """ def test_getitem_logical_indexing_fetches_result_from_param_file(): """ Ensure that `spec[spec['param1'] == 1]` fetches the correct delayed object from the param files """ def test_getitem_multidimensional_logical_index...
#!/usr/bin/env python NAME = 'Imperva SecureSphere' def is_waf(self): # thanks to Mathieu Dessus <mathieu.dessus(a)verizonbusiness.com> for this # might lead to false positives so please report back to sandro@enablesecurity.com for attack in self.attacks: r = attack(self) if r is None: ...
class Node(object): def __init__(self, val, parent=None): self.val = val self.leftChild = None self.rightChild = None self.parent = parent def getLeftChild(self): return self.leftChild def getRightChild(self): return self.rightChild def getParent(self...
"""Tests suite for pCrunch.""" __author__ = ["Jake Nunemaker", "Nikhar Abbas"] __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "Jake Nunemaker" __email__ = "jake.nunemaker@nrel.gov"
class FundNameException(BaseException): pass class FundOutFileNameException(BaseException): pass class FundNotFoundException(BaseException): pass class StockInformationMissingException(BaseException): pass class StockCandleInformatinMissingException(StockInformationMissingException): pass
#!/usr/bin/env python # -*- coding: utf-8 -*- """glyph.py: Represents a glyph for a dot matrix.""" __author__ = "Victor RENÉ" __copyright__ = "Copyright 2014, Kivy widget library" __license__ = "MIT" __version__ = "1.0" __maintainer__ = "Victor RENÉ" __email__ = "victor-rene.dev@outlook.com" __status__ = "Production"...
dp = {0:0,1:1,2:2} class Solution: def minDays(self, n: int) -> int: if n in dp: return dp[n] ans = 1 + min(n%2 + self.minDays((n-n%2)//2), n%3 + self.minDays((n-n%3)//3)) dp[n] = ans return ans
class MinStack: def __init__(self): """ initialize your data structure here. """ self.stack = list() def push(self, x: int) -> None: cur_min = self.getMin() if x < cur_min: cur_min = x self.stack.append((x, cur_min)) def pop(sel...
magicians = ['alice','david','carolina'] for magician in magicians: print(f"{magician.title()},that was a great trick!") for i in range(1,6): print(i) for j in range(6): print(j) numbers = list(range(1,6)) print(numbers) even_numbers = list(range(2,11,2)) print(even_numbers) squares = [] for value in ...
class ImeContext(object): """ Contains static methods that interact directly with the IME API. """ @staticmethod def Disable(handle): """ Disable(handle: IntPtr) Disables the specified IME. handle: A pointer to the IME to disable. """ pass @staticmethod ...
class Template: def __init__(self, bot, channel): self.bot = bot self.channel = channel channel.set_command("!command", self.on_command, "!command description") def on_command(self, message): pass # runs when a personal message is received # message is a dictionary con...
YOUTUBE_PREVIEW = { 'url': 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'domain': 'youtube.com', 'lastUpdated': '2021-04-09T23:28:10.364301Z', 'nextUpdate': '2021-04-10T23:28:09.016859Z', 'contentType': 'html', 'mimeType': 'text/html', 'size': 499047, 'redirected': True, 'redirectionUrl': 'https://w...
def setup(app): """Additions and customizations to Sphinx that are useful for documenting the Salt project. """ app.add_crossref_type(directivename="conf_master", rolename="conf_master", indextemplate="pair: %s; conf/master") app.add_crossref_type(directivename="conf_minion", rolename="...
# -*- coding: utf-8 -*- DEBUG = True TESTING = True SECRET_KEY = 'SECRET_KEY' DATABASE_URI = 'mysql+pymysql://root:root@127.0.0.1/git_webhook' CELERY_BROKER_URL = 'redis://:@127.0.0.1:6379/0' CELERY_RESULT_BACKEND = 'redis://:@127.0.0.1:6379/0' SOCKET_MESSAGE_QUEUE = 'redis://:@127.0.0.1:6379/0' GITHUB_CLIENT_ID = '...
__title__ = 'django-activeurl' __package_name__ = 'django_activeurl' __version__ = '0.1.12' __description__ = 'Easy-to-use active URL highlighting for Django' __email__ = 'hellysmile@gmail.com' __author__ = 'hellysmile' __license__ = 'Apache 2.0' __copyright__ = 'Copyright (c) hellysmile@gmail.com'
# Copyright 2018 The Bazel Authors. 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 la...
"""Sample Configuration The bot doesn't actually read sample-config.py; it reads config.py instead. So you need to copy this file to config.py then make your local changes there. (The reason for this extra step is to make it harder for me to accidentally check in private information like server names or passwords.) ""...
# # PySNMP MIB module AT-ISDN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AT-ISDN-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:14: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 2019, 0...
# Compound Interest P = float(input('Enter principal amount: $')) r = float(input('Enter annual interest rate %')) n = float(input('Enter number of times per year interest has compounded: ')) t = float( input('Enter number of years account will be left to earn interest: ')) r /= 100 # 50% = .50 A = P * ((1 + (r ...
#coding: utf-8 # Copyright 2005-2010 Wesabe, Inc. # # 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 a...
def pytest_addoption(parser): parser.addoption("--project", action="store", default='None') def pytest_generate_tests(metafunc): # This is called for every test. Only get/set command line arguments # if the argument is specified in the list of test "fixturenames". option_value = metafunc.config.option...
def endswith(x, lst): """ Select longest suffix that matches x from provided list(lst) :param x: input string :param lst: suffixes to compare with :return: longest suffix that matches input string if available otherwise None """ longest_suffix = None for suffix in lst: if x.endswith...
#!/usr/bin/env python3 class Solution: def findCircleNum(self, M): sz, num = len(M), 0 marked = [False] * sz def dfs(p): marked[p] = True for q in range(sz): if M[p][q] and (not marked[q]): dfs(q) for p in range(sz): ...
#prints all TRs in a table table = soup.findAll('table')[3] for row in table.findAll('tr'): print(row) #prints each TR and each child tag in TR table = soup.findAll('table')[3] for row in table.findAll('tr'): for line in row.findAll(): print(line)
#1. Idea here is we want to return a list of strings which contains all of the root to leaf paths in the binary tree. #2. So initialize a list (path_list) then we are going to make a recursive call function. In the function we will pass the root of the binary tree and a empty string which we will modify and add node v...
class NfDictionaryTryGetResults: def __init__( self): self.__key_exists = \ False self.__value = \ None def __get_key_exists( self) \ -> bool: key_exists = \ self.__key_exists return \ key_exis...
class Solution: """ @param nums: An integer array sorted in ascending order @param target: An integer @return: An integer """ def findPosition(self, nums, target): low = 0 high = len(nums) - 1 while low<=high : mid = (low+high) >> 1 if nums[mid]>ta...
# pylint: disable=missing-function-docstring, missing-module-docstring/ # coding: utf-8 x = 1 e1 = x + a e3 = f(x) + 1 # TODO e4 not working yet. we must get 2 errors #e4 = f(x,y) + 1
# -*- coding: utf-8 -*- """A Collection of Financial Calculators. This script contains a variety of financial calculator functions needed to determine loan qualifications. """ """Credit Score Filter. This script filters a bank list by the user's minimum credit score. """ def filter_credit_score(credit_score, ban...
# -*- coding: utf-8 -*- def command(): return "edit-instance-vmware" def init_argument(parser): parser.add_argument("--instance-no", required=True) parser.add_argument("--instance-type", required=True) parser.add_argument("--key-name", required=True) parser.add_argument("--compute-resource", requi...
############################################################################## # Documentation/conf.py # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. The...
config = { 'Department_level_configs': { 'Department_Name': 'Data Analisys Department', 'Department_Short_Name': 'DATA' } }
""" At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer, so that the net tra...
# coding: utf-8 class UtgError(Exception): MSG = None def __init__(self, **kwargs): super(UtgError, self).__init__(self.MSG % kwargs) self.arguments = kwargs class WordsError(UtgError): pass class WrongFormsNumberError(WordsError): MSG = 'constuctor of word receive wrong number of...
''' Abstract class of healthcheck. There is only one method to implement, that determines state of Vm or its underlying services. Initialization - consider following config: :: healthcheck: driver: SomeHC param1: AAAA param2: BBBB some_x: CCC All params will be passed as config dict to the dr...
# Solution #----------------------------------------------------# def prepend(self, value): """ Prepend a node to the beginning of the list """ if self.head is None: self.head = Node(value) return new_head = Node(value) new_head.next = self.head self.head = new_head #-------------...
class State(object): def __init__(self): print("Processing current state: ", str(self)) def on_event(self, event): """ Handle events that are delegated to this State. """ pass def __repr__(self): """ Leverages the __str__ method to describe the State. """ return self.__str__() def __str__(self)...
lines = int(input("Please enter number of lines : \n")) ln = 1 while ln <= lines: col = 1 while col <= lines: if ln == 1 or col == 1 or col == lines or ln == lines: print('*', end='') else: print(' ', end = '') col += 1 print() ln += 1
# -*- coding: utf-8 -*- """ Created on Sun Aug 1 22:16:33 2021 @author: McLaren """ # 邮件提醒功能,若启用必须设置为True,并配置后续内容 # 配置QQ邮箱的SMTP服务即可实现邮件发送 # 详见:https://www.cnblogs.com/Alear/p/11594932.html email_notice = True email = "" # 邮箱 passwd = "" # 填入发送方邮箱的授权码 # 体力恢复配置 use_Crystal_stone = False use_Gold_apple = True use_Si...
# Valid API version in URL path: YYYY-MM or unstable VERSION_PATTERN = r"([0-9]{4}-[0-9]{2})|unstable" # /oauth/authorize, /oauth/access_token do not require authentication NOT_AUTHABLE_PATTERN = r"\/oauth\/(authorize|access_token)" # /oauth/access_scopes does not require versioned API path NOT_VERSIONABLE_PATTERN = r"...
def iterate(pop): p = pop.copy() for i in range(8): p[i] = pop[i + 1] p[8] = pop[0] p[6] += pop[0] return p pop = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0} population = [int(n) for n in open('input.txt', 'r').readline().split(',')] for fish in population: pop[fish] += 1 f...
for c in range(6, 0,-1): print(c) n1 = int(input('Inicio: ')) n2 = int(input('Fim: ')) n3 = int(input('Passo: ')) for c in range(n1, n2 + 1, n3): print(c)
# # PySNMP MIB module SLAPM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SLAPM-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:06:04 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:23...
"""The CLI package.""" __all__ = [ "main", "bootstrap", "config", "log", "project", "experiment", "report", "run", "slurm" ]
# To format the names in title case input_first_name=input("Enter the first name: ") input_last_name= input("Enter the last name: ") def format_name(first_name,last_name): first_name = first_name.title() last_name = last_name.title() full_name = first_name + " "+last_name return full_name name = forma...
def determine_dim_size(dim_modalities, pick_modalities): if len(pick_modalities) < len(dim_modalities): dim_modalities = [dim_modalities[mod_idx] for mod_idx in pick_modalities] return dim_modalities def prepare_batch(multidimensional_ts, split_modalities, pick_modalities, dim_modalities): if split...
################################################################# # # # Program Code for Spot Micro MRL # # Of the Cyber_One YouTube Channel # # https://www.youtube.com/cyber_one ...
#!/usr/bin/env python3 # Extra Line added # -*- coding: utf-8 -*- """ Created on Sun Sep 30 13:52:32 2018 @author: jaley """ class Dog(object): # 2 Underscores def __init__(self,breed): self.breed = breed sam = Dog(breed='Lab') frank = Dog(breed='Huskie') print (sam.breed) class Animal(...
def printg(grid, name): print( '%s: [' % name) for row in grid: print( row) print( ']') def dist(p, q): dx = abs(p[0] - q[0]) dy = abs(p[1] - q[1]) return dx + dy; def reconstruct_path(came_from, current): total_path = [current] while current in came_from.keys(): curren...
#!/usr/bin/env python #pylint: skip-file # This source code is licensed under the Apache license found in the # LICENSE file in the root directory of this project. class ZtdDevice(object): def __init__(self): """ Attributes: swaggerTypes (dict): The key is attribute name and the value ...
FRONT_MATTER = '\ ---\n\ pageType: post\n\ game: {game_title_nospace}\n\ slug: /{game_title}-{article_type_hyphen}/\n\ title: "{article_title} <em class=\'game-title\'>{game_title_space_caps}</em>"\n\ postType: [{article_type_comma}]\n\ tagline: "{tagline}"\n\ date: {date}\n\ release-date: {release_date}\n\ image: {gam...
msg_soc='BA:?' msg_p='P:?' msg_ppvt='PV:?' msg_conso='CON:?' soc=101 try: tree = etree.parse(configGet('tmpFileDataXml')) for datas in tree.xpath("/devices/device/datas/data"): if datas.get("id") in configGet('lcd','dataPrint'): for data in datas.getchildren(): if data.tag =...
def average(number_list): total = 0 for each in number_list: total = total + each return total / len(number_list) number_list = [10, 20, 30, 40, 50, 60, 70, 80, 90] print("평균 :", average(number_list))
HP_SERIAL_FORMAT_DEFAULT = "auto" HP_SERIAL_FORMAT_CHOICES = ["auto", "yaml", "pickle"] HP_ACTION_PREFIX_DEFAULT = "hp"
# 二分查找 # 返回 x 在 arr 中的索引,如果不存在返回 -1 def binarySearch (arr, x): low = 0 # 最小数下标 high = len(arr) - 1 # 最大数下标 while low <= high: mid = (low + high) // 2 # 中间数下标 if arr[mid] == x: # 如果中间数下标等于val, 返回 return mid elif arr[mid] > x: # 如果val在中间数左边, 移动high下标 high =...
"""Implements the BiDi Rule. (Source: RFC 5893, Section 2) The following rule, consisting of six conditions, applies to labels in Bidi domain names. The requirements that this rule satisfies are described in Section 3. All of the conditions must be satisfied for the rule to be satisfied. 1. The first character mus...
class TranslatorExceptions(Exception): def __init__(self, message): super().__init__() self.message = message class LangDoesNotExists(TranslatorExceptions): def __init__(self): super().__init__( 'Requested language does not exists\nTry to run \'lang\' command to be familiar...
routes = [ ('Binance Futures', 'ETH-USDT', '30m', 'SimplEma'), # r'(╯°□°)╯︵ ┻━┻' ] extra_candles = []