What is the first project to do in Python

онлайн тренажер по питону
Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

Mastering Python: Project Ideas for Beginners

Why Start with a Simple Project?

A common mistake for beginners is tackling complex projects like creating a Telegram bot or neural network right away. This leads to frustration and the feeling that "programming is not for me."

Starting with small, complete projects allows you to:

  • Apply theoretical knowledge in practice
  • Reinforce skills in working with variables, loops, conditions, and functions
  • Experience the joy of completing a project
  • Obtain your first working result to be proud of
  • Gradually increase complexity without the risk of burnout

Top 10 Python Project Ideas for Beginners

1. Calculator

This is a classic programming exercise for beginners. You'll learn to handle user input and perform basic mathematical operations.

What to use:

  • input() to get data
  • if, elif, else statements
  • Simple functions
  • Exception handling

Example Implementation:

def calculator():
    try:
        a = float(input("Enter the first number: "))
        b = float(input("Enter the second number: "))
        op = input("Enter the operation (+, -, *, /): ")

        if op == '+':
            print(f"Result: {a + b}")
        elif op == '-':
            print(f"Result: {a - b}")
        elif op == '*':
            print(f"Result: {a * b}")
        elif op == '/':
            if b != 0:
                print(f"Result: {a / b}")
            else:
                print("Error: division by zero!")
        else:
            print("Invalid operation!")
    except ValueError:
        print("Error: enter a valid number!")

calculator()

2. Password Generator

This project helps you learn how to work with modules and random values, which is essential for security.

What to use:

  • random module
  • string module
  • Loops and lists
  • User input

Example Implementation:

import random
import string

def generate_password(length, include_symbols=True):
    characters = string.ascii_letters + string.digits
    if include_symbols:
        characters += string.punctuation

    password = ''.join(random.choice(characters) for _ in range(length))
    return password

def main():
    try:
        length = int(input("Enter the password length (minimum 8): "))
        if length < 8:
            print("Password length must be at least 8 characters!")
            return

        symbols = input("Include special characters? (y/n): ").lower() == 'y'
        password = generate_password(length, symbols)
        print(f"Your password: {password}")
    except ValueError:
        print("Error: enter a valid number!")

main()

3. "Guess the Number" Game

A great way to practice using loops, conditions, and working with user input.

import random

def guess_number_game():
    number = random.randint(1, 100)
    attempts = 0
    max_attempts = 10

    print("Welcome to the 'Guess the Number' game!")
    print(f"I have chosen a number between 1 and 100. You have {max_attempts} attempts.")

    while attempts < max_attempts:
        try:
            guess = int(input(f"Attempt {attempts + 1}: "))
            attempts += 1

            if guess < number:
                print("Higher!")
            elif guess > number:
                print("Lower!")
            else:
                print(f"Congratulations! You guessed the number in {attempts} attempts.")
                return
        except ValueError:
            print("Enter a valid number!")

    print(f"Game over! The number was: {number}")

guess_number_game()

4. Simple To-Do List

Learn to work with lists, functions, and files to save data.

import json
import os

TASKS_FILE = 'tasks.json'

def load_tasks():
    if os.path.exists(TASKS_FILE):
        with open(TASKS_FILE, 'r', encoding='utf-8') as file:
            return json.load(file)
    return []

def save_tasks(tasks):
    with open(TASKS_FILE, 'w', encoding='utf-8') as file:
        json.dump(tasks, file, ensure_ascii=False, indent=2)

def show_tasks(tasks):
    if not tasks:
        print("The task list is empty.")
    else:
        print("\nYour tasks:")
        for idx, task in enumerate(tasks, 1):
            status = "✓" if task.get('completed', False) else "○"
            print(f"{idx}. {status} {task['text']}")

def add_task(tasks):
    task_text = input("Enter a new task: ")
    tasks.append({'text': task_text, 'completed': False})
    print("Task added!")

def complete_task(tasks):
    show_tasks(tasks)
    try:
        task_num = int(input("Enter the number of the completed task: ")) - 1
        if 0 <= task_num < len(tasks):
            tasks[task_num]['completed'] = True
            print("Task marked as completed!")
        else:
            print("Invalid task number!")
    except ValueError:
        print("Enter a valid number!")

def main():
    tasks = load_tasks()

    while True:
        print("\n=== TASK LIST ===")
        print("1. Show tasks")
        print("2. Add task")
        print("3. Mark as completed")
        print("4. Exit")

        choice = input("Select an action (1-4): ")

        if choice == '1':
            show_tasks(tasks)
        elif choice == '2':
            add_task(tasks)
            save_tasks(tasks)
        elif choice == '3':
            complete_task(tasks)
            save_tasks(tasks)
        elif choice == '4':
            print("Goodbye!")
            break
        else:
            print("Invalid selection!")

