content
stringlengths
7
1.05M
# -*- coding: utf-8 -*- """ Created on Fri May 31 16:00:39 2019 @author: Administrator """ class Solution: def flipAndInvertImage(self, A: list) -> list: for a in A: p, q = 0, len(a)-1 while p<=q: if p == q: a[p] = 1 - a[p] br...
""" Given a 32-bit signed integer, reverse digits of an integer. """ class Solution: def isPalindrome(self, x: int) -> bool: if x < 0: s = str(x) s = s[1:] a = int(s[::-1]) return -a else: s = str(x) return int(s[::-1]) prin...
result = [] for count in range (1,100): if count % 3 == 0: result.append("Fizz") if count % 5 == 0: result.append("Buzz") else: result.append(count) print(result)
def on_data_received(): global cmd cmd = serial.read_until(serial.delimiters(Delimiters.HASH)) basic.show_string(cmd) if cmd == "0": basic.show_leds(""" . # # # . . # . # . . # . # . . # . # . ...
class SgfTree(object): def __init__(self, properties=None, children=None): self.properties = properties or {} self.children = children or [] def __eq__(self, other): if not isinstance(other, SgfTree): return False for k, v in self.properties.items(): if k...
# <<<DBGL8R>>> def add_floats(float_1, float_2): """ Add two floating point numbers together. """ return float_1 + float_2 print('Hello world') # <<<DBGL8R
class ListView: __slots__ = ['_list'] def __init__(self, list_object): self._list = list_object def __add__(self, other): return self._list.__add__(other) def __getitem__(self, other): return self._list.__getitem__(other) def __contains__(self, item): return self....
def print_with_linenumbers(*args, numberwidth=3): """Prints every argument in a new line and adds line numbers""" for i,arg in enumerate(args): print(f"{i:0{numberwidth}d}: {arg}")
class DSSnet_hosts: 'class for meta process/IED info' p_id = 0 def __init__(self, msg, IED_id, command, ip, pipe = True): self.properties= msg self.IED_id = IED_id self.process_id= DSSnet_hosts.p_id self.command = command self.ip = ip self.pipe = pipe...
''' Longest Increasing Subarray Find the longest increasing subarray (subarray is when all elements are neighboring in the original array). Input: [10, 1, 3, 8, 2, 0, 5, 7, 12, 3] Output: 4 ========================================= Only in one iteration, check if the current element is bigger than the previous and i...
# This method breaks up text into words for us def break_words(text): words = text.split() return words # Counts the number of words def count_words(words): return len(words) # Sorts the words (alphabetically) def sort_words(words): words.sort() return words # Takes in a full sentence and returns...
class Damper: def __init__(self): self.damper_force0 = 0 def d_damper_force(self, force, action): damper_force = force * -action # AIが決定するパラメータで、与えられた力に対して、どんな割合で力を返すかを決める値 d_damper_force = damper_force - self.damper_force0 self.damper_force0 = damper_force return d_damp...
# Faça um programa que peça um número inteiro e determine se ele é ou não um número primo. Um número primo é aquele que é divisível somente por ele mesmo e por 1. num = int(input("Digite um número inteiro: ")) tot = 0 for c in range(1, num+1): if num % c == 0: print('\033[33m', end="") tot += 1 ...
def esc_kw(kw): """ Take a keyword and escape all the Solr parts we want to escape!""" kw = kw.replace('\\', '\\\\') # be sure to do this first, as we inject \! kw = kw.replace('(', '\(') kw = kw.replace(')', '\)') kw = kw.replace('+', '\+') kw = kw.replace('-', '\-') kw = kw.replace...
def main(): # input a, b = input().split() # compute # output print('H' if a==b else 'D') if __name__ == '__main__': main()
# -*- coding: utf-8 -*- description = 'DNS detector setup' group = 'lowlevel' includes = ['counter'] sysconfig = dict( datasinks = ['LiveView'], ) tango_base = 'tango://phys.dns.frm2:10000/dns/' devices = dict( LiveView = device('nicos.devices.datasinks.LiveViewSink', ), dettof = device('nicos_mlz....
#/* n=int(input("Enter the number to print the tables for:")) #for i in range(1,11): # print(n,"x",i,"=",n*i) n=int(input("Enter the number")) for i in range(1,11): print (n ,"x", i, "=", n * i)
# -*- coding: utf-8 -*- """ File: config.sample.py - Copy `config.sample.py` to `config.py`. """ # Subscription Key for calling the Cognitive Face API. FACE_API_KEY = "your_face_api_key" # subscription key for speach API SPEACH_API_KEY = "your_speach_api_key" # Base URL for calling the Cognitive Face API. BASE_URL =...
class CMDDiffLevelEnum: BreakingChange = 1 # diff breaking change part Structure = 2 # Associate = 5 # include diff for links All = 10 # including description and help messages
def isColoured(mult,i,j): if i//mult%2==j//mult%2: return True return False def colour(i,j): col = False for each in mults: if isColoured(each,i,j): col = (col==False) return col data = open("DATA21.txt") input = data.readline for j in range(10): n = int(input()) mults = [] for i in ...
def is_narcissistic_number(n): original_number = n number_of_digits = get_number_of_digits(n) sum = 0 while n != 0: sum += (n % 10) ** number_of_digits n //= 10 return original_number == sum def get_number_of_digits(n): return len(str(n)) if __name__ == "__main__": n = ...
# Program to work with file input / output (i/o) # This is pulling the days.txt file in this directory in this repo path = 'days.txt' days_file = open(path,'r') days = days_file.read() new_path = 'new_days.txt' new_days = open(new_path,'w') title = 'Days of the Week\n' new_days.write(title) print(title) new_days.w...
#!/usr/bin/env python # coding: utf-8 # In[3]: # DEMO OF WEAK TYPING in PYTHON # int age = 4 <-strongly typed variables, declare type along with id age = 4; # we CANNOT declare a type for variable age print(age) print(type(age)) age = ('calico','calico','himalyian') print(age) print(type(age)) # # Allegheny county...
""" Created on October 15, 2019 This file is subject to the terms and conditions defined in the file 'LICENSE.txt', which is part of this source code package. @author: David Moss """ # Task priorities TASK_PRIORITY_DETAIL = 0 TASK_PRIORITY_INFO = 1 TASK_PRIORITY_WARNING = 2 TASK_PRIORITY_CRITICAL = 3 def update_tas...
""" topc: 实现迭代器协议 desc: 构建一个能支持迭代操作的自定义对象,并希望找到一个能实现迭代协议的简单方法。 """ class Node: def __init__(self, value): self._value = value self._children = [] def __repr__(self): return 'Node({!r})'.format(self._value) def add_child(self, node): self._children.append(node) def __...
class Rectangle(object): def __init__(self, x, y): self._x = x # don't trigger _setSide prematurely self.y = y # now trigger it, so area gets computed def _setSide(self, attrname, value): setattr(self, attrname, value) self.area = self._x * ...
orders = ["daisies", "periwinkle"] print(orders) orders.append("tulips") orders.append("roses") print(orders)
#6. As Organizações Tabajara resolveram dar um aumento de salário aos seus colaboradores e lhe contraram para # desenvolver o programa que calculará os reajustes. # Faça um programa que recebe o salário de um colaborador e o reajuste segundo o seguinte critério, baseado no salário atual: # salários até R$ 280,00 (inc...
def test_parameters(api_client, api_prefix): url = f"{api_prefix}/parameterset/" response = api_client.get(url) assert response.status_code == 200 json_dict = response.json expected = { "parameter_list_url": f"{api_prefix}/parameters/", "parameter_set": { "name": None, ...
#! /usr/bin/python3 DATA_FILENAME = "data.txt" data_file = open(DATA_FILENAME, 'r') # open the file for reading date_string = data_file.readline() date_string = date_string.strip() year, month, day = tuple(date_string.split('-')) year, month, day = int(year), int(month), int(day) month_names = {1:'January', 2:'Februa...
# Version-specific constants - EDIT THESE VALUES VERSION_NAME = "Version003 - Brute Force, Even Smarter Iteration" VERSION_DESCRIPTION = """ A slightly more formulaic approach, but still iterative. """ def solution(resources, args): """Problem 1 - Version 3 Use a formula to determine the additional sum 15 int...
""" link: https://leetcode-cn.com/problems/find-mode-in-binary-search-tree problem: 给二叉排序树,求其众数,要求空间O(1) solution: 中序遍历记录前访问值。 """ class Solution: def findMode(self, root: TreeNode) -> List[int]: res, m, pre, cnt = [], 1, -1, 0 def dfs(k: TreeNode): if not k: return ...
# Author: SAHIL SAINI # This script helps to count number of words, number of lines and number of characters from a file def countWords(fileName): numwords = 0 numchars = 0 numlines = 0 with open(fileName, 'r') as file: for line in file: wordlist = line.split() numlines...
def handle_error_response(resp): codes = { -1: FATdAPIError, -32600: InvalidRequest, -32601: MethodNotFound, -32602: InvalidParam, -32603: InternalError, -32700: ParseError, -32800: TokenNotFound, -32801: InvalidToken, -32802: InvalidAddress, ...
class Hitbox: def __init__(self): pass def point_inside(self, obj, point): return False class Box(Hitbox): def __init__(self, width, height): Hitbox.__init__(self) self.width = width self.height = height def point_inside(self, obj, pos): x = obj.x y = obj.y xm = x + (self.width*obj.scale) ym =...
def Function(anumber): if anumber == 1: print ("One") elif anumber == 2: print ("Two") elif anumber == 3: print ("Three") elif anumber == 4: print ("Four") elif anumber == 5: print ("Five") elif anumber == 6: print ("Six") elif anumber == 7: ...
def disp(*txt, p): print(*txt) ask = lambda p : p.b(input()) functions = {">>":disp,"?":ask}
''' Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number.Return the decimal value of the number in the linked list. Example : 1 ---> 0 ---> 1 Input: head = [1,0,1] Output: 5 Explanation: (...
val = int(input(print("Enter a number: "))) option = { "n":"Nae nigga nae \n", "c":"Uohhhhhh :sob::sob::sob: \n", "i":"I am living in your walls, oomfie. \n" } userinput = input("Choose your poison: [N]iggas, [C]unny, [I]solation") with open("outputtings.txt",'w') as f: f.write(option[userinput.l...
''' Ganon's Tower ''' __all__ = 'LOCATIONS', LOCATIONS = { "Ganon's Tower Entrance (I)": { 'type': 'interior', 'link': { 'Castle Tower Entrance (E)': [('settings', 'inverted')], "Ganon's Tower Entrance (E)": [('nosettings', 'inverted')], "Ganon's Tower Lobby": ...
class Codec: def __init__(self): self.codec_dict = dict() self.codec_reversed = dict() self.codec_len = 0 def encode(self, longUrl: str) -> str: """Encodes a URL to a shortened URL. """ if longUrl not in self.codec_dict: self.codec_dict[longUrl]=self....
# -*- coding: utf-8 -*- """ Created on Wed May 22 17:54:15 2019 @author: Parikshith.H """ L1 = [10,20,30,40] print(L1) print(L1[0]) print(L1[3]) L1[3] = 50 print(L1) #output: # ============================================================================= # [10, 20, 30, 40] # 10 # 40 # [10, 20, 30, 50] # ===========...
def siOr(s0, s1): '''Performs s0 | s1 where s0 and s1 are lists of sections or intervals''' actSec = [False, False] secs = [] k0 = [i for s in s0 for i in s] k1 = [i for s in s1 for i in s] keyPoints = list(sorted([(k, 0) for k in k0] + [(k, 1) for k in k1], key=lam...
class Solution: def numIslands(self, grid: 'List[List[str]]') -> 'int': if not grid: return 0 no_lines = len(grid) no_cols = len(grid[0]) def solve(line_idx, col_idx): grid[line_idx][col_idx] = '-1' queue = [(line_idx, col_idx)] idx =...
a = [[3,],[]] for x in a: x.append(4) # print (x) print (a) b= [] for x in b: print (3) print (x)
filename='pi_million_digits.txt' with open(filename) as file_object: lines=file_object.readlines() pi_string='' for line in lines: pi_string+=line.strip() birthday=input("Enter your birthday, in the form mmddyy:") if birthday in pi_string: print("Your birthday appears in the first millions digits of pi!") ...
""" This module is used to define constants used throughout the code. It should not depend on any other part of the globus-cli codebase. (If you need to import something else, maybe it's not simple enough to be a constant...) """ __all__ = ["EXPLICIT_NULL"] class _ExplicitNullClass: """ Magic sentinel value...
"""https://adventofcode.com/2021/day/21""" class Die: def __init__(self, sides=100): self.sides = sides self.value = 0 self.rolled = 0 def roll(self): self.rolled += 1 self.value = self.value % self.sides + 1 return self.value data = open("day-21/input.txt", ...
def outer(): def inner(): print(out_var) out_var = 10 inner() if "__main__" == __name__: outer()
# Copyright (c) Vera Galstyan Jan 2018 favorite_places ={ 'vera': ['lyon','paris','london'], 'ofa':['berlin','madrid','milan'], 'karen':['dubai','barcelona'] } for name,places in favorite_places.items(): print("\n" + name + "'s favorite places are:") for place in places: print(place)
number1 = 10 pi_number = 3.1415 img_number = -10+4j first_name = 'kaveh' last_name = "mehrbanian" bio = """some description about me""" is_sad = False is_happy = True initial_value = None
# -*- coding: utf-8 -*- # See /usr/include/sysexits.h EX_OK = 0 EX_USAGE = 64 EX_DATAERR = 65 EX_NOUSER = 67 EX_PROTOCOL = 76 EX_TEMPFAIL = 75 EX_CONFIG = 78 # Standard for Bash: <http://www.tldp.org/LDP/abs/html/exitcodes.html> EX_CTRL_C = 130 exit_vals = { 'success': EX_OK, 'config_error': EX_CONFIG, 'url...
class bidict(dict): """Bi-directional dictionary for label Lookup. Implementation by Basj :param dict: dictionnary to be made bi-directional :type dict: dict """ def __init__(self, *args, **kwargs): super(bidict, self).__init__(*args, **kwargs) self.inverse = {} for key, va...
# 可用来判断该文件是否为入口文件,并做一些逻辑 if __name__ == '__main__': print('this is app') print('this is module')
class Error: def __init__(self, error_type: str, details: str, file: str, line: int, column: int): self.error_type = error_type self.details = details self.file = file self.line = line self.column = column def __repr__(self): return "{} ERROR: '{}', fi...
# -*- coding: utf-8 -*- ''' Escreva a sua solução aqui Code your solution here Escriba su solución aquí ''' vendedor = input() salario_fixo = float(input()) total_vendas = float(input()) TOTAL = salario_fixo + total_vendas * 0.15 print("TOTAL = R$ %.2f" %TOTAL)
#!/usr/bin/env python3 def main(): s = str(input('What country are you from? ')) print('I have heard that {0} is a beautiful country.'.format(s)) if __name__ == "__main__": main()
{ "targets": [ { "target_name": "nodeNativeInput", "sources": [ "src/nodeNativeInput.cpp", "src/getOne/getOne.cpp", "src/getTwo/getTwo.cpp", "src/getThree/getThree.cpp" ], "include_dirs": ["<!(node -e \"require('nan')\")"], "conditions": [ ["OS...
# -*- coding: utf-8 -*- """Test file.""" """ >>> from pyrgg import * >>> import pyrgg.params >>> import random >>> import os >>> import json >>> import yaml >>> import pickle >>> pyrgg.params.PYRGG_TEST_MODE = True >>> get_precision(2) 0 >>> get_precision(2.2) 1 >>> get_precision(2.22) 2 >>> get_precision(2.223) 3 >>> ...
# working with strings # function to sort frase def sort(str): print(f'Frase usando sorting: {str[num_sorts1:num_sorts2]}') # function to print frase 2 in 2 def print_f(str): print(str[::2]) print('Frase de 2 en 2: ') for e in str[::2]: print(f'{e}', end='') # functional def print_str(str, num_...
message_decrypter=input("Votre message a decrypter:") cle=int(input("Nombre de decalage ?:")) longueur=len(message_decrypter) i=0 alph="" resultat="" for i in range(longueur): asc=ord(message_decrypter[i]) if asc>=65 or asc<=90: asc=asc-cle resultat=resultat+chr(asc) print (resultat)
class VowelConsonant: def __init__(self): """Heuristic strategy: place words that are have either more vowels of consonants based on the letters remaining in the rack_tiles""" # Row below not needed but given for refrence of constants # constants ["b", "c", "d", "f", "g", "h", "j",...
class Kilobyte: def __init__(self, value_kilobytes: int): self._value_kilobytes = value_kilobytes self.one_kilobyte_in_bits = 8000 self._value_bits = self._convert_into_bits(value_kilobytes) self.id = "KB" def _convert_into_bits(self, value_kilobytes: int) -> int: return value_kilobytes * self.one_kilobyt...
class Credential: """ Class that generates new instances of Credentials . """ Credential_list = [] # Empty User list def __init__(self,Account,user_name,password): # docstring removed for simplicity self.Account= Account self.user_name = user_name self.password ...
def matchmaking(): people = [ { 'name': "Мария", 'interests': ['пътуване', 'танци', 'плуване', 'кино'], 'age': 24, 'gender': "female", "ex": ["Кирил", "Петър"], }, { 'name': "Диана", 'interests': ['мода', 'сп...
# Inheritance is used to share property and functionality across similar code. # like car and 2 wheels # It creates resuable code. # Breaks code into hierarchy, more generics to more specific. # Objects higher up in the hiearchy is more generics. # Multiple inheritance is possible in Python.z class Vehicle: def _...
"""Intialise the counter i=j=first element of array and pivot=last element of array if array[j]< pivot swap array(i,j) and increment i last swap array(i,pivot) element this algorithm give in place 0(n) partitioning in 0(1) extra memory """ def pivot(array, a, b): i = a x = array[b - 1] ...
######################################################### # Fred12 Setup the Head Servos ######################################################### # We will be using the following services: # Servo Service ######################################################### # In Fred's head, we have a Servo to turn the head fr...
# -*- coding: UTF-8 -*- #!/usr/bin/env python #------------------------------------------------------------------------------- # Name: # Purpose: # # Author: hekai #------------------------------------------------------------------------------- arrs = ['a', 'b', 'c', ['x', 'y'],'d', 'e'] print(arrs) # 浅拷贝 a...
# Done by Carlos Amaral (16/09/2020) # SCU_2.7 - Modify a User-Defined Function def my_function(x, y): return (x+y)/2 x = 4 y = 5 print("The average is: ", my_function(x,y))
def fib(n): if n < 0: raise FibonacciError elif n <= 2: return 1 else: return fib(n-1) + fib(n-2) class FibonacciError(Exception): pass class FibTestClass: pass
#coding=utf-8 #披萨配料P110 2017.4.17 active = True while active: seasoning = input("please input the seasoning that you want to add in your pizza"+ "(input 'quit' to exit)\n") if seasoning == 'quit': break else: print("We'll add "+seasoning+' your pizza!')
class Solution: """ @param A: an array @return: divide the array into 3 non-empty parts """ def threeEqualParts(self, A): total = A.count(1) if total == 0: return [0, 2] if total % 3: return [-1, -1] k = total // 3 count = ...
"""Custom synapse-related classes.""" # Copyright 2020-2021 Blue Brain Project / EPFL # 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 # Unle...
COLLECTION_NAME = "types" TYPE_NAME_KEY = "name" TYPE_VERSION_KEY = "version" DEFAULT_TYPE_VERSION = 1 TYPE_COLLECTION_KEY = "collection" TYPE_PRIMITIVE_VALUE = "primitive" DEFAULT_TYPE_COLLECTION = TYPE_PRIMITIVE_VALUE STRING_VALUE = "String" NUMBER_VALUE = "Number" def make_app_stack_type(type_name, **kwargs): ...
# Autonr : Biswadeep Roy # import os ''' thiple single quote is used to do multiple line comments''' print("Hello world")
class Box: def __init__(self, xmin, xmax, ymin, ymax): assert xmax > xmin >= 0, ("Got invalid box with xmin: {0} and xmax {1}".format(xmin, xmax)) assert ymax > ymin >= 0, ("Got invalid box with ymin: {0} and ymax {1}".format(ymin, ymax)) self._xmin = xmin self._xmax = xmax s...
"""Session 2 Class, object, instance Attributes, methods Constructor, destructor """ class Object: """Object only has a defined attribute `name` """ def __init__(self, name='anonymous python object'): """Constructor performs initialization of the instances of Object class. """ ...
class FindShortestID: __slots__ = 'short_id', 'new_id' def __init__(self): self.short_id = '' self.new_id = None def step(self, other_id, new_id): self.new_id = new_id for i in range(len(self.new_id)): if other_id[i] != self.new_id[i]: if i > len...
# x=frase[0] # y=frase[1] # z=frase[2] # w=frase[3] # print('seu numero: {} \nTem como unidade:{}\nDezena:{} \ncentena:{} \nmilhar:{}'.format(frase,w,z,y,x)) num: int = int(input('digite um numero: ')) u = num % 10 d = num // 10 % 10 c = num // 100 % 10 m = num // 1000 % 10 print('analisando o numero {} '.format(num)) ...
BLACK_HEX = '000' WHITE_HEX = 'fff' IMG_BLUEHAT = "https://assets.imgix.net/examples/bluehat.jpg" IMG_PINE = "https://sherwinski.imgix.net/pineneedles.jpg" BROKEN_URL = "https://assets.imgix.net/examples/invalid" INVALID_URL = "https://google.com" CSS_BLUEHAT = """.image-fg-1 { color:#0d0c10 !important; } .image-bg-1 ...
class PradamClass(object): def __init__(self, name, age): self._name = name self._age = age @property def name(self): return self._name @name.setter def name(self, val): if val.lower() == 'pradam': print('Corrent Name.') else: rai...
TEMPLATES_AUTO_RELOAD = True SECRET_KEY = '£$%^HJGE97655@~?><XGHWEDI7974' DEBUG = False ##mails MAIL_SERVER = 'smtp.gmail.com' MAIL_PORT = 465 MAIL_USE_SSL = True MAIL_USERNAME = 'rmachaz@gmail.com' MAIL_DEFAULT_SENDER = 'rmachaz@gmail.com' MAIL_PASSWORD = '684192684192' ## databases SQLALCHEMY_DATABASE_URI = 'mysq...
'''MongoExceptions''' class MongoExceptions(Exception): def __init__(self, *args): self.args = args class NoDatabaseException(MongoExceptions): def __init__(self, message = 'No such Database!', code = 422, args = ('No such Database!',)): self.args = args self.message = message ...
# -*- coding:utf-8 -*- CSRF_ENABLED = True # CSRF_ENABLED 激活 跨站点请求伪造 保护。激活该配置 使得你的应用程序更安全。 SECRET_KEY = "TEST_BLOG" # SECRET_KEY 配置仅仅当 CSRF 激活时才需要,用来建立一个加密令牌,验证表单。务必设置很难被猜测到密钥
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def isPalindrome(self, head): """ :type head: ListNode :rtype: bool """ # Runtime: 1036 ms ...
# cook your dish here test = int(input()) while test > 0 : n = int(input()) l = list(map(int,input().split())) l.sort() count = 0 for i in range(n - 1) : if l[i] == l[i + 1] : print("NO") break else : count += 1 if count == n - 1 : prin...
"""Binary Exponentiation.""" # Author : Junth Basnet # Time Complexity : O(logn) def binary_exponentiation(a, n): if (n == 0): return 1 elif (n % 2 == 1): return binary_exponentiation(a, n - 1) * a else: b = binary_exponentiation(a, n / 2) return b * b if __name__ == ...
def mean(u): if type(u) == dict: the_mean = sum(u.values())/len(u) else: the_mean = sum(u) / len(u) return the_mean student_grades = {"Marry":9.8, "jhon":2.1, "Kayle":6.5} mondey_temparature = [2,3,54,48,48,57] print('This is a mean of a Dictonary',mean(student_grades)) print('This is a m...
#Filter Fucntion Example 2 def isVow(x): if x=='a' or x=='e' or x=='i' or x=='o' or x=='u': return True def isCons(x): if x!='a' and x!='e' and x!='i' and x!='o' and x!='u': return True print("Enter the letters:") lst = [x for x in input().split()] print('-'*40) vowlist = list(f...
print(2**3) print(2**3.) print(2.**3) print(2.**3.) print(5//2) print(2**2**3) print(2*4) print(2**4) print(2.*4) print(2**4.) print(2/4) print(2//4) print(-2/4) print(-2//4) print(2%4) print(2%-4)
# # PySNMP MIB module Nortel-MsCarrier-MscPassport-AtmNetworkingMIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-MsCarrier-MscPassport-AtmNetworkingMIB # Produced by pysmi-0.3.4 at Wed May 1 14:29:08 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by...
class Agent(object): """Keeps relevant data of NPC and handles behavior.""" def __init__(self, name, hitpoints, strenght): self.name = name self.hitpoints = hitpoints self.strenght = strenght def move(self): pass def talk(self): pass def give_item(self): ...
input = """ p(2) | f. -p(1) :- true. true. :- f. """ output = """ p(2) | f. -p(1) :- true. true. :- f. """
DIRECT_LINK_SCHEMA = { "type": "object", "properties": { "local_file": { "type": ["string", "null"], "description": "local zip file path" } } } IMAGE_SCHEMA = { "type": "object", "properties": { "original": { "type": "file" }, ...
# -*- coding: utf-8 -*- # @Time : 2019-08-26 16:34 # @Author : Kai Zhang # @Email : kai.zhang@lizhiweike.com # @File : ex1-LetterCombinationsofaPhoneNumber.py # @Software: PyCharm class Solution(object): def letterCombinations(self, digits): """ :type digits: str :rtype: List[str]...
#!/usr/bin/python3 """ BaseCaching module.""" class BaseCaching(): """ BaseCaching defines: - constants of your caching system - where your data are stored (in a dictionary) """ MAX_ITEMS = 4 def __init__(self): """Initiliaze.""" self.cache_data = {} def print_cache(...
# by usingt he above trick we see that kidney_data.gsms is a dictionary (you can validate this) type(kidney_data.gsms) # a dict is a container of key,value pairs. The values in this case are of the class GEOparse.GEOTypes.GSM # e.g. print(type(list(kidney_data.gsms.values())[0])) ## to get the available methods: f...
def remove_smallest(n, lst): if n <= 0: return lst elif n > len(lst): return [] dex = [b[1] for b in sorted((a, i) for i, a in enumerate(lst))[:n]] return [c for i, c in enumerate(lst) if i not in dex]
class Solution: def countServers(self, grid: List[List[int]]) -> int: rows = defaultdict(set) cols = defaultdict(set) m = len(grid) n = len(grid[0]) for i in range(m): for j in range(n): if grid[i][j]: rows[i].add(j) ...