Basic Python Programming Questions Class XI

Basic Python Programming Questions for Class XI

🟢 Level 1 – Very Basic

  1. Write a Python program to input your name, class and age and display them.
  2. Write a program to input two numbers and display their sum, difference, product and quotient.
  3. Write a program to calculate the area and perimeter of a rectangle.
  4. Write a program to calculate the area and circumference of a circle.
  5. Write a program to convert Celsius temperature into Fahrenheit.
  6. Write a program to calculate Simple Interest.
  7. Write a program to input marks of five subjects and calculate the total and percentage.
  8. Write a program to swap the values of two variables.

🟡 Level 2 – Conditional Statements

  1. Write a program to check whether a number is positive, negative or zero.
  2. Write a program to check whether a number is even or odd.
  3. Write a program to find the greater of two numbers.
  4. Write a program to find the largest of three numbers.
  5. Write a program to check whether a given year is a leap year.
  6. Write a program to check whether a person is eligible to vote based on age.
  7. Write a program to input marks and display the grade according to the following criteria:
  • 90–100 → A
  • 75–89 → B
  • 60–74 → C
  • 40–59 → D
  • Below 40 → Fail
  1. Write a program to check whether a given character is a vowel or consonant.
  2. Write a program to check whether a number is divisible by both 5 and 11.
  3. Write a program to calculate the electricity bill according to the following unit slabs:
    First 100 units (0–100): Charged at ₹5.0 per unit.
    Next 100 units (101–200): Charged at ₹7.0 per unit for the consumption over 100.
    Next 100 units (201–300): Charged at ₹10.0 per unit for the consumption over 200.
    Above 300 units: Charged at ₹15.0 per unit for any units exceeding.

🟠 Level 3 – Loops

  1. Write a program to print numbers from 1 to 10 using a for loop.
  2. Write a program to print all even numbers from 1 to 50.
  3. Write a program to print the multiplication table of a number entered by the user.
  4. Write a program to find the sum of first N natural numbers.
  5. Write a program to find the factorial of a number.
  6. Write a program to count the number of digits in a number.
  7. Write a program to find the sum of digits of a number.
  8. Write a program to reverse a given number.
  9. Write a program to check whether a number is a palindrome.
  10. Write a program to check whether a number is an Armstrong number.
  11. Write a program to display all prime numbers between 1 and 100.
  12. Write a program to check whether a given number is prime or not.

🔵 Level 4 – Strings

  1. Write a program to input a string and count the number of vowels in it.
  2. Write a program to count the number of uppercase and lowercase characters in a string.
  3. Write a program to count the number of words in a sentence.
  4. Write a program to reverse a string without using slicing.
  5. Write a program to check whether a given string is a palindrome.
  6. Write a program to count how many times a particular character occurs in a string.
  7. Write a program to find the longest word in a sentence.

🔴 Level 5 – Lists

  1. Write a program to input 10 numbers into a list and find the largest and smallest number.
  2. Write a program to find the sum and average of elements of a list.
  3. Write a program to count the number of even and odd elements in a list.
  4. Write a program to search for a given element in a list.
  5. Write a program to remove duplicate elements from a list.
  6. Write a program to find the second largest element in a list.
  7. Write a program to create a list containing the squares of numbers from 1 to 10.

⭐ Good Exam-Level Questions

For a Class XI test, I would particularly recommend these:

  • Q1. Largest of three numbers
  • Q2. Grade calculation using if-elif
  • Q3. Electricity bill using conditions
  • Q4. Factorial using loop
  • Q5. Sum of digits
  • Q6. Reverse and palindrome number
  • Q7. Prime number checking
  • Q8. Armstrong number
  • Q9. Vowel counting in a string
  • Q10. Largest/smallest element in a list

These cover the core beginner concepts: input/output, operators, if-elif-else, for, while, strings and lists.

answers/programs

1. Name, Class and Age

name = input("Enter your name: ")
class_name = input("Enter your class: ")
age = int(input("Enter your age: "))

print("Name:", name)
print("Class:", class_name)
print("Age:", age)

2. Sum, Difference, Product and Quotient

a = float(input("Enter first number: "))
b = float(input("Enter second number: "))

print("Sum =", a + b)
print("Difference =", a - b)
print("Product =", a * b)
print("Quotient =", a / b)

3. Area and Perimeter of Rectangle

length = float(input("Enter length: "))
breadth = float(input("Enter breadth: "))

area = length * breadth
perimeter = 2 * (length + breadth)

print("Area =", area)
print("Perimeter =", perimeter)

4. Area and Circumference of Circle

r = float(input("Enter radius: "))

area = 3.14 * r * r
circumference = 2 * 3.14 * r

print("Area =", area)
print("Circumference =", circumference)

5. Celsius to Fahrenheit

c = float(input("Enter temperature in Celsius: "))

f = (9 / 5) * c + 32

print("Temperature in Fahrenheit =", f)

6. Simple Interest

p = float(input("Enter principal amount: "))
r = float(input("Enter rate: "))
t = float(input("Enter time: "))

si = (p * r * t) / 100

print("Simple Interest =", si)

7. Total and Percentage

m1 = float(input("Enter marks of subject 1: "))
m2 = float(input("Enter marks of subject 2: "))
m3 = float(input("Enter marks of subject 3: "))
m4 = float(input("Enter marks of subject 4: "))
m5 = float(input("Enter marks of subject 5: "))

total = m1 + m2 + m3 + m4 + m5
percentage = total / 5

print("Total =", total)
print("Percentage =", percentage)

8. Swap Two Variables

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

a, b = b, a

