230k views
0 votes
Write an expression that prints 'You must be rich!' if the variables young and famous are both True.

young = True
famous = False
if ''' Your solution goes here ''':
print('You must be rich!')
else:
print('There is always the lottery...')
Python 3 language

1 Answer

0 votes

Answer:

Following are the expression to this question:

if (young and famous==True):

Step-by-step explanation:

For print, the given expression the code requires some modification that can be defined as follows:

young = True#defining a bool variable that holds a value True

famous = True#defining a bool variable that holds a value True

if (young and famous==True):#defining if block that check variable value

print('You must be rich!')#print message

else:#else block

print('There is always the lottery...')#print message

Output:

You must be rich!

Code explanation:

In the above-given code, two variable "young and famous" is declared, that hold a "True" which is a bool value, in this code, a conditional statement has used, that checks variable value, which can be defined as follows:

  • In the if block, it uses the above declared variable with and gate to check its value is equal to true.
  • If the condition is true, it will print the true block message, otherwise, go to the else block in this, it will print the else block message.
User Ashunigion
by
5.0k points