Python Compiled Questions For XI CS Batch 2024-25
Python Compiled Questions For XI CS Batch 2024-25
>10000 20%
<=7000 10%
Q. Write a program to accept percentage and display the Category according to
the following criteria :
Percentage Category
< 40 Failed
>=65 Excellent
Q. Accept three sides of a triangle and check whether it is an equilateral, isosceles or scalene
triangle.
Note :
An equilateral triangle is a triangle in which all three sides are equal.
A scalene triangle is a triangle that has three unequal sides.
An isosceles triangle is a triangle with (at least) two equal sides.
Q. Write a program to accept two numbers and mathematical operators and perform
operation accordingly.
Like:
M 700
>=18 and <30
F 750
M 800
>=30 and <=40
F 850
If age does not fall in any range then display the following message: “Enter appropriate age”
Q. Accept three numbers from the user and display the second largest number.
Q. Accept three sides of triangle and check whether the triangle is possible or not.
(triangle is possible only when sum of any two sides is greater than 3rd side)
Q. Accept the electric units from user and calculate the bill according to the following rates.
First 100 Units : Free
Next 200 Units : Rs 2 per day.
Above 300 Units : Rs 5 per day.
if number of unit is 500 then total bill = 0 +400 + 1000 = 1400
Q. Accept the number of days from the user and calculate the charge for library according to
following :
Till five days : Rs 2/day.
Six to ten days : Rs 3/day.
11 to 15 days : Rs 4/day
After 15 days : Rs 5/day
Q. Accept the kilometers covered and calculate the bill according to the following criteria:
First 10 Km Rs11/km
Next 90Km Rs 10/km
After that Rs9/km
Q. Accept the marks of English, Math and Science, Social Studies Subject and display the
stream allotted according to following
All Subjects more than 80 marks — Science Stream
English >80 and Math, Science above 50 –Commerce Stream
English > 80 and Social studies > 80 — Humanities
TOPIC: if else, elif, Nested if, Ladder if and looping
SHEET – 2
Q. Write a program to input two integers a, b. Interchange values stored in a, b. Print values
of a, b before and after interchange using suitable messages.
Q. Write a program to input a character. Check and print whether it is a capital alphabet or
small alphabet or a digit. Print the character along with suitable message.
Q. Write a program to input a character and convert into its opposite case. Print the original
character and new character.
Q. Write a program to input a character. Print next five characters including the given
character. Input the character not beyond ‘v’. The character may be in upper case or in lower
case.
Q. Write a program to input a character check if it is an alphabet then convert into upper
case form if it is lowercase. Print the next five characters in circular alphabet list including
the modified character.
Q. Write a program to input two integers and a character. The character contains any one of
the arithmetic operator (+, -, *, / or %). Your program should check the operator entered and
perform the corresponding operation.
Q. Write a program to input basic and to find the gross pay of an employee for the following
allowances and deduction.
Dearness allowance = 25 % of Basic.
House Rent Allowance = 15% of Basic.
Provident Fund = 8.33% of Basic.
Net Pay = Basic + Dearness Allowance + House Rent Allowance.
Gross Pay = Net Pay – Provident Fund.
Q. Write a program to find the roots i.e. x1, x2 by inputting the value of a, b, c from the
following relation.
−𝒃±√𝒃𝟐 −𝟒𝒂𝒄
𝒙=
𝟐𝒂
Q. Write a program to calculate and print roots of a quadratic equation ax2 + bx + c = 0
(a!=0)with appropriate messages the root are given by:
−𝒃 ± √𝒃𝟐 − 𝟒𝒂𝒄
𝒙𝟏 𝒂𝒏𝒅 𝒙𝟐 =
𝟐𝒂
If b2 – 4ac > 0 then roots are real and unequal.
If b2 – 4ac = 0 then roots are real and equal.
If b2 – 4ac < 0 then roots are imaginary.
Q. Write a program to input a character and print whether it is a digit or a white space.
Q. Write a program to input hours and minutes in two different variables. Convert hours to
minutes and minutes to hours.
Q. Write a program to convert a given temperature from Fahrenheit to Celsius and vice
versa. For an incorrect choice, an appropriate message should be displayed. C= 5/9 x (F-32) ,
F = 1.8 x (C + 32)
Q. A cloth showroom has announced the following festival discounts on the purchase of
items based on the total cost of the items purchased.
Total Cost Discount (in Percentage)
Less then Rs. 2000 5%
Rs. 2001 to Rs. 5000 25%
Rs. 5001 to Rs. 10000 35%
Above Rs. 10000 50%
Write a program to input the total cost and to compute and display the amount to be
paid by the customer.
Q. The telephone department wishes to compute monthly telephone bills for its customers
using the following rules on the basis of call made:
Number of calls Rate
First 80 calls Rs. 250/-
Next 80 Calls 60 paisa per call
Next 160 Calls 50 paisa per call
Any call above 280 Calls 40 paisa per call
Write a program to input number of calls and compute total bill amount.
Q. An institute has decided to admit new candidates in different streams on the following
criteria:
Total marks obtained Stream offered
300 and above SCIENCE
200 and above but less than 300 COMMERCE
Below 200 but not below 75 HUMANITIES
Otherwise Admission is not granted.
Write a program to input total marks obtained in an examination and print the stream
allotted.
Q. Write a program to compute salesman commission on the following basis:
Sales (Rs.) Commission
1 – 100000 15%
100001 – 200000 25%
Above 200000 45%
Q. Write a program with three integer values as a three sides of a triangle and decide
whether it is a scalene, isosceles or equilateral triangle.
Q. An employee is entitled to pay an income tax based on his gross annual income as per the
given rule:
Gross annual income (Rs.) Annual tax deduction
Less than or equal to 100000 NIL
100001 to 150000 10% of the income exceeding 100000
150001 to 200000 5000 + 20% of the income exceeding
150000
Above 200000 15000 + 30% of the income exceeding 200000
Write a program to input gross annual income and print the payable income tax by the
employee.
Q. A Library charges a fine for books returned late. Following are the fines:
First Five Days: 40 paise per day
Six to Ten Days: 65 paise per day
Above Ten days: 100 paise per day
Write a program which takes as input the number of days late and prints the fine.
Q. Write a program to enter a character and check whether it is a vowel or consonant. Your
program should print the given character along with the suitable message.
Q. Write a program to input two lengths in feet and inches. Add the length and print the sum
of lengths.
Example: Let Length1 = 8 feet 17 inch
Let Length2 = 7 feet 10 inch
Sum of Length1 and Length2 is = 17 feet 03 inch ( where 12 inch = 1 feet)
Q. Write a program to input two timings in degrees and minutes. Add the timings and print
the sum of timings.
Example: Let time1 = 20 degree 80 minutes
Let time2 = 10 degree 70 minutes
Sum of time1 and time2 is = 32 degree 30 minutes (where 60 minutes = 1 degree)
Q. Write a program to input 3 integers and find the greatest from them.
Q. Write a program to input 3 integers and find the lowest from them.
Q. Write a program to input a digit (0 – 9) and print the number names.
Q. Write a program to input week number and print day of week.
Q. Write a program to input month number and print name of the month.
Q. Write a program to input number and print its absolute value of a number. (Without
using function)
Q. Write a program to input a number (between 1 – 12) print the name of month using the
number.
Q. Write a program to input a number (between 1 – 7) print the name of week using the
number.
Q. Write a program to print the various designations on the basis of the first letter given as
input. The designations are limited in the process as given: Manager, Producer, Charted
Accountant, Engineer, Minister, Officer and Teacher. Input a character (in capital or small)
and print the corresponding designation. Input: M Output: Manager
TOPIC: Looping
SHEET – 3
Q. Write the output of the following.
a=5
while a>0:
print(a)
a=a-1
Q. for loop statement is terminated by symbol ___________
Q. What is the difference between break and continue statements?
Q. Convert the following loop into for loop :
x=4
while(x<=8):
print(x*10)
x+=2
Q. Write the output of the following:
for k in range(10,20,4):
print(k)
Q. Find errors in the following code:
x = input(“Enter value”)
for k in range[0,20]
if x=k
print(x+k)
else:
Print(x-k)
Q. Write the output of the following:
x=3
if x>2 or x<5 and x==6:
print(“Bye”)
else:
print(“Thankyou”)
Q. Write the output of the following:
x,y=2,4
if(x+y==10):
print(“Thankyou”)
else:
print(“Bye”)
Q. Write the output of the following:
x=10
y=1
while x>y:
x=x-4
y=y+3
print(x)
Q. Write the output of the following:
for x in range(3):
for y in range(2):
print(“Practice Questions of loops in python”)
print()
Q. Write the output of the following
for x in range(10,20):
if (x%2==0):
continue
print(x)
Q. What do you mean by jump statement?
Q. What is nested loop?
Q. Find errors in the following code:
a = int(“Enter any number”)
for i in Range[2,6]
if a=i
print(“A”)
else
print(“B”)
Q. Write the output of the following:
1. for i in "Myblog":
print (i, '?')
2. for i in range(5):
print(i)
3. for i in range(10,15):
print(i)
Q. Write the output of the following
1. for i in (1,10):
print(i)
2. for i in (5,9):
print(i)
3. for i in range(2,7):
print(i)
4. for i in "csiplearninghub":
print(i)
5. for i in "python":
print(i, end=' ')
6. for i in "python":
print(i, end=='?')
7. for i in "python":
print(i, '?$')
8. for i in (1,2,3,4):
print(i)
9. for i in (3,4,7):
print(i)
10. for i in range(2,10,2):
print(i)
Q1. Write the output of the following code :
[1]
x=5
while(x<15):
print(x**2)
x+=3
[2]
a=7
b=5
while(a<9):
print(a+b)
a+=1
[3]:
b=5
while(b<9):
print("H")
b+=1
[4]:
b=15
while(b>9):
print("Hello")
b=b-2
[5]:
x=15
while(x==15):
print("Hello")
x=x-3
[6]:
x = "123"
for i in x:
print("a")
[7]:
i=9
while True:
if i%3==0:
break
print("A")
[8]:
a=6
while(a<=10):
print("a")
a+=1
[9]:
i=0
while i<3:
print(i)
i=i+1
else:
print(7)
[10]:
i=0
while i<3:
print(i)
i=i+1
print(0)
[11]:
i=2
for x in range(i):
i+=1
print(i)
print(i)
[12]:
i=2
for x in range(i):
x+=1
print(x)
print(x)
[13]:
i=2
for x in range(i):
x+=1
print(x)
print("x")
[14]:
i=100
while i<57:
print(i)
i+=5
Q. How many times the following loop execute?
c=0
while c < 20:
c += 2
Q. Write the output of the following.
c = -9
while c < 20:
c += 3
print(c)
Q. Write a program to input two integers n, x and print n raised to power x. (Without using
function)
Q. Write a program to input a two digit number (your program should display a message if
the number is not having two digits). Split both the digits of that number and print the
corresponding number name for each digit. Input: 46 Output: Four Six / SIX FOUR
Q. Write a program to calculate and print the sum of odd numbers and sum of even numbers
for the first 100 natural numbers.
Q. Write a program to input an integer. Print the Factorial of the integer.
Q. Write a program to input an integer. Print the Reverse of the integer. (Ex: Input: 2435
Output: 5342)
Q. Write a program to input an integer. Print the Factors of the integer. (Ex: Input: 6 Output:
1,2,3,6)
Q. Write a program to input an integer. Print the Multiplication table till 20 of the integer.
Q. Write a program to input an integer. Print the Sum of the digits of the integer. (Ex: Input:
2354 Output: 14)
Q. Write a program to input an integer. Print the Product of the first and last digit of the
integer. (Ex: Input: 2354 Output: 8, Input: 682354 Output: 24)
Q. Write a program to print all ASCII numbers i.e. 0 to 255 with their ASCII values.
Q. Write a program to input a number and check whether it is a Prime number or not.
Q. Write a program to input a number and check whether it is a Palindrome number or not.
Q. Write a program to input a number and check whether it is a Perfect number or not. (Ex.
6 = 2x6 = 1+2+3+6)
Q. Write a program to input a number and check whether it is an Armstrong number or not.
(Ex. 153 = 13+53+33)
Q. Write a program to input a number and check whether it is a Special number or not. (Ex.
145 =1! + 4! + 5!)
Q. Write a program to input a number and check whether it is an Automorphic number or
not. (Ex. 5= 25, 25 = 625)
Q. Write a program to input an integer number and check whether it is a Buzz number or
not. (Number which either ends with 7 or divisible by 7)
Q. Write a program to input two integers and print their LCM.
Q. Write a program to input two integers and print their HCF.
Q. Write a program to input a number and print sum of all the digits and count of all the
digits. Input: 5623 Output: Count = 4, Sum = 16
Q. Write a program to input a number and check whether it is a Neon number or not. (Ex. 9 =
9x9 = 81, 8+1=9)
Q. Write a program to input two integers n and p. Find and print n raised to the power
without using function.
Q. Write a program to input an integer n1 and another integer n2. Merge n2 after n1 and
store merged number M. Print n1, n2 and merged number M. (Ex. Input: n1=24, n2=567
Output: M=24567)
Q. Write a program to input an integer and find out the difference between the greatest and
the lowest digit present in the number.
Q. Write a program to print all twin prime numbers from 2 to 500. (Twin Prime are prime
numbers whose difference is 2. Ex: 3,5 : 5,7 : 11,13 : 17,19 : etc.)
Q. Write a program to print all Perfect numbers from 0 to 1000.
Q. Write a program to print all Armstrong numbers from 0 to 1000.
Q. Write a program to print all Special numbers from 0 to 1000.
Q. Write a program to print all Automorphic numbers from 0 to 1000.
Q. Write a program to print the following series on the screen. Each number should be
printed followed by one blank space.
a. 1, 3, 6, 11, 20 . . . . . . . . . . . . . . . . . . . . .10 terms
b. 1, 11, 111, 1111, . . . . . . . . . . . . . . . . . .10 terms
c. 1, 1, 2, 3, 5, 8 . . . . . . . . . . . . . . . . . . . . .10 terms
d. 1, 3, 6, 10, 15, . . . . . . . . . . . . . . . . . . . . .10 terms
e. 1, 4, 9, 16, 25, . . . . . . . . . . . . . . . . . . . . .10 terms
f. 1, 8, 27, 64, . . . . . . . . . . . . . . . . . . . . . ..10 terms
Q. Write a program to find the sum of the following series
a. 1 – 2 + 3 – 4 + 5 – . . . . . . . . . . . . . . . . .. . . . . . . . . .10 terms
b. 0 + 1 + 1 + 2 + 3 + 5 + 8 + . . . . . . . . . . . . . . . . . . . . .10 terms
c. 2 + 3 + 5 + 8 + 12 + 17 + . . . . . . . . . . . . . . . . . . . . . .10 terms
d. 12 + 33 + 55 + . . . . . . . . . . . . . . . . . . . . . . . . .. . . . .. .10 terms
e. (1x22) + (2x32) + (3x42) + . . . . . . . . . . . . . . . . . . . . .10 terms
f. ½ + ¾ + 5/6 + . . . . . . . . . . . . . . . . . . . .. . . . . . . . .. . .10 terms
g. 1/1! + 2/3! + 3/5! + . .. . . . . . . . . . . . . . . . . .. . . .10 terms
h. 1+(1+2)+(1+2+3)+(1+2+3+4)+ . . . . . . . . . . . . . .10 terms
Q. Write a program to print the following patterns :
A 12345 b 1 c 54321 d 12345 e 1 f 11111 g 0
12341 12 5432 1234 11 1111 101
12312 123 543 123 111 111 21012
12123 1234 54 12 1111 11 3210123
11234 12345 5 1 11111 1 432101234
H a i ABCDE j 54321 k 1 l 55555 m 12345 n 123 4
ab FGHI 4321 22 4444 1234 246 8
abc JKL 321 333 333 123 3 6 9 10
abcd MN 21 4444 22 12 4 8 1216
abcde O 1 55555 1 1
O 1a p1 q 12345 r 1 s 1 t 1 2 3 4 5 U 5
2b 3c BB ABCD b c 10 F G H I 10-15
4d 5e 6f 333 123 4 5 6 101 10 11 12 20-25-30
7g 8h 9i 10j CCCC AB g h I j 1010 M N 35-40
55555 1 11 12 13 14 15 10101 15 45
V ZYXW w 10 9 8 7 x 1 y 1 z 4
VUT 654 35 2-3 434
SR 32 7 9 11 4-5-6 43234
Q 1 7-8-9-10 4321234
43234
434
4