Lab 2 - Experimenting with math

You are probably wondering when we will get to actually using Python. Now is the time. In this lab, you get to experiment with simple math using Python. The goal is to show you a few things, before we explore them formally. See if you can figure out what is going on!

What you need to do

In this lab, you will fire up the Python interpreter from the command line:

python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55)
...
>>>

This waa on my Mac, which uses an older Python.

Your sign-on will be different. The final prompt >>> is the important part. In the following sections, you will enter the code shown after that prompt, and record what you see in a text file. Use an editor of your choice to do this.

After you record your results, add a comment indicating why you think you got the result you see.

Sample problems:

Note

You might need to look up a few of the terms you see here. Do not worry if they are a bit confusing now, we will clear things up soon!

  1. >>> 1/2

  2. >>> int(1/2)

  3. >>> 1 // 2

  4. >>> “bye” * 5

  5. >>> “bye” / 5

  6. >>> 1+2/5

  7. >>> (1+2)/5

  8. >>> sqrt(5)

  9. >>> from math import sqrt

    >>> sqrt(5)

  10. >>> sqrt(5)*sqrt(5)

>>> for i in range(5):
...     print(i*5)
...

On that last one, press enter after the last set of dots.

What to turn in

Even though this is labeled a lab, turn it in in the homework folder (just name the directory where you place it LAB2). Push to GitHub and you are done. Push the file to the server and email me to let me know it is ready for grading.

When is this due?

On Sunday of the week assigned, at Midnight.