This module was a direct expansion on the previous module, however far more in-depth. With the use of for-else statements, various methods and functions, for/while loops, and variable/list assignment I was asked to complete a set of tasks to achieve a fully-fledged script. My script needed to achieve the following:
1) Print my last name from a created list
2) Have corrected errors from a prewritten code set
3) Populate an empty list with 20 random integers
4) Remove an "unlucky" number from the previously created list
Step 1 included mainly utilizing string assignment and simple function to print my name. For step 2, I was given a set of prewritten code and successfully corrected two syntax errors to get the code to run correctly. Steps 3 and 4 built off of each other and required a far more complex set of functions and methods within various loop structures. With some tenacity I was able to complete each step and get my script to return the following:
Admittedly, this flowchart is not perfect and I need more practice making flowcharts. However, I believe the column of processes on the right hand side accurately depicts the order of processes in the script based on an if-else statement.
Finally, here are some notes I took based on my experience with the assignment:
-When splitting my name into a list, it seemed counterintuitive that the split method needed no argument in the parentheses. However, it seems to be a special case which in turn makes it easier to remember.
-Correcting the errors in step 2 was quite easy after the lecture material. It seems like one of the most common errors in Python is when 2 different types of data are attempted to run together in the same function. After running the script it became obvious that dice, which was previously set as an integer, needed to be changed into a string to run the print function properly. The other error was far more simple, as case sensitivity is a very real thing in Python so the capital “X” needed to become a lowercase “x” for the script to associate x as the assigned variable throughout the script.
-The language of loops is something that will take me some time but realizing that the “else” portion of an if statement basically means the opposite of what was coded in the “if” statement.


Comments
Post a Comment