Page 225 - Computer Science V2.0 Class 11
P. 225
7. What will be the output of the following program?
def cal(x,y,z):
x+=10
y*=5
z-=2
print(x,y,z)
var1=-1
var2=20
var3=50
cal(var2,var3,var1)
Ans. 30 250 -3
8. Rewrite the program given below after removing the errors. Underline all the corrections made.
def circle(radius)
area = 2 * 3.14 * radius
print("Area of circle is : " + area)
r=float("Enter the radius of the circle : ")
circle()
Ans. def circle(radius):
area= 3.14 * radius**2
print("Area of circle is : " , area)
r=float(input("Enter the radius of the circle : "))
circle(r)
9. Predict the output of the following code, if input given is 12.
def inputData():
inches=float(input("Enter the length in inches : "))
cm=convert(inches)
print("The length in cms is : " , cm)
def convert(length):
return length * 2.54
inputData()
Ans. The length in cms is : 30.48
Solved Programming Questions
1. Write a function that takes a number as an argument and returns True if the number is even, and False otherwise.
def isEven(number):
'''
Objective: To determine whether the number is even
Input Parameters: number: numeric values
Return Value: True, if the number is even, and False
otherwise
'''
boolResult = number % 2 == 0
return boolResult
2. Write a function that takes radius as an input and computes the area of a circle.
def areaCircle(radius):
'''
Objective: To compute the area of a circle
Introduction to Functions 211

