Page 508 - Computer Science V2.0 Class 11
P. 508
'''
gcd = 1
for i in range(1,num1+1):
if num1 % i == 0 and num2 % i == 0:
gcd = i
return gcd
def LCM(num1,num2,gcd):
'''
Objective : To calculate the LCM of 2 numbers
Input Parameter : num1,num2,gcd - numeric value
Return Value : gcd - numeric value
'''
lcm = num1 * num2 / gcd
return lcm
num1 = int(input("Enter first number : "))
num2 = int(input("Enter second number : "))
gcd = GCD(num1,num2)
print("GCD of ", num1, "and", num2, "is : ", gcd)
lcm = LCM(num1,num2,gcd)
print("LCM of ", num1, "and", num2, "is : ", lcm)
Program 11: Write a program that accepts a string as input from the user and prints the count of vowels, consonants,
uppercase, and lowercase characters.
Ans. def countChar(dataString):
'''
Objective : To display the count of vowels, consonants, upper case, and lower
case characters
Input Parameters : dataString - string
Return Value : Tuple with count of vowels, consonants, upper case, and lower
case characters
'''
cntV = 0
cntC = 0
cntU = 0
cntL = 0
for ch in dataString:
if ch.isalpha():
if ch in "aeiouAEIOU" :
cntV += 1
else:
494 Touchpad Computer Science (Ver. 2.0)-XI

