.pyfiles containing your work. (If you upload a screenshot or other file format, you won't get credit.)
This homework assignment must be submitted in Gradescope by 10am CST on Tuesday, October 5, 2021.
This homework assignment focuses on:
Collaboration is prohibited, and you may only access resources (books, online, etc.) listed below.
The course materials you may refer to for this homework are:
This homework assignment has 2 problems, numbered 2 and 3. The grading breakdown is:
Ask your instructor or TA a question by email, in office hours, or on discord.
Gradescope will show the results of the automated syntax check of all submitted files as the score for problem 1.
Suppose a company called NetShareTube has decided to rename itself to SynerGrowthTech. Unfortunately, they have a lot of text files (Python program code, documentation, etc.) that will need to be updated because they refer to the old name.
Write a Python program
hwk6prob2.py to assist with the renaming as follows:
NetShareTubeis changed to
SynerGrowthTech, and the result is written to the output file
For example, if a file
mission_statement.txt in the current directory contains this text:
At NetShareTube, we are committed to excellence in all its forms. We produce scalable enterprise solutions for delivering excellent customer experiences. NetShareTube was founded in 2019 by a visionary leader who is no longer with the company.
and if the following command is run
python3 hwk6prob2.py mission_statement.txt mission_statement_updated.txt
then a new file
mission_statement_updated.txt should be created with the following content:
At SynerGrowthTech, we are committed to excellence in all its forms. We produce scalable enterprise solutions for delivering excellent customer experiences. SynerGrowthTech was founded in 2019 by a visionary leader who is no longer with the company.
Write a program
hwk6prob3.py that uses Python's random module to simulate rolling two 6-sided dice (each with the numbers 1, 2, 3, 4, 5, 6 on its faces) 20 times in a row. The program should make note of each time the dice roll totals to 7. The program should display the results on the screen as a table in the following format:
D1 D2 S? SPct 2 5 Y 100.00 1 3 N 50.00 2 5 Y 66.67 2 6 N 50.00 2 1 N 40.00 2 3 N 33.33 1 4 N 28.57 2 6 N 25.00 4 1 N 22.22 6 6 N 20.00 4 4 N 18.18 3 5 N 16.67 2 1 N 15.38 1 4 N 14.29 1 6 Y 20.00 1 4 N 18.75 2 5 Y 23.53 4 3 Y 27.78 6 2 N 26.32 5 6 N 25.00
D1 shows the roll of the first die,
D2 shows the roll of the second die, and
N to indicate whether or not the dice sum to 7. The final column
SPct shows the percentage of rolls so far that sum to 7. Notice that the columns are nicely aligned, with the right edge of each column label matching the right hand side of the column of numbers or values. Also, percentages are shown with 2 digits after the decimal point (so, allowing for 3 digits before the decimal point and the point itself, each percentage is shown in a way that has a total width of 6 characters).
While you can certainly use the solution to the "coin flip report" from Worksheet 6 as a starting point for this problem, make note of a key difference: