less than 1 minute read

Python is dynamically typed, which means I don’t need to explicitly declare the data type of a variable. Python will infer the data type based on the assigned value.

I can assign a value to a variable using the assignment operator (=). Here’s how I can create and use variables in Python:

# Assigning values to variables
name = "John"
age = 30
height = 6.2

# Using variables in expressions
birth_year = 2023 - age
greeting = "Hello, " + name + "!"

# Displaying variable values
print("Name:", name)
print("Age:", age)
print("Height:", height)
print("Birth Year:", birth_year)
print(greeting)

# Output
Name: John
Age: 30
Height: 6.2
Birth Year: 1993
Hello, John!

Leave a comment