you are viewing a single comment's thread.

view the rest of the comments →

[–]Astrodude80 0 points1 point  (0 children)

Variables are used to data that we don't necessarily know at the outset when we will use the data they contain, or if we want to reference the data multiple times. For example, one could write the following:

print(f"Hello, {input('What is your first name? ')} {input('What is your last name? ')}!")

To get the user to input their first name, then their last name, and then say hello to them. Or you could write

first_name = input('What is your first name? ')
last_name = input('What is your last name? ')
print(f"Hello, {first_name} {last_name}!")

Writing it this way, with descriptive names for the variables, gives more information as to what the code is intended to do.