#Sam Ola
#10/4/2021
#I learned how to create functions with a paramater
#I had difficulty understand task 2 and 3 so i wasn't able to finish those ones
# [ ] define and call a function short_rhyme() that prints a 2 line rhyme
def short_ryhme(rhyme1, rhyme2):
rhyme = ("[1st] " + rhyme1.title() + "[2nd] " + rhyme2.title())
return rhyme
rhymes = short_ryhme("Roses are red violets are blue, i like green and I like you. ","His palms are sweaty, knees weak, arms are heavy There's vomit on his sweater already, mom's spaghetti.")
print('Rhymes:', rhymes)
# [ ] define (def) a simple function: title_it() and call the function
# - has a string parameter: msg
# - prints msg in Title Case
def short_message(msg):
message = "Msg" + msg
return message
quick_message = short_message("")
print(quick_message)
# [ ] get user input with prompt "what is the title?"
# [ ] call title_it() using input for the string argument
def fast_question(title_it):
question = input("what is the title? " + title_it.title())
return question
question = fast_question("what is the title?")
print(question)
# [ ] 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(book):
book = book_entry.title()
return book
book_entry = input("Input book title here: ")
print(title_it_rtn(book_entry))
# [ ] create, call and test bookstore() function
def bookstore(book, price):
example_output = "Title: " + title_it_rtn(book) + ", costs $" + price
return example_output
price_entry = input("input Price: ")
print(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()))