diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b0efd58 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..71d1b6a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/python_dlja_prodvinutih.iml b/.idea/python_dlja_prodvinutih.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/.idea/python_dlja_prodvinutih.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/caesars_code.py b/caesars_code.py deleted file mode 100644 index 2bbc6bb..0000000 --- a/caesars_code.py +++ /dev/null @@ -1,79 +0,0 @@ -purpose = input("What's your purpose - Encryption(e) or Decryption(d)? Type 'e' or 'd': ") -language = input('Choose language: English(en) or Russian(ru)? Type "en" or "ru": ') -shift = int(input("Choose code's shift in numbers (For example - 7): ")) -text = input('Enter your text: ') - - -def caesars_encrypt_en(text_inp, shift_inp): - encrypted_text = '' - for c in text_inp: - encrypted_letter = c - if c.isalpha(): - if c.isupper(): - encrypted_letter = ord(c) + shift_inp - if 90 < encrypted_letter < 97: - encrypted_letter -= 26 - elif c.islower(): - encrypted_letter = ord(c) + shift_inp - if encrypted_letter > 122: - encrypted_letter -= 26 - encrypted_letter = chr(encrypted_letter) - encrypted_text += encrypted_letter - return encrypted_text - - -def caesars_decrypt_en(text_inp, shift_inp): - decrypted_text = '' - for c in text_inp: - decrypted_letter = c - if c.isalpha(): - if c.isupper(): - decrypted_letter = ord(c) - shift_inp - if decrypted_letter < 65: - decrypted_letter += 26 - elif c.islower(): - decrypted_letter = ord(c) - shift_inp - if decrypted_letter < 97: - decrypted_letter += 26 - decrypted_letter = chr(decrypted_letter) - decrypted_text += decrypted_letter - return decrypted_text - - -# Русский сделан только для прописных букв. Нужно дополнить! - - -def caesars_encrypt_ru(text_inp, shift_inp): - encrypted_text = '' - for c in text_inp: - encrypted_letter = c - if c.isalpha(): - encrypted_letter = ord(c) + shift_inp - if encrypted_letter > 1103: - encrypted_letter -= 32 - encrypted_letter = chr(encrypted_letter) - encrypted_text += encrypted_letter - return encrypted_text - - -def caesars_decrypt_ru(text_inp, shift_inp): - decrypted_text = '' - for c in text_inp: - decrypted_letter = c - if c.isalpha(): - decrypted_letter = ord(c) - shift_inp - if decrypted_letter < 1072: - decrypted_letter += 32 - decrypted_letter = chr(decrypted_letter) - decrypted_text += decrypted_letter - return decrypted_text - - -if purpose == 'e' and language == 'en': - print(caesars_encrypt_en(text, shift)) -if purpose == 'd' and language == 'en': - print(caesars_decrypt_en(text, shift)) -if purpose == 'e' and language == 'ru': - print(caesars_encrypt_ru(text, shift)) -if purpose == 'd' and language == 'ru': - print(caesars_decrypt_ru(text, shift)) diff --git a/calculator.py b/calculator.py deleted file mode 100644 index 504dbc6..0000000 --- a/calculator.py +++ /dev/null @@ -1,58 +0,0 @@ -def ten_other(number, system): - new_number = [] - - while number >= system: - new_number.append(number % system) - - number //= system - - new_number.append(number) - - if system == 16: - - for i in new_number: - - num_letters = { - - 10: 'A', 11: 'B', 12: 'C', 13: 'D', 14: 'E', 15: 'F' - - } - - if i >= 10: - new_number[new_number.index(i)] = num_letters[i] - - print(*new_number[::-1], sep='') - - -def bukva_valid(bukva): - if not bukva.isalpha(): - print('Нужно ввести букву!') - return False - if bukva.isalpha(): - return bukva - elif bukva in guessed_letters: - print('Данная буква уже использована, введите другую.') - return False - - -def slovo_valid(slovo): - if not slovo.isalpha(): - print('Нужно ввести слово, состоящее только из букв!') - return False - if slovo.isalpha(): - return slovo - elif slovo in guessed_words: - print('Данное слово уже использована, введите другую.') - return False - - -guessed_letters = [] # список уже названных букв -guessed_words = [] - -let_word = input('Хотите ввести слово(с) или букву(б)? Введите соответсвующий символ из скобок --> "с" или "б": ') -if let_word == 'б': - bukva = input('Введите желаемую букву: ') - guessed_letters += bukva -if let_word == 'c': - slovo = input('Введите желаемое слово: ') - guessed_words += slovo diff --git a/hangman.py b/hangman.py deleted file mode 100644 index d45d5a7..0000000 --- a/hangman.py +++ /dev/null @@ -1,173 +0,0 @@ -import random - -word_list = ['год', 'человек', 'время', 'дело', 'жизнь', 'день', 'рука', 'раз', 'работа', - 'слово', 'место', 'лицо', 'друг', 'глаз', 'вопрос', 'дом', 'сторона', 'страна', 'мир', 'случай', - 'голова', 'ребенок', 'сила', 'конец', 'вид', 'система', 'часть', 'город', 'отношение', 'женщина', - 'деньги', 'земля', 'машина', 'вода', 'отец', 'проблема', 'час', 'право', 'нога', 'решение', 'дверь', - 'образ', 'история', 'власть', 'закон', 'война', 'бог', 'голос', 'тысяча', 'книга', 'возможность', - 'результат', 'ночь', 'стол', 'имя', 'область', 'статья', 'число', 'компания', 'народ', 'жена', - 'группа', 'развитие', 'процесс', 'суд', 'условие', 'средство', 'начало', 'свет', 'пора', 'путь', 'душа'] - - -def get_word(): - return random.choice(word_list).upper() - - -def display_hangman(tries): - stages = [ # финальное состояние: голова, торс, обе руки, обе ноги - ''' - -------- - | | - | O - | \\|/ - | | - | / \\ - - - ''', - # голова, торс, обе руки, одна нога - ''' - -------- - | | - | O - | \\|/ - | | - | / - - - ''', - # голова, торс, обе руки - ''' - -------- - | | - | O - | \\|/ - | | - | - - - ''', - # голова, торс и одна рука - ''' - -------- - | | - | O - | \\| - | | - | - - - ''', - # голова и торс - ''' - -------- - | | - | O - | | - | | - | - - - ''', - # голова - ''' - -------- - | | - | O - | - | - | - - - ''', - # начальное состояние - ''' - -------- - | | - | - | - | - | - - - ''' - ] - return stages[tries] - - -def print_word(word_, list_): - for c in word_: - if c in list_: - print(c, end=' ') - else: - print('_', end=' ') - print() - - -def play(word): - word_completion = '_' * len(word) # строка, содержащая символы _ на каждую букву задуманного слова - guessed = False # сигнальная метка - guessed_letters = [] # список уже названных букв - guessed_words = [] # список уже названных слов - tries = 6 # количество попыток - print("Let's play GUESS THE WORD") - print('Below you can see, how many letters in this word') - print(word_completion) - - while tries != -1: - print('Tries left: ' + str(tries)) - if tries == 0: - print('You lost, word was - ' + word) - print(display_hangman(tries)) - prodolzhenie = input('Do you wanna play again? If yes, enter "y", or press ENTER to leave') - if prodolzhenie == 'y': - play(get_word()) - else: - print('Bye-bye') - break - - print(display_hangman(tries)) - let_word = input('Enter word or letter in russian: ').upper() - - if not let_word.isalpha(): - print('Entered symbol(s) are not letters, try again!') - continue - - if len(let_word) == 1: - if let_word not in guessed_letters: - if let_word in word: - guessed_letters.append(let_word) - for c in word: - if c not in guessed_letters: - print('Guessed letter!') - print_word(word, guessed_letters) - guessed = False - break - guessed = True - if guessed: - print_word(word, guessed_letters) - print('Congrats, you guessed the word!') - prodolzhenie = input('Do you wanna play again? If yes, enter "y", or press ENTER to leave') - if prodolzhenie == 'y': - play(get_word()) - else: - print('Bye-bye') - break - tries -= 1 - else: - print('This letter already exit, enter another one.') - continue - - if len(let_word) > 1: - if let_word not in guessed_words: - guessed_words.append(let_word) - if let_word == word: - print('Поздравляем, вы угадали слово! Вы победили!') - prodolzhenie = input('Do you wanna play again? If yes, enter "y", or press ENTER to leave') - if prodolzhenie == 'y': - play(get_word()) - else: - print('Bye-bye') - break - if let_word != word: - print('Try again. This time you was wrong!') - tries -= 1 - else: - print('Already mentioned, enter another word, please.') - continue - - -print(play(get_word())) diff --git a/kv_matrix_summa_glavnoj_diagonali.py b/kv_matrix_summa_glavnoj_diagonali.py new file mode 100644 index 0000000..39df7b9 --- /dev/null +++ b/kv_matrix_summa_glavnoj_diagonali.py @@ -0,0 +1,6 @@ +n = int(input()) +matrix = [input().split() * n for _ in range(n)] +total = 0 +for i in range(n): + total += int(matrix[i][i]) +print(total) diff --git a/magic_eight b/magic_eight deleted file mode 100644 index 9959fc0..0000000 --- a/magic_eight +++ /dev/null @@ -1,20 +0,0 @@ -import random - -answers = ['Бесспорно', 'Предрешено', 'Никаких сомнений', 'Определённо да', 'Можешь быть уверен в этом', - 'Мне кажется - да', 'Вероятнее всего', 'Хорошие перспективы', 'Знаки говорят - да', 'Да', - 'Пока неясно, попробуй снова', 'Спроси позже', 'Лучше не рассказывать', - 'Сейчас нельзя предсказать', 'Сконцентрируйся и спроси опять', 'Даже не думай', - 'Мой ответ - нет', 'По моим данным - нет', 'Перспективы не очень хорошие', - 'Весьма сомнительно'] -print('Привет Мир, я магический шар, и я знаю ответ на любой твой вопрос.') -name = input('Назови себя: ') -print(f'Привет {name}!') - -again = 'да' - -while again.lower() == 'да': - question = input('Задай вопрос, на который можно ответить утвердительно или отрицательно: ') - print(random.choice(answers)) - again = input('Хотите задать еще один вопрос? (да / нет) ') - if again.lower() != 'да': - print('Возвращайся если возникнут вопросы!') diff --git a/main.py b/main.py index 4f12fe0..e69de29 100644 --- a/main.py +++ b/main.py @@ -1,32 +0,0 @@ -def caesars_encrypt_en(text_inp, shift_inp): - encrypted_text = '' - for c in text_inp: - encrypted_letter = c - if c.isalpha(): - if c.isupper(): - encrypted_letter = ord(c) + shift_inp - if 90 < encrypted_letter < 97: - encrypted_letter -= 26 - elif c.islower(): - encrypted_letter = ord(c) + shift_inp - if encrypted_letter > 122: - encrypted_letter -= 26 - encrypted_letter = chr(encrypted_letter) - encrypted_text += encrypted_letter - return encrypted_text - - -text = input().split() -new_text = [] -for i in range(len(text)): - code_len = 0 - prepin = 0 - if text[i].isalpha(): - code_len = len(text[i]) - if not text[i].isalpha(): - for j in range(len(text[i])): - if not text[i][j].isalpha(): - prepin += 1 - code_len = len(text[i]) - prepin - new_text.append(caesars_encrypt_en(text[i], code_len)) -print(*new_text) diff --git a/pass_generator.py b/pass_generator.py deleted file mode 100644 index ca48fcf..0000000 --- a/pass_generator.py +++ /dev/null @@ -1,35 +0,0 @@ -import random - -digits = '0123456789' -lowercase_letters = 'abcdefghijklmnopqrstuvwxyz' -uppercase_letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' -punctuation = '!#$%&*+-=?@^_' -chars = '' - -pass_q = input('How many passwords do you need? Please enter number: ') -passlen = input('Enter password length in numbers. (For example: 5): ') -pass_dig = input('Do you want to add digits to your password? Type y(yes) or n(no): ') -pass_up = input('Do you want to add uppercase letters to your password? Type y(yes) or n(no): ') -pass_low = input('Do you want to add lowercase letters to your password? Type y(yes) or n(no): ') -pass_ambig = input('Do you want to remove ambiguity symbols your password? Type y(yes) or n(no): ') - -if pass_dig == 'y': - chars += digits -if pass_up == 'y': - chars += uppercase_letters -if pass_low == 'y': - chars += lowercase_letters -if pass_ambig == 'y': - for c in 'il1Lo0O': - chars.replace(c, '') - - -def generate_password(length, char): - new_pass = '' - for _ in range(length): - new_pass += random.choice(char) - return new_pass - - -for _ in range(int(pass_q)): - print(generate_password(int(passlen), chars)) diff --git a/ugadajka.py b/ugadajka.py deleted file mode 100644 index 2483d5e..0000000 --- a/ugadajka.py +++ /dev/null @@ -1,30 +0,0 @@ -from random import randint - -a = randint(1, 100) -print("'Добро пожаловать в числовую угадайку'") -name = input('Введите Ваше имя: ') - - -def is_valid(num): - if not num.isdigit(): - print('Нужно ввести (неотрицательное) ЧИСЛО!') - return False - if num.isdigit() and 1 <= int(num) <= 100: - return num - if num.isdigit() and int(num) not in range(1, 101): - print('Число в диапазоне от 1 до 100!') - return False - - -while True: - guess = input(f'Уважаемый(ая) {name}, Введите число от 1 до 100: ') - if is_valid(str(guess)) is False: - continue - elif int(guess) > a: - print('Слишком МНОГО, попробуйте еще раз!') - elif int(guess) < a: - print('Слишком мало, давайте еще разок!') - elif int(guess) == a: - print('Вы угадали, поздравляем!') - break -print('Спасибо, что играли в числовую угадайку. Еще увидимся...') \ No newline at end of file diff --git a/venv/test.py b/venv/test.py new file mode 100644 index 0000000..e69de29