Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
410 views

NCERT Solutions For Class 11 Science Computer Science Chapter 5 - Getting Started With Python

The document provides NCERT solutions for Class 11 Computer Science chapter 5 - Getting Started With Python. It includes solutions to 6 multiple choice and short answer questions from the chapter with explanations. The questions are about Python identifiers, assignment statements, logical expressions, order of operations, variable assignment, and data types.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
410 views

NCERT Solutions For Class 11 Science Computer Science Chapter 5 - Getting Started With Python

The document provides NCERT solutions for Class 11 Computer Science chapter 5 - Getting Started With Python. It includes solutions to 6 multiple choice and short answer questions from the chapter with explanations. The questions are about Python identifiers, assignment statements, logical expressions, order of operations, variable assignment, and data types.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

NCERT SOLUTIONS

BOARD PAPER SOLUTIONS

 SIGN IN
CREATE ACCOUNT

TEXTBOOK SOLUTIONS

LIVE CLASSES

NCERT Solutions for Class 11 Science Computer science


Chapter 5 - Getting Started With Python
DOWNLOAD PDF Share with your friends  Share

NCERT Solutions 
Class 11 
Computer Science 
Getting Started With Python

NCERT Solutions for Class 11 Science Computer science Chapter 5 Getting Started With Python are provided here with
simple step-by-step explanations. These solutions for Getting Started With Python are extremely popular among Class 11
Science students for Computer science Getting Started With Python Solutions come handy for quickly completing your
homework and preparing for exams. All questions and answers from the NCERT Book of Class 11 Science Computer
science Chapter 5 are provided here for you for free. You will also love the ad-free experience on Meritnation’s NCERT
Solutions. All NCERT Solutions for class Class 11 Science Computer science are prepared by experts and are 100% 
Share
accurate.

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 1/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Page No 115:

Question 1:

Which of the following identifier names are invalid and why?

i Serial_no. v Total_Marks
ii 1st_Room vi total-Marks
iii Hundred$ vii _Percentage
iv Total Marks viii True

ANSWER:

i) Serial_no.: Invalid - Identifier in python cannot contain any special character except underscore(_).

ii) 1st_Room: Invalid - Identifier in Python cannot start with a number.

iii) Hundred$:  Invalid - Identifier in Python cannot contain any special character except underscore(_).

iv) Total Marks: Invalid - Identifier in Python cannot contain any special character except underscore(_). If more than one word is
used as a variable then it can be separated using underscore ( _ ), instead of space.

v) Total_Marks: Valid

vi) total-Marks: Invalid - Identifier in Python cannot contain any special character except underscore(_). If more than one word is
used as a variable then it can be separated using underscore ( _ ), instead of a hyphen ( - ).

vii) _Percentage: Valid



Share

viii) True: Invalid - Identifier in Python should not be a reserved keyword.

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 2/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Page No 115:

Question 2:

Write the corresponding Python assignment statements:

a) Assign 10 to variable length and 20 to variable breadth.

b) Assign the average of values of variables length and breadth to a variable sum

c) Assign a list containing strings ‘Paper’, ‘Gel Pen’, and ‘Eraser’ to a variable stationery.

d) Assign the strings ‘Mohandas’, ‘Karamchand’, and ‘Gandhi’ to variables first, middle and last.

e) Assign the concatenated value of string variables first, middle and last to variable fullname. Make sure to incorporate blank
spaces appropriately between different parts of names.

ANSWER:

a) length, breadth = 10,20

b) sum = (length + breadth)/2

c) stationary =['Paper','Gel Pen','Eraser']

d) first,middle,last = "Mohandas","Karamchand","Gandhi"

e) fullname = first +" "+ middle +" "+ last

Page No 115: 
Share

Question 3:

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 3/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Write logical expressions corresponding to the following statements in Python and evaluate the expressions (assuming variables
num1, num2, num3, first, middle, last are already having meaningful values):

a) The sum of 20 and –10 is less than 12.

b) num3 is not more than 24

c) 6.75 is between the values of integers num1 and num2.

d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string ‘last’

e) List Stationery is empty

ANSWER:

a) (20 + (-10)) < 12

b) num3 <= 24   or not(num3 > 24)

c) (6.75 >= num1) and (6.75 <= num2)

d) (middle > first) and (middle < last)

e) len(Stationery) == 0

Page No 116:

Share
Question 4:

