1/14/25

Part 1

Data Types - What type is value it is?

Python(GIS Term)

Interger(short or long)

-whole number

Float(float or double)

-fractional number(number with decimals)

-float is a smaller decible point

String(text)

-letters, numbers, and other characters

Boolean

-true or false

List

-sequence of items

Tuple

-list that cannont be modified

Dictionary

-key/value pairs

ex: key is color and value is red

Date- no native data type for date in Python. Must use the dateime module to work with date object.

Variables - a name that refers to a value

-a container that stores a value

Python does not require the variable to be declared before assigning it to a value.

Python does not require the variable to be defined as a particular type. Python knows what type of varaible it is by the value it is assigned. This is called a dynamic assignment

Rules:

-only letters, digits, and undercoures - no spaces or special characters

-cannot begin with the digit

-cannont be python keywords

-do not use function names - will not cause immediate error but could interfere with the proper use of function

ex: print and type

Guidelines:

-use case descriptive names

ex:

-keep it short

-avoid confusion

-ask to follow pep8 guidelines

Python Fundamentals

Variables

x = 5

y = 2

print(y)

x is the variable and 5 is being stored in x

-it would print 2

1varible = hello world

would print an error

Operators

Floor Division

-gives you a whole number

Operator Precedence

Numeric expressions follow the standard order of operations

Parantheses


Exponents

Unary Plus/Minus

Multiplication, Division, Floor Division, Modulus

Addition and Subtraction

Examples

x = 10 -5

print(x)

Working with strings

Quotation marks are required for strings!

quotation marks tell the computer where the string begins and where it ends

-single and double quotes are interchangable but you cannot use both

Triple Quotes

-can be used for strings that span multiple lines

-can be single quotes or double quotes

Combining Strings

use + operaterto to concatenate strings

when combining strings and numbers, the number must first be convert(cast) to a string

use the str()function to convert the number to a string

w