PFP191_Practical Exercise
PFP191_Practical Exercise
I. Required knowledge: Operators, Data types, Variables and expression, Basic input/output
2. Write a Python program to print student informaion: student name, student ID, Class ID,
date of birth and mobile number.
Student Name:
Student ID:
Class ID:
Date of birth
Mobile Number:
3. Write a program in Python that reads a forename, surname and year of birth and display the
names and the year one after another sequentially
Ex: Expected Output :
Input your firstname: Tom
Input your lastname: Davis
Input your year of birth: 1982
Tom Davis 1982
6. Write a program to input two numbers and find their quotient and modulus.
7. Write a program to input two numbers and perform all arithmetic operations: sum,
difference, product, quotient and modulus.
8. Write a program to input length and width of a rectangle and calculate perimeter and area
of the rectangle.
9. Write a program to input radius of a circle from user and find diameter, circumference and
area of the circle.
10.Write a program to input a positive integer N with 2 digits from the keyboard, output to the
screen the sum of the digits of N.
Ex: Input: N=48. Output: 4+8=12.
11.Write a program to input temperature in degrees Celsius and convert to Fahrenheit, using
the conversion formula:
12. Write a program that allows input hours, minutes and seconds and convert it to seconds
and print the result.
Ex: Input: h=1, m=2, s=2. Output: 3722 seconds.
13.Write a program in C that takes minutes as input, and display the total number of hours and
minutes
14.Write a program to input number of days from user and convert it to years, weeks and
days.
Ex: Input: Enter days: 373.
Output: Years: 1
Weeks: 1
Days: 1
15.Write a program to enter length in centimeter and convert it into meter and kilometer.
16.Write a program to calculate the perimeter and area of shapes: triangles, squares, rectangles
and circles with the information that needs to be entered from the keyboard.
17.Write a program to enter two integers a and b. Print the maximum value to the screen.
18.Write a program to check whether an integer entered number by the user is odd or even.
21.Write a program input three numbers a,b,c. Print to the screen in ascending order of
numbers.
23.Write a Python program to find whether a given year is a leap year or not.
(A leap year is a year that is divisible by 4 and not by 100. Or it is divisible by 400)
Ex: Enter year : 2016
Output : 2016 is a leap year.
27.Write a program to input a three-digit integer n. Output to the screen in ascending order of
digits.
Ex: Enter n : 291
Output : 129
28.Write a program in C to read any day number in integer (2….8) and display day name in
the week
Test Data : 4
Expected Output :Wednesday
III. Loop
29.Calculate: 𝑛! (𝑛 >0)
36.Write a program to input two positive integers a and b. Find the greatest common divisor
and least common multiple of a and b.
IV. Collection
38.Write a program in Python to store elements in an list and print it.
39.Write a program in Python to read n number of values in an list and display it in reverse
order
40.Write a program in Python to find the sum of all elements of the list
41.Write a program in Python to find the maximum and minimum element in an list
42.Write a program in Python to separate odd and even integers in separate lists.
45.Write a Python program that inputs a string and prints the reversed string.
46.Write a Python program that counts special characters in a string. Special characters are
47.Write a Python program to input a list of item names and print the list with the item names
48.Write a Python program to input a string anh print number of words in the string (each
Email, Phone, Salary) include functions: add new, search by name, remove, update, and