Add a pair of parentheses to each expression so that it evaluates to True.

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 4/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

a) 0 == 1 == 2

b) 2 + 3 == 4 + 5 == 7

c) 1 < -1 == 3 > 4

ANSWER:

a) ( 0 == (1==2))

b) (2 + (3 == 4) + 5) == 7

c) (1 < -1) == (3 > 4 )

Page No 116:

Question 5:

Write the output of the following.

a) num1 = 4

  num2 = num1 + 1

  num1 = 2
  print (num1, num2)

b) num1, num2 = 2, 6

  num1, num2 = num2, num1 + 2


  print (num1, num2)
Share

c) num1, num2 = 2, 3

  num3, num2 = num1, num3 + 1

  print (num1, num2, num3)


https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 5/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

ANSWER:

a) 2, 5

b) 6, 4

c) Error as num3 is used in RHS of line 2 (num3, num2 = num1, num3 + 1) before defining it earlier.

Page No 116:

Question 6:

Which data type will be used to represent the following data values and why?

a) Number of months in a year

b) Resident of Delhi or not

c) Mobile number

d) Pocket money

e) Volume of a sphere

f) Perimeter of a square

g) Name of the student

h) Address of the student



Share

ANSWER:

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 6/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

a) The int data type will be used to represent 'Number of months in a year' as it will be an integer i.e. 12.

b) The boolean data type will be used to represent 'Resident of Delhi or not' as a person will be either a resident of Delhi or not a
resident of Delhi. Therefore, the values True or False will be sufficient to represent the values.

c) The integer data type will be used to represent 'Mobile number' as it will be a ten-digit integer only.

d) The float data type will be used to represent 'Pocket money' as it can be in decimal. e.g Rs. 250.50 i.e 250 rupees and 50
paise.

e) The float data type will be used to represent 'Volume of a sphere'.

The formula for the volume of a sphere:

Volume of sphere, V=43πr3

Even if 'r' is a whole number, the value of volume can be a fraction which can be represented in a decimal form easily by float
data type.

f) The float data type will be used to represent 'Perimeter of a square'.

The perimeter of a square:

Perimeter = 4 × side length

If the side length is a decimal number, the result may come out to be a decimal number which can be easily represented by float
data type.

Note:- If the side length is a whole number, the perimeter will always be an integer, however, we should be open to the possibility
that the side length can be in decimal as well.

g) The string data type will be used to represent 'Name of the student'.

h)The string data type will be used to represent 'Address of the student'. However, if we have to store the address in a more
structured format, we can use dictionary data type as well. e.g. Address = { 'Line1': ‘Address line 1',
'Line2':'Address Line2', 'Locality':'Locality Name', 'City':'City Name', 'Pincode':110001,
'Country':'India'}

Share

Page No 116:

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 7/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Question 7:

Give the output of the following when num1 = 4, num2 = 3, num3 = 2

a) num1 += num2 + num3

   print (num1)

b) num1 = num1 ** (num2 + num3)

  print (num1)

c) num1 **= num2 + num3

d) num1 = '5' + '5'

  print(num1)

e) print(4.00/(2.0+2.0))

f) num1 = 2+9*((3*12)-8)/10

  print(num1)

g) num1 = 24 // 4 // 2

  print(num1)

h) num1 = float(10)

    print (num1)

i) num1 = int('3.14')

  print (num1)

j) print('Bye' == 'BYE')


Share
k) print(10 != 9 and 20 >= 20)

l) print(10 + 6 * 2 ** 2 != 9//4 -3 and 29>= 29/9)

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 8/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

m) print(5 % 10 + 10 < 50 and 29 <= 29)

n) print((0 < 6) or (not (10 == 6) and (10<0)))

ANSWER:

a) num1 += 3 + 2

The above statement can be written as

num1 = num1 + 3 + 2 = 4 + 3 + 2 = 9

Therefore, print(num1) will give the output 9.

b) num1 = num1 ** (num2 + num3)

The above statement will be executed as per the following steps.

num1 = 4 ** (3 + 5) = 4 ** 5 = 1024

Therefore, print(num1) will give the output 1024.

c) num1 **= num2 + num3

The above statement can be written as

num1 **= 5
num1 = num1 ** 5

num1 = 4 ** 5

num1 = 1024

Therefore, the output will be 1024.

d) num1 = '5' + '5'

