Day 9 - pre-class assignment

Goals for today's pre-class assignment

  • Use random number generators to create a sequence of random floats and integers
  • Create a function and use it to do something.

Assignment instructions

Watch the videos below, read through Section 4.6, 4.7.1, and 4.7.2 of the Python Tutorial, and complete the programming problems assigned below.

This assignment is due by 11:59 p.m. the day before class, and should be uploaded into the "Pre-class assignments" dropbox folder for Day 9. Submission instructions can be found at the end of the notebook.


In [ ]:
# Imports the functionality that we need to display YouTube videos in a Jupyter Notebook.  
# You need to run this cell before you run ANY of the YouTube videos.

from IPython.display import YouTubeVideo

In [ ]:
# WATCH THE VIDEO IN FULL-SCREEN MODE

YouTubeVideo("fF841G53fGo",width=640,height=360)  # random numbers

Some possibly useful links:

And some interesting links on what you use random numbers to do in programming:

Question 1: Using the Python random module, first seed the random number generator with a number of your choosing and then use a loop to create and print out several floating-point numbers whose values are between 5 and 10. Verify that if you re-run this code several times, the random numbers stay the same, and that if you comment out the code they change!


In [ ]:
# put your code here.

In [ ]:
# WATCH THE VIDEO IN FULL-SCREEN MODE

YouTubeVideo("o_wzbAUZWQk",width=640,height=360)  # functions

Question 2: Give a function a list of floating-point numbers and have it return the min, max, and average of them as three separate variables. Store those in variables and print them out.


In [ ]:
# put your code here.

Question 3: Give a function a list of floating-point numbers and have it return either the min, max, or mean value, depending on an optional keyword (that you give it as a second argument). The default should be to provide the mean value. Store that in a variable and print it out.


In [ ]:
# put your code here

Assignment wrapup

Question 4: What questions do you have, if any, about any of the topics discussed in this assignment after watching the videos, reading the link to the Python tutorial, and trying to write the programs?

Put your answer here!

Question 5: Do you have any further questions or comments about this material, or anything else that's going on in class?

Put your answer here!

Question 6: How long did this assignment take you to complete?

Put your answer here!

Congratulations, you're done!

Submit this assignment by uploading it to the course Desire2Learn web page. Go to the "Pre-class assignments" folder, find the dropbox link for Day 9, and upload it there.

See you in class!