lab06 : String formatting, random, and file IO

num ready? description assigned due
lab06 true String formatting, random, and file IO Wed 02/20 09:00AM Wed 02/27 11:59PM

In this lab, you’ll get more practice with:

This lab may be done solo, or in pairs.

Before you begin working on the lab, please decide if you will work solo or with a partner.

A reminder about working with a pair programming partner:

Once you and your partner are in agreement, choose an initial driver and navigator, and have the driver log into their account.

Instructions

In this lab, you will need to create two files:

Starter code is provided for you and are located at (you may need to refresh the page if the links do not load immediately):

  1. Create a directory called ~/cs8/lab06 (using the mkdir command) and cd into that directory.
  2. Use idle3 (you might try idle3 & if you want to be able to type commands on your terminal window after IDLE opens).
  3. Use “New File” to create empty files called lab06.py and lab06_tests.py in that ~/cs8/lab06 directory.
  4. Download input1.txt and input2.txt in that ~/cs8/lab06 directory. These are used when running pytest on lab06_tests.py.

You are encouraged to try submitting to Gradescope periodically for several reasons:

Some notes about printing the dice distribution

This portion of the lab will be manually graded by our TAs and not autograded by gradescope (though your submission must include the rollDice, rollDistribution and printDistribution functions in lab06.py.

An example printDistribution function will appear as follows:

Distribution of dice rolls

 2:     7 (  2.8%)  *******
 3:    14 (  5.6%)  **************
 4:    29 ( 11.6%)  *****************************
 5:    26 ( 10.4%)  **************************
 6:    34 ( 13.6%)  **********************************
 7:    41 ( 16.4%)  *****************************************
 8:    30 ( 12.0%)  ******************************
 9:    23 (  9.2%)  ***********************
10:    23 (  9.2%)  ***********************
11:    16 (  6.4%)  ****************
12:     7 (  2.8%)  *******
------------------------------
250 rolls

>>> printDistribution(rollDistribution(250))

Some notes about the File I/O functions

This portion of the lab will be autograded by gradescope. Two input files are provided for you to test your functionality. One additional input file is not provided and will be tested with your submission on Gradescope.

Note that all words are separated by a whitespace character, and a word contains only alpha-numeric characters that does not include punctuation characters. For simplicity, you may assume the text only contains the ,.!?; punctuation characters. Your code will need to split and strip the text file string appropriately.

Upload lab06.py and lab06_tests.py to Gradescope.

Once you’re done with writing your functions, navigate to the Lab assignment “Lab06” on Gradescope and upload your lab06.py and lab06_tests.py files. Remember to add your partner to Groups Members for this submission on Gradescope if applicable. At this point, if you worked in a pair, it is a good idea for both partners to log into Gradescope and see if you can see the uploaded files for Lab06.