Module 3 lab involved using modules, conditions, and loops. To get the results of the screenshot below, I had to import the math module. Part of the script creates a list of players and the dice game results. Next, I created a
while loop that randomly selects 20 integers ranging from 0 to 10. I then printed one list of all the integers. From the random numbers that were selected, if the number 8 was in the list, I had it removed. To do this, I counted how many times the number 8 appeared in the list. Once I had the number, I used a
while loop inside a condition statement to remove the number 8 until it was gone. By counting how many 8's there are, that determined if the
while loop continued to run. The results printed.
|
Script Results |
I felt this lab was rather difficult. It was a challenge to figure out the correct syntax and order of each operation. By working through the lab, I learned quickly how important indenting is to the script. Below is a flow chart of the script.
|
Flow Chart of Step 4 |
No comments:
Post a Comment