0% found this document useful (0 votes)
24 views7 pages

Python Programs for Class 10

Uploaded by

niyamyadav2009
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)
24 views7 pages

Python Programs for Class 10

Uploaded by

niyamyadav2009
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

Class 10 – Python Practical Programs

Program 1: Print Hello World

print("Hello World")

Program 2: Add Two Numbers

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
print("Sum =", a + b)

Program 3: Even or Odd

n = int(input("Enter a number: "))


if n % 2 == 0:
print("Even")
else:
print("Odd")
Program 4: Greatest of Two Numbers

a = int(input())
b = int(input())
if a > b:
print(a)
else:
print(b)

Program 5: Greatest of Three Numbers

a = int(input())
b = int(input())
c = int(input())
if a>b and a>c:
print(a)
elif b>c:
print(b)
else:
print(c)

Program 6: Positive, Negative or Zero

n = int(input())
if n > 0:
print("Positive")
elif n < 0:
print("Negative")
else:
print("Zero")
Program 7: Print 1 to 10

for i in range(1, 11):


print(i)

Program 8: Sum of First 10 Numbers

total = 0
for i in range(1, 11):
total = total + i
print(total)

Program 9: Table of a Number

n = int(input())
for i in range(1, 11):
print(n, "x", i, "=", n*i)
Program 10: Factorial of a Number

n = int(input())
fact = 1
for i in range(1, n+1):
fact = fact * i
print(fact)

Program 11: Prime Number

n = int(input())
count = 0
for i in range(1, n+1):
if n % i == 0:
count += 1
if count == 2:
print("Prime")
else:
print("Not Prime")

Program 12: Reverse a Number

n = int(input())
rev = 0
while n > 0:
rev = rev * 10 + n % 10
n = n // 10
print(rev)
Program 13: Palindrome Number

n = int(input())
temp = n
rev = 0
while n > 0:
rev = rev * 10 + n % 10
n = n // 10
if temp == rev:
print("Palindrome")
else:
print("Not Palindrome")

Program 14: Count Vowels

s = input()
count = 0
for ch in s:
if [Link]() in "aeiou":
count += 1
print(count)

Program 15: Simple Calculator

a = int(input())
b = int(input())
print("Add =", a+b)
print("Sub =", a-b)
print("Mul =", a*b)
print("Div =", a/b)

You might also like