Lab 01 - Lab Exercise
Lab 01 - Lab Exercise
Exercise
01. Basics
1. Evaluate the following expressions yourself (and then use Python terminal to check them).
(e) 2 ∗ 3 + 4
2 22×3
(a) 32 (c) 4+3
2 2 2(2×3) 2
(b) ( 3 ) (d) 4+3 (f) 23
2. Determine the values of the following logical expressions before trying them out in Python terminal.
3. Write relational expressions to check the following situations and verify whether they are correct:
2. Write a Python script (name it Lab01B.py) to calculate the volume of a cone. Request the user to enter
the radius (r) and the height (h) of the cone and display the volume in the following format. [Hints: (a)
The volume (V ) of a cone can be calculated using V = 13πr2h (b) use π as 3.14]
1 Volume of a co ne
2 ----------------
3 Enter radius : 7
4 Enter height : 10
5 The volu me of the cone is 513.127
3. In Civil Engineering, the vertical stress under the centre of a loaded circular area is given by the formula
given below.
Write a Python script (Lab01C.py) to get the user input for q, r and z and output the value for s. Use
appropriate formatting options to display the answer to the user.
Department of Computer Engineering, University of Peradeniya 1
Computing
General Program Lab 01: Exercise GP106
Important
Copying someone else’s codes (including your group mate’s) or showing your source codes to anyone else will
earn you zero mark for the whole lab exercise.