/
EkaterinaZan
/
Python_Homework
Обзор
Документация
Войти
/
EkaterinaZan
/
Python_Homework
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
08.10.25
143 строки
4 KB
EkaterinaZan
update 08.10.25
10 окт 2025, 14:15
10 окт 2025, 14:15
eee25ee
Код
Авторство
О чём код?
task 1: import random numb = random.randint(1,100) attempt = 3 while attempt!=0: a = input("Введите число: ") if (str(a).isdigit()): if int(a) > numb: print("Загаданное число МЕНЬШЕ") attempt -= 1 if int(a) < numb: print("Загаданное число БОЛЬШЕ") attempt -= 1 if attempt == 1: if numb % 2 == 0: print("Подсказка: число чётное") else: print("Подсказка: число нечётное") if int(a)== numb: print(f"Поздравляю! вы угадали число {numb}.") break if not (str(a).isdigit()): print("Вы ввели НЕ ЧИСЛО! Введите число") if attempt == 0: print(f"Вы проиграли! Загаданное число:{numb}") task 2: from collections import Counter text = input("Enter a sentence: ") count_vowels = 0 count_non_vowels = 0 count_tabs = 0 count_words = 0 for char in text: if char in "aeyuioуеыаоэяию": count_vowels += 1 if char not in "aeyuioуеыаоэяию ": count_non_vowels += 1 if char == ' ': count_tabs += 1 char_count = Counter(char for char in text if char != ' ') count_words = count_tabs + 1 print("Number of vowels:", count_vowels) print("Number of non-vowels:", count_non_vowels) print("Number of tabs:", count_tabs) print("Number of 3 the most popular symbols:", char_count.most_common(3)) print("Number of words:", count_words) task 3: import random attempts = 3 score1 = 0 score2 = 0 print("Welcom to the Game rock, paper, scissor!") while attempts > 0: b = input("Choose: rock, paper, scissor") a = random.choice(["rock", "paper", "scissor"]) if b != "rock" and b != "paper" and b != "scissor": print("Invalid choice") continue if a == b: print('Draw') attempts -= 1 score1 += 1 score2 += 1 if a == "rock" and b == "scissor" or \ a == "scissor" and b == "paper" or \ a == "paper" and b == "rock": print("You lost!") score2 += 1 attempts -= 1 else: print("You won!") attempts -= 1 score1 += 1 if attempts == 0: if score1 > score2: print("You win!") else: print("You lose!") task 4: count_account = int(input("How many accounts do you have? ")) balance = [0] * count_account #Список балансов for i in range(count_account): balance[i] = int(input(f"What is your balance for account {i+1}? ")) option = int(input(("Choose number of option:\n" "1 - transfer;\n" "2 - adding funds to account;\n" "3 - deduction from the account;\n" "4 - checking the account balance;\n" "5 - creating an account."))) if option == 1: a = int(input("Enter the amount of money: ")) def transfer(a): b = int(input("Enter the balance number from which yo want to transfer money: ")) c = int(input("Enter the balance number to which yo want to transfer money: ")) if balance[b-1] < a: return f"You don't have enough money!" else: balance[c-1] += a balance[b-1] -= a return f"You have {balance[c-1]}$ on {c} balance and {balance[b-1]}$ on {b} balance." print(transfer(a)) if option == 2: a = int(input("Enter the amount of money: ")) def add_funds(a): b = int(input("Enter the balance number to which yo want to add funds: ")) balance[b-1] += a return f"You have {balance[b-1]}$ on {b} balance" print(add_funds(a)) if option == 3: a = int(input("Enter the amount of money: ")) def deduct(a): b = int(input("Enter the balance number from which yo want to deduct: ")) if balance[b-1] < a: return f"You don't have enough money!" else: balance[b-1] -= a return f"You have {balance[b-1]}$ on {b} balance" print(deduct(a)) if option == 4: b = int(input("Enter the balance number where you want to chek the account balance: ")) def check_balance(b): return f"You have {balance[b-1]}$ on {b} balance" print(check_balance(b)) if option == 5: print("You may call to this number to create new account: +79000339474.") print("Thank you for using this program!")