b) Write the conditional statements for the following decision making
situation:
[2+2=4]
() If value of X is greater than 10 then increment the value of Y by 1
otherwise decrement the value of Y by 5.
(ii)If the result of (4x®+5x®) is greater than (2x+y)/5 and the result of
12yº+2y+3y is equal to yº+3y? then print the message "WELLDONE"
otherwise print the message "TRYAGAIN".
Answers
Explanation:
The colon (:) is significant and required. It separates the header of the compound statement from the body.
The line after the colon must be indented. It is standard in Python to use four spaces for indenting.
All lines indented the same amount after the colon will be executed whenever the BOOLEAN_EXPRESSION is true.
Here is an example:
food = 'spam'
if food == 'spam':
print('Ummmm, my favorite!')
print('I feel like saying it 100 times...')
print(100 * (food + '! '))
The boolean expression after the if statement is called the condition. If it is true, then all the indented statements get executed. What happens if the condition is false, and food is not equal to 'spam'? In a simple if statement like this, nothing happens, and the program continues on to the next statement.
Run this example code and see what happens. Then change the value of food to something other than 'spam' and run it again, confirming that you don’t get any output