0% found this document useful (0 votes)
2 views3 pages

Python 10 Programs With Output

The document presents 10 Python programs along with their outputs, covering basic programming concepts. Programs include printing 'Hello, World!', adding two numbers, checking even or odd, finding factorials, generating Fibonacci series, checking for prime numbers, reversing a number, palindrome checking, creating a multiplication table, and finding the GCD. Each program is accompanied by its respective output for clarity.

Uploaded by

hafijask1812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Python 10 Programs With Output

The document presents 10 Python programs along with their outputs, covering basic programming concepts. Programs include printing 'Hello, World!', adding two numbers, checking even or odd, finding factorials, generating Fibonacci series, checking for prime numbers, reversing a number, palindrome checking, creating a multiplication table, and finding the GCD. Each program is accompanied by its respective output for clarity.

Uploaded by

hafijask1812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

10 Python Programs with Output

1. Hello World
print("Hello, World!")
Output:
Hello, World!

2. Add Two Numbers


a = 5
b = 3
print("Sum:", a + b)
Output:
Sum: 8

3. Check Even or Odd


num = 4
if num % 2 == 0:
print("Even")
else:
print("Odd")
Output:
Even

4. Find Factorial (Using Loop)


num = 5
fact = 1
for i in range(1, num + 1):
fact *= i
print("Factorial:", fact)
Output:
Factorial: 120

5. Fibonacci Series
n = 5
a, b = 0, 1
for _ in range(n):
print(a, end=" ")
a, b = b, a + b
Output:
01123

6. Check Prime Number


num = 7
if num > 1:
for i in range(2, num):
if num % i == 0:
print("Not Prime")
break
else:
print("Prime")
else:
print("Not Prime")
Output:
Prime

7. Reverse a Number
num = 1234
rev = int(str(num)[::-1])
print("Reversed:", rev)
Output:
Reversed: 4321

8. Palindrome Check
text = "madam"
if text == text[::-1]:
print("Palindrome")
else:
print("Not Palindrome")
Output:
Palindrome

9. Multiplication Table
num = 5
for i in range(1, 11):
print(f"{num} x {i} = {num * i}")
Output:
5x1=5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
10. Find GCD
import math
a, b = 36, 60
print("GCD:", math.gcd(a, b))
Output:
GCD: 12

You might also like