Практическая работа 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.


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


Quack-SMS-BOMBER - Quack Toolkit By IkigaiHack

Quack Toolkit By IkigaiHack About Quack Toolkit Quack Toolkit is a set of tools

Marcel 2 Aug 19, 2022
universal messaging & notifications api

Pronounced "boat-shahft" What is botschaft? Botschaft is unified messaging & notifications appliance. Want to text yourself when a long-running task c

Tyler M. Kontra 25 Aug 16, 2022
Create Discord Accounts Semi-Automatically Without Captcha Solving API Key

Discord-Account-Generator Create Discord Accounts Semi-Automatically without captcha solving api key IMPORTANT: Your chromedriver version should be th

NotSakshyam 11 Mar 21, 2022
A Python script to create customised Spotify playlists using the JSON, Spotipy Library and Spotify Web API, based on seed tracks in your history.

A Python script to create customised Spotify playlists using the JSON, Spotipy Library and Spotify Web API, based on seed tracks in your history.

Youngseo Park 1 Feb 01, 2022
Uploader-Bot - A Modified Telegram Url Uploader Bot With Mongodb, Zee5, Sonyliv Support and Many Other Yt-dlp Sites

𝚁𝚎𝚚𝚞𝚒𝚛𝚎𝚍 𝚅𝚊𝚛𝚒𝚊𝚋𝚕𝚎𝚜 🔊 APP_ID API_HASH TG_BOT_TOKEN DATABASE_URL

11 Sep 10, 2022
Instagram boosting

instagram boosting bot This bot can boost your instagram account! Rules and Instruction Use git clone to download this repository Open cmd/terminal an

Eskimo 4 Oct 20, 2022
A delightful and complete interface to GitHub's amazing API

ghapi A delightful and complete interface to GitHub's amazing API ghapi provides 100% always-updated coverage of the entire GitHub API. Because we aut

fast.ai 428 Jan 08, 2023
Get informed when your DeFI Earn CRO Validator is jailed or changes the commission rate.

CRO-DeFi-Warner Intro CRO-DeFi-Warner can be used to notify you when a validator changes the commission rate or gets jailed. It can also notify you wh

5 May 16, 2022
Discord Rich Presence for Team Fortress 2

TF2 Rich Presence Discord Rich Presence for Team Fortress 2 Detects current game state, queue info, playtime, and more Configurable, reliable, and per

Kataiser 33 Dec 31, 2022
A google search telegram bot.

Google-Search-Bot A google search telegram bot. Made with Python3 (C) @FayasNoushad Copyright permission under MIT License License - https://github.c

Fayas Noushad 37 Nov 24, 2022
Telegram bot for making Heroku app.json by @AbirHasan2005

Heroku-app.json A Telegram bot for making Heroku app.json by @AbirHasan2005. Demo Bot Host Bot Deploy to Heroku Click Below Button to Deploy to Heroku

Abir Hasan 46 Nov 13, 2022
Trust-minimized Bitcoin wallet

coldcore Trust-minimized, airgapped Bitcoin management This is experimental software. Wait for a formal release before use with real funds. A trust-mi

James O'Beirne 121 Jan 01, 2023
Tracker to check the covid shot slot availability in India and send mobile alerts via Twilio Messaging Service.

Cowin-Slot-Tracker Tracker to check the covid vaccine slot availability in India and send mobile notifications through Twilio Messaging Service. Requi

invalid username 27 Nov 12, 2022
A telegram mirror bot with an integrated RSS feed reader.

About What is this repo? This is a slightly modified fork which includes some extra features & memes added to my liking. How's this different from the

11 May 15, 2022
Python functions for opentargets.org API

What is opy_Targets? Opentargets.org uses GraphQL API to explore it's content via coding. This ensemble of functions aim is to make it easy to use the

1 Jan 10, 2022
A Python wrapper for discord slash-commands, designed to extend discord.py.

dislash.py An extending library for discord.py that allows to build awesome slash-commands. ⭐

173 Dec 19, 2022
A simple and modular Discord bot with various functionalities.

All-In-Bot for Discord A simple and modular Discord bot with various functionalities. How to use the bot? Simple! Just invite the bot to your server u

Th3J0nny 3 Jan 29, 2022
A listener for RF >= 4.0 that prints a Stack Trace to console to faster find the code section where the failure appears.

robotframework-stacktrace A listener for RF = 4.0 that prints a Stack Trace to console to faster find the code section where the failure appears. Ins

marketsquare 16 Nov 24, 2022
An Amazon Price Tracker app helps you to buy which product you want within sale price by sending an E-Mail.

Amazon Price Tracker An Amazon Price Tracker app helps you to buy which product you want within sale price by sending an E-Mail. Installing Download t

Aytaç Kaşoğlu 2 Feb 10, 2022
Prometheus exporter for CNMC API

CNMC Prometheus exporter It needs a Prometheus Pushgateway Install requirements via pip install -r requirements.txt Export the following environment v

GISCE-TI 1 Oct 20, 2021