Python Fundamentals
GIS5103 - GIS Programming - Module 2
Learning outcomes:
- Run Python script using Notebook in ArcGIS Pro
- F5 run module in IDLE
- ctrl+enter in Arc Notebook. This is a convenient way to run one line of code at a time.
- Work with string variables in Python
- covered in the first step of the lab in which we assign our name to a variable. We then split the string variable to only show our last name.
- Use and import modules
- imported the 'random' module, this allowed us to create our game by randomly generating numbers
- Save Python code as a script
- Include comments in scripts
- this lab's script gave instructions using #s, giving ample experience to become comfortable with how and when to use comments in scripts.
- Create loops and conditional statements
- Covered in steps 3 and 4
- Iterate variables within loops to control script workflow
- The screenshot below shows my successful program:
- First the computer prints my last name
- Then, the computer rolls for each player
- After that the computer adds 20 randomly generated numbers from 0 to 10 to an empty list.
- The computer then prints out a statement telling how many times an unlucky number was added. (in this case I assigned 3 as the unlucky number)
- Once all of the numbers have been removed the computer prints a new list.
Comments
Post a Comment