Page 353 - Information_Practice_Fliipbook_Class11
P. 353

num2 = int(input("Enter second number : "))

                 gcd = 1

                 for i in range(1,num1+1):
                  if num1%i == 0 and num2%i == 0:

                    gcd = i
                 print("GCD of ", num1, "and", num2, "is : ", gcd)

                 lcm = num1 * num2 / gcd
                 print("LCM of ", num1, "and", num2, "is : ", lcm)

            Program 24: Write a program that takes a list as an input and prints the largest and smallest numbers from the list.

            Ans. '''

                 Objective: To find the largest and smallest number in the list

                 Input: myList
                 Output: largest and smallest number

                 '''
                 myList = []

                  num = int(input("Enter the number of elements that you want of add to the
                 list : "))
                 for x in range(num):

                     item = int(input("Enter number : "))

                     myList.append(item)
                 print("The list formed is : ", myList)

                 print("The largest number is ", max(myList))
                 print("The smallest number is ", min(myList))

            Program 25: Write a program that takes a user-provided list as input and then generates a new list comprising swapped
            values at odd indices with those at even indices.


            Ans. '''

                 Objective: To swap values at odd indices with those at even indices
                 Input: myList - list

                 Output: list with swapped values
                 '''

                 myList = []
                  num = int(input("Enter the number of elements that you want of add to the
                 list : "))

                 for x in range(num):




                                                                                                      Practical  339
   348   349   350   351   352   353   354   355   356   357   358