Python Worksheet – Class 10
This worksheet contains 10 simple Python programs based on the Class 10 Computer
Applications curriculum.
Students should practice typing and executing each program, observe the output, and try
modifying them for better understanding.
1. Find the Greatest of Two Numbers
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
if a > b:
print("Greatest number is:", a)
else:
print("Greatest number is:", b)
2. Check Whether Number is Even or Odd
num = int(input("Enter a number: "))
if num % 2 == 0:
print(num, "is Even")
else:
print(num, "is Odd")
3. Check if Number is Positive, Negative, or Zero
n = int(input("Enter a number: "))
if n > 0:
print("Positive")
elif n < 0:
print("Negative")
else:
print("Zero")
4. Print Multiplication Table
n = int(input("Enter a number: "))
for i in range(1, 11):
print(n, "x", i, "=", n * i)
5. Sum of First N Natural Numbers
n = int(input("Enter a number: "))
sum = 0
for i in range(1, n + 1):
sum += i
print("Sum of first", n, "natural numbers is:", sum)
6. Check if a String is a Palindrome
s = input("Enter a string: ")
if s == s[::-1]:
print("Palindrome")
else:
print("Not a palindrome")
7. Count Vowels in a String
s = input("Enter a string: ")
vowels = "aeiouAEIOU"
count = 0
for ch in s:
if ch in vowels:
count += 1
print("Number of vowels:", count)
8. Find Largest Element in a List
numbers = [10, 25, 4, 78, 56]
print("List:", numbers)
print("Largest number:", max(numbers))
9. Display Fibonacci Series up to N Terms
n = int(input("Enter number of terms: "))
a, b = 0, 1
print("Fibonacci Series:")
for i in range(n):
print(a, end=" ")
a, b = b, a + b
10. Find Factorial of a Number (Using Function)
def factorial(n):
fact = 1
for i in range(1, n + 1):
fact *= i
return fact
num = int(input("Enter a number: "))
print("Factorial of", num, "is:", factorial(num))