Function Name: compliments Parameters: answer1 - a boolean (True or False) representing whether the user is "smart" answer2 - a boolean (True or False) representing whether the user is "awesome" answer3 - a boolean (True or False) representing whether the user is "fun" Description: Write a function that outputs a string of compliments based on the adjectives selected by the inputs. Use the inputs True and False. The function should return the string “You are” concatenated with the compliments that are true. The three compliments should be: "smart" "awesome" and "fun". If none of the compliments are true, print the string “Goodbye.” instead. Test Cases: >>>compliments(True, True, True) You are smart awesome fun. >>>compliments(False, True, False) You are awesome. >>>compliments(False, False, False) Goodbye.

Question
Asked Mar 8, 2019
74 views

Function Name: compliments Parameters: answer1 - a boolean (True or False) representing whether the user is "smart" answer2 - a boolean (True or False) representing whether the user is "awesome" answer3 - a boolean (True or False) representing whether the user is "fun" Description: Write a function that outputs a string of compliments based on the adjectives selected by the inputs. Use the inputs True and False. The function should return the string “You are” concatenated with the compliments that are true. The three compliments should be: "smart" "awesome" and "fun". If none of the compliments are true, print the string “Goodbye.” instead. Test Cases: >>>compliments(True, True, True) You are smart awesome fun. >>>compliments(False, True, False) You are awesome. >>>compliments(False, False, False) Goodbye.

check_circle

Expert Answer

Step 1

Solution:

The following function displays the outputs as string of compliments.

Step 2

compliments() function:

#Define the function

def compliments(answer1, answer2, answer3):

    str = "You are"

    #Check if "num1" is greater than "num2" and "num3"

    if(answer1 == True) and  (answer2 == False) and (answer3 == False):

        #Display the "num1" value

        print(str + " smart")

    #Otherwise, check if "num2" is greater than "num1" and "num3"

    if(answer1 == False) and  (answer2 == True) and (answer3 == False):

        #Display the "num1" value

        print(str +" awesome")

    #Otherwise, check if "num2" is greater than "num1" and "num3"

    if(answer1 == False) and&...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: This program uses hours, pay rate, state tax and fed tax to determine grossand net pay. The code is ...

A: Program Descriptions:The given program does not have any errors.It takes input from a file named pay...

question_answer

Q: Part 1: Stack As mentioned in class, Python 3 provides the LifoQueue class as part of the Queue libr...

A: Import the given class in another file.Create the function postfix() which takes a string as its arg...

question_answer

Q: Prove that the following languages are not regular: (b) L = {anblak : k ≠ n + l}. (c) L = {anblak : ...

A: In the given question, multiple parts are there and we will solve only first three parts as no parti...

question_answer

Q: Read in 5 numbers from the keyboard and, if any of the entered numbers is < 0, then print out “Ne...

A: Pseudo code is given below to read five numbers from the keyboard and print “Negative” if the number...

question_answer

Q: Financial Application:• Write a program that computes future investment value at a given interest ra...

A: Program plan:Import necessary packages.Define a class named “Investment”.Define a method named “comp...

question_answer

Q: How to write a function in python where it takes a list of string s. Where s= ["hello","lazyness","p...

A: The program has the following algorithm:Intitialize the counter counting string list position number...

question_answer

Q: Transform the grammar with productions S → baAB, A → bAB|λ, B → BAa |A| λ into Chomsky normal form.

A: A context free grammar is in Chomsky normal form if its productions are in the formA → a or A → BC o...

question_answer

Q: getRandomLib.h: // This library provides a few helpful functions to return random values// * getRand...

A: Program Instructions:Include the necessary header files.Print hello message and as for a response.De...

question_answer

Q: Hi, please do you help with questions of Python? If so, I need help with the following: Write a prog...

A: Program Instructions:Use range() to print from 1 to 25.Use end in print() function to print the valu...