print("After swapping:")
print("a =", a)
print("b =", b)

Conditional Statements

9. Positive, Negative or Zero

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

if n > 0:
    print("Positive")
elif n < 0:
    print("Negative")
else:
    print("Zero")

10. Even or Odd

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

if n % 2 == 0:
    print("Even")
else:
    print("Odd")

11. Greater of Two Numbers

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

if a > b:
    print("Greater =", a)
else:
    print("Greater =", b)

12. Largest of Three Numbers

a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))

if a >= b and a >= c:
    print("Largest =", a)
elif b >= a and b >= c:
    print("Largest =", b)
else:
    print("Largest =", c)

13. Leap Year

year = int(input("Enter year: "))

if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
    print("Leap Year")
else:
    print("Not a Leap Year")

14. Voting Eligibility

age = int(input("Enter age: "))

if age >= 18:
    print("Eligible to vote")
else:
    print("Not eligible to vote")

15. Grade Calculation

marks = float(input("Enter marks: "))

if marks >= 90:
    print("Grade A")
elif marks >= 75:
    print("Grade B")
elif marks >= 60:
    print("Grade C")
elif marks >= 40:
    print("Grade D")
else:
    print("Fail")

16. Vowel or Consonant

ch = input("Enter a character: ")

if ch in "aeiouAEIOU":
    print("Vowel")
else:
    print("Consonant")

17. Divisible by 5 and 11

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

if n % 5 == 0 and n % 11 == 0:
    print("Divisible by both 5 and 11")
else:
    print("Not divisible by both 5 and 11")

Loop Programs

18. Print 1 to 10

for i in range(1, 11):
    print(i)

19. Even Numbers from 1 to 50

for i in range(2, 51, 2):
    print(i)

20. Multiplication Table

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

for i in range(1, 11):
    print(n, "x", i, "=", n * i)

21. Sum of First N Natural Numbers

n = int(input("Enter N: "))

s = 0

for i in range(1, n + 1):
    s = s + i

print("Sum =", s)

22. Factorial

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

fact = 1

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

print("Factorial =", fact)

23. Count Number of Digits

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

count = 0

while n > 0:
    n = n // 10
    count = count + 1

print("Number of digits =", count)

24. Sum of Digits

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

s = 0

while n > 0:
    digit = n % 10
    s = s + digit
    n = n // 10

print("Sum of digits =", s)

25. Reverse a Number

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

rev = 0

while n > 0:
    digit = n % 10
    rev = rev * 10 + digit
    n = n // 10

print("Reverse =", rev)

26. Palindrome Number

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

original = n
rev = 0

while n > 0:
    digit = n % 10
    rev = rev * 10 + digit
    n = n // 10

if original == rev:
    print("Palindrome")
else:
    print("Not a Palindrome")

27. Prime Number

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

count = 0

for i in range(1, n + 1):
    if n % i == 0:
        count = count + 1

if count == 2:
    print("Prime Number")
else:
    print("Not a Prime Number")

28. Prime Numbers from 1 to 100

for n in range(2, 101):
    count = 0

    for i in range(1, n + 1):
        if n % i == 0:
            count = count + 1

    if count == 2:
        print(n)

String Programs

29. Count Vowels

s = input("Enter a string: ")

count = 0

for ch in s:
    if ch in "aeiouAEIOU":
        count = count + 1

print("Number of vowels =", count)

30. Count Uppercase and Lowercase

s = input("Enter a string: ")

upper = 0
lower = 0

for ch in s:
    if ch.isupper():
        upper = upper + 1
    elif ch.islower():
        lower = lower + 1

print("Uppercase =", upper)
print("Lowercase =", lower)

31. Count Words

s = input("Enter a sentence: ")

words = s.split()

print("Number of words =", len(words))

32. Reverse a String Without Slicing

s = input("Enter a string: ")

rev = ""

for ch in s:
    rev = ch + rev

print("Reverse =", rev)

33. String Palindrome

s = input("Enter a string: ")

rev = ""

for ch in s:
    rev = ch + rev

if s == rev:
    print("Palindrome")
else:
    print("Not a Palindrome")

List Programs

34. Largest and Smallest Element

numbers = []

for i in range(10):
    n = int(input("Enter number: "))
    numbers.append(n)

print("Largest =", max(numbers))
print("Smallest =", min(numbers))

35. Sum and Average of List

numbers = [10, 20, 30, 40, 50]

total = sum(numbers)
average = total / len(numbers)

print("Sum =", total)
print("Average =", average)

36. Count Even and Odd Elements

numbers = [10, 15, 22, 31, 40, 55]

even = 0
odd = 0

for n in numbers:
    if n % 2 == 0:
        even = even + 1
    else:
        odd = odd + 1

print("Even numbers =", even)
print("Odd numbers =", odd)

37. Search an Element in List

numbers = [10, 20, 30, 40, 50]

n = int(input("Enter number to search: "))

if n in numbers:
    print("Element found")
else:
    print("Element not found")

38. Remove Duplicate Elements

numbers = [10, 20, 10, 30, 20, 40, 30]

new_list = []

for n in numbers:
    if n not in new_list:
        new_list.append(n)

print("List without duplicates =", new_list)

39. Second Largest Element

numbers = [10, 25, 15, 40, 30]

numbers.sort()

print("Second largest =", numbers[-2])

40. Squares from 1 to 10

squares = []

for i in range(1, 11):
    squares.append(i * i)

print(squares)

For a Class XI beginner test, Questions 9–28 are especially useful because they provide good practice with if-else, for, while, %, //, counters, and accumulators.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top