Lab 1

Lab Description: getting familiar with python data types assigning values to variables and using the variables with operators also  and also comments in python.

Exercise 2

in the interpreter mode numbers displayed directly while “x=5” saved x as a variable with the value 5 and when using x in with the operator “x+1” it used the value of the variable x and displayed 6. while in the script mode the codes as it is displayed nothing when running the program.

ex2-1ex2-2

after adding print in the script mode it showed the values as in the interpreter mode.

ex2-3

 

Exercise 3

width/2 displays 8 “int” instead of 8.5 as python doesn’t display fraction automatically.

width/2.0 displays 8.5 “float-point” as the entered data contain fraction.

height/3 displays 4.0 “float-point” as the entered data contain fraction.

1+2*5 displays 11 “int”.

delimiter*5 displays “…..” as the entered value was string so python used * to repeat the string value 5 times.

ex3

Leave a Reply

Your email address will not be published. Required fields are marked *

A City Tech OpenLab ePortfolio