From the course: Learning ArcGIS Python Scripting
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Work with numeric values - ArcGIS Pro Tutorial
From the course: Learning ArcGIS Python Scripting
Work with numeric values
- [Instructor] When working with variables, you always have to think about whether that variable expects to hold numbers, dates, text strings, or some other kind of data, like a feature class object. If you're not paying attention, Python can do some pretty funny math, like in this case. I have a new notebook open and I'm going to create a couple of variables here. My first variable will be numPolygons, and the second will be numLines. So then I'll print numPolygons plus numLines. When I run it, you see I get 102 instead of 12. This happened because we put quotes around the numbers, forcing them to be treated as strings and the plus sign concatenate strings, as we learned earlier in the course. To make these values be treated as numbers, just don't put quotes around them. So that works. When you're reading a value in from an attribute table, you may not know in advance whether it's numeric or text, but we'll see later there are some functions that'll let you determine the data type…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.