Respuesta :
Answer:
jellybeans = 10
licorice = 35
delicious = (jellybeans > 20) or (licorice > 30) or ((jellybeans + licorice) > 40)
print(delicious)
Explanation:
*The code is in Python.
Set the jellybeans and licorice to any values you like
In order to have the value of True or False without using the if statement, we need to set delicious as boolean variable. As you may know, boolean variables are the variables that have a value of either True or False
Check if jellybeans is greater than 20 or not → (jellybeans > 20)
Check if licorice is greater than 30 or not → (licorice > 30)
Check if their sum is greater than 40 or not → ((jellybeans + licorice) > 40)
All of the above expressions are boolean expressions. They return True if the statement is correct. Otherwise, they return False
Also, note that we combined all the expressions with or
For these values → jellybeans = 10, licorice = 35:
The first statement returns False
The second statement returns True
The third statement returns True
delicious = False or True or True → True
Note that if the expressions are combined with or, the result will be True if one of the expression is True.
The code that sets the value of a variable named delicious to True if jellybeans is greater than 20, or licorice is greater than 30, or their sum is greater than 40 is as follows:
jellybeans = 30
licorice = 35
delicious = (jellybeans > 20) or (licorice > 30) or (jellybeans + licorice > 40)
print(delicious)
Code explanation
- The first line of code, we declared a variable called jellybeans and initialise it to 30.
- The second line of code, we declared a variable called licorice and initialise it to 35.
- Then the variable "delicious" is used to store the condition if jelly fish is greater than 20 or if licorice is greater than 30 or the sum of licorice and jellyfish is greater than 40
- If any of the condition is true, the print statement will print out True else it will print False.
learn more variable here : https://brainly.com/question/19661456?referrer=searchResults