The RHS in the above statement is '5' + '5'. Please note that 5 is enclosed in quotes and hence will be treated as a string.
Therefore, the first line is just a string concatenation which will give the output 55. The type of output will be a string, not an
integer.

e) print(4.00/(2.0 + 2.0))

Share
The numbers written in the statement are in float data type therefore, the output will be also in float data type.

print(4.00/(2.0 + 2.0))

print(4.0/4.0)

1.0
https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 9/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Therefore, the output will be 1.0.

f) num1 = 2 + 9 * ((3 * 12) - 8) /10

 # The expression within inner brackets will be evaluated first

num1 = 2 + 9 * (36 - 8) /10 

# The expression within outer brackets will be evaluated next         

num1 = 2 + 9 * 28/10

# * and / are of same precedence, hence, left to right order is followed

num1 = 2 + 252/10           

num1 = 2 + 25.2           

num1 = 27.2

Therefore, the output will be 27.2.

g) num1 = 24 // 4 // 2

#When the operators are same, left to right order will be followed for operation

num1 = 6 // 2  

#When floor division is used, return value will be int data type     

num1 = 3       

Therefore, the output will be 3

h) num1 = float(10)

float(10) will convert integer value to float value and therefore, the output will be 10.0.

i) num1 = int('3.14')

This will result in an error as we cannot pass string representation of float to an int function.

j) print('Bye' == 'BYE')

As Python compares string character to character and when different characters are found then their Unicode value is compared.
The character with lower Unicode value is considered to be smaller. Here, 'y' has Unicode 121 and 'Y' has 89. Therefore, the 
Share
output will be 'False'.

k) print(10 != 9 and 20 >= 20)

print(True and True)

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 10/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

print(True)

Therefore, the output will be 'True'.

l) print(10 + 6 * 2 ** 2 != 9//4 -3 and 29>= 29/9)

Taking the above statement in two separate parts

LHS:

10 + 6 * 2 ** 2 != 9//4 - 3

10 + 6 * 4 != 2 - 3

10 + 24 != -1

34 != -1
True

RHS:

29 >= 29/9
True

Now the complete equation can be written as

print(True and True)

Therefore, the output will be 'True'.

m) print(5 % 10 + 10 < 50 and 29 <= 29)

Taking the above statement in two separate parts

LHS :

5 % 10 + 10 < 50

5 + 10 < 50

15 < 50
True


RHS:
Share
29 <= 29
True

Now, the complete equation can be written as

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 11/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

print(True and True)

Therefore, the output will be 'True'.

n) print( (0 < 6) or (not (10 == 6) and (10<0) ) )

print(True or (not False and False))

print(True or (True and False))

# not will be evaluated before and/or.

print(True or False)

print(True)

Therefore, the output will be 'True'.

Page No 117:

Question 8:

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

a) 25 / 0

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

ANSWER:

a) Runtime Error. The syntax for the division is correct. The error will arise only when 'interpreter' will run this line.

b) Runtime Error. The syntax is correct. The error will arise only when 'interpreter' will run the line containing these statements.  
Share

Page No 117:

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 12/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Question 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 centre 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:

The distance formula can be used to calculate the distance between the points where the dart hits the dartboard and the centre
of the dartboard. 

The distance of a point P(x, y) from the origin is given by x2+y2.

To calculate the square root, the equation can be raised to the power 0.5. 

Program:

x = int(input('Enter X Coordinate: '))

y = int(input('Enter Y Coordinate: '))

dis = (x ** 2 + y ** 2) ** 0.5

#if dis is greater than 10, means that dart is more than 10 units away from the centre.

print(dis <= 10)

The output for the dart coordinates are as follows:

a) (0,0): True

b) (10,10): False

c) (6,6): True
Share
d) (7,8): False

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 13/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Page No 117:

Question 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:

Program:

#defining the boiling and freezing temp in celcius

boil = 100
freeze = 0
print('Water Boiling temperature in Fahrenheit::')

#Calculating Boiling temperature in Fahrenheit

tb = boil * (9/5) + 32

#Printing the temperature

print(tb)

print('Water Freezing temperature in Fahrenheit::')

#Calculating Boiling temperature in Fahrenheit

tf = freeze * (9/5) + 32

#Printing the temperature

print(tf)

OUTPUT:

Water Boiling temperature  in Fahrenheit::

