Практическая работа 6 - Документирование кода

Overview

Практическая работа №6

ПСП – правильная скобочная последовательность – последовательность из открывающих «(« и закрывающих «)» круглых скобок. Программа содержит две функции:

  • Первая функция. Проверяет, является ли полученная строка ПСП.
  • Вторая функция. При заключении что строке не ПСП, находит количество изменений, чтобы получить ПСП из полученной строки.

Оглавление

  1. Функция is_cbs
  2. Функция need_to_move
  3. Вставка изображения

Функция is_cbs

Функция is_cbs проверяет, является ли полученная строка ПСП. При заключении, что полученная строка ПСП функция возвращает 1, в противном случае 0. Код функции:

', '()', '{}', '[]'] while any(x in string_to_check for x in brackets): for bracket_parts in brackets: string_to_check = string_to_check.replace(bracket_parts, '') return not string_to_check">
def is_cbs(string_to_check: str) -> int:
    """
    Функция проверяет, является ли полученная строка ПСП
    :param string_to_check: Полученная строка
    :return:string_to_check При заключении, что полученная строка ПСП,
     функция возвращает 1, в противном случае 0
    """
    brackets = ['«»', '<>', '()', '{}', '[]']
    while any(x in string_to_check for x in brackets):
        for bracket_parts in brackets:
            string_to_check = string_to_check.replace(bracket_parts, '')
    return not string_to_check

Функция need_to_move

Функция need_to_move находит количество изменений, необходимых для получения ПСП из полученной строки. Код функции:

', ')', '}', ']'] total = 0 temp = 0 for p in lisp_reference: if p in open_brackets: total += 1 elif p in close_brackets and total: total -= 1 else: temp += 1 return total + temp">
def need_to_move(lisp_reference: str) -> int:
    """
    Функция находит количество изменений,
    чтобы получить ПСП из полученной строки.
    :param lisp_reference:Полученная строка
    :return: количество изменений,
    чтобы получить ПСП из полученной строки
    """
    open_brackets = ['«', '<', '(', '{', '[']
    close_brackets = ['»', '>', ')', '}', ']']
    total = 0
    temp = 0
    for p in lisp_reference:
        if p in open_brackets:
            total += 1
        elif p in close_brackets and total:
            total -= 1
        else:
            temp += 1
    return total + temp

Вставка изображения

Изображение


Для оформления этого файла был использован облегчённый язык разметки markdown.


⬆️ Оглавление


Using a Gameboy emulator and making it into a DIscord bot !

Gameboy-Discord Using a Gameboy emulator and making it into a Discord bot ! Im not the best at doing this, and i suck at coding so its completely unde

7 Oct 18, 2022
ServiceX DID Finder Girder

ServiceX_DID_Finder_Girder Access datasets for ServiceX from yt Hub Finding datasets This DID finder is designed to take a collection id (https://gird

1 Dec 07, 2021
Music bot for playing music on telegram voice chat group.

Somali X Music 🎵 Music bot for playing music on telegram voice chat group. Requirements FFmpeg NodeJS nodesource.com Python 3.8+ or Higher PyTgCalls

Abdisamad Omar Mohamed 4 Dec 01, 2021
A Telegram Bot to Extract Various Types Of Archives

IDN Unzip Bot A Telegram Bot to Extract Various Types Of Archives Features Extract various types of archives like rar, zip, tar, 7z, tar.xz etc. Passw

IDNCoderX 8 Jul 25, 2022
ApiMoedas - This API is a extesion of API

🪙 Api Moeda 🪙 Este projeto é uma extensão da API Awesome API. Basicamente, ele mostra todas as moedas que a Awesome API tem e todas as suas conversõ

Abel 4 May 29, 2022
This bot plays the most recent video from the Daily Silksong News Youtube Channel whenever a specific user enters voice chat once a day.

Do you have that one friend that really likes Hollow Knight. Are they waiting for Silksong to come out? Heckle them with this Discord bot.

Tommy Rousey 2 Feb 09, 2022
Custom bot I've made to host events on my personal Discord server.

discord_events Custom bot I've made to host events on my personal Discord server. You can try the bot out in my personal server here: https://discord.

AlexFlipnote 5 Mar 16, 2022
PESU Academy Discord Bot built for PESsants and PESts of PES University

PESU Academy Bot PESU Academy Discord Bot built for PESsants and PESts of PES University You can add the bot to your Discord Server using this link. O

Aditeya Baral 0 Nov 16, 2021
A Discord token grabber written in Python3, with awesome obfuscation and anti-debug protection.

☣️ Plague ☣️ Plague is a Discord token grabber written in Python3, obfuscated with Kramer, protected from traffic analysers with Scarecrow and using t

Billy 125 Dec 20, 2022
Coin-based opinion monitoring system

介绍 本仓库提供了基于币安 (Binance) 的二级市场舆情系统,可以根据自己的需求修改代码,设定各类告警提示 代码结构 binance.py - 与币安API交互 data_loader.py - 数据相关的读写 monitor.py - 监控的核心方法实现 analyze.py - 基于历史数

luv_dusk 6 Jun 08, 2022
Group Management Bot

❤️ 𝗦𝗛𝗔𝗗𝗜𝗬𝗢 ❤️ A Powerful, Smart And Advance Group Manager ... Written with AioGram , Pyrogram and Telethon... ⭐️ Thanks to everyone who starred

Abdisamad Omar Mohamed 4 Dec 01, 2021
A Python library wrapping the iFixit (Dozuki) API.

A Python library wrapping the iFixit API. Status Working, but incomplete. Fully tested and documented. Hacking I highly recommend using virtualenv: [$

James Pearson Hughes 13 May 24, 2021
A discord bot to check if messages have the correct code formatting.

discord-code-formatter A discord bot to check if messages have the correct code formatting. This was a basic project to help me learn Python and learn

Nash Boisvert 1 Nov 23, 2021
A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster

tokeks A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster. No AWS CLI, third-party client or library (boto3, botoc

Chris Karageorgiou Kaneen 6 Nov 04, 2022
Algofi Python SDK is useful for developers who want to programatically interact with the Algofi lending protocol

algofi-py-sdk Algofi Python SDK Documentation https://algofi-py-sdk.readthedocs.

Algofi 41 Dec 15, 2022
a Disqus alternative

Isso – a commenting server similar to Disqus Isso – Ich schrei sonst – is a lightweight commenting server written in Python and JavaScript. It aims to

Martin Zimmermann 4.7k Jan 02, 2023
Um bot para contar quantas vezes o meu amigo troca de pfp/nick/tag essas coisas ae pq aquele mlk n para quieto

EkiBot Um bot que tem apenas as suas funções de audit log com as PFP's (avatares) dos usuários Pode ser usado para um usuário em específico, ou até me

Samuel 3 Aug 11, 2021
TON Miner from TON-Pool.com

TON-Pool Miner Miner from TON-Pool.com

21 Nov 18, 2022
Python written Rule34 API

Python written Rule34 API

1 Nov 11, 2021
An Open Source ALL-In-One Telegram RoBot, that can do lot of things.

URL Uploader Bot An Open Source ALL-In-One Telegram RoBot, that can do lot of things. My Features Installation The Easy Way You can also tap the Deplo

NT BOTS 1 Oct 23, 2021