This week, we were given the start of a script. The import random module was already loaded at the start of the script. We then needed to find some errors in a block of code that would allow the scipt to run properly. Luckily, the lecture helped to clear this up. And then step three happened. In step three we were to create a list from scratch using 20 random numbers between 0 and 10. I knew some of the modules that I needed to use, and individually I could run them with proper results, however, the while loop, threw me. I had a very hard time comprehending how to include the append function and the random integer. Once I got past step 3, things seemed to move along a little better. Once I had my list created, I needed to create a random unlucky number that would be counted and then removed from the list. I'm not sure why this while loop was easier to understand than the last one, perhaps because I was able to dissect the previous one. Our final results were to include the original block of code that we fixed, our created list, a statement declaring how many of the unlucky number would be removed from our list; if any, and our final list with the unlucky number removed. Below are the result of the my script.
Script results |
Here's hoping my clicker works better next week.
No comments:
Post a Comment