212.0
Water Freezing temperature in Fahrenheit::

Share
32.0

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 14/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Page No 117:

Question 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.

ANSWER:

Program:

#Asking the user for Principal, rate of interest and time

P = float(input('Enter the principal: '))

R = float(input('Enter the rate of interest per annum: '))

T = float(input('Enter the time in years: '))

#calculating simple interest

SI = (P * R * T)/100

#caculating amount = Simple Interest + Principal

amount = SI + P

#Printing the total amount

print('Total amount:',amount)

OUTPUT:-

Enter the principal: 12500

Enter the rate of interest per annum: 4.5

Enter the time in years: 4

Total amount: 14750.0


Share

Page No 118:
https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 15/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Question 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:

#Asking for the number of days taken by A, B, C to complete the work alone

x = int(input('Enter the number of days required by A to complete work alone: '))

y = int(input('Enter the number of days required by B to complete work alone: '))

z = int(input('Enter the number of days required by C to complete work alone: '))

#calculating the time if all three person work together

#formula used as per the question

combined = (x * y * z)/(x*y + y*z + x*z)

#rounding the answer to 2 decimal places for easy readability

days = round(combined,2)

#printing the total time taken by all three persons

print('Total time taken to complete work if A, B and C work together: ', days)

OUTPUT:-

Enter the number of days required by A to complete work alone: 8

Enter the number of days required by B to complete work alone: 10

Enter the number of days required by C to complete work alone: 20

Total time taken to complete work if A, B and C work together: 3.64


Share

Page No 118:

Question 13:
https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 16/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

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

ANSWER:

Program:

#Program to input two numbers and performing all arithmetic operations

#Input first number

num1 = int(input("Enter first number: "))

#Input Second number

num2 = int(input("Enter second number: "))

#Printing the result for all arithmetic operations

print("Results:-")

print("Addition: ",num1+num2)

print("Subtraction: ",num1-num2)

print("Multiplication: ",num1*num2)

print("Division: ",num1/num2)

print("Modulus: ", num1%num2)

