Class 11 Computer Science Chapter 5 Getting Started with Python NCERT Solution


By Anjeev Kr Singh – Computer Science Educator
Published on : August 30, 2021 | Updated on : February 2, 2022

NCERT Book Exercise Solution

Class 11 Computer Science

Chapter 5 – Getting Started with Python


8. Categorise the following as syntax error, logical error or runtime error:

a) 25 / 0

Answer: Run Time Error : Division by Zero

b) num1 = 25; num2 = 0; num1/num2

Answer: Run Time Error : Division 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)


Answer: Expression : -10 <= x <= 10 and -10 <= y <= 10

(a) (0, 0)

>>> x, y = (0,0)
>>> -10 <= x <= 10 and -10 <= y <= 10
True

(b) (10, 10)

>>> x, y = (10,10)
>>> -10 <= x <= 10 and -10 <= y <= 10
True

(c) (6,6)

>>> x, y = (6,6)
>>> -10 <= x <= 10 and -10 <= y <= 10
True

(d) (7,8)

>>> x, y = (7,8)
>>> -10 <= x <= 10 and -10 <= y <= 10
True


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)

Answer: Convert Temperature form Celsius to Fahrenheit

# waterboiling = 100 in celcius
# waterfreezing = 0 in celcius 

 temp_celcius = int(input("Input Temperatur in Celcius : "))
 temp_farh = temp_celcius * 9/5 + 32
 print("Temperature in Farenheit : ", temp_farh) 

Output:

Input Temperatureu in Celcius : 100
Temperature in Farenheit : 212.0

Input Temperature in Celcius : 0
Temperature in Farenheit : 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 = 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.

Answer: – Program to calculate Simple Interest

 p = float(input("Enter Principal Amount : "))
 r = int(input("Enter rate of interest : "))
 t = int(input("Enter time : "))
 si = (p * r * t) / 100
 print("Simple Interest Rs. ", si)
 amount_payable = p + si
 print("Amount Payable Rs.", amount_payable)

Output:

Enter Principal Amount : 1000

Enter rate of interest : 10

Enter time : 2

Simple Interest Rs. 200

Amount Payable Rs. 1200

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.

Answer: Program to Calculate Total Days taken when worked together

 print("Total Number of Days Calculator ")
 x = int(input("No of days taken by A : "))
 y = int(input("No of days taken by B : "))
 z = int(input("No of days taken by C : "))
 total_days = (x * y * z )/ (x * y + y * z + x * z)
 print("Total days taken, when worked together : ", total_days)


Output

Total Number of Days Calculator
No of days taken by A : 14
No of days taken by B : 10
No of days taken by C : 8
Total days taken, when worked together : 3.3734939759036147


13 Write a program to enter two integers and perform all arithmetic operations on them.

Answer:

 n = int(input("Enter Number 1 : "))
 m = int(input("Enter Number 2 : "))
 print("Arithmetic Operations")
 print (n, '+', m,' = ', n+m)
 print (n, '-', m, ' = ', n-m)
 print (n, '', m, ' = ', nm)
 print (n, '/', m, ' = ', n/m)
 print (n, '//', m, ' = ', n//m)
 print (n, '%', m, ' = ', n%m)
 print (n, '**', m, ' = ', n**m)


Output:

Enter Number 1 : 5
Enter Number 2 : 4
Arithmetic Operations
5 + 4 = 9
5 – 4 = 1
5 * 4 = 20
5 / 4 = 1.25
5 // 4 = 1
5 % 4 = 1
5 ** 4 = 625


14. Write a program to swap two numbers using a third variable.

Answer: Swapping of two numbers without third variable.

 x = 25
 y = 30
 print("Before Swap: x = ", x, "y = ", y)
 z = x + y
 x = z - x
 y = z - y
 print("After Swap : x = ", x, "y = ", y)

Output:

Before Swap: x = 25 y = 30
After Swap : x = 30 y = 25

NCERT Exercise Solution – Next Page


About the Author

Anjeev Kr Singh

Anjeev Kr Singh

Computer Science Educator, Author, and HOD. Guiding CBSE students in CS, IP, IT, WA & AI via mycstutorial.in. Creator of Question Bank for Class 10 & 12 students.

You cannot copy content of this page

Scroll to Top