Python Practical List (4)
Python Practical List (4)
Practical List
3. WAP that accepts the dimensions of a triangle and checks if it is equilateral, isosceles, or
scalene.
4. Write a program that checks if a year is a leap year and also identifies if it is a century year.
5. WAP that accepts the marks of a student in five subjects (out of 100) and calculates the
total marks, percentage, and grade based on the following criteria:
If the percentage is
90 or above, the grade is A+
Between 80 and 89, the grade is A
Between 70 and 79, the grade is B+
Between 60 and 69, the grade is B
Between 50 and 59, the grade is C
Between 40 and 49, the grade is D
Below 40, the grade is F (Fail)
10. WAP to compute the sum of first n terms of the following series:
i. S = x + x2/2 + x3/3 + x4/4 + ……
11. WAP to compute the sum of first n terms of the following series:
S = 1 – 2 + 3 – 4 + 5 – 6 +…….
14. Write a program to find nth prime number. Read the value of n through the command line
arguments and if the user has not entered the value as the command line argument, then
prompt the user to enter value of n.
4. Write a function that accepts two strings and returns the indices of all the occurrences of
the second string in the first string as a list. If the second string is not present in the first
string then it should return -1.
5. WAP to count number of vowels, consonants, digits and special characters in a string.
Lists
1. WAP to do the following using list comprehension:
a. Create a list of squares of all even numbers from 1 to 20.
b. Given a string, create a list of all vowels occurring in the string.
c. Flatten a 2D list into a 1D list.
d. Find common elements between two lists.
e. Generate all pairs (x, y) where x is from list1 and y is from list2.
f. Create a list of the cubes of only the even integers appearing in the input list (may have
elements of other types also).
g. Remove the duplicates from the list.
h. Flatten a 2D list
3. WAP that takes two lists and returns True if they have at least one common member.