Exercise 4.6 (Pythons type() function)
1. Ensure you have viewed the video (associated with this exercise) at this link >>
2. Predict the output of the program below (Example 1).
Exercise 4.6 Example 1
3. Predict the output of the program below (Example 2).
Exercise 4.6 Example 2
4. Predict the output of the program below (Example 3).
Exercise 4.6 Example 3
5. A data structure that appears in code between the following type of brackets is referred to as what?
[ ... ]
[ ... ]
6. A data structure that appears in code between the following type of brackets is referred to as what?
{ ... }
{ ... }
7. A data structure that appears in code between the following type of brackets is referred to as what?
( ... )
Note: I strongly recommend that you learn the meanings of these brackets as they apply to Python data structures.
( ... )
Note: I strongly recommend that you learn the meanings of these brackets as they apply to Python data structures.
8. In your own words describe the relationship between a class and an instance of the class.
9. Draw the execution space (as covered in the videos) for the following assignment statement:
x = 6.248
x = 6.248
10. In your own words explain why the type() function always returns the word class. For example the following program:
w=65
print(type(w))
produces the following output:
<class 'int'>
>>>
w=65
print(type(w))
produces the following output:
<class 'int'>
>>>
END Next Exercise >>