Professional Documents
Culture Documents
Type Object
int …-3,-2,-1,0, 1, 2,3 …
float -123.56, 2.657E+07
complex 2+3j, -3 + 4j, 0 + j
bool True, False
list [1,2,3,4]
tuple (3,-6,,8), ('a', 'e', 'd')
dict {1:'a', 2:'b', 3:'c'}
str 'Python'
set {3,5,,1,2}
Page 1 of 6
Bachelor of Applied Information Technology
Module Code CIT101
Module Title: Fundamentals of Programming
We use input() function to read input from the user through the keyboard. The input()
function converts the object you enter into a string object. Strings are non-numeric
objects. (They do not take part in calculations)
Example:
Variable Function User Prompt
>>> type(int_num)
<class 'int'> '12' object belongs to 'int' class
Page 2 of 6
Bachelor of Applied Information Technology
Module Code CIT101
Module Title: Fundamentals of Programming
>>> type(comp_num)
<class 'complex'> '2 + 3j' object belongs to 'complex' class
Page 3 of 6
Bachelor of Applied Information Technology
Module Code CIT101
Module Title: Fundamentals of Programming
10 int
10.5 float
2+3j complex
True bool
"Lanka" str
[1,2,3] list
('a','b','c') tuple
{1:'a',2:'b} dict
{4,1,3} set
Practical 3 Submission
You have to submit all your workings to LMS clearly in a .pdf file by putting file name as
follows. (Delete all error messages)
Page 4 of 6
Bachelor of Applied Information Technology
Module Code CIT101
Module Title: Fundamentals of Programming
Practical 3:
1. With justifications, identify invalid or unsuitable Identifiers in Python from the following.
Example:
2. For each of the following, write a set of single Python statements in the interactive mode to
display the resulting output in a meaningful way. You should also use appropriate variable
names.
Example:
A can contains 42.35 gallons of coconut oil. What is the capacity in litres.
[1 gallon = 3.79 litres]
a) Find the length of a 10 m cable in inches rounded to nearest first decimal place.
(1m = 39.37 inches).
b) Express the speed of a car driven at 60 kmph in mph (miles per hour).
(8 km = 5 miles)
c) Find the hypotenuse of a right angled triangle in cm, if the lengths of the other two
sides are 3.5 cm and 1.73 cm respectively.
Page 5 of 6
Bachelor of Applied Information Technology
Module Code CIT101
Module Title: Fundamentals of Programming
3. Example:
Write a Python application to input the radius and the height of a right circular cone in cm, and
display its volume in cm3 rounded to 2 decimal places.
import math
a) Write a Python application to read the length, breadth and height of a cool box in
meters and display its capacity in m3.
b) Write a Python application to input the number of boys and girls in a class and display the
ratio of girls and boys as a percentage of the total number of students.
c) Write a Python application to input the area of a square shaped room in square feet and
find the length of a side in feet.
d) Write a Python application to calculate the simple interest when the principal amount,
annual rate and the period are input by the user.
e) A machine fills (x) number of bottles of water every (t) minutes where x > 0. Write an
expression to find the number of hours (h), it takes this machine to fill (y) number of bottles.
Write a Python application to input feasible values for x, t, y and calculate h in hours and
minutes.
End of Practical 3
Page 6 of 6