Page 292 - Computer Science V2.0 Class 11
P. 292
'''
Objective: To accept marks in English, Hindi, Maths, Science and Social
Science and display the grade
Input Parameters: None
Return Value: None
'''
# Approach: The main function makes use of function grade to compute grade based
on the marks entered
marksEnglish = int(input('Enter marks scored in English : '))
marksHindi = int(input('Enter marks scored in Hindi : '))
marksMaths = int(input('Enter marks scored in Maths : '))
marksSc = int(input('Enter marks scored in Science : '))
marksSSc = int(input('Enter marks scored in Social Science : '))
print('Grade:', grade(marksEnglish, marksHindi, marksMaths, marksSc, marksSSc))
main()
4. Murthy is learning about triangles in mathematics. He knows that the sum of all three internal angles of a triangle is 180.
Therefore, he wants to write a program in Python that accepts 3 angles in degrees and prints whether the given angles
form a triangle or not. Help him complete the task.
Ans. def isTriangle(angle1, angle2, angle3):
'''
Objective: To check whether the given angles form a triangle
Input Parameters: angle1, angle2, angle3 in degree
Return Value: True, if given angles form a triangle
False, otherwise
'''
return angle1+angle2+angle3 == 180
angle1 = int(input('Enter a first angle in degrees: '))
angle2 = int(input('Enter a second angle in degrees: '))
angle3 = int(input('Enter a third angle in degrees: '))
flag = isTriangle(angle1, angle2, angle3)
if flag == True:
print('Given angles form a triangle')
else:
print("Given angles don't form a triangle")
Assessment
A. Multiple Choice questions.
1. When the execution of statements in a program depends on the evaluation of a condition, flow of control is known as
____________ flow.
a. Iterative b. Conditional c. Sequential d. Looping
278 Touchpad Computer Science (Ver. 2.0)-XI