print("Floor Division: ",num1//num2)

print("Exponentiation: ",num1 ** num2)

OUTPUT:

Enter first number: 8

Enter second number: 3

Results:-
Addition:  11

Subtraction:  5

Multiplication:  24

Division:  2.6666666666666665
Share
Modulus:  2

Floor Division:  2

Exponentiation:  512

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 17/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Page No 118:

Question 14:

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

ANSWER:

Program:

#defining two variables

x = 5
y = 6

#printing the values before swapping

print("The values of x and y are",x,"and",y,"respectively.")

# k is the third variable used to swap values between x and y

k = x                        

x = y
y = k

#printing the values after swapping

print("The values of x and y after swapping are",x,"and",y,"respectively.")

OUTPUT:

The values of x and y are 5 and 6 respectively.
Share
The values of x and y after swapping are 6 and 5 respectively.

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 18/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Page No 118:

Question 15:

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

ANSWER:

Program:

#defining two variables

x = 5
y = 6

#printing the values before swapping

print("The values of x and y are",x,"and",y,"respectively.")

# Using 'multiple assignment' to swap the values

x,y = y,x

#printing the values after swapping

print("The values of x and y after swapping are",x,"and",y,"respectively.")

OUTPUT:

The values of x and y are 5 and 6 respectively.

The values of x and y after swapping are 6 and 5 respectively.


Page No 118: Share

Question 16:

Write a program to repeat the string ''GOOD MORNING'' n times. Here 'n' is an integer entered by the user.
https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 19/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

ANSWER:

The string will be repeated only if the value is greater than zero, otherwise, it will return a blank. Therefore, ‘if’ condition will be
used to check the values of 'n' first and then the print statement will be executed.

Program:

str = "GOOD MORNING "

n = int(input("Enter the value of n: "))

if n>0:
    print(str * n)
else:
    print("Invalid value for n, enter only positive values")

OUTPUT:

Enter the value of n: 5

GOOD MORNING GOOD MORNING GOOD MORNING GOOD MORNING GOOD MORNING

Page No 118:

Question 17:

Write a program to find average of three numbers.

ANSWER:

Program:

#defining three variables
Share
a = 5
b = 6
c = 7

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 20/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

#calculating average using the formula, average = (sum of variables)/(number of variables)

average = (a + b + c)/3

#print the result

print("The average of",a,b,"and",c,"is",average)

OUTPUT:

The average of 5 6 and 7 is 6.0

Page No 118:

Question 18:

The volume of a sphere with radius r is 4/3πr3. Write a Python program to find the volume of spheres with radius 7 cm, 12 cm, 16
cm, respectively.

ANSWER:

Program:

#defining three different radius using variables r1, r2, r3

r1 = 7
r2 = 12
r3 = 16
#calculating the volume using the formula

volume1 = (4/3*22/7*r1**3)

volume2 = (4/3*22/7*r2**3)

volume3 = (4/3*22/7*r3**3)

Share

#printing the volume after using the round function to two decimal place for better readability

print("When the radius is",r1,"cm, the volume of the sphere will be", round(volume1,2),"cc")

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 21/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

print("When the radius is",r2,"cm, the volume of the sphere will be", round(volume2,2),"cc")

print("When the radius is",r3,"cm, the volume of the sphere will be", round(volume3,2),"cc")

OUTPUT:

When the radius is 7 cm, the volume of the sphere will be 1437.33 cc

When the radius is 12 cm, the volume of the sphere will be 7241.14 cc

When the radius is 16 cm, the volume of the sphere will be 17164.19 cc

Page No 118:

Question 19:

Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the user the
year in which they will turn 100 years old.

ANSWER:

Program:

#Program to tell the user when they will turn 100 Years old

name = input("Enter your name: ")

# age converted to integer for further calculation

age = int(input("Enter your age: "))

#calculating the 100th year for the user considering 2020 as the current year

hundred = 2020 + (100 - age)


#printing the 100th year
Share
print("Hi",name,"! You will turn 100 years old in the year",hundred)

OUTPUT:

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 22/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Enter your name: John

Enter your age: 15

Hi John ! You will turn 100 years old in the year 2105

Page No 118:

Question 20:

The formula E = mc2 states that the equivalent energy (E) can be calculated as the mass (m) multiplied by the speed of light (c =
about 3×108 m/s) squared. Write a program that accepts the mass of an object and determines its energy.

ANSWER:

The formula is given as:

E = mc2

where, E ⇒ energy measured in Joule,

m ⇒ mass in Kilogram,

c ⇒ speed of light in m/s.

Program:

#Program to calculate the equivalent energy of an object

#asking for the mass in grams

mass = float(input("Enter the mass of object(in grams): "))

#Speed of light is known and given in the question

c = 3 * 10 ** 8

#calculating the energy, mass is divided by 1000 to convert it into kilogram

Energy = (mass/1000) * c ** 2

Share

#printing the output

print("The energy of an object with mass",mass," grams is",Energy,"Joule.")

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 23/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

OUTPUT:

Enter the mass of object(in grams): 25

The energy of an object with mass 25.0  grams is 2250000000000000.0 Joule.

Page No 118:

Question 21:

Presume that a ladder is put upright against a wall. Let variables length and angle store the length of the ladder and the angle
that it forms with the ground as it leans against the wall. Write a Python program to compute the height reached by the ladder on
the wall for the following values of length and angle:

a) 16 feet and 75 degrees

b) 20 feet and 0 degrees

c) 24 feet and 45 degrees

d) 24 feet and 80 degrees

ANSWER:

The diagram can be drawn as follows:


Share

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 24/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

Here:

sin(θ) = height / length

⇒ height = length × sin(θ)

To calculate the sin() value in Python, math module sin() function is needed. The values need to be passed in radians to the sin()
function. Therefore, the degree will be converted to radians and then the sin() function will be applied.

Program:

#import the math module, to use sin & radians function

import math
length = int(input("Enter the length of the ladder: "))

degrees = int(input("Enter the alignment degree: "))

#Converting degrees to radian

radian = math.radians(degrees)

#Computing sin value

sin = math.sin(radian)

# Calculating height and rounding it off to 2 decimal places

height = round(length * sin,2)

#displaying the output

print("The height reached by ladder with length",length,"feet and aligned at",degrees,"degrees


is",height, "feet.")

OUTPUT:

a) Enter the length of the ladder: 16

Enter the alignment degree: 75

The height reached by the ladder with length 16 feet aligned at 75  degrees is 15.45 feet.

b) Enter the length of the ladder: 20

Enter the alignment degree: 0


The height reached by the ladder with length 20 feet and aligned at 0 degrees is 0.0 feet.
Share

