generated from mwc/lab_names
checkpoint 1 -A name is like an identifier that is empty. It only gains importance once it is assigned a value, which is the data stored under the name. It's like the net worths. people are just people until you find out their networth. -it's easier to refer back to and connect your code when using variables. It also allows you to change the values without having to change all your code checkpoint 2 -a function is similar to a variable because it makes it easier to reference a set of code. With it, you don't need to repeatedly write out the same few lines of code -functions are like mini projects in a big scheme. You can solely achieve the big picture by completing functions. The best part of is that you can check if a function is working wihout having to run all your code. the names lab is a good example, I tested the shapes as I wrote the functions and once they were done, I could run the drawing.
12 lines
238 B
Python
12 lines
238 B
Python
# circle_area.py
|
|
# --------------
|
|
# By MWC Contributors
|
|
|
|
print("This program will calculate the area of a circle.")
|
|
radius = float(input("What is the circle's radius? "))
|
|
import math
|
|
|
|
area= math.pi*radius**2
|
|
print("area is "+ str(area))
|
|
|