Module 3 - Python Fundamentals Part 2
This week's lesson proved to be extremely challenging. Nonetheless, it was very rewarding and eye-opening. For lecture, we covered topics regarding working with paths; working with and importing modules; controlling workflow using conditional statements, such as if, elif, and else statements and the importance of indentation; loop structures (specifically the while and for loops); and commenting (#) on scripts.
Our lab assignment had a few components to it. We were provided an unfinished script that ultimately would perform a little dice rolling game based on the player's name length, a random list creation, and some adjustments based on an unlucky number (which I chose to be 3, by the way). First, we were tasked to import the appropriate modules so that we could use their functionality within our script. Then, we were tasked to correct 2 errors in a block of code containing for loops. Then, we needed to create a while loop that added 20 random numbers (between 0 and 10) to a printed list. And finally, for the big shabam, we wrote a block of code where the script removes all instances of the unlucky number from the random list, printing a new list without the unlucky number, and for every occasion, provide specific messages.
The entire process was nerve-racking and weird. It was weird because I didn't know what I was going to create until I literally started typing. It was kind of like a "as you go" type of thought-process. I'm glad that after I running every print statement, it worked. For the last part of the assignment, this is the English thought-process version:
Our lab assignment had a few components to it. We were provided an unfinished script that ultimately would perform a little dice rolling game based on the player's name length, a random list creation, and some adjustments based on an unlucky number (which I chose to be 3, by the way). First, we were tasked to import the appropriate modules so that we could use their functionality within our script. Then, we were tasked to correct 2 errors in a block of code containing for loops. Then, we needed to create a while loop that added 20 random numbers (between 0 and 10) to a printed list. And finally, for the big shabam, we wrote a block of code where the script removes all instances of the unlucky number from the random list, printing a new list without the unlucky number, and for every occasion, provide specific messages.
The entire process was nerve-racking and weird. It was weird because I didn't know what I was going to create until I literally started typing. It was kind of like a "as you go" type of thought-process. I'm glad that after I running every print statement, it worked. For the last part of the assignment, this is the English thought-process version:
- If any number generated in the random list does not contain the value of the unlucky number, then I want you to tell me “The list does not contain that unlucky number.”
- However, if any number generated in the random list does contain the value of the unlucky number, then I want you to tell me that you will be “Removing the unlucky number from the list, and how many times."
- And for every time that it does contain the value of the unlucky number, you will remove it, and re-generate the list without it.
My results are provided in the screenshot above.
Comments
Post a Comment