Page 504 - Computer Science V2.0 Class 11
P. 504
num = int(input("Enter the number till you want to show the pattern: "))
displayPattern(num)
(ii) #Pattern 2
def displayPattern(num):
'''
Objective : To print a pattern
Input Parameter : num – numeric value
Return Value : None
'''
for i in range(num,0,-1):
for x in range(1,i+1):
print(x,end='')
print()
numLines = int(input("Enter the number till you want to show the pattern: "))
displayPattern(numLines)
(iii) # Pattern3
def displayPattern(num):
'''
Objective : To print a pattern
Input Parameter : num – numeric value
Return Value : None
'''
for i in range(0, num):
asciiValue = 65
for x in range(1,i+1):
charValue = chr(asciiValue)
print(charValue,end='')
asciiValue += 1
print()
num = int(input("Enter the number till you want to show the pattern: "))
displayPattern(num)
Program 5: Write a function perfectNumber(number) that takes an integer argument number as an input and
checks whether the number 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. Invoke the function to print an appropriate
message for the user-entered number.
Ans. def perfectNumber(number):
'''
Objective : To check whether a number is perfect number
Input Parameter : number - numeric value
490 Touchpad Computer Science (Ver. 2.0)-XI

