Page 345 - Information_Practice_Fliipbook_Class11
P. 345

print("  1. Sort in ascending  order\n","2.  Sort in Descending  order\n","3.
                 Largest Number\n", "4. Smallest Number\n")

                 ch = int(input("Enter Your Choice : "))

                 if ch == 1:
                      L.sort()

                      print(L)
                 elif ch ==2:

                      L.sort(reverse = True)
                      print(L)




                 elif ch ==3:
                      print("The largest number is : ",max(L))

                 elif ch ==4:
                      print("The smallest number is : ",min(L))

                 else:
                      print("Wrong Choice")

            Program 10: Write a program to accept a decimal number and display its binary equivalent.

            Ans. '''

                 Objective: To calculate binary equivalent of decimal number

                 Input: decNum – numeric value
                 Output: Binary equivalent of decNum

                 '''


                 dNum = int(input("Enter the decimal number: "))
                 binaryEquivalent = ""

                 num = dNum

                 while dNum >= 1:
                     binaryEquivalent = str(dNum % 2) + binaryEquivalent

                     dNum //= 2


                 print("The binary equivalent of", num, "is:", binaryEquivalent)











                                                                                                      Practical  331
   340   341   342   343   344   345   346   347   348   349   350