Читать книгу Introduction to Python Programming for Business and Social Science Applications - Frederick Kaefer - Страница 24
Stop, Code, and Understand! SCU 1.1 Introducing Stop, Code, and Understand! Exercises
ОглавлениеWe incorporate coding exercises throughout the book to make sure you understand the topics that we are covering. Each one uses comments (which begin with the # sign) to indicate precisely where you need to add or change Python code. To complete each exercise, download the corresponding Python file from the companion website, open the file in the Python IDLE editor, make the requested change, and execute the code to verify that you understand the concept. We explain the solutions to the Stop, Code, and Understand! exercises in Appendix D at the end of the book, and the solution files for each exercise are available on the companion website.
For the first exercise, download the file “SCU 1_1.py” from the companion website and save it either on your computer or on a removable storage device. Next, open the Python IDLE shell and then open the file “SCU 1_1.py” in the Python IDLE editor by clicking on File/Open from the menu and selecting the file you just saved. Run the code by clicking on Run/Run Module from the menu. Next, add a line of Python code where indicated in the following program to print out the message “I would like to go to the airport.” Run the revised code by clicking on Run/Run Module from the menu to verify that your added code works correctly.
Lessons learned: In this section, we learned how to write and execute Python code that we save in plain text files. Using files enables the storing and execution of many lines of code as a program that we can save and run later.