Download (right-click, save target as ...) this page as a jupyterlab notebook from:

Laboratory 2 - HW


Laboratory 2: First Steps ...

LAST NAME, FIRST NAME

R00000000

ENGR 1330 Laboratory 2 - Homework

Notice the code cell below! From this notebook forward please include and run the script in the cell, it will help in debugging a notebook. Its ok if the code makes no sense right now - mostly the cell executes system commands. As you change machines, and rerun the cell the output will change (its supposed to!)

Exercise 1

The cell below is type RAW, change it into a code cell and activate (suppress the comments) and run the script.

What is the value of area?

# Demonstrate some assignment operations width = 4 #length := width #length += 2 # area = length * width

Copy your working script below and add necessary code to output the value of area.

Exercise 2

Change the RAW cell below into a Code cell, and run the script (fix any syntax errors)

# data types print ('integers and reals') x1 = 1.0 y1 = 1. z1 = 1 x2 = 5.0 y2 = 5. z2 = 5 print ('x1 = ', x1, ' y1 = ', y1, ' z1 = ', z1) print ('x2 = ', x2, ' y2 = ', y2, ' z2 = ', z2) print ('x1/x2 = ',x1/x2,' y1/y2 = ',y1/y2,' z1/z2 = ',z1//z2)

a. Of the six variables, which are integers?

b. What is the difference (in effect) between x1=1.0 and y1=1.?

c. Examine the division results; Why does z1//z2 return a value of 0?


Exercise 3

Exploring arithmetic. First define three variables a,b, and c.

# change this cell to CODE to run a = 21 b = 10 c = 0

Then change the cell below to code and run it.

# change this cell to CODE to run c = a + b print ("Value of c is ", c)

Now using the example in the cell above, exaluate the following expressions in the indicated cells below: