Lab Description:
This Lab required me to complete exercises 2 and 3 from chapter 2 of the python book. Exercise 2 asked me to put some statements into a script and modify each expression into print statements. When I ran the script the value 5 was assigned to the variable x thus we got 6 when it printed the result of the expression x + 1.
Exercise 3 asked me to take a set of expressions and to write the output values of these expressions as well as the type of the values that were given. I used the print statement to display the results of the given expressions using the given assignment statements. I then used the print type function to display the type of each result.
Code:
Exercise 2
print 5 x = 5 print x + 1
Exercise 3
width = 17 height = 12.0 delimiter = '.' print width/ 2 print type(width/2) print width/ 2.0 print type(width/ 2.0) print height/ 3 print type(height/ 3) print 1 + 2 * 5 print type(1 + 2 * 5) print delimiter * 5 print type(delimiter * 5)
Screenshots: