generated from mwc/lab_names
- A value can have many different types but a name is just a reference to a value. - When you are filling out a form you are providing values for names. If the form asks you to do something like "combine lines 1 and 3" your answer better not be "line 1 line 3". - When you need to repeat a value, like the area of a circle, many times it is easier and more efficient to save the value to a variable. It also makes code more understandable.
10 lines
232 B
Python
10 lines
232 B
Python
# circle_area.py
|
|
# --------------
|
|
# By MWC Contributors
|
|
|
|
from math import pi
|
|
|
|
print("This program will calculate the area of a circle.")
|
|
radius = float(input("What is the circle's radius? "))
|
|
area = pi * radius * radius
|
|
print(area) |