LAB WORK
CLASS - XI
2024-25
IF-ELSE BASED QUESTIONS
1. rite a Python code to find the area of an equilateral triangle, an
W
isosceles triangle and a scalene triangle as per the user’s choice.
1. Equilateral Triangle =
2
3
4
𝑠 , 𝑠 = 𝑠 𝑖𝑑𝑒𝑜
𝑓𝑎
𝑛𝑒𝑞𝑢𝑖𝑙𝑎𝑡𝑒𝑟𝑎𝑙𝑡 𝑟𝑖𝑎𝑛𝑔𝑙𝑒
1 2 2
2. Isosceles Triangle = 4 𝑏 * 4𝑎 − 𝑏
3. Scalene Triangle = 𝑠 * (𝑠 − 𝑚) * (𝑠 − 𝑛) * (𝑠 − 𝑝),
𝑚+𝑛+
𝑝
s = 2
Where m, n and p are three sides of a triangle
2. rite a Python code to enter three integer numbers a,b, and c.
W
Further, enter the value of a control variable n (1 or 2).
isplay the sum of product of the numbers a, b and c for the given
D
value of n as 1 and 2 respectively.
I n case, the value of n is entered any other number then an error
message “Invalid choice” must be displayed.
3. rite a Python code to input three unequal numbers and display
W
the second smallest number.
ample Input: 65, 41, 98
S
Sample Output: 65
4. rite a Python program that checks whether a given letter is a
W
vowel or a consonant.
5. rite a program that compares two numbers and determines
W
whether they are equal, greater than, or less than each other.
6. rite a Python program that converts temperatures between
W
Celsius and Fahrenheit. The user should input the temperature
and its unit (C or F), and the program should convert it to the
other unit.
FOR LOOP BASED QUESTIONS
1. rite a program to display the first ten numbers of the
W
Fibonacci series:
0, 1, 1, 2, 3, ………………….
2. rite a program to enter a program and display the sum of its
W
digits.
ample Input: 642
S
Sample Output: 12
Explanation: (6+4+2 = 12)
3. rite a program to accept a number and check whether the
W
number is a palindrome or not.
Display the message accordingly.
ample Input: 707
S
Sample Output: 707 is a palindrome number
4. Write a menu driven program:
( i) to accept a number from the user and to check whether it a
‘BUZZ’ number or not.
(ii) to accept any two numbers and display their ‘GCD’
UZZ: A BUZZ number is the number which either ends with
B
digits 7 or is divisible by 7.
5. rite a program to input ten different numbers. Display the
W
greatest and the smallest numbers among them.
6. Write a program to accept a number and check whether it is a
prime number or not.
7. Write a program to find and display the sum of the given series:
S = 1 + (1*2) + (1*2*3) + ----------- + (1*2*3*4…….n)
8. rite a program to input a number and display all the digits of
W
the number.
ample Input: 734
S
Sample Output: 4
3
7
9. rite a program to find and display the sum of the factorial of
W
all the natural numbers from 1 to n.
S = 1! + 2! + 3! + 4! + ------------------- + n!
10. W
rite a python based on the user choice to print a particular
pattern.
I f the user chooses 1, print the pyramid pattern of numbers.
If the user chooses 2, print the Inverted pyramid pattern of
numbers.
If the user chooses 3, print the Pyramid pattern with the same digit.
If user chooses 4, print inverted half-pyramid pattern with number
yramid pattern of numbers
P
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Inverted pyramid pattern of numbers
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Pyramid pattern with the same digit
1 1 1 1
1
2 2 2 2
3 3 3
4 4
5
Inverted half-pyramid pattern with number
5 5 5 5
5
5 5 5 5
5 5 5
5 5
5
11. Print reverse number from 10 to 1
1
3 2
6 5 4
10 9 8 7
12. Right Angles Pattern with Characters
STRING BASED QUESTIONS
1. rite a python code to input a string. Replace the letter ‘E’ or
W
‘e’ with ‘*’ in the given string. Display the new string.
ample Input: English Literature
S
Sample Output: *nglish Lit*ratur*
2. Write a Python code to input a string and display:
( i) the number of lowercase letters
(ii) the number of uppercase letters
(iii) the number of digits
(iv) the number of special characters
3. pecial words are those words which start and end with the
S
same letter.
Example: EXISTENCE, COMIC, WINDOW
alindrome words are those words which read the same from
P
left to right and vice-versa
xample: MALYALAM, MADAM, LEVEL, ROTATOR,
E
CIVIC
rite a Python code to accept a word. Check and display
W
whether the given word is a palindrome or only a special
word, or none of them.
4. rite a Python code to enter a sentence. Now, display a word
W
formed by joining all the first characters of each word of the
sentence.
ample Input: Vital Information Resource Under Seize
S
Sample Output: VIRUS
5. rite a Python code to enter a sentence and display the
W
longest word present in the string along with its length.
ample Input: TFA WILL PLAY FOOTBALL MATCH
S
AGAINST ATK CLUB
ample Output: The longest word: FOOTBALL
S
The Length of the word: 8
6. Write a Python program to count repeated characters in a string.
Sample string: 'thequickbrownfoxjumpsoverthelazydog'
xpected output :
E
o 4
e 3
u 2
h 2
r 2
t 2
7. rite a Python program that accepts a comma-separated sequence
W
of words as input and prints the distinct words in sorted form
(alphanumerically).
ample Words : red, white, black, red, green, black
S
Expected Result : black, green, red, white,red
8. rite a python program to find the first appearanceof the substrings
W
'not' and 'poor' in a given string. If 'not' follows 'poor', replace the
whole 'not'...'poor' substring with 'good'. Return the resulting string.
ample String : 'The lyrics is not that poor!'
S
'The lyrics is poor!'
xpected Result : 'The lyrics is good!'
E
'The lyrics is poor!'
9. rite a Python program to add 'ing' at the end of a given string
W
(length should be at least 3). If the given string already ends with 'ing',
add 'ly' instead. If the string length of the given string is less than 3,
leave it unchanged.
ample String : 'abc'
S
Expected Result : 'abcing'
ample String : 'string'
S
Expected Result : 'stringly'
10. Write a python program to get a single string fromtwo given strings,
eparated by a space and swap the first two characters of each
s
string.
ample String : 'abc', 'xyz'
S
Expected Result : 'xyc abz'
11. Write a python program to get a string made of the first 2 and last 2
haracters of a given string. If the string length is less than 2, return
c
the empty string instead.
ample String : 'DPS RUBY'
S
Expected Result : 'DPBY'
ample String : 'w3'
S
Expected Result : 'w3w3'
ample String : ' w'
S
Expected Result : Empty String
12. Write a python code to input a string and display all the vowels
present in it.
ample Input: Computer
S
Sample Input: o
u
e