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

At Orchids International School, a lot of emphasis is given to providing the students with the most comprehensive and practical study material. In Class 11 Computer Science, Getting Started with Python is a must-read when getting initiated to the programming language of Python. In this chapter, students get to learn some very basic concepts about Python, which help them really get started with their foundation in coding. Additional support is also provided with the Class 11 Computer Science Chapter 5 PDF along with examples to help understand in a more descriptive manner. "Getting Started with Python" is not just about syntax but how the given concept is used while one writes a program and makes problem-solving in real life. By using available resources, such as the class 11 computer science chapter 5 PDF, it is possible for students to gain an overview and develop skills in computer science at Orchids International School.

Download PDF For NCERT Solutions for Computer-Science Getting Started with Python

The NCERT Solutions Class 11 Computer Science Chapter 5 Getting Started with Python are tailored to help the students master the concepts that are key to success in their classrooms. The solutions given in the PDF are developed by experts and correlate with the CBSE syllabus of 2023-2024. These solutions provide thorough explanations with a step-by-step approach to solving problems. Students can easily get a hold of the subject and learn the basics with a deeper understanding. Additionally, they can practice better, be confident, and perform well in their examinations with the support of this PDF.

Download PDF

Access Answers to NCERT Solutions Class 11 Computer Science Chapter 5 Getting Started with Python

Students can access the NCERT Solutions Class 11 Computer Science Chapter 5 Getting Started with Python. Curated by experts according to the CBSE syllabus for 2023–2024, these step-by-step solutions make Computer-Science much easier to understand and learn for the students. These solutions can be used in practice by students to attain skills in solving problems, reinforce important learning objectives, and be well-prepared for tests.

Getting Started with Python

Question 1 :

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

 

Answer :

first_number=int(input(“Enter First Number: “))

second_number=int(input(“Enter Second Number: “))

 

def swap(first_number,second_number):

third_variable=first_number

first_number=second_number

second_number=third_variable

returnfirst_number,second_number

print(swap(first_number,second_number))

 


Question 2 :

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

Answer :

first_number=int(input(“Enter First Number: “))

second_number=int(input(“Enter Second Number: “))

def swap(first_number,second_number):

first_number,second_number=second_number,first_number

returnfirst_number,second_number

print(swap(first_number,second_number))

 


Question 3 :

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

a) 25 / 0

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

 

Answer :

a) 25 / 0 :- Runtime Error, because of divisible by zero

b) num1 = 25; num2 = 0; num1/num2 :- Runtime Error, because of divisible by zero

 


Question 4 :

Write a program to repeat the string ‘‘GOOD MORNING” n times. Here ‘n’ is an integer entered by the user.

 

Answer :

n=int(input(“Enter Number: “))

for i in range(n):

print(“GOOD MORNING “)

 


Question 5 :

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

Reason- (.) is not allowed in identifier

ii) 1st_Room :- Invalid

Reason- identifier can’t start with number

iii) Hundred$ :-  Invalid

Reason- We can’t use special symbol $ in identifier

iv) Total Marks :- Invalid

Reason- We can’t use space between in identifier

v) Total_Marks :- Valid

Reason- We can use underscore between in identifier

vi) total-Marks :- Invalid

Reason- We can’t use hyphen between in identifier

vii) _Percentage:- Invalid

Reason- Identifier can’t begin with underscore

viii) True :- Invalid

Reason- We can’t use keyword as a identifier

 


Question 6 :

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) Assign 10 to variable length and 20 to variable breadth.

length = 10

breadth = 20

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

Sum = (length + breadth)/2

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

Stationary=[‘Paper’ ,  ‘Gel Pen’ , ‘Eraser’

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

first = ‘Mohandas’

middle= ‘Karamchand’

last= ‘Gandhi’

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.

fullname = first +” “+ middle +” “+ last

 


Question 7 :

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 :

STATEMENT

LOGICAL EXPRESSIONS

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

(20 + (-10)) < 12

num3 is not more than 24.

num3 <= 24   or not(num3 > 24)

6.75 is between the values of integers num1 and num2.

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

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

(middle > first) and (middle < last)

List Stationery is empty.

len(Stationery) == 0

 


Question 8 :

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

a) 0 == 1 == 2

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

c) 1 < -1 == 3 > 4

 

Answer :

 

EXPRESSION

EXPRESSION WITH PARENTHESIS

0 == 1 == 2

(0 == (1 == 2))

2 + 3 == 4 + 5 == 7

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

1 < -1 == 3 > 4

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

 


Question 9 :

Write a program to find the average of three numbers.

 

Answer :

x=int(input(“Enter First Number: “))

y=int(input(“Enter Second Number: “))

