Complete the following problems from the textbook: 1, 2, 3, 4, 5, 6, 7, 8, 11, 12 (pages 78 79)
- What is a program?
- Python is an interpreted language. What does interpreted mean in this context?
- What is a Python comment? How do you indicate a comment? What purpose do they serve?
- What is a namespace in Python?
- Whitespace:
- What is whitespace in Python?
- When does whitespace matter?
- When does whitespace not matter?
- Explain the difference between a statement and an expression. Give an example of both, and explain what is meant by a statement having a side effect.
- Mixed operations:
- What type results when you divide an integer by a float? A float by an integer?
- Explain why that resulting type makes sense (as opposed to some other type).
- Consider integer values of a, b, and c, and the expression (a + b) * c. In mathematics, we can substitute square brackets, [], or curly braces, {}, for parentheses, (). Is that same substitution valid in Python? Try it.
- Assignment:
my_int = 5my_int = my_int + 3print(my_int)
- If you execute the three lines of code, what will be printed? Explain your answer using the rules of assignment.
- Rewrite my_int = my_int + 3 using the += symbol
- Assignment:my_var1 = 7.0my_var2 = 5print(my_var1 % my_var2)If you execute these three lines of code, what will be printed?
Reviews
There are no reviews yet.