In this video, Jennifer Harrison walks through the process of writing a simple script to do unit conversion. Learn various ways to use the print statement and convert data types on the fly.
- [Instructor] I'm gonna demonstrate how to write…a simple Python script that converts feet to meters,…to show the use of the print statement, and basic math.…Since this is a very basic script,…I'll just put the length value into the code.…I'm in IDLE and I have a new blank script file open.…Some important points:…scripts are written in the editor window,…and then saved with a .py extension.…I've already saved this script as domath.py.…
The print statement is used to print a message…to the user.…The message will show up in the shell window down here.…This script will require a basic Python structure…that is used all the time in the ArcMap…field calculator, and in the label expressions.…The plus sign, for string concatenation.…Some notes about the plus sign in Python first.…The plus sign is used for string concatenation,…but it can also do math.…It knows which action you want it to perform…by looking at the values that you pass it.…
So if it's passed two strings, it concatenates them.…If it's passed two numbers, it adds them.…
- Writing and running Python scripts in IDLE
- Making scripts flexible with variables
- Commenting scripts
- Manipulating string data
- Object-oriented programming in Python
- Creating loops
- Reading and writing text files
- Capturing input at runtime
- Documenting your scripts
Skill Level Beginner
1. Python for ArcGIS Basics
2. Strings, Numbers, and Variables
Work with numeric values5m 22s
3. Syntax Rules
4. Manipulating Strings
5. Object-Oriented Programming
6. Using Loops
7. Generate Log Files
8. Input at Run Time
9. Help Documents
Documenting a script1m 59s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.