Wednesday, May 27, 2020

Module 2: Python Fundamentals



     This week's lesson focused on the fundamentals of Python. The lab required us to write code that printed our last name from a list, compiled a list of random integers between 0 and 10, and removed a designated integer from that list. We were also required to debug a selection of code for a dice game. In the process of completing the assignment, we were required to utilize while loops and several methods. Among these methods were the append, remove, and count methods.
     For the removal of the designated integer, first I assigned the integer to be removed to the variable "unlucky". I then wrote the code for finding, counting, and printing the number of "unlucky" integers in the "luckyList" list before I ran the code to test it and copy/pasted it into the script. The code for the removal of all "unlucky" integers from the list was written and then ran to test it before it too was copy/pasted into the script. Finally, I wrote the code for printing luckyList and ran the script to ensure the whole code worked together. The results of the script (top) and the flowchart for the creation and updating of luckyList (bottom) are pictured above.

No comments:

Post a Comment