generated from mwc/lab_names
I added import math, area = math.pi * (radius * radius) and print(area). Checkpoint 1: Value is anything that is what it is instead of referring to something else. Name is referred to something else. A name could change or be different depending on different contexts. A name can be refer to you but you can change your name or you may have different variations of your name. Variables are a name that refers to a value. Assign a value to a variable. Variables are very useful in programming as we can assign the value on the right to the name on the left (name = value). If we want to change the value of the name we can easily go back and change it which is helpful in programming. You also can use the name/variable name instead of the value. For example for the value of pi rather than typing that value out you can assign the value to the name and use the name throughout the whole programming code.
10 lines
230 B
Python
10 lines
230 B
Python
# circle_area.py
|
|
# --------------
|
|
# By MWC Contributors
|
|
import math
|
|
|
|
print("This program will calculate the area of a circle.")
|
|
radius = float(input("What is the circle's radius? "))
|
|
area = math.pi * (radius * radius)
|
|
print(area)
|