Computer Science, asked by puspendrakhari, 4 months ago

Question 5.
Which of these if-statements will not work?
Answer:
ifi > 7: print('Hello')
if i > 7: if i 7: print('Hello') else: print('Hi')
O print('Hello') ifi > 7 else print('Hi')
None of the above​

Attachments:

Answers

Answered by vanshpandey928
1

Answer:

the answer is 2nd option and 3rd option

Explanation:

I hope this gonna help You :)

Answered by Equestriadash
4

Given statements:

#1. if i > 7:

     print('Hello')

#2. if i > 7:

      if i 7:

         print('Hello')

   else:

      print('Hi')

#3. print('Hello') if i > 7 else print('Hi')

The incorrect statements would be #2 and #3.

Reasons:

In statement #2, under the second if statement, there is no exact relation between i and 7 that needs to be tested. That implies that there must be some relational operator between i and 7 or something similar where the if statement can return a Boolean value. Since that isn't there, it would render an error.

In statement #3, the syntax of the whole line is messed up. print('Hello') must come after the if statement, and there must be a colon after if and else. Since none of that is right, it will render an error.

Similar questions