generated from mwc/lab_names
In greetings.py, I changed the first line to
my_name = input("What is your name?") as instructed.
In circle_area.py, I finished the program by assigning
3.141592653 to pi and then printing the value of
pi * radius * radius, which is the area of a circle.
Checkpoint 1:
A value is what it is, but a name refers to a value.
An everyday life situation where it's important to
distinguish between a name and the value it refers to
is when multiple people have the same name. For example,
I went to high school with two people who were both
Kevin Ng. Despite the jokes, they weren't interchangable,
and the relationships I had with each were different.
Variables can be useful in programming for a number
of reasons. In the assignment text, pi was assigned
the value 3.141592653. pi is much quicker and easier
to type. Another reason a variable might be useful is
because the value a name refers to might change. For
example, the price of a fruit might change from $1 to $2,
but we'd still refer to monetary amount as price.
Checkpoint 2: Not there yet! Was asked to submit at
checkpoint 1.
This commit is contained in:
@@ -4,3 +4,5 @@
|
||||
|
||||
print("This program will calculate the area of a circle.")
|
||||
radius = float(input("What is the circle's radius? "))
|
||||
pi = 3.141592653
|
||||
print(pi * radius * radius)
|
||||
@@ -2,6 +2,6 @@
|
||||
# ------------
|
||||
# By MWC contributors
|
||||
|
||||
my_name ="Chris"
|
||||
my_name = input("What is your name? ")
|
||||
greeting = "Hello, " + my_name
|
||||
print(greeting)
|
||||
|
||||
Reference in New Issue
Block a user