main()

5. Body Mass Index (BMI) Calculator

This project will help you understand mathematical calculations and output formatting.

def calculate_bmi():
    try:
        weight = float(input("Enter weight (kg): "))
        height = float(input("Enter height (m): "))

        if weight <= 0 or height <= 0:
            print("Weight and height must be positive numbers!")
            return

        bmi = weight / (height ** 2)

        print(f"\nYour body mass index: {bmi:.2f}")

        if bmi < 18.5:
            category = "Underweight"
        elif bmi < 25:
            category = "Normal weight"
        elif bmi < 30:
            category = "Overweight"
        else:
            category = "Obese"

        print(f"Category: {category}")

    except ValueError:
        print("Error: enter valid numbers!")

calculate_bmi()

6. Currency Converter

Learn to get data from the user and perform calculations with exchange rates.

def currency_converter():
    # Exchange rates (in a real project, you can get them through the API)
    exchange_rates = {
        'USD': {'RUB': 75.5, 'EUR': 0.85},
        'EUR': {'RUB': 88.2, 'USD': 1.18},
        'RUB': {'USD': 0.013, 'EUR': 0.011}
    }

    print("Available currencies: USD, EUR, RUB")

    try:
        amount = float(input("Enter the amount: "))
        from_currency = input("From which currency: ").upper()
        to_currency = input("To which currency: ").upper()

        if from_currency == to_currency:
            print(f"Result: {amount} {to_currency}")
            return

        if from_currency in exchange_rates and to_currency in exchange_rates[from_currency]:
            rate = exchange_rates[from_currency][to_currency]
            result = amount * rate
            print(f"Result: {result:.2f} {to_currency}")
        else:
            print("Unsupported currency pair!")

    except ValueError:
        print("Error: enter a valid amount!")

currency_converter()

7. Countdown Timer

Master working with time and create a useful tool.

import time

def countdown_timer():
    try:
        minutes = int(input("Enter the number of minutes: "))
        seconds = int(input("Enter the number of seconds: "))

        total_seconds = minutes * 60 + seconds

        print(f"Timer started for {minutes} minutes and {seconds} seconds")

        while total_seconds > 0:
            mins, secs = divmod(total_seconds, 60)
            print(f"\rRemaining: {mins:02d}:{secs:02d}", end='', flush=True)
            time.sleep(1)
            total_seconds -= 1

        print("\nTime's up!")

    except ValueError:
        print("Error: enter valid numbers!")
    except KeyboardInterrupt:
        print("\nTimer stopped by user!")

countdown_timer()

8. File Organizer

A script to automatically sort files by extension.

import os
import shutil

def organize_files(directory):
    if not os.path.exists(directory):
        print("Folder not found!")
        return

    # Create folders for different file types
    file_types = {
        'images': ['.jpg', '.jpeg', '.png', '.gif', '.bmp'],
        'documents': ['.pdf', '.doc', '.docx', '.txt', '.xlsx'],
        'videos': ['.mp4', '.avi', '.mkv', '.mov'],
        'music': ['.mp3', '.wav', '.flac'],
        'archives': ['.zip', '.rar', '.7z', '.tar']
    }

    moved_files = 0

    for filename in os.listdir(directory):
        if os.path.isfile(os.path.join(directory, filename)):
            file_extension = os.path.splitext(filename)[1].lower()

            for folder, extensions in file_types.items():
                if file_extension in extensions:
                    folder_path = os.path.join(directory, folder)
                    if not os.path.exists(folder_path):
                        os.makedirs(folder_path)

                    source = os.path.join(directory, filename)
                    destination = os.path.join(folder_path, filename)

                    try:
                        shutil.move(source, destination)
                        moved_files += 1
                        print(f"Moved: {filename} → {folder}/")
                    except Exception as e:
                        print(f"Error while moving {filename}: {e}")
                    break

    print(f"Organization completed! Moved files: {moved_files}")

def main():
    directory = input("Enter the path to the folder to organize: ")
    organize_files(directory)

main()

9. "Rock, Paper, Scissors" Game

A classic game for learning randomness and logic.

import random

