Module 2: Python Fundamentals


The purpose of this lab was to create a Python script by manipulating string variables using a list, creating loops and conditional statements, and iterating variables within loops to control workflows. The final Python script had to be run using Spyder. The tasks performed by the script include printing my last name, running a dice game (the code was provided and debugged), populating and printing a list with 20 random integers from 0 to 10, and removing an integer (in my case 2) from the list and reprinting it. One run of my final script is above. I found it easiest to test individual lines of code and steps of the assignment in new, separate files in order to get them to run properly. There was a lot of trial and error for me in this assignment and I found creating the while loops the most troublesome.

The first two steps of the assignment - printing my last name and debugging code - were the easiest. In order to print my name, I assigned my full name to a string, split the string, and wrote a print statement indexing my last name to be printed. To debug the code, I ran the script, looked up the error and corrected the syntax. There was an x that was capitalized in an if statement when it should have been lower case, and a string function missing. 

The last two steps of the assignment required creating my own code with conditional statements and while loops. I found it difficult to get the while loops to run properly. The while loops were tricky because they have to have defined conditions in a certain arrangement. In both instances when I had to use the loops, I forgot to define the conditions, had code out of place and kept getting errors. Once I figured out the correct order and arrangement, the script ran correctly. For the if and if, else statements, I hand drew some flowcharts to help visualize the expected outcomes. This helped clarify the steps to write the code.  


Comments

Popular posts from this blog

Module 2: Coordinate Systems

Module 6: Proportional Symbol and Bivariate Choropleth Mapping

Module 8: Isarithmic Mapping