content
stringlengths
7
1.05M
#https://leetcode.com/problems/binary-tree-tilt/ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: tilt =0 def findTilt(self, root: Optional[TreeNode]) -...
# !/usr/bin/env python3 # Author: C.K # Email: theck17@163.com # DateTime:2021-11-07 14:32:50 # Description: class Solution: def coinChange(self, coins: List[int], amount: int) -> int: n = len(coins) dp = [[math.inf] * (amount + 1) for _ in range(n + 1)] for i in range(n + 1): dp...
config = {} def process_adapter_message(message): type = message.get("type", None) if type == "initialize": return __initialize__() elif type == "turn_on": return __set_state_internal__("on") elif type == "turn_off": return __set_state_internal__("off") elif type == "set_s...
#!/usr/bin/env python3 # encoding: UTF-8 burstCtrl = "burst.controller" identityCtrl = "identity.controller"
for _ in range(int(input())): n=int(input()) l=list(map(int,input().split())) l=sorted(l) a1=[] for i in range(n-1): if l[i]==l[i+1]: a1.append(l[i]) a2=set(l) a2=sorted(a2) print(*a2,*a1)
def construct_failure_array(pattern): failure_array = [0] * (len(pattern) + 1) for i in xrange(2, len(failure_array)): last_val = failure_array[i - 1] while True: if pattern[last_val] == pattern[i - 1]: failure_array[i] = last_val + 1 break ...
""" List Comprehension List cromprehension is a way to build lists without having to create a for loop. """ temps = [221, 234, 340, 230] new_temps = [temp / 10 for temp in temps] # This is an print(new_temps) # [22.1, 23.4, 34.0, 23.0]
DEFAULT_BIBLE_VERSION = 'esv' LITERAL_WORD_URLS = { 'esv' : 'http://esv.literalword.com/', 'nasb' : 'http://nasb.literalword.com/', }
N=int(input()) for t in range(N): # print("Enter Any Number") # speak.Speak("Enter Any Number") n=int(input()) s=0 while(n>0): r=n%10 s=s*10+r n=n//10 # print("Your Reverse Number is:") # speak.Speak("Your Reverse Number is") print(s)
def deleteNode(llist, position): # Write your code here if position == 0: llist = llist.next else: node = llist for _ in range(position-1): node = node.next node.next = node.next.next return llist
def wnut(srcPath, tarPath): wf = open(tarPath, 'w') with open(srcPath, 'r') as file: strline = "" tagline = "" for line in file: line = line.strip() print(line) if len(line) > 0: tokens = line.split('\t') ...
for i in range(int(input())): n,d = [j for j in input().split()] d = int(d) n = [int(j) for j in str(n)] ind = -1 c = len(n) m = 10 while(ind<len(n)-1): m = min(n[ind+1:]) p = ind+1 ind = n[ind+1:].index(m) ind+=p if(m<d): print(m,end = '')...
class Edge: def __init__(self, src, dst): self.src = src self.dst = dst def get_src(self): return self.src def get_dst(self): return self.dst
# Foundations of Computer Science # BSc Computer Engineering, University of Rome Tor Vergata # Exercise: Implement an image complementary effect. def complementaryPicture(picture): # @param picture:Picture; pixels = getPixels(picture) for pixel in pixels: setRed(pixel, 255 - getRed(pixel)) setGreen(pixel, ...
def _protocol_name(protocol): if protocol.metc == 'Request from clinic': return 'Request from clinic' elif protocol.date_of_signature is None: date_str = 'unknown date' else: date_str = f'{protocol.date_of_signature:%d %b %Y}' return f'{protocol.metc} ({date_str})' def _name(na...
def _get_issue_title(pull): return f"[ISSUE] {pull.title}" def _get_issue_info(issue): return f"{issue.title} #{issue.number} state: {issue.state}" def _get_issue(repo, pull): issue_title = _get_issue_title(pull=pull) for _issue in repo.get_issues(): if _issue.title == issue_title and _issue...
# -*- coding: utf-8 -*- __doc__ = r""" >>> from formalchemy.tests import * >>> jose = User(email='jose@example.com', ... password='6565', ... name=u'Jos\xe9') >>> order4 = Order(user=jose, quantity=4) >>> session.add(jose) >>> session.add(order4) >>> session.flush() >>> FieldSet.default_rendere...
_base_ = "./ss_mlBCE_MaskFull_PredDouble_PBR05_woCenter_edgeLower_refinePM10_01_02MasterChefCan.py" OUTPUT_DIR = "output/self6dpp/ssYCBV/ss_mlBCE_MaskFull_PredDouble_PBR05_woCenter_edgeLower_refinePM10/03_04SugarBox" DATASETS = dict( TRAIN=("ycbv_004_sugar_box_train_real_aligned_Kuw",), TRAIN2=("ycbv_004_sugar_...
def Sort(a): for passnum in range(len(a)-1,0,-1): for i in range(passnum): if a[i]>a[i+1]: temp = a[i] a[i] = a[i+1] a[i+1] = temp a = [] n = int(input("What number of elements do you want to insert to the array?")) print("Enter numbers that y...
text = """ This file contains different words which can repeat This file contains different words which can repeat or not This file contains different words which can repeat, this """ # Let's find uniq words: uniq_words = set() for word in text.split(" "): uniq_words.add(word) print(uniq_words) # {'', 'di...
diagonal_maior = float(input('Diagonal maior: ')) diagonal_menor = float(input('Diagonal menor: ')) area = (diagonal_maior * diagonal_menor) / 2 print(f'Area de um losango: {area:.2f}')
def count_upper(s): """ Given a string s, count the number of uppercase vowels in even indices. For example: count_upper('aBCdEf') returns 1 count_upper('abcdefg') returns 0 count_upper('dBBE') returns 0 """ count = 0 for i in range(0, len(s), 2): if s[i] in "AEIOU": ...
''' Archivo con configuraciones o parámetros Este código se ejecuta solamente la primera vez que se importa este módulo, entonces cuando main.py haga "from config import prm" el objeto "prm" se va a crear. Cuando otro módulo como video.py haga lo mismo, en vez de crearse otro "prm" se le va a dar una referencia al obj...
# -*- coding: utf-8 -*- # Copyright 2021 Cohesity Inc. class TypeCassandraProtectionSourceEnum(object): """Implementation of the 'Type_CassandraProtectionSource' enum. Specifies the type of the managed Object in Cassandra Protection Source. Replication strategy options for a keyspace. 'kCluster' indi...
distance = int(input('What your travel distance? :\n')) price =int() if distance <= 200 : price = 0.50 print ('This price of travel is : \n your bill is : USD {} '.format(price * distance)) else: price = 0.45 print('wow ! your travel deserved an discount \n your bill is : USD {}' .format( price *distan...
# Enter your code here. Read input from STDIN. Print output to STDOUT def weightedMean(values:list, weights:list) -> float: sumWeightedValues = 0 sumWeights = 0 for i in range(len(values)): value = values[i] weight = weights[i] sumWeightedValues += value * weight sumWeights +...
print__ = True def impute_missing_feat_vals(X, col_to_impute, value_of_missing_data, print_=print__): """ Purpose: Impute missing values, allowing selection of what the value of missing data is, and print custom views. Accepts columns with categorical/string values. Method: LabelEncode...
num1 = 13 num2 = 13 if num1 == num2: print("\033[0;32;40mOs valores são iguais\033[m") elif num1 > num2: print("O numeor 1 é maior que o numero 2") elif num1 < num2: print("O numeor 1 é menor que o numero 2") else: print("Os valores são diferentes")
result = 0 for i in range(1, 1001): result += i ** i print(str(result)[-10:])
# -*- coding: utf-8 -*- def main(): print(input() + 'pp') if __name__ == '__main__': main()
## Annexe sur differents styles pour retrouver m k = int(input("k ? ")) # première version (style 1): parcours ordre decroissant m = 179 while m >= 91: if k*360 % m == 0: break m = m - 1 print(m) # première version (style 2): parcours ordre inverse # plus beau mais ne suppose pas que m existe i =...
# coding: utf-8 class Movie(object): def __init__(self, title=None, year=None, imdb=None, aka=None, duration=None, rating=None): self.title = title self.year = year self.imdb = imdb self.aka = aka self.duration = duration self.rating = rating @classmethod ...
class Queue(object): def __init__(self): """ initialize your data structure here. """ self.inStack, self.outStack = [], [] def push(self, x): """ :type x: int :rtype: nothing """ self.inStack.append(x) def pop(self): """ ...
# -*- coding: utf-8 -*- """Top-level package for fileSortingApp.""" __author__ = """Alexander Craggs""" __email__ = 'eyrecraggs@gmail.com' __version__ = '0.1.0'
# # PySNMP MIB module HPICF-ACTIVATE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPICF-ACTIVATE-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:24:43 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
ESCAPE_SEQUENCE = "^^^" _SYSTEM_PREFIX = ESCAPE_SEQUENCE + "SYS" _REQUEST_PREFIX = ESCAPE_SEQUENCE + "RQS" TARGET_SERIAL_NUMBER_PREFIX = ESCAPE_SEQUENCE + "NMB" CMD_DELAY_NEXT_PACKET = _SYSTEM_PREFIX + "PDL" CMD_GET_SERIAL_NUMBER = _REQUEST_PREFIX + "SRN" CMD_SET_DATE_AND_TIME = _SYSTEM_PREFIX + "DTM" CMD_SET_PACKET_...
__all__ = [ 'battles', 'finance_minister', 'fleets', 'foreign_minister', 'host', 'launch', 'messages', 'new_game', 'orders', 'planetaryministers', 'planets', 'plans', 'play_complete', 'race_editor', 'race_viewer', 'render_stars', 'research_minister', ...
def _peaks(A): peaks = [False] * len(A) for i in range(1, len(A)-1): if A[i-1] < A[i] > A[i+1]: peaks[i] = True return peaks def create_peaks(A): peaks = _peaks(A) count = 0 for key, value in enumerate(peaks): if value: count += 1 peaks...
def search(arr, n, x): for i in range (0, n): if (arr[i] == x): return i; return -1; arr = [] number=int(input("Enter array length")) for i in range(number): data=int(input()) arr.append(data) x = int(input("What number you looking for? ")); n = len(arr);...
DATE = "2021-02-28" VERSION = "0.10.3-x" MAJOR = 0 MINOR = 10 PATCH = 3
class ListModelMixin(object): def setup_list_data(self): raise NotImplementedError('Please implement setup_list_data') def assert_list_response_anonymous(self): raise NotImplementedError( 'Please implement assert_list_response_anonymous') def assert_list_response_authenticated...
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ if not head or not head.next: ...
"PyEdit" 'User configurations file' ''' This is mostly a convenience, for providing an initial look-and-feel other than the default. PyEdit is coded to work even if this module is missing or contains syntax errors. This file is primarily intended for when PyEdit is the top-level script run. Here’s what this division o...
""" Metric examples used in other examples. """ request_count = { "name": "request-count", "metricObj": { "apiVersion": "iter8.tools/v2alpha2", "kind": "Metric", "metadata": { "name": "request-count" }, "spec": { "type": "Counter", "par...
def n_choose_m_iterator(N, M, startpoint=None): if startpoint is None: subscripts = list(range(M)) else: subscripts = copy.deepcopy(startpoint) while True: yield subscripts off = M - 1 while off > -1: rev_off = M - off if subscripts[off] < N ...
class BishopMove: def howManyMoves(self, r1, c1, r2, c2): def is_in_range(r, c): for i in xrange(8): if ( (r2 == r+i and c2 == c+i) or (r2 == r+i and c2 == c-i) or (r2 == r-i and c2 == c+i) or (r2 == ...
#here is a secret file, which need 2 key, #mapquest_key is develop key for mapquest api #mapbox_key is develop key for mapbox api class Secret(): def __init__(self): self.mapquest_key = "0QFqsOaM2IuBdUQWnAi6EZHD3GwedpjK" self.mapbox_key = "pk.eyJ1IjoieXUzNHBvIiwiYSI6ImNpdW5xb3J3cTAwMHUydGw4djlrbjBxNXEif...
n = int(input()) for i in range(2, n): if n % i == 0: print("NO") exit() print("YES")
NAME = 'flight.py' ORIGINAL_AUTHORS = [ 'Angelo Giacco' ] ABOUT = ''' returns flight information ''' COMMANDS = ''' >>> .flight <<flight callsign>> ''' WEBSITE = ''
config.load_autoconfig() ## Key bindings. # Opening. config.bind('t', 'set-cmd-text -s :open -t') config.bind('b', 'set-cmd-text -s :open -b') config.bind('w', 'set-cmd-text -s :open -w') config.bind('O', 'set-cmd-text :open {url}') config.bind('T', 'set-cmd-text :open -t {url}') config.bind('B', 'set-cmd-text :open ...
#Preforms a basic caesar shift, then prints output def caesar(instr, shift): instr = instr.upper() newstr = "" for char in instr: if char == " " or char == ".": newstr += char continue ltr = ord(char) - 65 newstr += chr(((ltr + shift) % 26) + 65) print("Sh...
# -*- coding: utf-8 -*- def test_add_some(cards_db, some_cards): expected_count = len(some_cards) for c in some_cards: cards_db.add_card(c) assert cards_db.count() == expected_count def test_non_empty(non_empty_db): assert non_empty_db.count() > 0
# -*- coding: utf-8 -*- """Bangla number to English number convesion Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1Z4zWV3nCQFcLkUx5TwPk49dWNXPbLAqO """ # একটি ফাংশন যেটি বাংলা নাম্বারকে ইংলিশে পরিবর্তন করে , বাংলা নাম্বারের স্ট্রীং হিসেবে ইনপুট দিলে...
#Cédulas #Leia um valor inteiro. A seguir, calcule o menor número de notas possíveis (cédulas) no qual o valor pode ser decomposto. As notas consideradas são de 100, 50, 20, 10, 5, 2 e 1. A seguir mostre o valor lido e a relação de notas necessárias. #Entrada #O arquivo de entrada contém um valor inteiro N (0 < N < 1...
class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: res = [] nums.sort() for i in range(len(nums) - 2): if i > 0 and nums[i] == nums[i - 1]: continue a = nums[i] left = i + 1 ...
def transform(value, subject): value *= subject value, r = divmod(value, 20201227) return r value = 1 subject = 7 card = 8458505 door = 16050997 cardloop = 0 or 15260454 # I can't be bothered to recalculate this doorloop = 0 or 10476062 for i in range(100000000): value = transform(value, subject) ...
# # PySNMP MIB module VERILINK-ENTERPRISE-NCMDSU-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/VERILINK-ENTERPRISE-NCMDSU-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:26:46 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python ...
n = 1 while n <= 100: print(n) n = n + 1
"""OpenAPI Types Use the Type class to determine the OpenAPI data type. """ class SchemaMixin(object): """Schema mixin type for schema value""" @property def schema(self): """Gets the type schema details""" schema = {"type": self.name} if self.format: schema.update({"f...
def get_opcode(code): strcode = str(code) while len(strcode) < 5: strcode = '0' + strcode return (int(strcode[0]), int(strcode[1]), int(strcode[2]), int(strcode[3])*10+int(strcode[4])) def calculate(): program = [3,225,1,225,6,6,1100,1,238,225,104,0,1102,72,20,224,1001,224,-1440,224,4,224,1...
hugs = [ 'https://i.pinimg.com/originals/f2/80/5f/f2805f274471676c96aff2bc9fbedd70.gif', 'https://media1.giphy.com/media/l2QDM9Jnim1YVILXa/source.gif', 'https://i.pinimg.com/originals/a1/64/6c/a1646c77119633b484ba98fc90613f15.gif', 'https://media1.tenor.com/images/977c0043ee29cdae790dc47507fcb91d/tenor....
#!/usr/bin/python # -*- coding: utf8 -*- """ Class describing the Fasta format (As of the 07/20/2016, only used with the reference genome) """ class Fasta(object): def __init__(self, false_path, name, assembly_id): self.false_path = false_path self.name = name if not assembly_id: ...
print("Aが真かつBが真なら真") print(1 == 1 and 1 == 1) # True print(1 == 2 and 1 == 1) # False print(1 == 2 and 1 == 2) # False print("Aが真又はBが真なら真") print(1 == 1 or 1 == 1) # True print(1 == 2 or 1 == 1) # True print(1 == 2 or 1 == 2) # False print("Aが真なら偽になる") print(not 1 == 1) # false
def print_move(fr, to): print('Move from ' + str(fr) + ' to ' + str(to)) def towers(n, fr, to, spare): if n == 1: print_move(fr, to) else: towers(n - 1, fr, spare, to) towers(1, fr, to, spare) towers(n - 1, spare, to, fr) towers(5, 'f', 't', 's')
"""Utility functions for templates """ def get_variable_changes(older, newer): """Generate sequence of changes between two dictionaries Expects to have two variable/namespace dictionaries passed as arguments, and it yields the differences assuming the first is the older and the second is the newe...
#region headers # * author: igor.zecevic@nutanix.com # * version: v1.0 - initial version # * date: 10/03/2020 # task_name: VcSoapGetObjects # description: Get list of MOID (Managed Object ID) using the SearchIndex Method # input vars: vc_cookie, api_server, datacenter, cluster, vm_name # output vars:...
# ------------------------------------------------------------------------ # # Copyright 2005-2015 WSO2, Inc. (http://wso2.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....
class GuetError(Exception): pass class InvalidInitialsError(GuetError): pass class UnexpectedError(GuetError): pass
def contatos(): agenda = [] for i in range(0,10): dados = {} dados['nome'] = str(input('nome:')) dados['endereco'] = str(input('endereco:')) dados['cep'] = str(input('CEP:')) dados['Bairro'] = str(input('Bairro:')) dados['telefone'] = int(input('telefone:')) ...
# returns the commands to setup common interface-properties indifferent of the number of connections # returns commands for the local node only def get_common_setup_commands(config): # common part cmds = ["#!/bin/sh"] # shutdown existing cmdScheduler-instance cmds.append("sudo killall cmdScheduler") ...
class YourClass: classy = "class value" # def x(self): # return if __name__ == '__main__': print(YourClass.classy) dd = YourClass() print(dd.classy) dd.classy = "Instance value" print(dd.classy) del dd.classy print(dd.classy) #理解实例对象的内容,需要调用才能够生成,直接删除是不可以的,因为还没生成.不能直接获取.
def my_dir(obj): return dir(obj) class SingleClassInModule(object): def __init__(self, prop): raise NotImplementedError() def not_implemented(self, param): raise NotImplementedError()
''' By using a where() clause, you can target the delete statement to remove only certain records. For example, Jason deleted all rows from the employees table that had id 3 with the following delete statement: delete(employees).where(employees.columns.id == 3) Here you'll delete ALL rows which have 'M' in the sex c...
class UserNotFoundException(Exception): pass class ProductNotFoundException(Exception): pass class UnrecognizedEventType(Exception): pass class UnrecognizedEventOperation(Exception): pass class UnrecognizedArgs(Exception): pass
# O(nv) where n is length of denominations list and v is target value def can_make_change(denominations, value): table = [[0 for _ in range(len(denominations))] for __ in range(value+1)] for i in range(len(denominations)): table[0][i] = True for i in range(1, value+1): for j in range(len(denomina...
# This is a test Python module class hello: """ This is a class """ def __init__(self): print('Hello World') class Nodocstring: pass class Alongdocstring: """ This is a long docstring. It is greater than 100 characters and will be caught. If not, the analyser is broken """
## >--- ## >YamlDesc: CONTENT-ARTICLE ## >Title: python functions ## >MetaDescription: python functions parameters arguments, Variable Length arguments, function with parameters, function with return value example code, tutorials ## >MetaKeywords: python functions parameters arguments, Variable Length arguments, functi...
""" Partition: Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x. If x is contained within the list, the values of x only need to be after the elements less than x (see below). The partition element x can appear anywhere in the ...
# Project 4 – Word Puzzle # # Name: Dominic Gaiero and Russell Caletena # Instructor: S. Einakian # Section: 05 # https://github.com/dgaiero/cpe101-proj4 # # ###### # # # #### ##### ##### # # # # ###### ###### # ###### # # # # # # # # # # # # # ...
# -*- coding: utf-8 -*- """Connection states.""" INIT = 0 CONNECTED = 1 DISCONNECTED = 2 RUNNING = 3 BACKOFF = 4 THROTTLED = 5 CLOSED = 6
def teach_是(subj, obj, getItem): subjIns = getItem(subj) objIns = getItem(obj) subjIns.pushRelevant(obj) subjIns.pushMember(subj) objIns.pushMember(subj) return subjIns, objIns
""" return node at begining of a cricularly linked list """ def findBeginning(linkedlist): slow = linkedlist.head fast = linkedlist.head while (fast != None) and (fast.next != None): slow = slow.next fast = fast.next.next if fast == slow: return fast
""" INCOMPLETE Given an array of positive or negative integers I= [i1,..,in] you have to produce a sorted array P of the form [ [p, sum of all ij of I for which p is a prime factor (p positive) of ij] ...] P will be sorted by increasing order of the prime numbers. The final result has to be given as a string in Ja...
# Lists all sequences of length 5 fo = open("data/all_5s.txt", "w") for i in range(100000): string_num = str(i) while len(string_num) != 5: string_num = "0" + string_num list_num = list(string_num) fo.write(" ".join(list_num) + "\n")
# You have N gardens, labelled 1 to N. In each garden, you want to plant one of 4 types of flowers. # paths[i] = [x, y] describes the existence of a bidirectional path from garden x to garden y. # Also, there is no garden that has more than 3 paths coming into or leaving it. # Your task is to choose a flower type f...
# # PySNMP MIB module TSL-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TSL-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:27:44 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:15)...
''' @name day-02 @author griffinmelnick @required ../ins/day-02.txt ''' def sol_a(ins): ''' account for "1202 program alarm" ''' ins[1] = 12 ins[2] = 2 i = 0 while True: opcode = ins[i] if ( opcode != 99 ): i1, i2, i3 = ins[ (i+1) : (...
''' We are making n stone piles! The first pile has n stones. If n is even, then all piles have an even number of stones. If n is odd, all piles have an odd number of stones. Each pile must have more stones than the previous pile but as few as possible. Write a Python program to find the number of stones in each pile. ...
def fibFastRec(n): def fib(prvprv, prv, c): if c < 1: return prvprv else: return fib(prv, prvprv + prv, c - 1) return fib(0, 1, n)
''' Created on 2016年1月31日 @author: Darren ''' ''' You are given an array of integers with values greater than or equal to 0, for example: [5, 6, 0, 4, 2, 4, 1, 0, 0, 4] You will develop and implement an algorithm to traverse the array in the shortest number of “hops” starting at index 0, where traversal is defined as...
"""Get search space for SM-NAS.""" class get_space(dict): """Class of get search space. :param name: name :type name: str """ def __init__(self, name, *args, **kwargs): super(get_space, self).__init__(*args, **kwargs) self._name = name self.__dict__ = self @property ...
def buy_skins(dam): # Finish the function to convert DAM to skins pass # Write the rest of your program here dic = {} print("Who's playing Dangerous Mafia?") name = input("Name: ") while name: DAM = int(input("Starting number of DAM: ")) tot = DAM / 40 dic[name] = DAM print(f"{name}'s here, startin...
# # PySNMP MIB module TIMETRA-TC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIMETRA-TC-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:16: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 2...
def field_generator(n): field = [list(map(str, input().split(" "))) for _ in range(n)] return field def find_player_coordinates(field): for row in range(len(field)): for col in range(len(field)): if field[row][col] == "P": return row, col def in_range(field, current_r...
class AmazonEvalF(object): PROD_ID = 'prod_id' CAT = 'cat' REV1 = 'rev1' REV2 = 'rev2' REV3 = 'rev3' REV4 = 'rev4' REV5 = 'rev5' REV6 = 'rev6' REV7 = 'rev7' REV8 = 'rev8' SUMM1 = 'summ1' SUMM2 = 'summ2' SUMM3 = 'summ3' REVS = [REV1, REV2, REV3, REV4, REV5, REV6, ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- state0 = 0 state1 = 1 state2 = 2 state3 = 3 class StepMotorController: def __init__(self, motor_id, port_controller, angle_step, long_revol, control_pins, limit, ...
x = y = z = True print (x) True print (y) True print (z) True x = 1 y = 2 z = 3 if y < x > z: print("la letra mayor es la primer letra. letra:", x) elif x < y > z: print("la letra mayor es la segunda letra. letra:", y) elif x < z > y: print("la letra mayor es la tercera letra. letra:", z...
""" Em Python há quatro tipos: 1. int (inteiro): 4, -3, 0 2. float (real): 4.0, -3.0, 1024.5 3. str ("string" ou cadeia de caracteres): "4.0", "Ronaldo, "João" 4. bool (booleana ou lógico): True e False Variáveis são valores armazenados em endereços de memória. Estão associados a um tipo de dado e seu...
# Time: O(n^3) # Space: O(n^2) try: xrange # Python 2 except NameError: xrange = range # Python 3 class Solution(object): def maxCoins(self, nums): """ :type nums: List[int] :rtype: int """ coins = [1] + [i for i in nums if i > 0] + [1] n = len(co...
def partition(array: list, start: int, end: int) -> int: """ Функция сортировки. Возвращает индекс граничного элемента. """ idx_left, idx_right = start, end - 1 pivot = array[(end + start) // 2] while True: while array[idx_left] < pivot: idx_left += 1 while pivot ...