Page 256 - CTS - CSA TP - Volume 2
P. 256

COMPUTER SOFTWARE APPLICATION - CITS




           Explanation:
           •  a = int(input(“Enter a: “)): Takes user input for the first number ‘a’ and converts it to an integer.
           •  b = int(input(“Enter b: “)): Takes user input for the second number ‘b’ and converts it to an integer.

           •  c = int(input(“Enter c: “)): Takes user input for the third number ‘c’ and converts it to an integer.
           •  The code uses a series of if statements to check which number among ‘a’, ‘b’, and ‘c’ is the largest.
           •  if a > b and a > c:: Checks if ‘a’ is greater than both ‘b’ and ‘c’.
           •  print(“From the above three numbers, given ‘a’ is the largest”): Prints a message if ‘a’ is the largest.

           •  Similar if statements and messages are present for ‘b’ and ‘c’.
           Output:









































           TASK 4: Python program to understand the elif statement
           Code:
           # Simple Python program to understand the elif statement
           # Taking an integer input for marks dynamically

           marks = int(input(“Enter the marks? “))
           # Checking various conditions using if-elif-else statements
           if marks > 85 and marks <= 100:
               # If the condition is true, we will enter this block
               print(“Congrats! You scored grade A...”)

           elif marks > 60 and marks <= 85:
               # If the condition is true, we will enter this block




                                                           241
                              CITS : IT & ITES - Computer Software Application - Exercise 125
   251   252   253   254   255   256   257   258   259   260   261