def rock_paper_scissors():
    choices = ['rock', 'scissors', 'paper']
    player_score = 0
    computer_score = 0

    print("Welcome to the 'Rock, Paper, Scissors' game!")
    print("Enter 'exit' to quit")

    while True:
        player_choice = input("\nYour choice (rock/scissors/paper): ").lower()

        if player_choice == 'exit':
            break

        if player_choice not in choices:
            print("Invalid choice! Try again.")
            continue

        computer_choice = random.choice(choices)
        print(f"Computer chose: {computer_choice}")

        if player_choice == computer_choice:
            print("Draw!")
        elif (player_choice == 'rock' and computer_choice == 'scissors') or \
             (player_choice == 'scissors' and computer_choice == 'paper') or \
             (player_choice == 'paper' and computer_choice == 'rock'):
            print("You win!")
            player_score += 1
        else:
            print("Computer wins!")
            computer_score += 1

        print(f"Score - You: {player_score}, Computer: {computer_score}")

    print(f"\nFinal score - You: {player_score}, Computer: {computer_score}")
    if player_score > computer_score:
        print("Congratulations! You won the overall standings!")
    elif computer_score > player_score:
        print("The computer won the overall standings!")
    else:
        print("Overall draw!")

rock_paper_scissors()

10. Random Quote Generator

Create a motivating application with a database of quotes.

import random
import json

def create_quotes_file():
    quotes = [
        "Programming is not a science, it is a craft.",
        "Code should be written for people, not for computers.",
        "Simplicity is the ultimate sophistication.",
        "The best code is the code you don't have to write.",
        "A programmer is someone who solves a problem you didn't know you had.",
        "Debugging is twice as hard as writing the code in the first place.",
        "A good programmer is someone who always looks both ways before crossing a one-way street.",
        "Code without tests is legacy code.",
        "First learn to program, then teach others.",
        "Programming is the art of telling a human what they want the computer to do."
    ]

    with open('quotes.json', 'w', encoding='utf-8') as file:
        json.dump(quotes, file, ensure_ascii=False, indent=2)

def load_quotes():
    try:
        with open('quotes.json', 'r', encoding='utf-8') as file:
            return json.load(file)
    except FileNotFoundError:
        create_quotes_file()
        return load_quotes()

def add_quote(quotes):
    new_quote = input("Enter a new quote: ")
    quotes.append(new_quote)

    with open('quotes.json', 'w', encoding='utf-8') as file:
        json.dump(quotes, file, ensure_ascii=False, indent=2)

    print("Quote added!")

def main():
    quotes = load_quotes()

    while True:
        print("\n=== QUOTE GENERATOR ===")
        print("1. Show a random quote")
        print("2. Add a quote")
        print("3. Show all quotes")
        print("4. Exit")

        choice = input("Select an action (1-4): ")

        if choice == '1':
            print(f"\n💡 {random.choice(quotes)}")
        elif choice == '2':
            add_quote(quotes)
        elif choice == '3':
            print("\nAll quotes:")
            for i, quote in enumerate(quotes, 1):
                print(f"{i}. {quote}")
        elif choice == '4':
            print("Goodbye!")
            break
        else:
            print("Invalid selection!")

main()

How to Choose the Ideal First Project?

Selection Criteria:

  • Assess your knowledge: If you only know the basics, start with a calculator or guess the number game.
  • Choose something interesting: Do you like games? Create text games. Do you like working with data? Write converters and calculators.
  • Take small steps: A complete simple project is better than an unfinished complex one.
  • Think about practical benefits: Create something you can use in everyday life.

Recommended Sequence:

  1. Calculator (basics)
  2. Guess the number game (loops and conditions)
  3. Password generator (modules and randomness)
  4. To-Do List (data handling)
  5. File Organizer (file system operations)

Helpful Tips for Beginners

Project Planning:

  • Start with a simple description of what the program should do
  • Break the task into small parts
  • Implement a minimal working version, then improve it

Best Practices:

  • Use clear variable and function names
  • Add comments to complex parts of the code
  • Handle user input errors
  • Test the program with different data

Where to Find Help:

  • Official Python documentation
  • Programming communities (Stack Overflow, GitHub)
  • Video tutorials and courses
  • Practical tasks on platforms like Codewars

What Skills Will You Gain?

After implementing these projects, you will master:

Programming Fundamentals:

  • Working with variables and data types
  • Using functions and modules
  • Control structures (loops, conditions)
  • Exception handling

Practical Skills:

  • Interacting with the user through the console
  • Working with files and data
  • Using standard Python libraries
  • Debugging and testing code

Soft Skills:

  • Planning and decomposing tasks
  • Finding and fixing errors
  • Reading documentation
  • Self-study of new features

Next Steps After Your First Project

  • Improve an existing project: add new features, improve the interface
  • Learn web development: create a web version of your project using Flask
  • Master working with databases: save data to SQLite
  • Try GUI: create a graphical interface with tkinter
  • Learn API: integrate external services into your projects

Your first Python project doesn't have to be complicated. The main thing is that it should be interesting to you and achievable in a reasonable time. By completing your first project, you will feel confident and understand that programming is a fascinating process of creating useful solutions.

Don't be afraid to experiment, add to your projects, and even break them - it is in the process of trial and error that true knowledge and programming skills are born.

News