Programming

30+ Python Basic Programs for Beginners to Practice in 2026

Master coding with this list of 30+ Python basic programs for beginners. From simple math to real-world utilities, get the hands-on practice you need to level up.

Modern Age Coders
Modern Age Coders March 29, 2026
16 min read
30+ Python Basic Programs for Beginners to Practice in 2026

You can watch a hundred hours of tutorials, but until your fingers hit the keyboard, you aren't actually learning Python. Reading about coding is like reading a book on how to swim—you have to get in the water to actually figure it out.

If you feel stuck in "tutorial hell," freezing the second you open a blank code editor, the only way out is to start building. To help you cross that bridge, we have curated a list of 35 Python basic programs for beginners, ranging from simple math to real-world utilities.

Let's transition you from just reading code to confidently writing your own scripts.

Why You Need to Practice with Basic Python Programs

When you type code out manually, you build muscle memory. You learn where the colons go, you figure out how Python handles indentation, and most importantly, you learn how to read error messages.

Making mistakes is the fastest way to learn. When a program crashes, you are forced to debug it, and that debugging process is what actually makes you a developer. Small, basic programs are the building blocks of complex software. You cannot build a machine learning model or a backend API if you do not understand how a for loop works.

Before you dive into the list, if you need a quick refresher on how the language operates, bookmark our comprehensive Python for beginners guide to keep handy while you code.

Level 1: The Absolute Basics (Programs 1–10)

These first ten programs are all about getting comfortable with Python's syntax. You will handle basic math, variable assignments, and simple user inputs. Try running these directly in your terminal or by using the official Python.org standard environment.

1. Print "Hello, World!"

The classic right of passage for every programmer. Just get the computer to say hi back to you.

2. Add Two Numbers

Write a script that asks the user to input two numbers, adds them together, and prints the total. You will learn how to use the input() function and convert strings to integers.

3. Find the Square Root of a Number

Import the math module and use it to calculate the square root of any number the user provides.

4. Calculate the Area of a Triangle

Take the base and height as inputs and apply the standard mathematical formula (0.5 * base * height) to find the area.

5. Swap Two Variables

Create two variables, x and y. Write a program that swaps their values. Try doing it the traditional way with a temporary variable, and then try Python's incredibly clean x, y = y, x method.

6. Generate a Random Number

Import the random module and write a script that prints a random number between 1 and 100 every time you run it.

7. Convert Kilometers to Miles

A practical utility script. Take an input in kilometers and multiply it by the conversion factor (0.621371) to output miles.

8. Convert Celsius to Fahrenheit

Similar to the previous program, but this time you will use the formula (Celsius * 1.8) + 32 to convert temperatures.

9. Check if a Number is Positive, Negative, or Zero

This introduces control flow. Use if, elif, and else statements to check the state of a user's inputted number.

10. Check if a Number is Even or Odd

You will use the modulo operator (%) to see if a number is cleanly divisible by 2. If you want to dive deeper into how Python handles division and remainders, check out our guide on understanding operators like floor division in Python.

Level 2: Loops, Conditions, and Logic (Programs 11–20)

Now that you have the syntax down, it is time to force your brain to think logically. These programs require loops (for and while) and nested conditions.

11. Check if a Year is a Leap Year

Write a program that determines if a year is a leap year based on the rules (divisible by 4, but not 100, unless it is also divisible by 400).

12. Find the Largest Among Three Numbers

Take three numbers as input and use if/elif/else blocks with and operators to find the largest one.

13. Check if a Number is a Prime Number

Write a loop that checks if a number is divisible by anything other than 1 and itself. This is a classic computer science problem.

14. Print All Prime Numbers in an Interval

Take the logic from program 13, but wrap it in another loop to print every prime number between 1 and 100.

15. Find the Factorial of a Number

Use a for loop to multiply a number by every integer below it (e.g., 5! = 5 x 4 x 3 x 2 x 1).

16. Display the Multiplication Table

Ask the user for a number, then use a loop to print out its multiplication table from 1 to 10.

17. Print the Fibonacci Sequence

Print a sequence where the next number is found by adding up the two numbers before it (0, 1, 1, 2, 3, 5, 8...). This is a fantastic test of your variable-updating skills.

18. Check if a Number is an Armstrong Number

Check if an n-digit number equals the sum of its digits raised to the power of n. This sounds complicated, but breaking it down is great practice.

