# Message double returns the string Argument doubled
def msg_double(phrase):
"""
Repeat and concatenate a phrase.
args:
phrase: string to be repeated
returns:
double: phrase repeated and concatenated
"""
double = phrase + " " + phrase
return double
# save return value in variable
msg_2x = msg_double("let's go")
print(msg_2x)
# example of functions with return values used in functions
def msg_double(phrase):
"""
Repeat and concatenate a phrase.
args:
phrase: string to be repeated
returns:
double: phrase repeated and concatenated
"""
double = phrase + " " + phrase
return double
# prints the returned object
print(msg_double("Save Now!"))
# echo the type of the returned object
type(msg_double("Save Now!"))
# create and call make_doctor() with full_name argument from user input - then print the return value
def make_doctor(name):
doctor=("Dr. "+ name )
return doctor
full_name=input("What's your name?")
print(make_doctor(full_name))
def make_schedule(period1, period2):
"""
Create schedule with period numbers and courses in title case.
args:
period1, period 2: courses to be made into a schedule
returns:
schedule: student schedule
"""
schedule = ("[1st] " + period1.title() + ", [2nd] " + period2.title())
return schedule
student_schedule = make_schedule("mathematics", "history")
print("SCHEDULE:", student_schedule)
# [ ] add a 3rd period parameter to make_schedule
# [ ] BONUS - print a schedule for 6 classes (Tip: perhaps let the function make this easy)
def make_schedule(period1, period2, period3):
"""
Create schedule with period numbers and courses in title case.
args:
period1, period 2, period 3: courses to be made into a schedule
returns:
schedule: student schedule
"""
schedule = ("[1st] " + period1.title() + ", [2nd] " + period2.title() + ", [3rd] " + period3.title())
return schedule
student_schedule = ("mathematics", "history", "science")
print("SCHEDULE:", student_schedule)