generated from mwc/lab_names
designs now displayed with appropriate orientation
value is a constant a name represents something else In my family we all have nicknames. My brother is named Ramiro, but we call him Pelon. My other brother Stewart is called Tui, my sister Regina is Nena. My husband thought that I had 6 siblings instead of 3. Both names respresent the one value of a person. Variables allow a user to provide a value on the fly or allow us to easily change the input to an equation. They also provide for more understandable code because we then know what the value may represent. 5 is not very informative. radius is more informative. A function can be defined and named like a variable A function can break down a problem by taking one part - in particular a repeatable part - and allowing that piece of the logic to happen within the function. Then we just call the function without having to worry about those details. It also allows us to break up the work. If we agree what functions need to be written and what we are expecting from them then we can let one person tackle each function and then call the as needed without having to worry about how it's all done on the inside. An example may be like a webservice to process a banking transaction. I can call a function and pass arguments of to account, from account and amount and the web service takes care of the details and just lets me know that it processed or didn't. Simple and secure!
This commit is contained in:
parent
8c3c8a4b9d
commit
e8c8d061a4
|
@ -4,3 +4,9 @@
|
|||
|
||||
print("This program will calculate the area of a circle.")
|
||||
radius = float(input("What is the circle's radius? "))
|
||||
circle_area = radius * radius * 3.14
|
||||
circle_areastr = str(circle_area)
|
||||
radiusstr = str(radius)
|
||||
|
||||
print ("The area of a circle with a raduis of " + radiusstr + " is " + circle_areastr)
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
# ------------
|
||||
# By MWC contributors
|
||||
|
||||
my_name ="Chris"
|
||||
my_name =input("What is your name?")
|
||||
greeting = "Hello, " + my_name
|
||||
print(greeting)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand.
|
||||
package = []
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.1"
|
||||
python-versions = ">=3.10,<4.0"
|
||||
content-hash = "7b8fc01b274bd807fb00372bbc8e138330f15ae7978ed61e180f3b17ec076725"
|
16
shapes.py
16
shapes.py
|
@ -5,7 +5,19 @@
|
|||
from turtle import *
|
||||
|
||||
def triangle(side_length):
|
||||
pass
|
||||
forward (side_length)
|
||||
right (360/3)
|
||||
forward (side_length)
|
||||
right (360/3)
|
||||
forward (side_length)
|
||||
right (360/3)
|
||||
|
||||
def rectangle(height, width):
|
||||
pass
|
||||
forward (width)
|
||||
right (90)
|
||||
forward (height)
|
||||
right (90)
|
||||
forward (width)
|
||||
right (90)
|
||||
forward (height)
|
||||
right (90)
|
||||
|
|
Loading…
Reference in New Issue