Welcome to your first Python tutorial! In this lesson, you’ll learn about variables and basic data types.
What are Variables?
Variables are containers for storing data values. In Python, you don’t need to declare the type of a variable.
Exercise 1: Creating Variables
Try creating a variable and printing it:
# Create a variable called 'name' with your name
name = "Alex"
print("Hello, " + name)
Numbers in Python
Python has two main numeric types: integers (whole numbers) and floats (decimal numbers).
Exercise 2: Math Operations
Let’s do some basic math:
# Calculate the area of a rectangle
width = 5
height = 10
area = width * height
print("The area is:", area)
Strings
Strings are sequences of characters enclosed in quotes.
Exercise 3: String Operations
# Combine strings and use string methods
first_name = "Python"
last_name = "Programming"
full_name = first_name + " " + last_name
print(full_name.upper())
print(full_name.lower())
Great job! You’ve learned the basics of Python variables and data types.