Learning Python becomes much easier when you start with small, working programs. Instead of reading too much theory, running simple programs helps you understand how Python actually works. This article lists 10 simple Python programs for beginners, each with clear code and example output. These programs use only basic concepts and are ideal for students, first-time learners, and anyone new to programming.
10 Simple Python Programs for Beginners

You can run these Python programs either using an online Python compiler or by installing Python on your computer. Beginners often start with online compilers because they require no setup. Simply copy the code, paste it into the editor, and click Run to see the output.
1. Print “Hello, World!”
This is usually the first program beginners write in any programming language.
Python Code
print("Hello, World!")Output
Hello, World!
Explanation
The print() function displays text on the screen. This program checks whether Python is installed and working correctly.
2. Add Two Numbers
This program takes two numbers from the user and displays their sum.
Python Code
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Sum:", a + b)
Output
Enter first number: 5
Enter second number: 3
Sum: 8
Explanation
input() takes user input. int() converts the input into numbers so Python can add them.
3. Check Whether a Number Is Even or Odd
This is one of the most common beginner programs.
Python Code
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even number")
else:
print("Odd number")
Output
Enter a number: 7
Odd number
Explanation
The % operator checks the remainder. If the remainder is 0, the number is even.
4. Find the Largest of Two Numbers
Python Code
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
if a > b:
print("Largest number:", a)
else:
print("Largest number:", b)
Output
Largest number: 10
5. Display Numbers from 1 to 10
Python Code
for i in range(1, 11):
print(i)
Output
1
2
3
4
5
6
7
8
9
10
Explanation
The for loop repeats code. range(1, 11) generates numbers from 1 to 10.
6. Find the Factorial of a Number
Python Code
num = int(input("Enter a number: "))
fact = 1
for i in range(1, num + 1):
fact = fact * i
print("Factorial:", fact)
Output
Enter a number: 5
Factorial: 120
7. Reverse a String
Python Code
text = input("Enter a string: ")
print("Reversed string:", text[::-1])
Output
Reversed string: nohtyP
8. Check Whether a Number Is Positive or Negative
Python Code
num = int(input("Enter a number: "))
if num > 0:
print("Positive number")
elif num < 0:
print("Negative number")
else:
print("Zero")
9. Find the Sum of Natural Numbers
Python Code
n = int(input("Enter a number: "))
total = 0
for i in range(1, n + 1):
total += i
print("Sum:", total)
10. Simple Calculator
Python Code
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)
Conclusion
These simple Python programs help beginners understand the basics of input, output, conditions, and loops. Practising these programs builds confidence and prepares you for more advanced concepts later.
Once you are comfortable with these, the next step is to try small Python projects and real-life applications.
Leave a Reply