19. Find the Sum of Natural Numbers

Write a script that adds up all positive integers up to a number provided by the user.

20. Display Powers of 2 Using an Anonymous Function

Learn how to use Python's lambda functions paired with the map() function to generate a list of powers of 2.

Level 3: Strings, Lists, and Functions (Programs 21–30)

The third tier introduces data structures like lists and dictionaries, and forces you to modularize your code by writing your own functions. If you haven't set up a local coding environment yet, skip the headache of manual installations. You can use a vibe coding platform like Replit to practice these modular programs right in your browser, and even collaborate with their AI agent when you get stuck.

21. Find the ASCII Value of a Character

Use Python's built-in ord() function to find the numerical value of any character on your keyboard.

22. Find HCF or GCD of Two Numbers

Write a function that calculates the Highest Common Factor (or Greatest Common Divisor) of two numbers using a while loop.

23. Make a Simple Calculator

Create a calculator that can add, subtract, multiply, and divide. Structure it so each math operation is its own function. If you aren't sure why this matters, read up on the advantages of using functions in Python.

24. Check Whether a String is a Palindrome

Write a script that checks if a word is spelled the same way backward as it is forward. Hint: look into Python's string slicing [::-1].

25. Remove Punctuations from a String

Take a messy sentence full of commas and exclamation points, and use a loop to strip them all out, leaving only the words.

26. Sort Words in Alphabetical Order

Take a sentence from the user, split it into individual words, and use the .sort() method to arrange them alphabetically.

27. Count the Number of Each Vowel

Ask the user for a string and use a dictionary to count how many times 'a', 'e', 'i', 'o', and 'u' appear.

28. Merge Two Dictionaries

Create two dictionaries with fake user data and write a script to merge them into one single dictionary.

29. Catch Multiple Exceptions in One Line

Write a script that intentionally causes a division-by-zero error and a value error, and use a try/except block to catch and handle both safely without crashing the program.

30. Safely Open, Read, and Write to a File

Create a text file using Python, write a sentence to it, close it, and then open it back up to read the contents using the with open() context manager.

Level 4: Real-World Utilities (Programs 31–35)

To really hit that "30+" mark, let's look at a few scripts that mimic what actual developers build on a day-to-day basis. These programs mix logic, modules, and data formatting.

31. Get the Current Date and Time

Import the datetime module and format the output so it prints today's date and the current time in a readable, human-friendly way (like "Monday, October 12, 2026").

32. Check if Two Strings are Anagrams

Write a script that takes two words from the user, converts them to lowercase, sorts their letters, and checks if they contain the exact same characters.

33. Generate a Secure Random Password

Import both the random and string modules. Write a function that generates a 12-character password containing a mix of uppercase letters, lowercase letters, numbers, and symbols.

34. Build a Simple Countdown Timer

Import the time module. Ask the user for a number of seconds, and use a while loop paired with time.sleep(1) to print a countdown that ends with "Time's up!".

35. Filter a List Using List Comprehensions

Take a list of 20 random numbers. Instead of using a standard for loop, use Python's powerful list comprehension syntax to create a brand new list that contains only the even numbers from the original list.

How to Get the Most Out of This List

Having a list of programs is only half the battle. How you practice determines how fast you learn.

First, do not copy and paste. It is tempting to Google the solutions, copy the code, run it, and tell yourself you learned it. You didn't. You have to type the code out yourself. The physical act of typing builds the mental connections you need.

Second, break things on purpose. Once you get a program working, change a variable. Delete an indent. See what kind of error Python throws at you. Getting familiar with error messages makes debugging much less scary in the future.

Finally, combine programs. Once you finish this list, start mashing them together. Build a secure password generator that saves the output to a text file, or a calculator that checks if the final answer is a prime number.

Conclusion

Completing these 35 Python basic programs for beginners gives you a rock-solid grasp of programming fundamentals. Consistency is key—tackle two or three programs daily, and the logic will quickly click.

Ready to stop guessing and start building real-world software? Take your skills to the professional level by enrolling in Modern Age Coders' comprehensive Python courses. We will teach you how to write the clean, efficient code that employers actually want to see.

Modern Age Coders

About Modern Age Coders

Expert educators passionate about making coding accessible and fun for learners of all ages.

Ask Misti AI
Chat with us