Page 198 - Computer Science V2.0 Class 11
P. 198
Ans. a. num1 += num2 + num3
print (num1)
Output:9
b. num1 = num1 ** (num2 + num3)
print (num1)
Output:1024
c. num1 **= num2 + num3
Output:1024
d. num1 = '5' + '5'
print(num1)
Output:55
e. print(4.00/(2.0+2.0))
Output:1.0
f. num1 = 2+9*((3*12)-8)/10
print (num1)
Output:27.2
g. num1 = 24 // 4 // 2
print(num1)
Output:3
h. num1 = float(10)
print (num1)
Output:10.0
i. num1 = int('3.14')
print (num1)
Output: error
j. print('Bye' == 'BYE')
Output: False
k. print(10 != 9 and 20 >= 20)
Output:True
l. print(10 + 6 * 2 ** 2 != 9//4 -3 and 29>= 29/9)
Output: True
m. print(5 % 10 + 10 < 50 and 29 <= 29)
Output: True
n. print((0 < 6) or (not(10 == 6) and (10<0)))
Output: True
8. Categorise the following as syntax error, logical error or runtime error:
a. 25 / 0
b. num1 = 25; num2 = 0; num1/num2
Ans. a. 25 / 0 :- Runtime Error, divisible by zero
b. num1 = 25; num2 = 0; num1/num2 :- Runtime Error, divisible by zero
9. A dartboard of radius 10 units and the wall it is hanging on are represented using a two-dimensional coordinate system, with the board’s
center at coordinate (0,0). Variables x and y store the x-coordinate and the y-coordinate of a dart that hits the dartboard. Write a Python
expression using variables x and y that evaluates to True if the dart hits (is within) the dartboard, and then evaluate the expression for
these dart coordinates:
a. (0,0) b. (10,10) c. (6, 6) d. (7,8)
Ans. The distance formula can be used to calculate the distance between the points where the dart hits the dartboard and the centre of the
2
dartboard. The distance of a point P(x, y) from the origin is given by x 2 + y . To calculate the square root, the equation can be raised
to the power 0.5.
184 Touchpad Computer Science (Ver. 2.0)-XI

