generated from mwc/lab_names
Added variable "r" that calculates the area
Checkpoint 1: - A value corresponds to something defined/fixed. In comparison, a name refers to something that can vary or be manipulated in some sort of way In real life, one example is SSN. Everyone has a distinct SSN (value). A person can move from their hometown (name) where they received their SSN but SSN will remain the same for all their lives. -It's helpful to use variable in programming because it allows us to use a value in different contexts/calculations. It also makes it easier for the author and the readers to understand what the numbers represent if they are named as variables. Checkpoint 2: -Function is more nested and can have different elements within, such as a value or a variable or another function. It is similar to a variable in a way that it can correspond to a certain value when executed. -Along the similar lines as the answer above, functions can help organizing our codes by chunking our calculations. I recall creating a lot of functions for my physics lab data analyses because it involved multiple dimensions of calculations with massive amounts of data. Labeling each (or a certain chunk of) calculation(s) greatly helped me keep track of my analyses.
This commit is contained in:
@@ -2,5 +2,10 @@
|
||||
# --------------
|
||||
# By MWC Contributors
|
||||
|
||||
import math
|
||||
print("This program will calculate the area of a circle.")
|
||||
radius = float(input("What is the circle's radius? "))
|
||||
r = round(((math.pi)*(radius)**2), 2)
|
||||
r =str(r)
|
||||
Area = "Area of the circle = " + r
|
||||
print(Area)
|
||||
Reference in New Issue
Block a user