c) Enter the length of the ladder: 24

Enter the alignment degree: 45

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 25/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python

The height reached by the ladder with length 24 feet and aligned at 45 degrees is 16.97 feet.

d) Enter the length of the ladder: 24

Enter the alignment degree: 80

The height reached by the ladder with length 24 feet and aligned at 80 degrees is 23.64 feet.

View NCERT Solutions for all chapters of Class


11

LOGIN
or
CREATE A FREE ACCOUNT


Share
NCERT SOLUTIONS RD SHARMA LAKHMIR SINGH CBSE BOARD PAPER
NCERT Solutions for Class
SOLUTIONS SOLUTIONS SOLUTIONS
12 Science RD Sharma Solutions for Lakhmir Physics Solutions CBSE Class 10 Results
Class 12 Science for Class 10
https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 26/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python
NCERT Solutions for Class Class 12 Science for Class 10 CBSE Class 10 Board
12 Commerce RD Sharma Solutions for Lakhmir Physics Solutions Exam Resources
NCERT Solutions for Class Class 11 Science for Class 9 CBSE Class 10 Board
12-Humanities RD Sharma Solutions for Lakhmir Chemistry Paper Solutions for Math
NCERT Solutions for Class Class 10 Solutions for Class 10 CBSE Class 10 Board
11 Science RD Sharma Solutions for Lakhmir Chemistry Paper Solutions for
NCERT Solutions for Class Class 9 Solutions for Class 9 Science
11 Commerce RD Sharma Solutions for Lakhmir Biology Solutions CBSE Class 10 Board
NCERT Solutions for Class Class 8 for Class 10 Paper Solutions for Social
11-Humanities RD Sharma Solutions for Science

NCERT Solutions for Class Class 7 CBSE Class 10 Board


HC VERMA SOLUTIONS
10 RD Sharma Solutions for Paper Solutions for English
Class 6 HC Verma Solutions for CBSE Class 10 Board
NCERT Solutions for Class
Class 12 Science Paper Solutions for Hindi
9
HC Verma Solutions for CBSE Class 12 Science
NCERT Solutions for Class
RS AGGARWAL Class 11 Science
8 Board Paper Solutions for
SOLUTIONS Math
NCERT Solutions for Class
7 RS Aggarwal Solutions for CBSE Class 12 Science
HOMEWORK
Class 10 Board Paper Solutions for
NCERT Solutions for Class QUESTIONS
RS Aggarwal Solutions for Physics
6
Class 9 Homework Questions for CBSE Class 12 Science
NCERT Solutions for Class Class 6
RS Aggarwal Solutions for Board Paper Solutions for
5
Class 8 Homework Questions for Chemistry
NCERT Solutions for Class Class 7
RS Aggarwal Solutions for CBSE Class 12 Science
4
Class 7 Homework Questions for Board Paper Solutions for
NCERT Solutions for Class Class 8 Biology
3 RS Aggarwal Solutions for
Homework Questions for

Class 6 CBSE Class 12 Commerce Share
NCERT Solutions for Class Class 9 Board Paper Solutions for
2 Economics
Homework Questions for
NCERT Solutions for Class TS GREWAL Class 10 CBSE Class 12 Commerce
1 SOLUTIONS Board Paper Solutions for
Homework Questions for
https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 27/28
7/13/2021 NCERT Solutions for Class 11 Science Computer science Chapter 5 - Getting Started With Python
Homework Questions for oa d ape So ut o s o
TS Grewal Solutions for Class 11 Science Accountancy
Class 12 Commerce Homework Questions for CBSE Class 12 Commerce
TS Grewal Solutions for Class 11 Commerce Board Paper Solutions for
Class 11 Commerce Business Studies
Homework Questions for
Class 11 Humanities CBSE Class 12 Commerce
Board Paper Solutions for
Homework Questions for
Math
Class 12 Science
CBSE Class 12 Humanities
Homework Questions for
Board Paper Solutions for
Class 12 Commerce
English
Homework Questions for
Class 12 Humanities

HOME
ABOUT US
BLOG
TERMS & CONDITIONS
OUR RESULTS
JOBS

 011-40705070


Share

https://www.meritnation.com/cbse-class-11-science/computer-science/computer-science-ncert-solution-2019/getting-started-with-python/ncert-solutions/41_71_3753_26424_115_146992 28/28

You might also like