z=int(input(“Enter Third Number: “))

def  average(x,y,z):

avg=x+y+z/3

returnavg

print(“Average : “)

print(average(x,y,z))

 


Question 10 :

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)

c) num1, num2 = 2, 3

num3, num2 = num1, num3 + 1

print (num1, num2, num3)

 

Answer :

a) num1 = 4

num2 = num1 + 1

num1 = 2

Output: 2,5

b) num1, num2 = 2, 6

num1, num2 = num2, num1 + 2

print (num1, num2)

Output: 6,4

c) num1, num2 = 2, 3

num3, num2 = num1, num3 + 1

print (num1, num2, num3)

Output: error

 

 


Question 11 :

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

 

Answer :

 

DATA VALUES

DATA TYPES

REASON

Number of months in a year

Integer

Number of months contain only number values (integer).

Resident of Delhi or not

Boolean

It gives the answer in the form of true and false

Mobile number

Integer

Mobile number only contain integer number value

Pocket money

Float

Money can be count as 100rs 50 paisa(100.50)

Volume of a sphere

Float

The volume can be calculated in the decimal point

Perimeter of a square

Float

The perimeter can be calculated in the decimal point

Name of the student

String

Name is a set of character, hence data type of name of student is string

Address of the student

String

Address is a set of character, hence data type of address of student is string

 


Question 12 :

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’)

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

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

>= 29/9)

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

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

(10<0)))

 

Answer :

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

 


Question 13 :

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 :

deffar_conv(t):

x=t*9/5 + 32

return x

print(far_conv(100))

 


Question 14 :

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 :

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
d) (7,8): False


Question 15 :

Write a Python program to calculate the amount payable if money has been lent on simple interest. Notes Ch 5.indd 117 08-Apr-19 12:35:13 PM 2020-21 118 Computer Science – Class xi 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 :

principal=int(input(“P=”))

rate=int(input(“I=”))

time=int(input(“T=”))

defamount_pay(principal,rate,time):

simple_intrest=(principal*rate*time)/100

TOTAL_amount=Print+simple_intrest

returnTOTAL_amount

print(“Total Payble amount”)

print(amount_pay(principal,rate,time))

 


Question 16 :

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 :

x=int(input(“x=”))

y=int(input(“Y=”))

z=int(input(“Y=”)) 

defwork_days(x,y,z):

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

return days

print(“Work will complete(in days)”)

print(work_days(x,y,z))

 


Question 17 :

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

 

Answer :

a=int(input(“Enter First Number: “))

b=int(input(“Enter Second Number: “))

defAddition(a,b):

return a+b

def subtraction(a,b):

return a-b

def multiplication(a,b):

return a*b

def division(a,b):

return a/b

print(“Addition of {0} & {1} is : “.format(a,b))

print(Addition(a,b))

print(“subtraction of {0} & {1} is : “.format(a,b))

print(subtraction(a,b))

print(“multiplication of {0} & {1} is : “.format(a,b))

print(multiplication(a,b))

print(“division of {0} & {1} is : “.format(a,b))

print(division(a,b))

 


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 7cm, 12cm, 16cm, respectively.

 

Answer :

defvolume_sphere(r):

pi=3.1415926535897931

volume=4.0/3.0*pi* r**3

return volume

print(“volume of spheres with radius 7cm”)

print(volume_sphere(7))

print(“volume of spheres with radius 12cm”)

print(volume_sphere(12))

print(“volume of spheres with radius 16cm”)

print(volume_sphere(16))

 


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 :

fromdatetime import datetime

name = input(‘Name \n’)

age = int(input(‘Age  \n’))

defhundred_year(age):

hundred = int((100-age) + datetime.now().year)

return hundred

x=hundred_year(age)

print (‘Hello %s.  You will turn 100 years old in %s.’ % (name,x))

 


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 :

m=int(input(“Enter Mass in Kg: “))

def Einstein(m):

c=299792458

e= m*c**2

return e

print(“Equivalent energy (E): “)

print(Einstein(m))

 


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 :

import math

defheight_reched(length,degrees):

radian=math.radians(degrees)

sin=math.sin(radian)

height=round(length*sin,2)

return height 

print(” height reached by the ladder on the wall for the  length is 16 feet and 75 degrees“)

print(height_reched(16,75))

print(” height reached by the ladder on the wall for the  length is 20 feet and 0 degrees “)

print(height_reched(20,0))

print(” height reached by the ladder on the wall for the  length is 24 feet and 45 degrees“)

print(height_reched(24,45))

print(” height reached by the ladder on the wall for the  length is 24 feet and 80 degrees“)

print(height_reched(24,80))

 


Enquire Now