Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
590 views

Practical Assignment Python

The document outlines 29 programming assignments covering Python fundamentals like variable swapping, conditional checking, looping, functions, recursion, file handling, exceptions, OOP concepts like classes, inheritance and polymorphism. Some key tasks include writing programs to check even/odd numbers, calculate student grades, demonstrate operators, print patterns, find digit sums, check palindromes, use lists, tuples, dictionaries, create and modify classes.

Uploaded by

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

Practical Assignment Python

The document outlines 29 programming assignments covering Python fundamentals like variable swapping, conditional checking, looping, functions, recursion, file handling, exceptions, OOP concepts like classes, inheritance and polymorphism. Some key tasks include writing programs to check even/odd numbers, calculate student grades, demonstrate operators, print patterns, find digit sums, check palindromes, use lists, tuples, dictionaries, create and modify classes.

Uploaded by

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

Python: Assignment – 1

1. Write a program that will swap the value of two variables.

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.

4. Write a menu driven program to demonstrate the use of python


operators using the guidelines mentioned next. The level 1 menu must
allow the user to select the type of operators. Based on the type of
operators selected the next menu must display all the operators of that
type. In the third step accept the required numbers from the user and
demonstrate the operator selected by user.

5. Write a program to print your name 5 times using while and for.

6. Write a program to print each character of your name.

7. Write a program to print the series: 100, 95, 90……..1.

8. Write a program to print first ‘n’ even numbers. Accept the value of ‘n’
from user.

9. Print the first ‘n’ prime numbers.


10. Print the following pattern upto ‘n’ lines. 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.

13. Write a program to check if the user entered number is a palindrome or


not. (Eg. 16461, 23932 etc…….)

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.

18. Write a program to create a Dictionary and demonstrate the various


methods of Dictionary.

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.

23. Use recursion to find:


- Factorial of a number.
- Generate first n terms of Fibonacci series.
- If user entered number or string is Palindrome.

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)

25. Write a program that will read: (use exceptions)


- All names from ‘Student.txt’ file.
- Only first four names from the file.

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.

28. Modify the above program 27 to include a method to modify the


book_price. Include one class variable that will count the number of
objects created.

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.

You might also like