0% found this document useful (0 votes)
3 views

Python Practical List (4)

Uploaded by

arman07022006
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python Practical List (4)

Uploaded by

arman07022006
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Object Oriented Programming using Python

Practical List

1. WAP to convert temperature in Degree into Fahrenheit.

2. WAP to find greatest of three numbers.

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)

6. WAP to find the sum and product of digits of an integer.

7. WAP to reverse an integer.

8. WAP to compute the sum of first n terms of the following series:


S = x - x 2 /2 + x 3 /3 - x 4 /4 + …………

9. WAP to compute the sum of first n terms of the following series:


S = 1 + 22 + 33 + 44 + 55 +……

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 +…….

12. WAP to find the roots of a quadratic equation.


13. Write a menu driven program to find:
(a) factorial of a number
(b) GCD of two positive numbers
(c) nth term of Fibonacci series

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.

15. WAP to accept a number ‘n’ and


a. Check if ‘n’ is prime
b. Generate all prime numbers till ‘n’
c. Generate first ‘n’ prime numbers
16. Write a program to produce the following patterns. The number of rows to be printed is to
be taken from user.

Pattern 1 Pattern 2 Pattern 3


1 12345 1
12 1234 12
123 123 123
1234 12 1234
12345 1 12345
1234
123
12
1

Pattern 4 Pattern 5 Pattern 6


1 12345 1
121 1234 1-2
12321 123 1-2-3
121 12 1-2-3-4
1 1 1-2-3-4-5

Pattern 7 Pattern 8 Pattern 9


A * 1-
A B A *** 1-2-
A B C B A ***** 1-2-3-
A B C D C B A ******* 1-2-3-4-
********* 1-2-3-4-5-
*********
*******
*****
***
*
Strings
1. WAP that accepts a character and performs the following:
a. print whether the character is a letter or numeric digit or a special character
b. if the character is a letter, print whether the letter is uppercase or lowercase
c. if the character is a numeric digit, prints its name in text (e.g., if input is 9, output
is NINE)

2. WAP to perform the following operations on a string


a. Find the frequency of a character in a string.
b. Replace a character by another character in a string.
c. Remove the first occurrence of a character from a string.
d. Remove all occurrences of a character from a string.

3. WAP to swap the first n characters of two strings.

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.

6. WAP to find the frequency of each character occurring in a string.


7. WAP to find the longest word in a sentence entered by the user.

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

2. WAP to swap the first and last element of the list.

3. WAP that takes two lists and returns True if they have at least one common member.

You might also like