# Yixuan Sun
# 9/20/2021
# I learn how to create a function with return value, parameter, multiple parameters, sequence in coding tasks
# the difficulties is make to code, read more notes
# [ ] define and call a function short_rhyme() that prints a 2 line rhyme
# I use define to enter 2 sentence and call the sentence out.
def short_rhyme():
print("today, we're going to the beach. we are going to eat peach.")
short_rhyme()
# [ ] define (def) a simple function: title_it() and call the function
# - has a string parameter: msg
# - prints msg in Title Case
def title_it(phrase):
print(phrase.upper() )
# call function with a string
title_it(" my name is Yixuan ")
# [ ] get user input with prompt "what is the title?"
# [ ] call title_it() using input for the string argument
# I creat an input is called what is the title to let user write in.
title_it = input("what is the title: ")
print(title_it)
# [ ] define title_it_rtn() which returns a titled string instead of printing
# [ ] call title_it_rtn() using input for the string argument and print the result
def title_it_rtn():
print(title_it_rtn)
print("hello")
# string argument
# I use 2 string arguments: book and price
# [ ] create, call and test bookstore() function
def bookstore (book, price):
book = (book_entry)
# bookstore returns a string in the sentence form
return 'title: ' + book + 'costs $' + price
book_entry = input("enter book name: ")
price_entry = input("price: ")
info=bookstore(book_entry, price_entry)
# print return value of bookstore()
bookstore(book_entry, price_entry)
def make_greeting(name, greeting = "Hello"):
return (greeting + " " + name + "!")
# get name and greeting, send to make_greeting
def get_name():
name_entry = input("enter a name: ")
return name_entry
def get_greeting():
greeting_entry = input("enter a greeting: ")
return greeting_entry
print(make_greeting(get_name(),get_greeting()))
# I fix it by move the print down to the last place