The Think Python author has given 2 more sample problems in order to understand the various statement and expression behaviours.
Assume that we execute the following assignment statements:
width = 17
height = 12.0
delimiter = '.'
For each of the following expressions, write the value of the expression and the type (of the value of the expression).
- width/2
- width/2.0
- height/3
- 1 + 2 * 5
- delimiter * 5
Use the Python interpreter to check your answers.
I’m trying to guess the answers first.
1. 8
2. 8.5
3. 4.0
4. 11
5. …..
Now I’m trying the same using interactive mode and the snapshot is given below.
Next problem is
No comments:
Post a Comment
Comments with advertisement links will not be published. Thank you.