content
stringlengths
7
1.05M
n = int(input('Me diga um número qualquer: ')) if (n % 2 == 0): print('O número {} é PAR'.format(n)) else: print('O número {} é IMPAR'.format(n))
""" 39.61% return ['Fizz' * (not i % 3) + 'Buzz' * (not i % 5) or str(i) for i in range(1, n+1)] """ class Solution(object): def fizzBuzz(self, n): """ :type n: int :rtype: List[str] """ result = [] for i in range(1, n+1): if i % 3 == 0 and i % 5 == 0: ...
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"generate": "00_numpy.ipynb", "square_root_by_exhaustive": "01_python03.ipynb", "square_root_by_binary_search": "01_python03.ipynb", "square_root_by_newton": "01_python03.ipynb", ...
class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ if len(s) == 0: return 0 else: words = s.split() return len(words[len(words) - 1])
answer1 = widget_inputs["radio1"] answer2 = widget_inputs["radio2"] answer3 = widget_inputs["radio3"] answer4 = widget_inputs["radio4"] is_correct = False comments = [] def commentizer(new): if new not in comments: comments.append(new) if answer1 == True: is_correct = True else: is_correct = is_c...
# -*- coding: utf-8 -*- """Top-level package for botorum.""" __author__ = """JP White""" __email__ = 'jpwhite3@gmail.com' __version__ = '0.1.0'
def buy(): return "期貨作多" def sell(): return "做空" def zero(): return "選擇權新倉" def C(): return "平倉" # 選擇器 def switcher(command): menu = { 'buy': buy, 'sell': sell, '0': zero, 'C': C, '4': lambda: print('Error') } func = menu.get(command, '4') # ...
# Open file for reading inputFile = open('input_1', 'rt') # Put values into array inputValues = [] for x in inputFile: inputValues.append(int(x)) inputFile.close() """ PUZZLE ONE """ increaseCount = 0 for currentIndex in range(len(inputValues)-1): if inputValues[currentIndex+1]-inputValues[currentIndex] > 0:...
"""Message type identifiers for Routing.""" MESSAGE_FAMILY = "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/routing/1.0" FORWARD = f"{MESSAGE_FAMILY}/forward" ROUTE_QUERY_REQUEST = f"{MESSAGE_FAMILY}/route-query-request" ROUTE_QUERY_RESPONSE = f"{MESSAGE_FAMILY}/route-query-response" ROUTE_UPDATE_REQUEST = f"{MESSAGE_FAMILY}/...
digit = input('Enter number:') name = input("Name:") if not digit.i: print("Input must be a digit") exit(1) print(int(digit) + 1)
# Zapytaj użytkownika o 3 ulubione potrawy i zapisz je w postaci listy # favourite_dishes = [] # dish = input("Jakie jest Twoje ulubione danie nr 1? ") # favourite_dishes.append(dish) # dish = input("Jakie jest Twoje ulubione danie nr 2? ") # favourite_dishes.append(dish) # dish = input("Jakie jest Twoje ulubione dani...
num1 = 11 num2 = 222 num3 = 3333333 num3 = 333 num4 = 44444
# mock data OP_STATIC_ATTRS = { "objectClass": ["top", "oxAuthClient"], "oxAuthScope": [ "inum=F0C4,ou=scopes,o=gluu", "inum=C4F5,ou=scopes,o=gluu", ], "inum": "w124asdgggAGs", } ADD_OP_TEST_ARGS = { "oxAuthLogoutSessionRequired": False, "oxAuthTrustedClient": False, "oxAut...
# -*- coding: utf-8 -*- """ @date: 2020/7/13 下午4:03 @file: __init__.py.py @author: zj @description: """ # This line will be programatically read/write by setup.py. # Leave them at the bottom of this file and don't touch them. __version__ = "0.1.9"
#!/usr/bin/env python3 # Day 15: Non-overlapping Intervals # # Given a collection of intervals, find the minimum number of intervals you # need to remove to make the rest of the intervals non-overlapping. # # Note: # - You may assume the interval's end point is always bigger than its start # point. # - Intervals lik...
aux = 0 num = int(input("Ingrese un numero entero positivo: ")) if num>0: for x in range(0,num+1): aux = aux + x print (aux)
start = [8,13,1,0,18,9] last_said = None history = {} def say(num, turn_no): print(f'turn {i}\tsay {num}') for i in range(30000000): if i < len(start): num = start[i] else: # print(f'turn {i} last said {last_said} {history}') if last_said in history: # print('in') ...
""" ****************************************************** Author: Mark Arakaki October 15, 2017 Personal Practice Use ***************************************************** Divisors: Create a program that asks the user for a number and then prints out a list of all the divisors of that number. (If you don't know wha...
num1 = '100' num2 = '200' # 100200 print(num1 + num2) # Casting - 300 num1 = int(num1) num2 = int(num2) print(num1 + num2)
print('Esse programa recebe 3 entradas numericas e diz qual o maior. ') um = int(input('Digite um numero: ')) dois = int(input('Digite outro numero: ')) tres = int(input('Digite um terceiro numero: ')) if um > dois and um >tres: print(um,'é o maior') elif dois > um and dois > tres: print(dois,'é o maio...
# Databricks notebook source exported at Sun, 13 Mar 2016 23:07:00 UTC # MAGIC %md # <img width="300px" src="http://cdn.arstechnica.net/wp-content/uploads/2015/09/2000px-Wikipedia-logo-v2-en-640x735.jpg"/> Clickstream Analysis # MAGIC # MAGIC ** Dataset: 3.2 billion requests collected during the month of February 2015...
# Python - 3.4.3 WALL = 1 START_POINT = 2 FINISH_POINT = 3 dirs = { 'W': (0, -1), 'E': (0, 1), 'N': (-1, 0), 'S': (1, 0) } # 尋找起點 def find_maze_start_point(maze): for row in range(len(maze)): for col in range(len(maze[0])): if maze[row][col] == START_POINT: ...
"""This file contains constants used used by the Ethereum JSON RPC interface.""" BLOCK_TAG_EARLIEST = "earliest" BLOCK_TAG_LATEST = "latest" BLOCK_TAG_PENDING = "pending" BLOCK_TAGS = (BLOCK_TAG_EARLIEST, BLOCK_TAG_LATEST, BLOCK_TAG_PENDING)
# ------- FUNCTION BASICS -------- def allotEmail(firstName, surname): return firstName+'.'+surname+'@pythonabc.org' name = input("Enter your name: ") fName, sName = name.split() compEmail = allotEmail(fName, sName) print(compEmail) def get_sum(*args): sum = 0 for i in args: sum += i return...
''' An approximation of network latency in the Bitcoin network based on the following paper: https://ieeexplore.ieee.org/document/6688704/. From the green line in Fig 1, we can approximate the function as: Network latency (sec) = 19/300 sec/KB * KB + 1 sec If we assume a transaction is 500 bytes or 1/2 KB, we...
class Spam(object): ''' The Spam object contains lots of spam Args: arg (str): The arg is used for ... *args: The variable arguments are used for ... **kwargs: The keyword arguments are used for ... Attributes: arg (str): This is where we store arg, ''' def __...
''' Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7]. ...
# Time: O(m * n) # Space: O(m * n) class Solution(object): def numDistinctIslands(self, grid): """ :type grid: List[List[int]] :rtype: int """ directions = {'l':[-1, 0], 'r':[ 1, 0], \ 'u':[ 0, 1], 'd':[ 0, -1]} def dfs(i, j, grid, island):...
# Тип данных СЛОВРИ (dict) # Инициализация dict_temp = {} print(type(dict_temp), dict_temp) dict_temp = {'dict1' : 1, 'dict2' : 2.1, 'dict3': 'name', 'dict4':[1,2,3]} print(type(dict_temp), dict_temp) dict_temp = dict.fromkeys(['a', 'b'], [12, 2020]) print(type(dict_temp), dict_temp) dict_temp = dict(brend = 'vol...
""" Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays. Example 1: Input: arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8] Output: [1,5] Explanation: Only 1 and 5 appeared in the three arrays. ...
# -*- coding: utf-8 -*- """ Created on Sat Apr 6 19:42:18 2019 @author: rounak """ num = int (input("Enter a number: ")) #if the elements in the range(2, num) evenly divides the num, #then it is included in the divisors list divisor = [x for x in range(2, num) if num % x == 0] for x in divisor: p...
class Solution(object): @staticmethod def min_steps(candy, n, m): min_step = float("inf") def dfs(curr, i, j, num_candy, steps): nonlocal min_step if num_candy == m: min_step = min(steps, min_step) if steps > min_step: return...
class Employee: # Constructor untuk Employee def __init__(self, first_name, last_name, monthly_salary): self._first_name = first_name self._last_name = last_name self._monthly_salary = monthly_salary if monthly_salary < 0: self._monthly_salary = 0 # Getter dan setter first_name @property def...
def test_Feeds(flamingo_env): flamingo_env.settings.PLUGINS = ['flamingo.plugins.Feeds'] flamingo_env.settings.FEEDS_DOMAIN = 'www.example.org' flamingo_env.settings.FEEDS = [ { 'id': 'www.example.org', 'title': 'Example.org', 'type': 'atom', 'output'...
class Solution: def minFallingPathSum(self, arr: List[List[int]]) -> int: min1 = min2 = -1 for j in range(len(arr[0])): if min1 == -1 or arr[0][j] < arr[0][min1]: min2 = min1 min1 = j elif min2 == -1 or arr[0][j] < arr[0][min2]: ...
GENERAL_HELP = ''' Usage: vt <command> [options] Commands: lists Get all lists list Return items of a specific list item Return a specific item show Alias for item done Mark an item done complete Alias for done undone Mark an item undone unc...
# -*- coding: utf-8 -*- """ @author: ashutosh A simple program to add two numbers. """ def main(): """ The main function to execute upon call. Returns ------- int returns integer 0 for safe executions. """ print("Program to add two numbers.\n") # two...
# slicing lab def swap(seq): return seq[-1:]+seq[1:-1]+seq[:1] assert swap('something') == 'gomethins' assert swap(tuple(range(10))) == (9,1,2,3,4,5,6,7,8,0) def rem(seq): return seq[::2] assert rem('a word') == 'awr' def rem4(seq): return seq[4:-4:2] print(rem4( (1,2,3,4,5,6,7,8,9,10,11), ) ) def ...
def minkowski(a, b, p) : summ = 0 n = len(a) for i in range(n) : summ += (b[i]-a[i])**p summ = summ ** (1/p) return summ a = [0, 3, 4, 5] b = [7, 6, 3, -1] p=3 print(minkowski(a, b, p))
frase=int(input('digite um numero: ')) x = frase % 2 if x == 1: print('{} é impar'.format(frase)) else:print('{} é par'.format(frase))
inp = input() points = inp.split(" ") for i in range(len(points)): points[i] = int(points[i]) points.sort() result = points[len(points) - 1] - points[0] print(result)
# Created by MechAviv # ID :: [4000013] # Maple Road : Inside the Small Forest sm.showFieldEffect("maplemap/enter/40000", 0)
# Define time, time constant t = np.arange(0, 10, .1) tau = 0.5 # Compute alpha function f = t * np.exp(-t/tau) # Define u(t), v(t) u_t = t v_t = np.exp(-t/tau) # Define du/dt, dv/dt du_dt = 1 dv_dt = -1/tau * np.exp(-t/tau) # Define full derivative df_dt = u_t * dv_dt + v_t * du_dt # Uncomment below to visualize...
al = 0 ga = 0 di = 0 x = 0 while x != 4: x = int(input()) if x == 1: al = al + 1 if x == 2: ga = ga + 1 if x == 3: di = di + 1 print('MUITO OBRIGADO') print('Alcool: {}'.format(al)) print('Gasolina: {}'.format(ga)) print('Diesel: {}'.format(di))
# 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 countNodes(self, root: TreeNode) -> int: maxDepth = self.findLeftMaxDepth(root) if maxDe...
''' A library to speed up physics data analysis. Contains functions for error analysis and calculations for various physics mechanics values. '''
# Creating variables dynamically. # To be able to pass arguments to variable file, we must define # and use "get_variables" in a similar manner as follows: def get_variables(server_uri, start_port): # Note that the order in which the libraries are listed here must match # that in 'server.py'. port ...
class StageOutputs: execute_outputs = { # Outputs from public Cisco docs: # https://www.cisco.com/c/en/us/td/docs/routers/asr1000/release/notes/asr1k_rn_rel_notes/asr1k_rn_sys_req.html 'copy running-config startup-config': '''\ PE1#copy running-config startup-config ...
class UnknownCommand(Exception): pass class ModuleNotFound(Exception): pass class VariableError(Exception): pass class ModuleError: error = "" def __init__(self, error): self.error = error
# Copyright 2017 Bloomberg Finance L.P. # 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 agreed to in writ...
CLAIM_TYPES = { 'stream': 1, 'channel': 2, 'repost': 3 } STREAM_TYPES = { 'video': 1, 'audio': 2, 'image': 3, 'document': 4, 'binary': 5, 'model': 6 } # 9/21/2020 MOST_USED_TAGS = { "gaming", "people & blogs", "entertainment", "music", "pop culture", "educat...
class Node: def __init__(self,tag,valid_bit = 1,next = None,previous = None): self.tag = tag self.valid_bit = valid_bit self.next = next self.previous = previous def set_next_pointer(self,next): self.next = next def set_previous_pointer(self,previous):...
# Do not hard code credentials client = boto3.client( 's3', # Hard coded strings as credentials, not recommended. aws_access_key_id='AKIAIO5FODNN7EXAMPLE', aws_secret_access_key='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE' ) # adding another line
#!/usr/bin/env python3 # ## @file # checkout_humble.py # # Copyright (c) 2020, Intel Corporation. All rights reserved.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent # NO_COMBO = 'A combination named: {} does not exist in the workspace manifest'
cuda_code = ''' extern "C" __global__ void my_kernel(float* input_domain, int input_domain_n, int* layer_sizes, int layer_number, float* full_weights, float* full_biases, float* results_cuda, int max_layer_size, int* activations) { // Calculate all the bounds, node by node, for each layer. 'new_layer_values' is ...
class Point: def __init__(self, x, y): self.x = float(x) self.y = float(y) def __str__(self): return "(" + str(round(self.x, 1)) + ', ' + str(round(self.y, 1)) + ")" class Triangle: def __init__(self, points): self.points = points def get_centroid(self): sum...
def func1(): """ # Model Management ## Introduction Dataloop's Model Management is here to provide Machine Learning engineers the ability to manage their research and production process. We want to introduce Dataloop entities to create, manage, view, compare, restore, and deploy training sessions....
global_var = 10 def func_exemple(local_var_1, local_var_2): print(local_var_1, local_var_2, global_var) func_exemple(11, 12) # След пример, мы пытаемся изменить значение перем Global_var в нутри перемен print(' След пример, мы пытаемся изменить значение перем Global_var в нутри перемен ') def func_exemple_1(l...
class TrackableObject: def __init__(self, objectID, centroid_frame_timestamp, detection_class_id, centroid, boxoid, bbox_rw_coords): # store the object ID, then initialize a list of centroids # using the current centroid self.objectID = objectID # initialize instance variable, 'oids...
""" STATEMENT Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. CLARIFICATIONS - The root is not leaf for trees with levels more than one? Yes. EXAMPLES (needs to be drawn) COMMENTS - A recursive solution ch...
#--------------------------------------- # Selection Sort #--------------------------------------- def selection_sort(A): for i in range (0, len(A) - 1): minIndex = i for j in range (i+1, len(A)): if A[j] < A[minIndex]: minIndex = j if minIndex != i: A[i], A[minIndex] = A[minIndex], A[i] A = [5,...
games = ["chess", "soccer", "tennis"] foods = ["chicken", "milk", "fruits"] favorites = games + foods print(favorites)
# Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. # For example, # Given the following matrix: # [ # [ 1, 2, 3 ], # [ 4, 5, 6 ], # [ 7, 8, 9 ] # ] # You should return [1,2,3,6,9,8,7,4,5]. class Solution: # @param {integer[][]} matrix # @return {i...
""" [2016-05-04] Challenge #265 [Hard] Permutations with repeat https://www.reddit.com/r/dailyprogrammer/comments/4i3xrm/20160504_challenge_265_hard_permutations_with/ The number of permutations of a list that includes repeats is `(factorial of list length) / (product of factorials of each items repeat frequency) for...
def Sequential_Search(elements): for i in range (len(elements)): #outer loop for comparison for j in range (len(elements)):#inner loop to compare against outer loop pos = 0 found = False while pos < len(elements) and not found: if j == i: ...
def palcheck(s): ns="" for i in s: ns=i+ns if s==ns: return True return False def cod(s): l=len(s) for i in range(2,l): if palcheck(s[:i]): t1=s[:i] k=s[i:] break t=len(k) for j in range(2...
# pylint: skip-file # pylint: disable=too-many-instance-attributes class Subnetwork(GCPResource): '''Object to represent a gcp subnetwork''' resource_type = "compute.v1.subnetwork" # pylint: disable=too-many-arguments def __init__(self, rname, project, ...
class Solution: def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: strs = [] tmp = '' for s in paragraph: if s in '!? \';.,': if tmp: strs.append(tmp) tmp = '' else: tmp += s.lowe...
""" ShellSort is a variation of insertion sort. Sometimes called as "diminishing increment sort". How ShelSort improves insertion sort algorithm? By breaking the original list into a number of sub-lists, each sublist is sorted using the insertion sort. It will move the items nearer to its original index. Algo...
class Solution: def rob(self, nums: List[int]) -> int: if len(nums) == 0: return 0 if len(nums) == 1: return nums[0] dp = [] dp.append(nums[0]) dp.append(max(nums[0], nums[1])) for i in range(2, len(nums)): dp.append(max(nums[i] + d...
def foo(x, y): s = x + y if s > 10: print("s>10") elif s > 5: print("s>5") else: print("less") print("over") def bar(): s = 1 + 2 if s > 10: print("s>10") elif s > 5: print("s>5") else: print("less") print("over")
#coding:utf-8 ''' filename:arabic2roman.py chap:6 subject:6 conditions:translate Arabic numerals to Roman numerals solution:class Arabic2Roman ''' class Arabic2Roman: trans = {1:'I',5:'V',10:'X',50:'L',100:'C',500:'D',1000:'M'} # 'I(a)X(b)V(c)I(d)' trans_unit = {1:(0,0,0,1),2:...
# AARD: function: __main__ # AARD: #1:1 -> #1:2 :: defs: %1 / uses: [@1 5:4-5:10] { call } # AARD: #1:2 -> #1:3, #1:4 :: defs: / uses: %1 [@1 5:4-5:10] if test(): # AARD: #1:3 -> #1:4 :: defs: %2 / uses: [@1 7:5-7:12] foo = 3 # AARD: #1:4 -> :: defs: %3 / uses: [@1 10:1-10:8] { call } print() ...
class Node: def __init__(self, value): self._value = value self._parent = None self._children = [] @property def value(self): return self._value @property def children(self): return self._children @property def parent(self): return self._par...
class Env: def __init__(self): self.played = False def getTime(self): pass def playWavFile(self, file): pass def wavWasPlayed(self): self.played = True def resetWav(self): self.played = False
algorithm_parameter = { 'type': 'object', 'required': ['name', 'value'], 'properties': { 'name': { 'description': 'Name of algorithm parameter', 'type': 'string', }, 'value': { 'description': 'Value of algorithm parameter', 'oneOf': [ ...
# -*- coding: UTF-8 -*- """ 此脚本用于实现计数器 """ def word_count(data): """ 输入一个列表,统计列表中各个元素出现的次数 参数 ---- data : list, 需要统计的列表 返回 ---- re : dict, 结果hash表,key为原列表中的元素,value为对应的出现次数 """ re = {} for item in data: re[item] = re.get(item, 0) + 1 return re
class solve_day(object): with open('inputs/day02.txt', 'r') as f: data = f.readlines() def part1(self): grid = [[1,2,3], [4,5,6], [7,8,9]] code = [] ## locations # 1 - grid[0][0] # 2 - grid[0][1] # 3 - grid[0][2] ...
class IntegerStack(list): def __init__(self): stack = [] * 128 self.extend(stack) def depth(self): return len(self) def tos(self): return self[-1] def push(self, v): self.append(v) def dup(self): self.append(self[-1]) def drop(self): s...
t = int(input('Primeiro termo: ')) r = int(input('Razão da PA: ')) pa = t cont = 1 while cont <= 10: print(f'{pa} -> ', end=' ') pa += r cont += 1 print('FIM')
'''n = int(input('Digite um número de 0 à 9999: ')) print('Unidade: ', n%10) print('Dezena: ', n%100//10) print('Centena: ', n%1000//100) print('Milhar: ', n%10000//1000)''' n = input('Digite um número de 0 à 9999: ') print('Unidade: ', n[3]) print('Dezena: ', n[2]) print('Centena: ', n[1]) print('Milhar: ', n[0])
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. { 'name': 'Collaborative Pads', 'version': '2.0', 'category': 'Extra Tools', 'description': """ Adds enhanced support for (Ether)Pad attachments in the web client. ========================================...
# Copyright 2019 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...
digit_mapping = { '2': ['a', 'b', 'c'], '3': ['d', 'e', 'f'] } def get_letter_strings(number_string): if not number_string: return if len(number_string) == 1: return digit_mapping[number_string[0]] possible_strings = list() current_letters = digit_mapping[number_string[0]] ...
class Solution: def minTaps(self, n: int, A: List[int]) -> int: dp = [math.inf] * (n + 1) for i in range(0, n + 1): left = max(0, i - A[i]) use = (dp[left] + 1) if i - A[i] > 0 else 1 dp[i] = min(dp[i], use) for j in range(i, min(i + A[i] + 1, n + 1)):...
type = input() if (type=='прямоугольник'): a = float(input()) b = float(input()) print(a * b) elif (type=='круг'): a = float(input()) print(3.14 * (a ** 2)) elif (type=='треугольник'): a = float(input()) b = float(input()) c = float(input()) p = (a+b+c)/2 print((p*(p-a)*(p-b)*(p-...
def fibo_recur(n): if n == 0: return 0 if n == 1: return 1 if n == 2: return 1 return fibo_recur(n-1) + fibo_recur(n-2) def fibo_dp(n, dp=dict()): if n == 0: return 0 if n == 1 or n == 2: return 1 if n in dp: return dp[n] dp[n...
class Square: def __init__(self, sideLength = 0): self.sideLength = sideLength def area_square(self): return self.sideLength ** 2 def perimeter_square(self): return self.sideLength * 4 class Triangle: def __init__(self, base : float, height : float): self.base = b...
#! /usr/bin/python3 def parse(): prev_data_S = "-1,-1,-1,-1,-1" prev_none_vga_data = "0" while(1): f_read = open("temp.txt","r") data = f_read.read() f_read.close() data_S = data.split('S') if(len(data_S)>2): none_vga_data = data_S[2].split('T') ...
class ResultKey: """ Key for storing and searching Metrics. """ def __init__(self, data_set_date, tags): self.data_set_date = data_set_date self.tags = tags def __str__(self): return "DataSetDate: {}\nTags: {}".format(self.data_set_date, self.tags) def __eq__(self, othe...
""" 3,猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,又多吃了一个。第二天早上又将剩下的桃子吃掉一半,又多吃了一个。 以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘了多少。 """ def find_x(day): x = 3*(2**(day-1))-2 return x print(find_x(10)) # a10=1 # a9=(a10+1)*2 # a8=(a9+1)*2 # .... # 数学思想,正常人的思想 # res = 1 # for i in range(9): # res += 1 # res ...
class color: PURPLE = '\033[95m' CYAN = '\033[96m' DARKCYAN = '\033[36m' BLUE = '\033[94m' GREEN = '\033[92m' YELLOW = '\033[93m' RED = '\033[91m' BOLD = '\033[1m' UNDERLINE = '\033[4m' END = '\033[0m' class DictList(dict): def __setitem__(self, key, value): try: ...
""" For strings S and T, we say "T divides S" if and only if S = T + ... + T (T concatenated with itself 1 or more times) Return the largest string X such that X divides str1 and X divides str2. Example 1: Input: str1 = "ABCABC", str2 = "ABC" Output: "ABC" Example 2: Input: str1 = "ABABAB", str2 = "ABAB" Output...
### Do something - what - print ### Data source? - what data is being printed? ### Output device? - where the data is being printed? ### I think these are rather good questions, it would be cool ### to specify these in the code print("Hello, World!\nI'm Ante")
# -*- coding: utf-8 -*- """ dbmanage Library ~~~~~~~~~~~~~~~~ """
input_size = 512 model = dict( type='SingleStageDetector', backbone=dict( type='SSDVGG', depth=16, with_last_pool=False, ceil_mode=True, out_indices=(3, 4), out_feature_indices=(22, 34), init_cfg=dict( type='Pretrained', checkpoint='open-mmlab:...
# 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"); you may...
def operation(): """ :return: Returns a number between 1 and 5 that represents the four fundamental mathematical operations and exit. """ print("Choose an option:") print("[1] Addition (+)") print("[2] Subtraction (-)") print("[3] Multiplication (*)") print("[4] Division (/)") ...
''' LEADERS OF AN ARRAY The task is to find all leaders in an array, where a leader is an array element which is greater than all the elements on its right side ''' print("Enter the size of array : ") num = int(input()) a = [] print("Enter array elements") for i in range(0, num): a.append(int(...
tupla = (int(input('Digite um número: ')), int(input('Digite outro número: ')), int(input('Digite mais um número: ')), int(input('Digite o último número: '))) print(f'Você digitou os valores {tupla}') n9 = tupla.count(9) if n9 >= 1: print(f'O valor 9 apareceu {n9} vez(es).') else: pri...