The beginning of wisdom is to call things by their proper name

Imagine you are meeting a new person for the very first time. More than likely, the first thing you will learn about this person is their name. Why might this be?

Names allow us to better communicate with each other, by providing an easy way to reference the person who is being discussed. It is obviously preferable to say: “I need to see a doctor" instead of “I need to see a person who is trained in the medical field.”

Variables provide a similar improvement to our programming experience, allowing us to easily refer to pieces of information important to our program! Perhaps you are working on a calculator app and will need a variable to track the current_total. Or maybe you are automating a notification via email, and you will need a variable to track the mailing_list.

Okay, now we understand the usefulness of variables, so what do they look like? In python, we can assign a value to a variable with the assignment operator, a single equals sign. For example, current_total = 0 would be a valid way to assign a value of ‘0’ to the ‘current_total’ variable.

Exercise 1: Calculator

<aside> ✍️ Copy the below snippet into VSCode or Replit and follow the comment instructions to assign your first variables!

</aside>

# Welcome to VBC (Very Basic Calculator)!
# Set your first variable below! Name it 'first_number' and assign a value of 1

# Now set the second variable! Name it 'second_number' and assign a value of 4

# Once you do your part, this 'sum_result` variable will be able to reference
# 'first_number' and 'second_number' to calculate the sum.
sum_result = first_number + second_number

print(f"Result: {sum_result}")

Exercise 1: Calculator (SOLUTION)

# Welcome to VBC (Very Basic Calculator)!
# Set your first variable below! Name it 'first_number' and assign a value of 1
first_number = 1

# Now set the second variable! Name it 'second_number' and assign a value of 4
second_number = 4
# Once you do your part, this 'sum_result` variable will be able to reference
# 'first_number' and 'second_number' to calculate the sum.
sum_result = first_number + second_number

print(f"Result: {sum_result}")

Next Lesson:

User Input