Ask Question
20 April, 13:32

Write an if statement that assigns 20 to the variable y, and assigns 40 to the variable z if the variable x is greater than 100.

+5
Answers (1)
  1. 20 April, 14:00
    0
    The command or declaration 'if' is understood as an order in which a decision is generated in front of an alternative proposed as an alternative route to execution.

    If the condition is met, it proceeds to take the proposed route, but leaves the structure.

    # Comparing x to be more than 100 in if-condition

    if (x>100):

    #Assign 20 to y

    y = 20

    #Assign 40 to z

    z = 40

    Explaining the previous code we can verify that the condition will be applied for values less than 100, so the variables y and z will take the value of 20 and 40 respectively.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write an if statement that assigns 20 to the variable y, and assigns 40 to the variable z if the variable x is greater than 100. ...” in 📗 Engineering if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers