A “different” function: return
##################################### # G. Elia # GreetingFunct2_YI.py # Greeting program with functions and # the return keyword # Python version 3.4 # Date 10/22 ##################################### # Functions ##################################### def welcome(): # something aName = input("What is your name? ") return aName def howRU(aName): # something else print ("Hi ", aName, "! Nice to meet you ") feeling = input(" How are you? ") print ("Did you say your are feeling ", feeling, "? ") ####################################### # Driver: control the flow of execution ####################################### # main aName = welcome() howRU(aName)
Homework:
The circle calcualtor program: CircleCalulations_YI.py
#####################################
# Functions
#####################################
def getRadius():
# prompt the user for radius
def sphereSurfArea(radius):
# calculate the area of the sphere
# print area with a message
#####################################
# Driver: control the flow of execution
#####################################
#
# main
radius = getRadius()
sphereSurfArea(radius)