Skip to main content
Chapter 5 of 11
NCERT Solutions

Getting Started with Python — NCERT Solutions

CBSE · Class 11 · Computer Science

NCERT question answers for Getting Started with Python, CBSE Class 11 Computer Science: 54 textbook questions solved step by step. Covers Exercise.

50 questions74 flashcards2 formulas & key relations5 concepts

Interactive on Super Tutor

Studying Getting Started with Python? Get the full interactive chapter.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for NCERT solutions and more.

Free trial, no card needed.

54 Questions Solved · 1 Section

The first 27 solutions are open to read. The other 27 are free with a Super Tutor account. Unlock all 54 free in Super Tutor

Exercise

1Which of the following identifier names are invalid and why?
iSerial_no.vTotal_Marks
ii1st_Roomvitotal-Marks
iiiHundred$vii_Percentage
ivTotal_MarksviiiTrue
Show solution

Invalid identifier names are:

  • Serial_no. — contains a dot (.), which is not allowed.
  • 1st_Room — begins with a digit, and an identifier cannot start with a digit.
  • Hundred∗∗—containsa∗∗specialsymbol(** — contains a **special symbol (), which is not allowed.
  • total-Marks — contains a hyphen (-), which is not allowed.
  • True — it is a keyword/reserved word, so it cannot be used as an identifier.

Valid identifier names among the given ones are Total_Marks and _Percentage.

Not sure why a step works? check your working in Super Tutor

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

Write the corresponding Python assignment statements:

Show solution

Use assignment statements:

length = 10
breadth = 20

Not sure why a step works? check your working in Super Tutor

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

Write the corresponding Python assignment statements:

Show solution

The average of two values is their sum divided by 2.

So the assignment statement is:

sum = (length + breadth) / 2

Not sure why a step works? check your working in Super Tutor

2(c)Assign a list containing strings 'Paper', 'Gel Pen', and 'Eraser' to a variable stationery.Show solution

A list is written in square brackets with items separated by commas:

stationery = ['Paper', 'Gel Pen', 'Eraser']

Not sure why a step works? check your working in Super Tutor

2(d)Assign the strings 'Mohandas', 'Karamchand', and 'Gandhi' to variables first, middle and last.

Write the corresponding Python assignment statements:

Show solution

Assign each string to its respective variable:

first = 'Mohandas'
middle = 'Karamchand'
last = 'Gandhi'

Not sure why a step works? check your working in Super Tutor

2(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.

Write the corresponding Python assignment statements:

Show solution

To join the three name parts with blank spaces, use string concatenation and add spaces in quotes:

fullname = first + ' ' + middle + ' ' + last

Not sure why a step works? check your working in Super Tutor

3(a)The sum of 20 and -10 is less than 12.

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

Show solution

Write the statement as a Python logical expression:

20 + (-10) < 12

Now evaluate:

  • 20+(−10)=1020 + (-10) = 10
  • 10<1210 < 12 is True

So the expression evaluates to True.

Not sure why a step works? check your working in Super Tutor

3(b)num3 is not more than 24.

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

Show solution

“Not more than 24” means less than or equal to 24.

So the logical expression is:

num3 <= 24

Not sure why a step works? check your working in Super Tutor

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

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

Show solution

To say that 6.75 is between num1 and num2, it must be greater than one and less than the other.

A correct Python expression is:

(num1 < 6.75 and 6.75 < num2) or (num2 < 6.75 and 6.75 < num1)

Not sure why a step works? check your working in Super Tutor

3(d)The string 'middle' is larger than the string 'first' and smaller than the string 'last'.

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

Show solution

In Python, string comparison is done lexicographically.

So the required logical expression is:

'first' < 'middle' and 'middle' < 'last'

Not sure why a step works? check your working in Super Tutor

3(e)List Stationery is empty.Show solution

A list is empty if it contains no items, but Stationery is not empty here because it refers to the list of stationery items. Therefore the statement “List Stationery is empty” is False.

Not sure why a step works? check your working in Super Tutor

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

0 == 1 == 2

Show solution

Add parentheses so that the equality is grouped first:

(0 == 1) == 2

This makes the expression evaluate according to the required grouping.

Not sure why a step works? check your working in Super Tutor

4(b)Add a pair of parentheses to each expression so that it evaluates to True.

2 + 3 == 4 + 5 == 7

Show solution

Parentheses are needed around the comparison parts so the expression groups as:

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

Now evaluate:

  • 2+3=52 + 3 = 5
  • 4+5=94 + 5 = 9
  • So the comparison becomes 5==9==75 == 9 == 7, which is False.

To make it evaluate to True, use parentheses to compare equal values, for example:

(2+3)==(2+3)==5(2 + 3) == (2 + 3) == 5

This gives 5==5==55 == 5 == 5, which is True.

Not sure why a step works? check your working in Super Tutor

4(c)Add a pair of parentheses to each expression so that it evaluates to True.

1 < -1 == 3 > 4

Show solution

The given comparison does not become True as written, because:

  • 1<−11 < -1 is False
  • −1==3-1 == 3 is False
  • 3>43 > 4 is False

Using parentheses, we can group the expression as:

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

Now evaluate:

  • 1<−11 < -1 → False
  • 3>43 > 4 → False
  • So the expression becomes False == False, which is True.

Not sure why a step works? check your working in Super Tutor

5(a)Write the output of the following:

num1 = 4
num2 = num1 + 1
num1 = 2
print (num1, num2)

Show solution

Step by step:

  • num1 = 4
  • num2 = num1 + 1 → num2 = 4 + 1 = 5
  • num1 = 2 → now num1 becomes 2
  • print(num1, num2) prints the current values of num1 and num2

So the output is:

2 5

Not sure why a step works? check your working in Super Tutor

5(b)Write the output of the following:

num1, num2 = 2, 6
num1, num2 = num2, num1 + 2
print (num1, num2)

Show solution

Step by step:

  • Initially, num1 = 2 and num2 = 6
  • num1, num2 = num2, num1 + 2
  • num1 gets the old value of num2, so num1 = 6
  • num2 gets num1 + 2 using the old num1 = 2, so num2 = 2 + 2 = 4
  • print(num1, num2) prints 6 4

So the output is:

6 4

Not sure why a step works? check your working in Super Tutor

5(c)Write the output of the following:

num1, num2 = 2, 3
num3, num2 = num1, num3 + 1
print (num1, num2, num3)

Show solution

Step by step:

  • Initially, num1 = 2 and num2 = 3
  • The statement is num3, num2 = num1, num3 + 1
  • Here, num3 on the right side is used before it has been assigned any value
  • So this causes an error: using an uninitialized variable

Therefore, the program does not produce a valid output. In Python, this would raise an error instead of printing a result.

Not sure why a step works? check your working in Super Tutor

6(a)Which data type will be used to represent the following data values and why?

Number of months in a year

Show solution

The number of months in a year is a whole number, so the suitable data type is integer (int). It stores numeric values without a decimal part.

Not sure why a step works? check your working in Super Tutor

6(b)Which data type will be used to represent the following data values and why?

Resident of Delhi or not

Show solution

For resident of Delhi or not, the data has only two possible states: yes/no or true/false. So the suitable data type is Boolean (bool).

Not sure why a step works? check your working in Super Tutor

6(c)Which data type will be used to represent the following data values and why?

Mobile number

Show solution

A mobile number is best represented as a string (str) because it is an identifier-like value and may contain leading zeros. It is not used for arithmetic.

Not sure why a step works? check your working in Super Tutor

6(d)Which data type will be used to represent the following data values and why?

Pocket money

Show solution

Pocket money may contain decimal values, so the suitable data type is float.

Not sure why a step works? check your working in Super Tutor

6(e)Which data type will be used to represent the following data values and why?

Volume of a sphere

Show solution

The volume of a sphere is a numerical quantity that can include decimal values, so the suitable data type is float.

Not sure why a step works? check your working in Super Tutor

6(f)Which data type will be used to represent the following data values and why?

Perimeter of a square

Show solution

Perimeter of a square is a number and may be a whole number or a decimal number. So the suitable data type is float if we want to allow decimal values as well.

Not sure why a step works? check your working in Super Tutor

6(g)Which data type will be used to represent the following data values and why?

Name of the student

Show solution

The name of the student is text data, so it should be stored as a string.

Not sure why a step works? check your working in Super Tutor

6(h)Which data type will be used to represent the following data values and why?

Address of the student

Show solution

The address of the student is text information and may contain letters, numbers, spaces and symbols, so it should be stored as a string.

Not sure why a step works? check your working in Super Tutor

7(a)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

num1 += num2 + num3
print (num1)

Show solution

Given num1=4num1=4, num2=3num2=3, num3=2num3=2.

  • First calculate num2+num3=3+2=5num2 + num3 = 3 + 2 = 5
  • Then do num1+=5num1 += 5, which means num1=num1+5=4+5=9num1 = num1 + 5 = 4 + 5 = 9
  • So print(num1) displays 9.

Not sure why a step works? check your working in Super Tutor

7(b)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

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

Show solution

Given num1=4num1=4, num2=3num2=3, num3=2num3=2.

  • First calculate num2+num3=3+2=5num2 + num3 = 3 + 2 = 5
  • Then evaluate num1=num1∗∗5=45num1 = num1 ** 5 = 4^5
  • 45=4×4×4×4×4=10244^5 = 4 \times 4 \times 4 \times 4 \times 4 = 1024

So the output is 1024.

Not sure why a step works? check your working in Super Tutor

7(d)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

num1 = '5' + '5'
print(num1)

Free with a Super Tutor account

7(e)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

print(4.00/(2.0+2.0))

Free with a Super Tutor account

7(f)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

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

Free with a Super Tutor account

7(g)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

num1 = 24 // 4 // 2
print(num1)

Free with a Super Tutor account

7(h)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

num1 = float(10)
print (num1)

Free with a Super Tutor account

7(i)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

num1 = int('3.14')
print (num1)

Free with a Super Tutor account

7(j)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

print('Bye' == 'BYE')

Free with a Super Tutor account

7(k)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

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

Free with a Super Tutor account

7(l)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

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

Free with a Super Tutor account

7(m)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

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

Free with a Super Tutor account

7(n)Give the output of the following when num1 = 4, num2 = 3, num3 = 2

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

Free with a Super Tutor account

8(a)Categorise the following as syntax error, logical
error or runtime error:

25 / 0

Free with a Super Tutor account

8(b)Categorise the following as syntax error, logical
error or runtime error:

num1 = 25; num2 = 0; num1/num2

Free with a Super Tutor account

9(a)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:

(0,0)

Free with a Super Tutor account

9(b)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:

(10,10)

Free with a Super Tutor account

10Write 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)

Free with a Super Tutor account

11Write 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.

Free with a Super Tutor account

12Write 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.

Free with a Super Tutor account

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

Free with a Super Tutor account

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

Free with a Super Tutor account

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

Free with a Super Tutor account

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

Free with a Super Tutor account

17Write a program to find average of three numbers.

Free with a Super Tutor account

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

Free with a Super Tutor account

19Write 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.

Free with a Super Tutor account

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

Free with a Super Tutor account

21Presume 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

Free with a Super Tutor account

27 more solved questions in Getting Started with Python

They are free with a Super Tutor account, along with practice quizzes and flashcards for this chapter. Free to start, no card needed.

Frequently Asked Questions

What are the important topics in Getting Started with Python for CBSE Class 11 Computer Science?
Key topics in Getting Started with Python include Introduction to Python, Identifiers, Variables, and Comments, Everything is an Object and id(), Data Types in Python. Study these first, then practise questions on each for Class 11 exams.
Are these NCERT Solutions for Getting Started with Python free?
The first 27 of the 54 solutions on this page are open to read. The other 27 are free with a Super Tutor account — signing up is free and needs no card.
How should I revise Getting Started with Python for Class 11 exams?
Learn the core ideas first, then work through the 50 practice questions on Getting Started with Python. Revise definitions regularly and use flashcards for quick recall before the exam.

Sources & Official References

Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.

For serious students

Get the full Getting Started with Python chapter — start free.

Quizzes, flashcards, an AI doubt solver and a study plan for CBSE Class 11 Computer Science. Free to start, no card needed.