content
stringlengths
7
1.05M
class Solution: def maximalRectangle(self, matrix: List[List[str]]) -> int: if not matrix: return 0 row, col = len(matrix), len(matrix[0]) dp = [0] * col ret = 0 for i in range(row): for j in range(col): if matrix[i][j] == '1': ...
database_name = "Health_Service" user_name = "postgres" password = "zhangheng" port = "5432"
""" Problem Set 5 - Problem 1 - Build the Shift Dictionary and Apply Shift The Message class contains methods that could be used to apply a cipher to a string, either to encrypt or to decrypt a message (since for Caesar codes this is the same action). In the next two questions, you will fill in the methods of the Mess...
#Exercise 3.2: Rewrite your pay program using try and except so # that yourprogram handles non-numeric input gracefully by # printing a messageand exiting the program. The following # shows two executions of the program: # Enter Hours: 20 # Enter Rate: nine # Error, please enter numeric input # Enter Hours: forty ...
def find_pairs_with_given_difference(arr, k): diffs = {} for y in arr: diffs[y-k] = y result=[] i = 0 while i < len(diffs): try: if arr[i] in diffs: result.append([ diffs[arr[i]], arr[i] ]) except: pass i+=1 return result ''' Pairs with Specific Difference A naive ...
_base_ = [ '../_base_/models/mask_rcnn_r50_fpn_icdar2021.py', '../_base_/datasets/icdar2021_instance_isolated.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] # data = dict( # samples_per_gpu=1, # workers_per_gpu=2) # optimizer = dict(type='SGD', lr=0.01, momentum=0.9, w...
""" Define custom exceptions """ __all__ = ( 'Track17Exception', 'InvalidCarrierCode', 'DateProcessingError' ) class Track17Exception(Exception): def __init__(self, message: str, code: int = None): self.message = message self.code = code super().__init__() def __str__(sel...
""" Ryan Kirkbride - Noodling around: https://www.youtube.com/watch?v=CXrkq7u69vU How to: - Run the statements line by line (alt+enter), go to the next one whenever you feel like - The "#### > run block <" blocks should be executed together (ctrl+enter) - If you want to fast-forward through the son...
HASS_EVENT_RECEIVE = 'HASS_EVENT_RECEIVE' # hass.bus --> hauto.bus HASS_STATE_CHANGED = 'HASS_STATE_CHANGE' # aka hass.EVENT_STATE_CHANGED HASS_ENTITY_CREATE = 'HASS_ENTITY_CREATE' # hass entity is newly created HASS_ENTITY_CHANGE = 'HASS_ENTITY_CHANGE' # hass entity's state changes HASS_ENTITY_UPDATE = 'HASS_ENT...
N, L = map(int, input().split()) amida = [] for _ in range(L+1): tmp = list(input()) amida.append(tmp) idx = amida[L].index('o') for i in reversed(range(L)): if idx != N*2-2 and amida[i][idx+1] == '-': idx += 2 elif idx != 0 and amida[i][idx-1] == '-': idx -= 2 print(idx//2+1)
# LSM6DSO 3D accelerometer and 3D gyroscope seneor micropython drive # ver: 1.0 # License: MIT # Author: shaoziyang (shaoziyang@micropython.org.cn) # v1.0 2019.7 LSM6DSO_CTRL1_XL = const(0x10) LSM6DSO_CTRL2_G = const(0x11) LSM6DSO_CTRL3_C = const(0x12) LSM6DSO_CTRL6_C = const(0x15) LSM6DSO_CTRL8_XL = const(0x17) LSM6D...
class Solution: def findPeakElement(self, nums: List[int]) -> int: l=0 r=len(nums)-1 while l<r: mid=l+(r-l)//2 if nums[mid]<nums[mid+1]: l=mid+1 else: r=mid return l
# Refers to `_RAND_INCREASING_TRANSFORMS` in pytorch-image-models rand_increasing_policies = [ dict(type='AutoContrast'), dict(type='Equalize'), dict(type='Invert'), dict(type='Rotate', magnitude_key='angle', magnitude_range=(0, 30)), dict(type='Posterize', magnitude_key='bits', magnitude_range=(4, ...
def tickets(people): twenty_fives = 0 fifties = 0 for p in people: if p == 25: twenty_fives += 1 if p == 50: if twenty_fives == 0: return 'NO' twenty_fives -= 1 fifties += 1 if p == 100: if fifties >= 1 and t...
# Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'targets': [ # Disable DYNAMICBASE for these tests because it implies/doesn't imply # FIXED in certain cases so it complicates the test for FIXED. {...
# Python program to Find Numbers divisible by Another number def main(): x=int(input("Enter the number")) y=int(input("Enter the limit value")) print("The Numbers divisible by",x,"is") for i in range(1,y+1): if i%x==0: print(i) if __name__=='__main__': main()
#给定一个二维的矩阵,包含 'X' 和 'O'(字母 O)。 # # 找到所有被 'X' 围绕的区域,并将这些区域里所有的 'O' 用 'X' 填充。 # # 示例: # # X X X X #X O O X #X X O X #X O X X # # # 运行你的函数后,矩阵变为: # # X X X X #X X X X #X X X X #X O X X # # # 解释: # # 被围绕的区间不会存在于边界上,换句话说,任何边界上的 'O' 都不会被填充为 'X'。 任何不在边界上,或不与边界上的 'O' 相连的 'O' 最终都会被填充为 'X'。如果两个元素在水平或垂直方向相邻,则称它们是“相连”的。 # Related ...
class multi(): def insert(self,num): for i in range(1, 11): print(num, "X", i, "=", num * i) d=multi() d.insert(num=int(input('Enter the number')))
a = 67 b = 1006 c = 1002 """if (a>=b and a>=c): print(a) elif (b>=c and b>=a) : print(b) elif (b>=a and b>=b) : print(c)""" max=a if a>=b: if b>=c: max =a else: if a>=c: max =a else: max = c else: if a>=c: max =b else: if b>=c: ...
""" Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome. Note: Have you consider that the string might be empty? This is a good question to ask during an in...
for value in range(10): print(value) print('All Done!')
""""" Datos de Entrada N Enteros Positivos = n = int K Enteros Positivos = k = int Datos de Salida Siempre que k sea menor a n Cuando N = K """"" n=int(input("Escriba el primer digito ")) k=int(input("Escriba el primer digito ")) while True: n=0 if(k<n): n=n-1 print(n) elif(n==k): ...
def shift_letter(char, shifts): if not isinstance(char, chr): raise ValueError('char should be typeof chr') if char == '' or char is None: raise ValueError('char should be typeof chr') if ord(char.upper()) < 65 or ord(char.upper()) > 90: raise ValueError('char should be only a-z Lati...
i = 1 while i < 20: print(i) i += 1 i = 1 while i < 100: print(i) i += 1 i = 50 while i < 60: print(i) i += 1 i = 5 while i < 60: print(i) i += 1 i = 1 while i < 6: print(i) if (i == 3): break i += 1 k = 1 while k < 20: print(k) ...
def count_words(message): #return len(message.split()) # words = [] count = 0 activeWord = False for c in message: if c.isspace(): activeWord = False else: if not activeWord: # words.append([]) count += 1 activeW...
class BufferFullException(Exception): def __init__(self, msg): self.msg = msg class BufferEmptyException(Exception): def __init__(self, msg): self.msg = msg class CircularBuffer: def __init__(self, capacity): self.list_circulator = list() self.list_circulator.append(','.jo...
DOMAIN = "microsoft_todo" CONF_CLIENT_ID = "client_id" CONF_CLIENT_SECRET = "client_secret" AUTH_CALLBACK_PATH = "/api/microsoft-todo" AUTHORIZATION_BASE_URL = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize" TOKEN_URL = "https://login.microsoftonline.com/common/oauth2/v2.0/token" SCOPE = ["Tasks.ReadW...
input = """ c | d. a | b :- c. a :- b. b :- a. """ output = """ {d} {c, a, b} """
class HouseScheme: def __init__(self, rooms, area, bathroomAvailability): if (area < 0) or ((bathroomAvailability is not True) and (bathroomAvailability is not False)): raise ValueError("Invalid value") self.rooms = rooms self.area = area self.bathroomAvailability...
def parse_response_from_json(r): response = '' try: response = r.json()['response'] except Exception as ex: response = str(ex) return response
# [Commerci Republic] Delfino Deleter 2 sm.setSpeakerID(9390256) # Leon Daniella sm.sendNext("I was so much faster than you! But you're the sidekick for a reason.") sm.sendNext("C'mon! We can't let them get their buddies. We have to finish this now! I'll be waiting for you at #m865020200#") # Canal 3 sm.sendNext("Wh...
ans=0 n=200 def f(n): fac=[0]*(n+10) fac[0]=1 for i in range(1,n+5): fac[i]=i*fac[i-1] return fac def c(n,m): return fac[n]//fac[n-m]//fac[m] def solve(i,asn,b,other): res=0 if i>b: if other>b+1: return 0 else: t=fac[b+1]//fac[b+1-other] for j in asn: if j: t//=fac[j] return t for j i...
a='ala ma kota' print(a) a=u'ala ma kota' print(a) a='ala'+'ma'+'kota' print(a) print(len(a)) if(a[:1]=='a'): print(a[-4]) else: print('No nie za brdzo') print('{0}, {1}, {2}'.format(*'abc')) a = 'Psa' print('%s ma %s' % (a,a))
distancia = int(input('Digite a distância de sua viagem: ')) if distancia > 200: print('O custo total de sua passagem é R${:.2f}'.format(0.45*distancia)) else: print('O custo total de sua passagem é R${:.2f}'.format(0.50 * distancia))
class ElectricMotor: """A class used to model an electric motor Assumptions: - linear magnetic circuit (not considering flux dispersions and metal saturation when high currents are applied) - only viscous friction is assumed to be present (not considering Coulomb frictions) - stator is ...
scan_utility_version = '1.0.11' detect_jar = "/tmp/synopsys-detect.jar" # workflow_script = "/Users/mbrad/working/blackduck-scan-action/blackduck-rapid-scan-to-github.py" # detect_jar = "./synopsys-detect.jar" # workflow_script = "/Users/jcroall/PycharmProjects/blackduck-scan-action/blackduck-rapid-scan-to-github.py" d...
""" 230. Kth Smallest Element in a BST """ # 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: def kthSmallest(self, root: TreeNode, k: int) -> int: A = [] ...
def collateFunction(self, batch): """ Custom collate function to adjust a variable number of low-res images. Args: batch: list of imageset Returns: padded_lr_batch: tensor (B, min_L, W, H), low resolution images alpha_batch: tensor (B, min_L), low resolution indicator (0 if pa...
class Pagination(object): def __init__(self,totalCount,currentPage,perPageItemNum=10,maxPageNum=7): # 数据总个数 self.total_count = totalCount # 当前页 try: v = int(currentPage) if v <= 0: v = 1 self.current_page = v except Exceptio...
destination = input() current_money = 0 while destination != 'End': vacation_money = float(input()) while current_money < vacation_money: work_money = float(input()) current_money += work_money print(f'Going to {destination}!') current_money = 0 destination = input()
"""Internal exception classes.""" class UnsatisfiableConstraint(Exception): """Raise when a specified constraint cannot be satisfied.""" pass class UnsatisfiableType(UnsatisfiableConstraint): """Raised when a type constraint cannot be satisfied.""" pass class TreeConstructionError(Exception): ...
class Book: def __init__(self, title, bookType): self.title = title self.bookType = bookType
XK_Aogonek = 0x1a1 XK_breve = 0x1a2 XK_Lstroke = 0x1a3 XK_Lcaron = 0x1a5 XK_Sacute = 0x1a6 XK_Scaron = 0x1a9 XK_Scedilla = 0x1aa XK_Tcaron = 0x1ab XK_Zacute = 0x1ac XK_Zcaron = 0x1ae XK_Zabovedot = 0x1af XK_aogonek = 0x1b1 XK_ogonek = 0x1b2 XK_lstroke = 0x1b3 XK_lcaron = 0x1b5 XK_sacute = 0x1b6 XK_caron...
load( "//scala:scala.bzl", "scala_library", ) load( "//scala:scala_cross_version.bzl", _default_scala_version = "default_scala_version", _extract_major_version = "extract_major_version", _scala_mvn_artifact = "scala_mvn_artifact", ) load( "@io_bazel_rules_scala//scala:scala_maven_import_exte...
# TimeTracker config # By Clok Much # # ver.1 # # 已废弃 class Default: track_time = 30 # 统计周期 int ,单位为 秒 ,指定时间为间隔,进行一次统计 graph_time = 5 # 绘图周期 int ,单位为 次 ,指定次数的统计时间后,进行一次数据输出和绘图 period = 8 # 将指定天数之前的数据视为过期数据,将之压缩并保存在 sub_dir output_dir = 'V:\\TimeTracker\\' # 统计结果输出的主目录 sub_dir = 'storage\...
def EDFB(U): if U>1: return False else: return True def SC_EDF(tasks): U=0 for itask in tasks: U+=(itask['execution']+itask['sslength'])/itask['period'] return EDFB(U)
""" Write a Python function that takes a number as an input from the user and computes its factorial. Written by Sudipto Ghosh for the University of Delhi """ def factorial(n): """ Calculates factorial of a number Arguments: n {integer} -- input Returns: factorial {integer} """ ...
#Faça um programa que leia um número inteiro e diga se ele é ou não um número primo. num = int(input('Digite um número: ')) total = 0 for c in range(1, num + 1): if num % c == 0: total += 1 if total == 2: print(f'O numero {num} é primo') else: print(f'O número {num} não é primo')
#buffer = [0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x80, 0x25, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00] #buffer = [0xB5, 0x62, 0x06, 0x09, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] #buffer = [0xB5, 0x62, 0x06, 0x3B,...
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param: he...
ifXTable = '.1.3.6.1.2.1.31.1.1.1' ifName = ifXTable + '.1' ifInMulticastPkts = ifXTable + '.2' ifHCInOctets = ifXTable + '.6' ifHCInUcastPkts = ifXTable + '.7' ifHCInMulticastPkts = ifXTable + '.8' ifHCInBroadcastPkts = ifXTable + '.9' ifHCOutOctets = ifXTable + '.10' ifHCOutUcastPkts = ifXTable + '.11' ifHCOutMultica...
# from django.views.generic.base import View # from rest_framework.views import APIView # from django.conf import settings #!/usr/bin/env python # def func(): # fun_list = [] # for i in range(4): # def foo(x, i=i): # return x*i # fun_list.append(foo) # return fun_list # # # for...
# modifying a list in a function # Start with some designs that need to be printed. unprinted_designs = ['phone case', 'robot pendant', 'dodecahedron'] completed_models = [] # Simulate printing each design, until none are left. # Move each design to completed_models after printing. while unprinted_designs: curren...
def foo(): x = 1 def bar(): nonlocal x baz() print(x) def baz(): nonlocal x x = 2 bar() foo()
"""Constants for the onboarding component.""" DOMAIN = "onboarding" STEP_USER = "user" STEP_CORE_CONFIG = "core_config" STEP_INTEGRATION = "integration" STEP_ANALYTICS = "analytics" STEP_MOB_INTEGRATION = "mob_integration" STEPS = [ STEP_USER, STEP_CORE_CONFIG, STEP_ANALYTICS, STEP_INTEGRATION, STE...
class MovieData: def __init__(self,movie_name,imdb_id,plot,review,facts_table,comments,spans,labels,chat,chat_id): self.movie_name=movie_name self.imdb_id=imdb_id self.plot=plot self.review=review self.facts_table=facts_table self.comments=comments s...
# when not using https CSRF_COOKIE_SECURE = False SESSION_COOKIE_SECURE = False #SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SECURE_PROXY_SSL_HEADER = None #https://docs.djangoproject.com/en/3.0/ref/settings/#secure-proxy-ssl-header #A tuple representing a HTTP header/value combination that # si...
# Tests: # ifstmt ::= testexpr _ifstmts_jump # _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM if True: b = False
class Solution: def checkEqualTree(self, root: Optional[TreeNode]) -> bool: if not root: return False seen = set() def dfs(root: Optional[TreeNode]) -> int: if not root: return 0 sum = root.val + dfs(root.left) + dfs(root.right) seen.add(sum) return sum sum = ...
#!/usr/bin/env python3 # Example: 3 Integer Printing (Recursion) # Print integers relative to various bases # i.e. printInteger(61,2) → 111101 # printInteger(61,10) → 61 def rec_printInteger(n, b): str = '0123456789ABCDEF' if n < b: return str[n] # base case else: return rec_printI...
# color references: # http://rebrickable.com/colors # http://www.bricklink.com/catalogColors.asp rebrickable_color_to_bricklink = { # Solid Colors 15: (1, 'White'), 503: (49, 'Very Light Gray'), 151: (99, 'Very Light Bluish Gray'), 71: (86, 'Light Bluish Gray'), 7: (9, 'Light Gray'), 8: (10, 'Dark Gray'), ...
""" Root-level catalog interface """ class ValidationError(Exception): pass class PrivateArchive(Exception): pass class EntityNotFound(Exception): pass class NoAccessToEntity(Exception): """ Used when the actual entity is not accessible, i.e. when a ref cannot dereference itself """ p...
def get_gender(sex='unknown'): if sex == 'm': sex = 'male' elif sex == 'f': sex = 'female' print(sex) get_gender('m') get_gender('f') get_gender()
# 選択肢が書き換えられないようにlistではなくtupleを使う chose_from_two = ('A', 'B', 'C') answer = [] answer.append('A') answer.append('C') print(chose_from_two) # ('A', 'B', 'C') print(answer) # ['A', 'C']
palavras = ('programacao','nomes','legal','que bacana','yeaaah','astronomia') for i in palavras: print(f"Na palavra {i} há as vogais", end=' ') for j in i: if j.lower() in ('aeiou'): print (f"{j}", end=',') print("\n")
description = 'Example Sans2D Pixel Detector Setup with Instrument View' group = 'basic' sysconfig = dict( instrument = 'sans2d', ) devices = dict( sans2d = device('nicos_demo.mantid.devices.instrument.ViewableInstrument', description = 'instrument object', responsible = 'R. Esponsible <r.esp...
class Student: def __init__(self,name="",roll=2): print("para init called") self.name=name self.roll_no=roll def hello(self): print("Hello this is: ",self.name) print("Your roll no. is: ",self.roll_no)
description = 'pressure filter readout' group = 'lowlevel' devices = dict( # p_in_filter = device('nicos_mlz.sans1.devices.wut.WutValue', # hostname = 'sans1wut-p-diff-fak40.sans1.frm2', # port = '1', # description = 'pressure in front of filter', # fmtstr = '%.2F', # logle...
#Python doesn't support Generics #you can do it like this in java or C++ or #any other Object Oriented language which supports Generics class AdvancedArithmetic(object): def divisorSum(n): raise NotImplementedError class Calculator(AdvancedArithmetic): def divisorSum(self, n): di...
class Solution: def solve(self, nums, k): history = [nums[:]] seen = {tuple(nums)} before_cycle = [] cycle = [] while True: nums2 = [0]*8 for i in range(1,7): l = (nums[i-1] if i-1 >= 0 else 0) + (nums[i+1] if i+1 < 8 else 0) ...
expected_output = { "Tunnel10": { "bandwidth": 100, "counters": { "in_abort": 0, "in_broadcast_pkts": 0, "in_crc_errors": 0, "in_errors": 0, "in_frame": 0, "in_giants": 0, "in_ignored": 0, "in_multicast_p...
input = open('input.txt'); length = int(input.readline()); tokens = input.readline().split(' '); input.close(); output = open('output.txt' , 'w'); i = 0; while i < length: j = 0; while (int(tokens[i]) >= int(tokens[j])) & (j < i): j += 1; if j < i: shelf = tokens[i]; k = i; w...
MSG_START = "Hello, {name}\!\n\nPlease, choose your language\." MSG_NOTIFY_EN = ( """Hello, {first_name}\!\n\n""" """As of {timestamp}, your order `{id}` has arrived to our base.\n""" """We are going to deliver it to your address _{address}_ no later than in 3 days.\n\n""" """*Product Details:*\n...
#!/usr/bin/env python ''' 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 ASF licenses this file to you under the Apache License, Version 2.0 (the "License")...
expected_output = { "ospf-database-information": { "ospf-area-header": {"ospf-area": "192.168.76.0"}, "ospf-database": { "@heading": "Type ID Adv Rtr Seq Age Opt Cksum Len", "advertising-router": "192.168.219.235", "age": "173...
# 1.Why carry is a&b: # If a and b are both 1 at the same digit, it creates one carry. # Because you can only use 0 and 1 in binary, if you add 1+1 together, it will roll that over to the next digit, and the value will be 0 at this digit. # if they are both 0 or only one is 1, it doesn't...
while True: h = int(input()) if h == 0: break arr = list() arr.append(h) while h != 1: if h%2 == 0: h = int((0.5)*h) arr.append(h) else: h = 3 * h + 1 arr.append(h) # print(arr) print(max(arr))
def read_input(): row, col = [int(x) for x in input().split()] arr = [list(input()) for _ in range(row)] return arr def print_output(obj): for i in obj: print(''.join(i)) def test_pos(obj, grid, row, col): for i in range(len(obj)): for j in range(len(obj[0])): if grid...
# import pytest class TestSingletonMeta: def test___call__(self): # synced assert True class TestSingleton: pass
i = 0 result = 0 while i <= 100: if i % 2 == 0: result += i i += 1 print(result) j = 0 result2 = 0 while j <= 100: result2 += j j += 2 print(result2)
# test for PR#112 -- functions should not have __module__ attributes def f(): pass if hasattr(f, '__module__'): print('functions should not have __module__ attributes') # but make sure classes still do have __module__ attributes class F: pass if not hasattr(F, '__module__'): print('classes should st...
# kano00 # https://adventofcode.com/2021/day/10 def calc1(chunk_list): left_brankets = ["(", "[", "{", "<"] right_brankets = [")", "]", "}", ">"] scores = [3,57,1197,25137] res = 0 def calc_points(chunk): stack = [] for c in chunk: for i in range(4): if ...
def show_magicians(magician_names, great_magicians): """Transfer the lis of magician in the great list""" while magician_names: magician = magician_names.pop() great_magicians.append(magician) def make_great(great_magicians): """Print the new list of magicians""" for great_magician in g...
#!/usr/bin/python li = [1, 2, 3, 1, 4, 5] # wrong 1 for v in li: if v == 1 or v == 2: li.remove(v) # wrong 2 for idx, v in enumerate(li): if v == 1 or v == 2: del li[idx] # wrong 3 for idx, v in enumerate(li[:]): if v == 1 or v == 2: del li[idx] # not recommend for v in li[:]: ...
def candidate_selection(wn, token, target_lemma, pos=None, gold_lexkeys=set(), debug=False): """ return candidate synsets of a token :param str token: the token :param str targe_lemm...
""" Write a Python function to map two lists into a dictionary. list1 contains the keys, list2 contains the values. Input lists: list1 = [1,2,3,4,5] list2 = [6,7,8,9,10] Expected output: {1: 6, 2: 7, 3: 8, 4: 9, 5: 10} """ #Solution is: def map_lists(list1,list2): return (dict(zip(list1,list2)))
largest = None smallest = None numbers = list() while True: num = input('Enter a number: ') if num == "done": if numbers == []: max = '(no input)' min = '(no input)' else: max = max(numbers) min = min(numbers) break try: num ...
# Iterable Data # - String # - List # - Set # - Dictionary for x in [3,5,2]: print(x) for x in "abc": print(x) for x in {"x":"123", "a":"456"}: print(x) ########## # max(iterable data) # sorted (iterable data) result=max([30, 20, 50, 10]) print(result) result2=sorted([30, 20, 50, 10]) print(result2)
print(population/area) # De indices worden gebruitk om te achterhalen welke elementen bij elkaar horen. # Strings kun je gewoon optellen! df1 = make_df(list('AB'), range(2)) # print(df1) df2 = make_df(list('ACB'), range(3)) # print(df2) print(df1+df2) # Alleen overeenkomstige kolommen zijn gebruikt, en de volgorde va...
class Solution(object): def XXX(self, root): """ :type root: TreeNode :rtype: int """ if not root: return 0 return max (self.XXX(root.left)+1 , self.XXX(root.right)+1)
n = int(input()) dot = (2 ** n) + 1 result = dot * dot print(result)
var1 = "Hello " var2 = "World" # + Operator is used to combine strings var3 = var1 + var2 print(var3)
#x = 3 #x = x*x #print(x) #y = input('enter a number:') #print(y) #x = int(input('Enter an integer')) #if x%2 == 0: # print('Even') #else: # print('Odd') # if x%3 != 0: # print('And not divisible by 3') #Find the cube root of a perfect cube #x = int(input('Enter an integer')) #ans = 0 #while ans*ans*an...
class Order: def __init__(self, orderInfo): self.order_id = orderInfo[0] self.customer_id =int(orderInfo[1]) self.order_date = orderInfo[2] self.status = orderInfo[3] self.total_price = float(orderInfo[4]) self.comment = orderInfo[5]
# # PySNMP MIB module Unisphere-Data-Registry (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Unisphere-Data-Registry # Produced by pysmi-0.3.4 at Wed May 1 15:31:00 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 6 19:14:57 2019 @author: athreya """ #Python Programming #Print function: Prints the given text within single/double quotes print('Hi wecome to Python!') #Hi wecome to Python! print("Hello World") #Hello World #Strings: Text in Python is consid...
RULE_TO_REMOVE = \ """ { "data-source-definition-name": "__RuleToRemove", "model-id": "__RuleToRemove", "model-description": "System DSD for marking rules to be removed.", "can-reflect-on-web": false, "fields": [ { "field-name": "rule_name", "type": "STRING", ...
# el binary searc solo sirve con una lista ordenada def run(): sequence = [1,2,3,4,5,6,7,8,9,10,11] print(binary_search(sequence,-5)) def binary_search(list,goal,start=None,end=None): if start is None: start = 0 if end is None: end = len(list)-1 midpoint = (start + end)...
# Func11.py def calc(n,m): return [n+m, n-m, n*m, n/m] print(calc(20, 10)) a,b,c,d = calc(20,10) print(a,b,c,d) # + - * / def swap(n,m): return m, n x= 200 y= 100 x,y = swap(x,y) print(x,y) # 100, 200
""" DeskUnity """ class Event: TEST = "TEST" CONNECTION_TEST = "CONNECTION_TEST" MOVE_MOUSE = "MOVE_MOUSE" MOUSE_LEFT_DOWN = "MOUSE_LEFT_DOWN" MOUSE_LEFT_UP = "MOUSE_LEFT_UP" MOUSE_RIGHT_DOWN = "MOUSE_RIGHT_DOWN" MOUSE_RIGHT_UP = "MOUSE_RIGHT_UP" MOUSE_WHEEL = "MOUSE_WHEEL" KEY...