Lecture 2 — Exercises ===================== Overview -------- These problems are exercises to work on at the end of lecture and to be submitted for a small part of your grade on Submitty. Solutions will normally be due within 24 hours of the end of the lecture they are associated with. However, Lab 1 is intended to familiarize you with Submitty and verify that everyone can successfully use the Submitty system. Because of this, we will be giving you an extended due date for the exercises associated with lectures 2,3 and 4. Lecture 2 exercises will need to be submitted to Submitty as part of Lab 1. We strongly encourage you to complete the exercises during, or immediately after the lecture that introduces them, but to wait until Lab 1 before you try to submit them. For lecture exercises, students are welcome to work on these problems in small groups, but each student should write the final version of their solutions independently. Each student must submit their own solutions. Getting Started with the Spyder IDE ------------------------------------ Open up the Spyder IDE: - You can practice with small sections of Python code by typing in the interpreter in the lower right pane. - In order to create a Python program that you save to a file, click *File -> New File*. You can save it to a file by typing *File -> Save As* - You should save your programs in an organized manner within your Dropbox folder. If you do not have a Dropbox folder, you will learn how to create one in Lab 0. Until then, just make sure you can find your file when you save it. - Once you have drafted your code to solve a problem or, better yet, have written enough that you are ready to experiment with what you have, click on the green triangle to run your code. You will see the results in the interpreter pane on the lower right. - If you do not see the green triangle, you need to save your code to a file first. Now you are ready to proceed... Problems for Grade Submission ----------------------------- #. Write a single line of Python code that converts the temperature 64 from Fahrenheit to Celsius and prints the value. Submit a Python file containing just this single line of code. The output should just be the number that your code produces. Your code must include the use of an expression involving multiplication and a ``print`` function call. #. Write Python code that creates three variables called ``length``, ``width`` and ``height`` to store the dimensions of a 16.5 x 12.5 x 5 box. Write additional code that calculates the volume of the box and calculates its surface area, storing each in a variable. Print the values of these variables. Your code must use five assignment statements and two print function calls. Submit a file containing these seven lines of Python code. Your output should be :: volume = 1031.25 area = 702.5 3. Your problem is to determine the output of the Python program shown below. You must submit a text file showing the output. (Hint: there should be two lines with one integer on each line.) While it is possible to just run the program and copy the output, we *strongly* encourage you to not do this. You need to develop the ability to read code and understand what it will do. You will be tested on it. :: z = 2 z = z**2**3 print(z) x = 6 x = x**2 + 6 - z // 10 * 2 print(x)