Page 14 - IPP-11
P. 14

(b)  Predict the output of the following code fragment–                                    (2)

                     x = 1
                     if x>3:
                       if x>4:
                         print("A", end=' ')
                       else:
                         print("B", end=' ')
                     elif x<2:
                       if (x!=0):
                         print("C", end=' ')
                     print("D")
                Ans.  Output:
                     C D
                 (c)  A year is a leap year if it is divisible by 4, except that years divisible by 100 are not leap years unless they
                    are also divisible by 400. Write a program that asks the user for a year and print out whether it is a leap
                    year or not.                                                                            (3)
                Ans.  year=int(input("Enter year to be checked:"))
                     if(year%4==0 and year%100!=0 or year%400==0):
                         print("The year is a leap year!")
                     else:
                         print("The year isn't a leap year!")
                 (d)  ABC shop deals in footwear and apparel. Write a program to calculate the total selling price after levying
                    GST. Do calculate Central Govt. GST and State Govt. GST. GST rates are applicable as under:   (3)

                                  Item                 GST Rate
                     Footwear <= 500 (per pair)      5%
                     Footwear > 500 (per pair)       18%
                     Apparel <= 1000 (per piece)     5%
                     Apparel > 1000 (per piece)      12%
                Ans.  itc=input("Enter item code (A)Apparel (F)Footwear-")
                     sp=float(input("Enter selling price-"))
                     if itc=='A':
                        if sp<=1000:
                          gstRate=5
                        else:
                          gstRate=12
                     elif itc=='F':
                         if sp<=500:
                          gstRate=5
                        else:
                          gstRate=18

                     cgst=sp*(gstRate/2)/100
                     sgst=cgst
                     amount=sp+cgst+sgst
                     print("Total selling price-",amount)





                                                               4
   9   10   11   12   13   14   15   16   17   18   19