Practical Assignment Python
Practical Assignment Python
2. Write a program that will check whether the user entered number is odd
or even.
3. Write a program that will accept marks of 5 different subjects from the
user and prints the grade secured by the student using the below given
guidelines.
Maximum marks of each subject: 100.
Passing Marks: 40
If percentage > 90, grade is A+,
if percentage >80 & <=90, grade is A,
if percentage >70 & <=80, grade is A-,
if percentage >60 & <=70, grade is B,
if percentage >50 & <=60, grade is C,
if percentage >40 & <=50, grade is Pass,
if percentage <=40 grade is Fail.
5. Write a program to print your name 5 times using while and for.
8. Write a program to print first ‘n’ even numbers. Accept the value of ‘n’
from user.
*
* *
* * *
* * * *
* * * * *
11. Print the following pattern upto ‘n’ lines. Accept the value of ‘n’ from
user.
1
2 2 2
3 3 3 3 3
4 4 4 4 4 4 4
12. Write a program to print the sum of digits for a user entered number.
14. Write a program to check the number of vowels in a user entered string.
( ‘A’, ‘E’,’I’,’O’,’U’ are vowels. Hence ‘SACHIN’ contains two vowels.)
15. Write a program to demonstrate the use of LIST. The program must
include the following features:
- Create a list LST with 5 numbers [20, 5, 15,10,25]. Print the list using
for loop.
- Disp5ay the first three elements of the list.
- Display the last element of the list using negative index.
- Add 5 at the end of the list.
- Add 44 at index value 3 in the list.
- Add 5,31 and 30 to the list.
- Remove the last number 30 from the list.
- Remove the number from index value 7.
- Create LST1 that is a copy of LST.
- Check the id of LST & LST1.
- Count how many times the number 5 is getting repeated in the list.
- Arrange the numbers of the list LST in ascending order.
- Arrange the numbers of the list LST1 in descending order.
- Using a single method remove all elements from LST1.
- Delete the list LST.
16. Create two lists – LST=[1,2,3,4], NAME=[‘ABC’,’DEF’]. Add the list NAME
to LST. Check the output. Add one more list [5,5] to LST at index value 2.
17. Write a program to create a tuple and demonstrate the various methods
of tuple.
19. Write a program to create a dictionary with name STUDENT. The key
must consist of your studentid. The value must include – name, contact
number, email id, address. (Use list for the value part of dictionary.)
20. Write a function that will return the maximum of three numbers.
21. Update program 20 so that the function will return the maximum as well
as minimum of three numbers.
22. Update program 20 so that the function will find maximum from n
numbers.
24. Write a program that creates a ‘Student.txt’ file. The file must contain
complete name (first name middle name last name) of 10 students. (use
exceptions)
26. Sort the names of ‘Student.txt’ file in ascending order. (use exceptions)
27. Write a program that creates a class ‘Books’. The class must contain a
constructor that initializes book_name, book_price and no_of_pages.
Create a method to print the book details.
29. Modify program 27 to include two more classes – ‘Publisher’ & ‘Books’.
Both classes should have member functions to get details from user and
print those details. The class ‘Books’ must be changed to a derived class
with ‘Publisher’ and ‘Books’ as base classes.