-
Notifications
You must be signed in to change notification settings - Fork 0
Ruff and pep8 edit #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ermmmaks
wants to merge
3
commits into
main
Choose a base branch
from
ruff_and_PEP8_edit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| def bubble_sort(arr): | ||
| n = len(arr) | ||
|
|
||
| for i in range(n): | ||
| swapped = False | ||
|
|
||
| for j in range(n - i - 1): | ||
| if arr[j] > arr[j + 1]: | ||
| temporary = arr[j] | ||
| arr[j] = arr[j + 1] | ||
| arr[j + 1] = temporary | ||
| swapped = True | ||
| if not swapped: | ||
| return arr | ||
|
|
||
| len_arr = int(input("Введите длину массива: ")) | ||
| user_arr = [] | ||
|
|
||
| for count in range(len_arr): | ||
| user_number = int(input(f"Число номер {count + 1}: ")) | ||
| user_arr.append(user_number) | ||
|
|
||
| print("Сортировка выполнена!") | ||
| print(bubble_sort(user_arr) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| USER_STR1 = str(input("Введите первую строку: ")) | ||
| USER_STR2 = str(input("Введите вторую строку: ")) | ||
| ALPHABET = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"[::-1] | ||
| MIN_LEN = min(len(USER_STR1), len(USER_STR2)) | ||
|
|
||
| # 1) чем символ дальше от начала алфавита (z), тем он старше | ||
| # 2) чем меньше длина строки, тем она старше | ||
|
|
||
|
|
||
| def lexic_order(string1, string2): | ||
| for latin in string1 + string2: | ||
| if latin not in ALPHABET: | ||
| return "Используйте только латиницу!" | ||
|
|
||
| for let in range(0, MIN_LEN): | ||
| let_s1 = string1[let] | ||
| let_s2 = string2[let] | ||
|
|
||
| if (let_s1 != let_s2) or ( | ||
| let == MIN_LEN - 1 and let_s1 == let_s2 | ||
| ): # сравнение возможно, если: | ||
| # 1. всретились разные буквы | ||
| # 2. буквы одинаковые вплоть до последнего символа одной из строк | ||
| if (ALPHABET.index(let_s1) > ALPHABET.index(let_s2)) or ( | ||
| len(string1) < len(string2) | ||
| and (let_s1 == let_s2) | ||
| and let == MIN_LEN - 1 | ||
| ): | ||
| return "Первая строка старше, чем Вторая" | ||
| elif (ALPHABET.index(let_s2) > ALPHABET.index(let_s1)) or ( | ||
| len(string1) > len(string2) | ||
| and (let_s1 == let_s2) | ||
| and let == MIN_LEN - 1 | ||
| ): | ||
| return "Вторая строка старше, чем Первая" | ||
| return "Строки идентичны" | ||
|
|
||
|
|
||
| print(lexic_order(USER_STR1, USER_STR2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| USER_STR1 = str(input("Введите первую строку: ")) | ||
| USER_STR2 = str(input("Введите вторую строку: ")) | ||
| ALPHABET = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"[::-1] | ||
| MIN_LEN = min(len(USER_STR1), len(USER_STR2)) | ||
|
|
||
| # 1) чем символ дальше от начала алфавита (z), тем он старше | ||
| # 2) чем меньше длина строки, тем она старше | ||
|
|
||
|
|
||
| def lexic_order(string1, string2): | ||
| for latin in string1 + string2: | ||
| if latin not in ALPHABET: | ||
| return "Используйте только латиницу!" | ||
|
|
||
| for let in range(0, MIN_LEN): | ||
| let_s1 = string1[let] | ||
| let_s2 = string2[let] | ||
|
|
||
| if (let_s1 != let_s2) or ( | ||
| let == MIN_LEN - 1 and let_s1 == let_s2 | ||
| ): # сравнение возможно, если: | ||
| # 1. всретились разные буквы | ||
| # 2. буквы одинаковые вплоть до последнего символа одной из строк | ||
| if (ALPHABET.index(let_s1) > ALPHABET.index(let_s2)) or ( | ||
| len(string1) < len(string2) | ||
| and (let_s1 == let_s2) | ||
| and let == MIN_LEN - 1 | ||
| ): | ||
| return "Первая строка старше, чем Вторая" | ||
| elif (ALPHABET.index(let_s2) > ALPHABET.index(let_s1)) or ( | ||
| len(string1) > len(string2) | ||
| and (let_s1 == let_s2) | ||
| and let == MIN_LEN - 1 | ||
| ): | ||
| return "Вторая строка старше, чем Первая" | ||
| return "Строки идентичны" | ||
|
|
||
|
|
||
| print(lexic_order(USER_STR1, USER_STR2)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем нужен этот файл?