content
stringlengths
7
1.05M
def staircase(size: int = 0) -> str: """Generates a staircase of '#', ascending to the right Args: size: Width and height of staircase. Returns: A string composed of '#' and ' ', separated by '\n'. When printed to console, renders the following (given 'size' of 5). # ...
class ObjDiff(object): """Represents a difference between two `CopyDiff` objects. Contains a list of `DiffField` objects that represent the changes to each field in the object. Also contains the `children` field which may be be a `ChildListField`. """ def __init__(self, old, new, changes, chil...
{ "targets": [ { "target_name": "memcpy", "sources": [ "src/memcpy.cc" ], "include_dirs" : [ "<!(node -e \"require('nan')\")", "<!(node -e \"require('node-arraybuffer')\")" ] } ] }
# extracting filter information c_ang = 2.99792458e18 # speed of light in Angstroms/s # galex filters ffuv = open('splash/filters/galex1500.res','r') fuv_band = array([]) fuv_band_sens = array([]) for line in ffuv: columns = line.strip().split() columns = array(columns).astype(float) fuv_band =...
class Move: """ A Player where the user chooses its moves. === Public Attributes === row: The row that move takes place. col: The column that move takes place. """ row: int col: int def __init__(self, row: int, col: int) -> None: """ Creates Move with <row> row ...
def calculate_subsidy(income, children_count): if 30_000 <= income < 40_000 and children_count >= 3: return 1000 * children_count elif 20_000 <= income < 30_000 and children_count >= 2: return 1500 * children_count elif income < 20_000: return 2000 * children_count retur...
#Let's teach the Robots to distinguish words and numbers. #You are given a string with words and numbers separated by whitespaces (one space). #The words contains only letters. You should check if the string contains three words in succession. #For example, the string "start 5 one two three 7 end" contains three word...
# The MIT License (MIT) # Copyright (c) 2020, Tangliufeng for labplus Industries # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights...
# Time: O(logn) # Space: O(1) class Solution(object): def singleNonDuplicate(self, nums): """ :type nums: List[int] :rtype: int """ left, right = 0, len(nums)-1 while left <= right: mid = left + (right - left) / 2 if not (mid%2 == 0 and mid+1...
# -*- coding: utf-8 -*- ''' 模拟一个快餐店门店 ''' __author__ = 'lai yao (lake.lai)' __date__ ="$2019-06-25 10:02:39$"
class resolutions(object): res_1080p = '1080p' res_720p = '720p' res_1080i = '1080i' res_1024x768 = '1024x768' res_1360x768 = '1360x768' class modes(object): single = 'single' pip = 'pip' side_full = 'side_full' side_scale = 'side_scale' class ports(object): port_1 = '1' ...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ :Purpose: This module contains various low-level conversion functions. :Platform: Linux/Windows | Python 3.8 :Developer: J Berendt :Email: development@s3dev.uk :Comments: These functions are designed to be as close to core Python, or a C-esque impl...
my_foods = ['pizza', 'tartalete', 'pastel', 'hamburguer'] miguel_foods = my_foods[:] print(my_foods, miguel_foods) # copia a lista do primeiro ao último item my_foods.append('strawberry') miguel_foods.append('lollipop') print(my_foods, miguel_foods) other_person_foods = miguel_foods.copy() # também serve para copiar ...
# Please complete the following exercise this week. Write a Python script containing a function called factorial() # that takes a single input/argument (x) which is a positive integer and returns its factorial. # The factorial of a number is that number multiplied by all of the positive numbers less than it. # For e...
class Generic: def __init__(self, **kwargs): self.__dict__.update(kwargs)
while True: if hero.canCast("regen"): bernardDistance = hero.distanceTo("Bernard") if bernardDistance < 10: hero.cast("regen", "Bernard") chandraDistance = hero.distanceTo("Chandra") if chandraDistance < 10: hero.cast("regen", "Chandra") else: ene...
m=0 n=120120 while 1: c=0 for i in range(1,n+1): if (n*n)%i==0: #print("--------",i,(n*n)%i,(n*(n+i))%i) c+=1 if c>m: m=c print(n,m) if(m>=1000): break else: n+=20
"""Configuration File for pyCon server and client""" HOST = '127.0.0.1' PORT = 8000 SERVER_ADDRESS = 'http://127.0.0.1:8000'
# 3Sum fixes one number and uses either the two pointers pattern or a hash set to find complementary pairs. Thus, the time complexity is O(N^2) # Two Pointers class Solution: def threeSumClosest(self, nums: List[int], target: int) -> int: diff = float('inf') nums.sort() for i in r...
# mypy: allow-untyped-defs class EventListener: def __init__(self, dispatcher_token): super().__init__() self.dispatcher_token = dispatcher_token self.token = None def send_message(self, message): raise Exception("Client.send_message(message) not implemented!")
class SkuItem(): def __init__(self, id, lookup, other_offers=None) -> None: self._id = id self._lookup = lookup self._unrelated_offers = other_offers if other_offers is not None else {} def _calc_free_unrealted_items(self, count): res = {} for other_id, other_count in ...
n = int(input()) values = [int(input()) for _ in range(n)] values_10_20 = [value for value in values if value >= 10 and value <= 20] print('{} in'.format(len(values_10_20))) print('{} out'.format(len(values) - len(values_10_20)))
class SessionHelper: def __init__(self, app): self.app = app def login(self, username, password): driver = self.app.driver self.app.open_page() driver.find_element_by_name("username").click() driver.find_element_by_name("username").clear() driver.find_element_by...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None """ timecomplexity= O(n) spacecomplexity = O(n) serialize construct recusive function to covert tree into string replace None by '# ' and use ' ' to s...
# -*- coding: utf-8 -*- __version__ = '0.0.2' __author__ = 'matteo vezzola <matteo@studioripiu.it>' default_app_config = 'ripiu.cmsplugin_vivus.apps.VivusConfig'
''' Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram. Time Complexity : O(N^2) ''' def Largest_Rectangle_In_Histogram(height): height.append(0) res = 0 st = [-1] for i in ran...
"""Gazebo colors. https://bitbucket.org/osrf/gazebo/src/default/media/materials/scripts/gazebo.material?fileviewer=file-view-default#gazebo.material-129 """ materials = { 'Gazebo/Grey': { 'ambient': [0.3, 0.3, 0.3, 1.0], 'diffuse': [0.7, 0.7, 0.7, 1.0], 'specular': [0.01, 0.01, 0.01, 1.0] ...
# Crie um programa que leia o nome de uma cidade e diga se ela começa ou não com o nome "SANTO" nome = str(input('Qual o nome da cidade que você nasceu? ')).strip() print(nome[:5].upper() == 'SANTO') # Exercício Python 025: Crie um programa que leia o nome de uma pessoa e diga se ela tem "SILVA" no nome. nome = str...
class SetSettings: def __init__(self, token: str, version: int = 1): self.token: str = token self.version: int = version self.headers: dict = dict(Authorization=self.token) self.url: str = 'http://devapi.set.uz' self.main_api: str = f'{self.url}/api/v{self.version}/integratio...
#!/usr/bin/env python # -*- coding:utf-8 -*- # file:__init__.py.py # author:PigKinght # datetime:2021/8/26 15:26 # software: PyCharm """ this is function description """
# -*- coding: utf-8 -*- ''' File name: code\perfection_quotients\sol_241.py Author: Vaidic Joshi Date created: Oct 20, 2018 Python Version: 3.x ''' # Solution to Project Euler Problem #241 :: Perfection Quotients # # For more information see: # https://projecteuler.net/problem=241 # Problem Statemen...
def trailingZeroes(n): res = 0 i = 5 while i <= n: res+= n//i i*=5 return res n = 30 print("Number of Zeros in factorial of {0} is ".format(n),trailingZeroes(n))
# Given the names and grades for each student in a Physics class of N students, # store them in a nested list and print the name(s) of any student(s) having the second lowest grade. # Note: If there are multiple students with the same grade, order their names alphabetically # and print each name on a new line. # # Inpu...
class Joueur(): def __init__(self, tour): self._score = 0 self._tour = tour self.listeCouleurs = [] def getScore(self): return self._score def ajouterScore(self, valeur): self._score += valeur def getTour(self): return s...
''' merge 2 orderd linked list into one linked list ''' class LinkedList: class Node: def __init__(self, data, next ): self.data = data self.next = next def __del__(self): print('结点被删除... 数据域值为 %s'...
__all__ = [ 'base_controller', 'mail_send_controller', 'events_controller', 'stats_controller', 'subaccounts_controller', 'subaccounts_delete_controller', 'subaccounts_get_sub_accounts_controller', 'setrecurringcreditddetails_controller', 'subaccounts_setsubaccountcredit_cont...
def upper_case_name(name): return name.upper() if __name__ == "__main__": name = "Nina" name_upper = upper_case_name(name) print(f"Upper case name is {name_upper}") print("dunder name", __name__)
# Source : https://leetcode.com/problems/find-all-the-lonely-nodes/ # Author : foxfromworld # Date : 13/11/2021 # First attempt # 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 = righ...
class Solution: def numSquareSum(self, n): squareSum = 0 while(n): squareSum += (n % 10) * (n % 10) n = int(n / 10) return squareSum def isHappy(self, n: int) -> bool: # initialize slow # and fast by n slow, fast = n while(True): ...
block_size = {"width": 0.3, "height": 0.2, "length": 0.6} wall_height = 3 wall_length = 10 print( "Общая длина 1 стены:", wall_length, "\nКоличество блоков на 1 ряд:", wall_length / block_size["length"], "\nРядов нужно:", wall_height / block_size["height"], "\nБлоков на 1 стену:", ((wal...
# Patick Corcoran # Chekc if a number is prime. # The primes are 2, 3, 5, 7, 11, 13, ... p = 347 isprime = True for m in range(2, p-1): if p % m == 0: isprime = False break if isprime: print(p, "is a prime number.") else: print(p, "is not prime,")
# Leo colorizer control file for yaml mode. # This file is in the public domain. # Properties for yaml mode. properties = { "indentNextLines": "\\s*([^\\s]+\\s*:|-)\\s*$", "indentSize": "2", "noTabs": "true", "tabSize": "2", "lineComment": "#", } # Attributes dict for yaml_main ruleset. yaml_main_...
# https://adventofcode.com/2020/day/8 def execute_code(code_lines: list[str]): """ Execute program code :param code_lines: code to execute given as lines of strings :return: (True, accumulator) if execution terminates; (False, accumulator) if it goes into an infinite loop """ accumulator = 0 ...
def maybeBuildTrap(x, y): hero.moveXY(x, y) item = hero.findNearestItem() if item and item.type == "coin": hero.buildXY("fire-trap", x, y) while True: maybeBuildTrap(12, 56) maybeBuildTrap(68, 56) maybeBuildTrap(68, 12) maybeBuildTrap(12, 12)
""" * * Author: Juarez Paulino(coderemite) * Email: juarez.paulino@gmail.com * """ n,m=map(int,input().split()) print(*[n//m]*(m-n%m)+[n//m+1]*(n%m))
# The minimal set of static libraries for basic Skia functionality. { 'variables': { 'component_libs': [ 'core.gyp:core', 'effects.gyp:effects', 'images.gyp:images', 'opts.gyp:opts', 'ports.gyp:ports', 'sfnt.gyp:sfnt', 'utils.gyp:utils', ], 'conditions': [ ...
precos = ('Lápis', 1.75, 'Borracha', 2, 'Caderno', 15.9, 'Estojo', 25, 'Transferidor', 4.2, 'Compasso', 9.99, 'Mochila', 120.32, 'Canetas', 22.3, 'Livro', 34.9) print('') print('-' * 40) print(f'{"LISTAGEM DE PREÇOS":^40}') print('-' * 40) for i in range(0, len(precos), 2): print(f'{precos[i]:.<30}R${precos[i+1]:...
# Memory reference instructions MRI = {"AND": ["0", "8"], "ADD": ["1", "9"], "LDA": ["2", "A"], "STA": ["3", "B"], "BUN": ["4", "C"], "BSA": ["5", "D"], "ISZ": ["6", "E"]} # Register reference instructions NON_MRI = {"CLA": 0x7800, "CLE": 0x7400, "CMA": 0x7200, "CME": 0x7100, "CIR": 0x7080, "CIL": 0x7040, ...
nome = "Cristiano" for letra in nome: print(letra)
def square(aList): return map(lambda x: x**2, aList) def merge(listOne, listTwo): result = [] while listOne and listTwo: #while both the lists still have elements if listOne[0] < listTwo[0]: result.append(listOne.pop(0)) #pops the first element from listOne from listOne and adds it to r...
# Operators print('Module', 10%3) print('Exponential', 5**3) print('Floor division', 9//2) # Data types print(type(5)) print(type("Luis")) print(type(5.2)) # Condition num1 = 5 num2 = 7 if num1 > num2: print(num1, 'is bigger') else: print(num2, 'is bigger')
class BaseCommand(): def __init__(self): self.pre_command() self.exec_command() self.post_command() def pre_command(self): return 0 def exec_command(self): return 0 def post_command(self): return 0 if __name__ == '__main__': cmd = BaseCommand...
class MergeSort: def __init__(self): pass def sort(self, arr): self.mergesort(arr, 0, len(arr)-1) def mergesort(self, arr, left, right): if(left >= right): return mid = int((left+right)/2) self.mergesort(arr, l...
# -*- coding: utf-8 -*- __version__ = '1.2.5' __author__ = 'G Adventures'
salario = float(input('Qual é o salário do funcionário? R$')) if salario <= 1250: aumento1 = salario * 15 / 100 + salario print(f'Quem ganhava R${salario:.2f} passa a ganhar R${aumento1:.2f}') else: aumento2 = salario *10 / 100 + salario print(f'Quem ganhava R${salario:.2f} passa a ganhar R${aumento2:.2...
class Solution: def minDistance(self, word1, word2): """ :type word1: str :type word2: str :rtype: int """ m, n = len(word1)+1, len(word2)+1 dp = [[0 for _ in range(n)] for _ in range(m)] for i in range(m): dp[i][0] = i for i in r...
''' Created on 2012. 8. 10. @author: root ''' class StaticTestingForm: header='' deviceConnection='' def __init__(self): self.header = '''import sys # Imports the monkeyrunner modules used by this program from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage''' ...
# 定义一个函数 def hcf(x, y): """该函数返回两个数的最大公约数""" # 获取最小值 if x > y: smaller = y else: smaller = x for i in range(1,smaller + 1): if((x % i == 0) and (y % i == 0)): hcf = i return hcf # 用户输入两个数字 num1 = int(input("输入第一个数字: ")) num2 = int(input("输入第二个数字: ")) print( num1,"...
# -*- coding: utf-8 -*- k = int(input()) data = {} for i in range(k): data[i] = str(input()) for q in data.items(): q = q[1].split(" ") a = int(q[0]) # 總數 b = int(q[1]) # 箱子數 c = int(q[2]) # 小箱子可裝 d = int(q[3]) # 大箱子可裝 for m in range(0, b + 1): n = b-m result = m...
{ 'name': 'prue01', 'description': 'Una aplicacion de facturacion.', 'author': 'Jose Antonio Duarte Perez', 'depends': ['mail'], 'application': True, 'data': ['views/contactos.xml'] }
stack = [3, 4, 5] stack.append(6) stack.append(7) print(stack) print(stack.pop()) print(stack) print(stack.pop()) print(stack.pop()) print(stack)
print('hi') s1 = input("input s1: ") s2 = input("input s2: ") print(s1) print(s2) shorter_length = 0 longer_s = '' if (len(s1) > len(s2)): shorter_length = len(s2) longer_s = s1 else: shorter_length = len(s1) longer_s = s2 result_s = '' for i in range(shorter_length): result_s += s1[i] + s2[i] fo...
#create veriable. cr_pass=0 defer=0 fail=0 valid=[0,20,40,60,80,100,120]#finding range. values=[] #start the programme. print("--------------------------------------------------------") while True: try: #insert from user cr_pass=int(input("Please enter your credits at pass:")) ...
def a_function(x, y): if isinstance(x, float): if isinstance(y, float): z = x + y return z
# mm => make mask dirty_imagename = "dirty/" + "RCrA_13CO_all_cube_dirty.image" beamsize_major = 7.889 beamsize_minor = 4.887 pa = -77.412 # find the RMS of a line free channel chanstat = imstat(imagename=dirty_imagename, chans="1") rms1 = chanstat["rms"][0] chanstat = imstat(imagename=dirty_imagename, chans="38") rm...
# pseudo code taken from CLRS book # vertices is list of vertex in graph : [0, 1, 2, 3 ...] (must be continuous) # adjacencyList is the list whose 'i'th element is list of vertices adjacent to vertex i time = 0; class vertex: def __init__(self, adjVertices, color='White', parent='None', discovery_time=float('inf...
# Time: O(min(n, h)), per operation # Space: O(min(n, h)) class TrieNode(object): # Initialize your data structure here. def __init__(self): self.is_string = False self.leaves = {} class WordDictionary(object): def __init__(self): self.root = TrieNode() # @param {string} wor...
""" TESTS is a dict with all you tests. Keys for this will be categories' names. Each test is dict with "input" -- input data for user function "answer" -- your right answer "explanation" -- not necessary key, it's using for additional info in animation. """ TESTS = { "Basics": [ { ...
class Damage(): def __init__(self, skill:float=1, added:float=1, dealing:float=1): self.__skill = skill self.__added = added self.__dealing = dealing def get_dmg(self): return (self.__skill, self.__added-1, self.__dealing) if __name__ == '__main__': dmg = Damage(1.15, 1...
class Animal: def __init__(self, name): self.name = name self.fed_times = 0 self.groomed_times = 0 def feed(self, times): print("Fed {}".format(times)) self.fed_times += times return self.fed_times def groom(self, times): print("Groomed {} times".for...
def main (): entry = int(input("Enter the number you want here : ")) prime = False #prime is defined as false and will change if entry number is a prime number. if entry > 1 : for numbers in range(2, entry): if (entry % numbers) == 0: # Check if entry number has a factor ...
#MaBe nomes = [] massas = [] while True: nome = input('Digite um nome: ').upper() massa = int(input('Digite a massa: ')) nomes.append(nome) massas.append(massa) r = input('Quer continuar? [s/n] ').lower() if r == 'n': break totcad = len(nomes) pesomai = max(massas) pesomin = min(m...
""" [2017-02-10] Challenge #302 [Hard] ASCII Histogram Maker: Part 2 - The Proper Histogram https://www.reddit.com/r/dailyprogrammer/comments/5t7l07/20170210_challenge_302_hard_ascii_histogram_maker/ # Description Most of us are familiar with the histogram chart - a representation of a frequency distribution by means...
n = int(input()) for row in range(0, n): if row == 0 or row == n - 1: print('*' * 2 * n + ' ' * n + '*' * 2 * n) else: if row == ((n - 1) // 2): print('*' + '/' * 2 * (n - 1) + '*' + '|' * n + '*' + '/' * 2 * (n - 1) + '*') else: print('*' + '/' * 2 * (n - 1) + '...
''' Implementação da priority queue com lista ordenada. ''' class Person(object): ''' nome -> nome da pessoa. prior -> prioridade da pessoa. ''' def __init__(self, name, prior): self.name = name self.prior = prior def getName(self): return self.name d...
# Configuration file for ipython-kernel. # See <https://ipython.readthedocs.io/en/stable/config/options/kernel.html> # With IPython >= 6.0.0, all outputs to stdout/stderr are captured. # It is the case for subprocesses and output of compiled libraries like Spark. # Those logs now both head to notebook logs and in...
# Copyright (C) 2001 Python Software Foundation __version__ = '0.4' __all__ = ['Errors', 'Generator', 'Image', 'MIMEBase', 'Message', 'MsgReader', 'Parser', 'StringableMixin', 'Text', 'address', 'date', ...
""" Search In Sorted Matrix: You're given a two-dimensional array (a matrix) of distinct integers and a target integer. Each row in the matrix is sorted, and each column is also sorted; the matrix doesn't necessarily have the same height and width. Write a function that returns an array of the row and column indices o...
# entrada v1 v1 = float(input()) # entrada v2 v2 = float(input()) # entrada v3 v3 = float(input()) # entrada v4 v4 = float(input()) # entrada v5 v5 = float(input()) # entrada v6 v6 = float(input()) # variaveis count = 0 countJ = 0 media = 0 listV = [] listP = [] # adicionar a lista listV.append(v...
# Pretty good, but I golfed the top one even more n=input s="".join(n()for _ in"_"*int(n())) print(s.count("00")+s.count("11")+1)
"""Provides the repo macro to import google libprotobuf_mutator""" load("//third_party:repo.bzl", "tf_http_archive") def repo(): """Imports libprotobuf_mutator.""" tf_http_archive( name = "com_google_libprotobuf_mutator", sha256 = "792f250fb546bde8590e72d64311ea00a70c175fd77df6bb5e02328fa15fe2...
def do_twice(f, v): f(v) f(v) def print_twice(s): print(s) print(s) # do_twice(print_twice, 'spam') def do_four(f, v): do_twice(f, v) do_twice(f, v) do_four(print, 'spam')
phi_list = {} def naples(num): b_count = 0 rel_list = [] for i in range(1, num+1): count = 0 for j in range(2, i): if num%j==0 and i%j==0: count += 1 break if count==0: b_count += 1 rel_list.append(i) phi_list[n...
# -*- coding: utf-8 -*- """ Created on Mon Dec 4 12:31:27 2017 @author: James Jiang """ with open('Data.txt') as f: for line in f: number = line digits = [i for i in str(number)] step = int(len(digits)/2) for i in range(int(len(digits)/2)): digits.append(digits[i]) sum = 0 for i in range(i...
# https://www.youtube.com/watch?v=OSGv2VnC0go names = ["rouge", "geralt", "blizzard", "yennefer"] colors = ["red", "green", "blue", "yellow"] for color in reversed(colors): print(color) for i, color in enumerate(colors): print(i, "-->", color) for name, color in zip(names, colors): print("{:<12}{:<12}"....
# -------------------------------------------------------------- # DO NOT EDIT BELOW OF THIS UNLESS REALLY SURE NFDUMP_FIELDS = [] NFDUMP_FIELDS.append( { "ID": "pr", "AggrType_A": "proto", "AggrType_s": "proto", "Name": "Protocol" } ) NFDUMP_FIELDS.append( { "ID": "exp", "AggrType_A": None, ...
# # Vivante Cross Toolchain configuration # load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "tool_path", "feature", "with_feature_set", "flag_group", "flag_set") load("//:cc_toolchain_base.bzl", "build_cc_tool...
dia = input('what day were you born?') mes = input('what month were you born?') ano = input('what year were you born?') saudacaoDia = ('voce nasceu no dia') saudacaoDe = ('de') print(saudacaoDia, dia,saudacaoDe,mes,saudacaoDe,ano)
#!/usr/bin/env python if __name__ == "__main__": N = int(raw_input()) for i in range(N): print(pow(i,2))
''' 1. Write a Python program to create a tuple. 2. Write a Python program to create a tuple with different data types. 3. Write a Python program to create a tuple with numbers and print one item. 4. Write a Python program to unpack a tuple in several variables. 5. Write a Python program to add an item in a tuple. ...
# Write a program that does the following: ## Prompt the user for their age. Convert it to a number, add one to it, and tell them how old they will be on their next birthday. ## Prompt the user for the number of egg cartons they have. Assume each carton holds 12 eggs, multiply their number by 12, and display the total ...
# coding=utf-8 """ @author: xing @contact: 1059252359@qq.com @file: testbed_parser.py @date: 2021/3/5 16:12 @desc: """ def get_version(testbed: str): path = [e for e in testbed.split(" ") if e.find("/") > -1][0] full_name = path.split("/")[-1] return full_name.replace(".jar", "") def parse_engine_name(...
listageral = [] listapar = [] listaimpar = [] while True: usuario = int(input('Digite um numero: ')) if usuario % 2 == 0: listageral.append(usuario) listapar.append(usuario) else: listageral.append(usuario) listaimpar.append(usuario) usuarioResp = str(input('Deseja conti...
def find_string_len(): str_dict = {x: len(x) for x in input().split(', ')} return str_dict def print_dict(dictionary): print(', '.join([f'{k} -> {v}' for k, v in dictionary.items()])) print_dict(find_string_len())
numbers = { items for items in range(2,471) if (items % 7 == 0) if (items % 5 != 0) } print (sorted(numbers))
class Node: def __init__(self, value): self.value = value self.next = None class Queue: def __init__(self): self.first = None self.last = None self.length = 0 def peek(self): if self.length > 0: return f"First: {self.first.value}\nLast: {self.las...
def mdc(number_one, number_two): max_mdc = 1 if number_one < number_two: for max in range(1, abs(number_one) + 1): if number_one % max == 0 and number_two % max == 0: max_mdc = max elif number_one >= number_two: for max in range(1, abs(number_two) + 1): ...
#!/usr/bin/env python command('start-configuration-editing') command('cd /') command('delete-element /sessionClusterConfig') command('activate-configuration')
class Field: __slots__ = ('name', 'typ') def __init__(self, typ, name=None): self.typ = typ self.name = name def __get__(self, instance, owner): if instance is None: return self typ = instance.__dict__.get(self.name) return typ.value if typ else typ ...
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: sample_16_3_coroaverager0 Description : 定义一个计算移动平均值得协程 date: 2022/3/8 ------------------------------------------------- """ def averager(): totoal = 0.0 count = 0 average = None while True:...