In Python, variables are names given to memory locations used to store data, while data types classify the kind of data a variable holds. Python is a dynamically typed language, so you do not need to explicitly declare the data type of a variable; the interpreter infers it automatically based on the assigned value.
Variables in Python
Assignment: Variables are created using the assignment operator (=). For example, age = 30 creates a variable named age storing the integer value 30.
Naming Rules:
Names can contain letters, numbers, and underscores (_).
They must start with a letter or an underscore.
They are case-sensitive (myVar and myvar are different).
Reserved Python keywords (e.g., if, else, for) cannot be used as variable names.
Dynamic Typing: A variable's type can change during program execution. For instance, a variable storing an integer can later be assigned a string value.
Checking Type: You can determine the data type of any variable using the built-in type() function, such as type(age).
#snsinstitutions #snsdesignthinkers #designthinking