Gaining Access to Lab Computers
If you have not done so, you must claim your U of M computer account using Iridium. From a logged in computer (maybe this is a good time to meet the person sitting next to you in the lab!) open a web browser and go to SignUM. Click on Click here to begin
. You will have to identify yourself, and then provide answers to a number of personal questions so that you can later log in even if your forget your password. This will enable you to access lab computers. Record your UMnetID
and password or otherwise take steps to remember them. If you have already claimed your ID, you can also change your password or answers to security questions using SignUM. The same user UMnetID will be used to log into the course UMLearn website.
To login, you must enter your complete U of M email address. Your email address is composed of: your UMnetID, followed by the @** symbol, and then myumanitoba.ca. For example, a student with UMnetID of chan139, the U of M email address is: [email protected]anitoba.ca**.
Exercise 1: Ensuring that Python works on your lab computer
For this course we are using Anaconda Python. You can acquire it for your personal computer from this link.
- Click on the
Start
button, choose INS Programs
, and thenProgramming
.- In the
Programming
sub-menu, you should seeSpyder (Python IDE)
.
Click on it to start the Spyder IDE. Note that the lab installation does not start the Launcher app.
Exercise 2: Interactive Mode
Execute some math in the interactive console (IPython) that is in the lower right-hand corner of the window.
Dont just copy and paste these! Type them in by hand to get your finger memory working with typing expressions.
Try some of the following:
42 + 42
5 / 2
"I can write anything here"
print("I can write anything here")
a = 3
a ** 2
print("Hello, my name is {} {}.".format("Inigo", "Montoya"))
Exercise 3: Programming (1 mark)
In Spyder, write a Python program (script) that has a variable num
that is set to the value 35607. Your program is to display the last and second-last digit of the value stored in num
. For example, when num
contains the value 35607, your program should print the last digit of 35607 is 7
and the second last digit of 35607 is 0
respectively.
Your program should be able to work with whatever number is stored in the variable num
. Test your program with num=35607
and num=6198
.
(Advanced) Exercise 4: Using log10(x)
Continuing with exercise 3, look up the log10
function from the math
library and use it to print the first digit in num
. For example, if num=35607
, then the output will be 3
.
Here is a page to demonstrates how to use log10
.
(Advanced) Exercise 5: Output formatting
If you finish all of the other exercises before the lab time is complete, try working on the following material that may not yet have been covered in class:
- Use String formatting to print out a number that has a maximum of 3 decimal places. Use the following resources to help solve this problem.
- Change the program AreaOfTriangle.py to output
The area of the triangle is 1.333
(3 decimal points). Decimal displays only work on decimal types, you may need to convert your datatype, or use a{f}
placeholders.
Reviews
There are no reviews yet.