Ask Question
1 September, 15:09

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.

+3
Answers (1)
  1. 1 September, 15:19
    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 you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers