2.19. Exercises
2-1. Variables, print, and the string format operator. Start the interactive interpreter. Assign values to some variables (strings, numbers, etc.) and display them within the interpreter by typing their names. Also try doing the same thing with the print statement. What is the difference between giving just a variable name versus using it in conjunction with print? Also try using the string format operator ( % ) to become familiar with it.
2-2. Program output. Take a look at the following Python script:
#!/usr/bin/env python 1 + 2 * 4(a) What do you think this script does?
(b) What do you think this script will output?
(c) Type the code in as a script program and execute it. Did it do what you expected? Why or why not?
(d) How does ...
Get Core Python Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.