Posts

Showing posts from October, 2024

S-1

  18.1.2.   Understanding If construct 02:40 The general syntax of if statement in  Python  is, If test expression:   statement(s) The  if-construct  is a selective construct. The statements within the if block are executed only once when the condition evaluates to True. Otherwise, the control goes to the first statement after the if-construct. In  Python , the body (block of statements) of the If statement is indicated by indentation and the first unindented line marks the end. Python  interprets  non-zero values  as  True .  None  and  0  are interpreted as  False . Here is a simple program to illustrate the simple  if-statement : if (12 % 2 == 0): print("12 is divisible by 2") # Notice the Indentation print("Execution done") Write a program to check whether the given integer is divisible by 3 or not, and print the result to the console as shown in the examples. Sample Input and Output 1...