TGViewer
Python RU Python RU @pro_python_code · 12.3K subscribers
Post #1034 2.48K
🐍 10 проектов на Python для начинающих

1. Игра “Виселица

Инструкции: Создайте классическую игру “Виселица”. Предложите пользователю угадывать слово по буквам до тех пор, пока он не угадает его правильно или пока не закончатся попытки.
import random

def hangman():
words = ['python', 'hangman', 'programming', 'code']
word = random.choice(words)
guesses = ''
attempts = 6

while attempts > 0:
for char in word:
if char in guesses:
print(char, end=' ')
else:
print('_', end=' ')
print()

guess = input("Guess a letter: ")
guesses += guess

if guess not in word:
attempts -= 1

if set(word) <= set(guesses):
print("Congratulations! You guessed the word.")
break
elif attempts == 0:
print("Sorry, you ran out of attempts. The word was", word)

hangman()


2. Калькулятор


Инструкции: Постройте простой калькулятор, выполняющий основные арифметические операции (+, -, *, /) над двумя числами.
def calculator():
num1 = float(input("Enter the first number: "))
operator = input("Enter an operator (+, -, *, /): ")
num2 = float(input("Enter the second number: "))

if operator == '+':
print(num1 + num2)
elif operator == '-':
print(num1 - num2)
elif operator == '*':
print(num1 * num2)
elif operator == '/':
print(num1 / num2)
else:
print("Invalid operator")

calculator()


3. Угадайте число

Инструкции: Создайте игру, в которой компьютер генерирует случайное число, а игрок пытается угадать его за определенное количество попыток.
import random

def guess_the_number():
number = random.randint(1, 100)
attempts = 0

while True:
guess = int(input("Take a guess: "))
attempts += 1

if guess < number:
print("Too low!")
elif guess > number:
print("Too high!")
else:
print("Congratulations! You guessed the number in", attempts, "attempts.")
break

guess_the_number()

4. Список дел

Инструкции: Создать приложение для составления списка дел, позволяющее пользователю добавлять, просматривать и удалять задачи.
def todo_list():
tasks = []

while True:
print("1. Add a task")
print("2. View tasks")
print("3. Remove a task")
print("4. Quit")

choice = input("Enter your choice: ")

if choice == '1':
task = input("Enter a task: ")
tasks.append(task)
elif choice == '2':
if tasks:
print("Tasks:")
for task in tasks:
print(task)
else:
print("No tasks.")
elif choice == '3':
if tasks:
task = input("Enter the task to remove: ")
if task in tasks:
tasks.remove(task)
print("Task removed.")
else:
print("Task not found.")
else:
print("No tasks.")
elif choice == '4':
break
else:
print("Invalid choice. Try again.")

todo_list()


▪ Продолжение

@pro_python_code
  • 🔥 8
  • 👍 6
  • ❤ 1
More from @pro_python_code
  1. Oct 4, 2026Hugging Face исследовали multi-harness RL: обучение с подкреплением сразу через Claude Cod…
  2. Oct 1, 2026DeepSeek Harness вышел на десктоп: плагины без терминала и задачи по расписанию DeepSeek в…
  3. Sep 30, 2026Пишем игру на Python: неоновая аркада с разбором кода и ИИ Pygame часто считают библиотеко…
  4. Sep 29, 2026photo post
  5. Sep 28, 2026photo post
  6. Sep 26, 2026🐧 Linux Cheat Sheet - шпаргалка по командам Linux Самая удобная шпаргалка по Linux и Bash…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →