Page 373 - Computer Science Class 11 Without Functions
P. 373

num = int(input("Enter the number till you want to show the pattern: "))

                for i in range(num,0,-1):
                   for x in range(1,i+1):
                      print(x,end='')
                   print()

              (iii)  # Pattern 3
                '''
                Objective: To print a pattern
                Input: num
                Output: pattern
                '''

                num = int(input("Enter the number till you want to show the pattern: "))
                for i in range(0, num):
                    asciiValue = 65
                    for x in range(1,i+1):

                       charValue = chr(asciiValue)
                       print(charValue,end='')
                       asciiValue += 1
                    print()
            Program 5

            Write a program that takes an integer as an input and checks whether it is a perfect square or not. In number theory,
            a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself.

            Ans. '''
                 Objective:
                  To check whether a number is perfect number

                 Input: number
                 Output: result whether it is perfect number or not
                 '''

                 number = int(input("Enter a Number: "))
                 sum = 0
                 for i in range(1, number):
                  if(number % i == 0):

                    sum = sum + i
                 if (sum == number):
                  print(" Is a Perfect Number")

                 else:
                  print("Is NOT a Perfect Number")







                                                                                                      Practical  371
   368   369   370   371   372   373   374   375   376   377   378