SOLVED: Functions soln

18.99 \$

Lab Overview The main goal of this lab is to learn to deﬁne and use functions in our programs and to learn good program structure. A good program is easy to read and debug. One of the ﬁrst things we want is for function deﬁnitions to come before any other code. We will work on this throughout this lab. Second, you will see that code we have given you contains simple comments to explain what the code does. These comments are preceded with a pound sign. We want you to get in the habit of commenting your code. This is also a good exercise to explain to yourself what you are doing. Checkpoint 1: Using existing functions First, we will experiment with using functions. Create a new directory in your dropbox for Lab 2, and copy from Piazza the program called lab2 check1.py. Run this code and see that it produces no output. Let’s look closely what the code does: it creates a function that takes four values: x1,y1,x2,y2, and returns a ﬂoating point value that represents the Euclidean distance between two points with Cartesian coordinates (x1,y1) and (x2,y2). Then, the code executes this function, but does not do anything with the output of the function.

Category:
Click Category Button to View Your Next Assignment | Homework