Variables and Data Types
Harry
· 14 Sep 2026
· 3 views
Advertisement
Variables in Python
A variable is a name that refers to a value. Python infers the type automatically, so you never declare it.
name = "Priya"
age = 28
price = 149.99
is_active = TrueCore Data Types
int- whole numbers, e.g.42.float- real numbers, e.g.3.14.str- text, e.g."hello".bool-TrueorFalse.None- represents no value.list,tuple,dict,set- collections.
Working With Strings
first = "Groovy"
last = "Grails"
full = first + " " + last # concatenation
print(full)
greeting = f"Welcome, {full}!" # f-string interpolation
print(greeting)Numbers and Operations
a = 10
b = 3
print(a + b) # 13
print(a / b) # 3.333...
print(a // b) # 3 integer division
print(a % b) # 1 remainder
print(a ** b) # 1000 powerType Checking and Conversion
x = "123"
print(type(x)) # <class 'str'>
y = int(x) # convert to integer
print(isinstance(y, int))Key Points
- Python is dynamically typed: types are checked at runtime.
- Use f-strings (
f"...{var}...") for clean interpolation. int(),float(),str()convert between types.