Introduction to
Python Programming
Dr. S. C. Galaveen / Dept. of Mech. Engineering / SDM
College of Engineering and Tech. Dharwad
TABLE OF CONTENTS
STUDENTS DETAILS ……………. 03
SENIOR CITIZEN ……………. 04
FIBONACCI SEQUENCE ……………. 05
FACTORIAL AND BINOMIAL ……………. 06
MEAN AND VARIANCE ……………. 07
MULTIDIGIT FREQUENCY ……………. 08
WORD FREQUENCY ……………. 09
SORT FILE ……………. 10
BACKUP FILE …………… 11
ZERO DIV. ERROR …………… 12
CLASS-COMPLEX NUMBER …………… 13
CLASS-STUDENTS DETAILS ……………. 14
STUDENTS DETAILS
1.a) Develop a program to read the student details like Name, USN, and Marks
in three subjects. Display the student details, total marks and percentage with
suitable messages.
SENIOR CITIZEN
1.b) Develop a program to read the name and year of birth of a person. Display
whether the person is a senior citizen or not.
REPORT TITLE | 4
FIBONACCI SEQUENCE
[Link] a program to generate a Fibonacci sequence of length (N). Read N from
the console.
REPORT TITLE | 5
FACTORIAL / BINOMIAL
COEFFICIENT
3. Write a function to calculate the factorial of a number. Develop a
program to compute the binomial coefficient (Given N and R).
REPORT TITLE | 6
MEAN AND VARIANCE
4. Read N numbers from the console and create a list. Develop a program to
print mean, variance and standard deviation with suitable
REPORT TITLE | 7
DIGIT FREQUENCY
5. Read a multi-digit number (as chars) from the console. Develop a program
to print the frequency of each digit with a suitable message.
with suitable
REPORT TITLE | 8
WORD FREQUENCY
6. Develop a program to print 10 most frequently appearing words in a text
file. [Hint: Use dictionary ]
REPORT TITLE | 9
SORT FILE
7. Develop a program to sort the contents of a text file and write the sorted
contents into a separate text file. [Hint: Use string methods strip(), len(), list
methods sort(), append(), and file methods open(), readlines(), and write()].
REPORT TITLE | 10
BACKUP FILE
8. Develop a program to backing Up a given Folder (Folder in a current
working directory) into a ZIP File by using relevant modules and suitable
methods.
REPORT TITLE | 11
ZERO DIV. ERROR
9. a) Write a function named DivExp which takes TWO parameters a, b and
returns a value c (c=a/b). Write suitable assertion for a>0 in function DivExp
and raise an exception for when b=0. Develop a suitable program which reads
two values from the console and calls a function Div Exp.
CLASS-COMPLEX NUMBER
9 b). Define a function which takes TWO objects representing complex numbers
and returns new complex number with a addition of two complex numbers. Define
a suitable class „Complex‟ to represent the complex number. Develop a program
to read N (N >=2) complex numbers and to compute the addition of N complex
numbers.
CLASS-STUDENTS DETAILS
10. Develop a program that uses class Student which prompts the user to
enter marks in three subjects and calculates total marks, percentage and
displays the score card details. [Hint: Use list to store the marks in three
subjects and total marks. Use init () method to initialize name, USN and the
lists to store marks and total, Use get Marks() method to read marks into the
list, and display() method to display the score card details.
REPORT TITLE | 14