Python Practical Programs
-Divyansh Khare 11th A
1. WAP to find the maximum of 2 numbers input by the user
Input
Output
2. WAP to check whether a number is even or not.
Input
Output
3. WAP to input principal and time and calculate the simple interest with
rate as 4% if time is less than 5 years otherwise 10% using a function.
Input
Output
4. WAP to input the 3 sides of a triangle and check its validity with the
help of another function that takes the three sides as parameters.
Input
Output
5. WAP to find the smallest of 3 numbers input by the user using
independent if statements.
Input
Output
6. WAP to find the greatest of 3 integers using nested if.
Input
Output
7. WAP to find the factorial of a number.
Input
Output
8. WAP to find the roots of a quadratic equation.
Input
Output
9. WAP to input principal, rate and time and calculate the simple interest
using independent lines.
Input
Output
10.WAP to input principal, rate and time and calculate the compound
interest using a function and calling the function independently.
Input
Output
11. Write a Python program to swap the consecutive characters in a
string input by the user.
For example input: “jackiechan”, output: “ajkcicehan”
Input
Output
12.Write a Python program to input 2 strings i.e. s1 and s2 and find the
presence of s1 in s2, if present then replace it with equal number of #
in it.
Eg input: s1=“cd” s2=“abcdefchdjpcdert”, output: ab##ef##h#jp##ert
Input
Output
13.Write a Python program to remove the characters which have odd
index values of a given string.
Input
Output
14.Write a Python function to convert a given string to all uppercase if it
contains at least uppercase characters in the first 4 characters.
Input
Output
15.Write a Python program to remove duplicate characters of a given
string.
Input
Output
16.Write a python program to check if a string is palindrome or not?
Input
Output
17.Write a python program to print its reverse.
Input
Output
18.Write a Python program to get a single string from two given strings,
separated by a space and swap the first two characters of each string.
Eg input: ‘abc’, ‘xyz’ output: ‘xyc abz’
Input
Output
19.Write a Python program to add ‘ing’ at the end of a given string
(length should be at least 3).
If the given string already ends with ‘ing’ then add ‘ly’ instead. If the
string length of the given string is less than 3, leave it unchanged.
Eg input: ‘abc’ output: ‘abcing’ input: ‘string’ output: ‘stringly’
Input
Output
20.Write a Python function to reverse a string if its length is a multiple of
4.
Input
Output
21.Write a Python program to input n integers and an upper value. All
the values less than upper value should get removed from the list.
Input
Output
22.Write a Python program to find the second largest number in a list.
Input
Output
23.Write a Python program to sum all the items in a list input by the user.
Input
Output
24.Write a Python program to get the largest number from a list.
Input
Output
25.Write a Python program to find the second smallest number in a list.
Input
Output
26.Write a Python program to multiply all the items in a list input by the
user that are odd multiples of 5.
Input
Output
27.Write a Python program to input a m*n matrix and display it.
Input
Output
28.Write a Python program to find the second smallest number in a list.
Input
Output
29.Write a Python program to input a line of text and count the number
of words in it.
Input
Output
30.Write a Python program to remove duplicates from a list.
Input
Output