Page 199 - Computer Science V2.0 Class 11
P. 199
x = int(input('Enter x-coordinate: ')) # user input
y = int(input('Enter y-coordinate: ')) # user input
distance = ((x ** 2 + y ** 2)) ** 0.5 # distance from (0, 0) point
if(distance <= 10):
print('Within Board')
else:
print(Outside Board')
(a) (0,0) : Within Board
(b) (10,10) : Outside Board
(c) (6,6) : Within Board
(d) (7,8) : Outside Board
10. Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water boils at 100 degree C and freezes as 0
degree C, use the program to find out what is the boiling point and freezing point of water on the Fahrenheit scale.
(Hint: T(°F) = T(°C) × 9/5 + 32)
Ans. Program:
#defining the boiling and freezing temp in celcius
boilingTempCelcius = 100
freezingTempCelcius = 0
print('Water Boiling temperature in Fahrenheit::')
#Calculating Boiling temperature in Fahrenheit
boilingTempFahrenheit = boilingTempCelcius * (9/5) + 32
#Printing the temperature
print(boilingTempFahrenheit)
print('Water Freezing temperature in Fahrenheit::')
#Calculating Boiling temperature in Fahrenheit
freezingTempFahrenheit = freezingTempCelcius * (9/5) + 32
#Printing the temperature
print(freezingTempFahrenheit)
OUTPUT:
Water Boiling temperature in Fahrenheit::
212.0
Water Freezing temperature in Fahrenheit::
32.0
11. Write a Python program to calculate the amount payable if money has been lent on simple interest. Principal or money lent = P, Rate of
interest = R% per annum and Time = T years. Then Simple Interest (SI) = (P x R x T)/ 100. Amount payable = Principal + SI. P, R and T are
given as input to the program.
Ans. principal = float(input('Enter Principal Amount: '))
rate = float(input('Enter Rate of Interest '))
time = float(input('Enter Time (in Years)'))
simpleInterest = (principal * rate * time) / 100
amountPayable = principal + simpleInterest
print('Total Payable amount', amountPayable)
12. Write a program to calculate in how many days a work will be completed by three persons A, B and C together. A, B, C take x days, y days
and z days respectively to do the job alone. The formula to calculate the number of days if they work together is xyz/(xy + yz + xz) days
where x, y, and z are given as input to the program.
Ans. x = int(input('Enter the number of days required by A alone: '))
y = int(input('Enter the number of days required by B alone: '))
Data Types and Operators 185

