Files
lab_names/greetings.py
angelotr a611163e21 For greetings.py I changed the code so that it
always greets me by name. Now, when I run the program, it automatically
prints "Hello Angelo".

Checkpoint 1:

A value is the acutal data, like the number 5 or the text "Angelo".
A name is a label that refers to the value. For example, in my_name = "Angelo", the value is "Angelo" and the name is my_name.
An everyday example is a mailbox. The name on the mailbox shows whose mail it is, while the letters inside are the actual content.
Changing the name doesn't change the letters so it is important to distinguish between the two.

Variables are useful in programming because they let you give a name to a value, making your code easier to read, understand, and reuse.
Instead of repeatedly typing the same value, you can use a name that represents it, which makes it easier to update the value in one place if it changes.

Checkpoint 2:

A function is like a variable because it has a name that refers to a piece of code, just like a variable has a name that refers to a value.
 Once you define a function, you can use its name to run the code it contains, without rewriting the same instructions each time.

Functions are helpful because they let you break a big problem into smaller, easier steps.
For example, if you want to find the area and perimeter of many circles, you can make one function to calculate the area and another to calculate the perimeter.
Then you can use these functions whenever you need them without rewriting the same code.
2025-09-01 22:16:13 -04:00

8 lines
118 B
Python

# greetings.py
# ------------
# By MWC contributors
my_name ="Angelo"
greeting = "Hello, " + my_name
print(greeting)