Skip to main content
Chapter 5 of 11
NCERT Solutions

Getting Started with Python

CBSE · Class 11 · Computer Science

NCERT Solutions for Getting Started with Python — CBSE Class 11 Computer Science.

50 questions74 flashcards5 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.

1,000+ Class 11 students started this chapter today

55 Questions Solved · 1 Section

28 worked solutions below. Unlock all 55 free in Super Tutor

EXERCISE

1Which of the following identifier names are invalid and why?Show solution
Invalid identifier names are:
- 1st_Room — it starts with a digit, and an identifier cannot start with a digit.
- **Hundreditcontainsaspecialsymbol** — it contains a **special symbol** ``, which is not allowed in identifiers.
- total-Marks — it contains a hyphen `-`, which is not allowed in identifiers.
- True — it is a keyword/reserved word in Python.

Valid identifiers from the list are Serial_no.? No, it is also invalid because it contains a dot `.`, which is a special symbol.
So the invalid names are Serial_no., 1st_Room, Hundred$, total-Marks, and True.

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

2(a)Assign 10 to variable `length` and 20 to variable `breadth`.Show solution
Assign the given values using the assignment operator =:

```python
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`.Show solution
The average of two values is their sum divided by 2.

So the assignment statement is:

```python
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:

```python
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`.Show solution
String values are written in quotation marks and assigned separately:

```python
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.Show solution
To concatenate the three name parts with blanks in between, use + with space strings:

```python
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.Show solution
The sum is 20+(10)=1020 + (-10) = 10.
Since 10<1210 < 12, the statement is True.

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

3(b)`num3` is not more than 24.Show solution
“Not more than 24” means less than or equal to 24.
So the expression is:

```python
num3 <= 24
```
This is True if `num3` is at most 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.Show solution
“6.75 is between the values of integers `num1` and `num2`” means `6.75` must be greater than one and less than the other. A correct logical expression is:

```python
num1 < 6.75 < num2
```
This is True when `num1` is smaller than `6.75` and `num2` is larger than `6.75`.

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'.Show solution
Python compares strings lexicographically. The expression is:

```python
'middle' > 'first' and 'middle' < 'last'
```
This evaluates to True.

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.Show solution
Use parentheses to force the comparison to be evaluated as one part:

```python
(0 == 1) == 2
```
This is not the intended True form, so a correct way is to group as:

```python
0 == (1 == 2)
```
But this still is not True. From the chapter’s idea of using parentheses to override precedence, the expression that can be made True is:

```python
(0 == 1) == 2
```
However, this evaluates to False.

So this particular item cannot be made True by adding only one pair of parentheses without changing the expression itself.

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.Show solution
For the expression `2 + 3 == 4 + 5 == 7`, add parentheses so the comparison works as a chained expression around the arithmetic parts:

```python
(2 + 3) == (4 + 5) == 7
```
But this evaluates to False because 5==95 == 9 is false.
So with the expression exactly as given, it cannot be made True just by adding one pair of parentheses.

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.Show solution
For `1 < -1 == 3 > 4`, parentheses can be added to show the comparisons clearly:

```python
1 < (-1 == 3) > 4
```
This is not True, because `-1 == 3` is False.
The chapter’s rule about parentheses overrides precedence, but this expression still cannot be made True without changing the values/operators.

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

5(a)Write the output of the following:Show solution
Step by step:
- `num1 = 4`
- `num2 = num1 + 1 = 4 + 1 = 5`
- `num1 = 2`
- `print(num1, num2)` prints the current values of `num1` and `num2`.

So the output is:

```python
4 5
```

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

5(b)Write the output of the following:Show solution
Step by step:
- Initially, `num1, num2 = 2, 6`
- Then `num1, num2 = num2, num1 + 2`
- So `num1 = 6` and `num2 = 2 + 2 = 4`
- `print(num1, num2)` displays them.

Output:

```python
6 4
```

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

5(c)Write the output of the following:Show solution
This code gives an error because `num3` is used before it is assigned a value in the statement `num3, num2 = num1, num3 + 1`.

So the program does not produce output; it raises an error for using an uninitialized variable.

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?Show solution
The number of months in a year is a whole number, so the suitable data type is int.

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?Show solution
A resident of Delhi or not is a yes/no condition, so the suitable data type is 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?Show solution
A mobile number is best stored as a string because it is an identification number and may contain leading zeros; we do not do arithmetic on it.

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?Show solution
Pocket money may include paise/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?Show solution
The volume of a sphere can be a decimal value, so float is suitable.

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?Show solution
The perimeter of a square may be a decimal value if side length is not a whole number, so float is suitable.

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?Show solution
The name of a student is textual data, so the suitable data type is str.

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?Show solution
The address of a student is textual data and may contain letters, numbers and symbols, so the suitable data type is str.

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 = 2Show solution
Using the given values, the statement is evaluated as:

- `num1 += num2 + num3`
- `num1 = 4`, `num2 = 3`, `num3 = 2`
- First calculate the right side: 3+2=53 + 2 = 5
- Then add to `num1`: 4+5=94 + 5 = 9

So `num1` becomes `9` and is printed.

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 = 2Show solution
Evaluate step by step:

- `num1 = num1 ** (num2 + num3)`
- First calculate the exponent: 3+2=53 + 2 = 5
- Then compute: 45=10244^5 = 1024

But the question set says this item is from the same group of outputs, and the textbook expression for this line is exactly `num1 = num1 ** (num2 + num3)`, which gives `1024` when `num1 = 4`.

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

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

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
7(e)Give the output of the following when num1 = 4, num2 = 3, num3 = 2
7(f)Give the output of the following when num1 = 4, num2 = 3, num3 = 2
7(g)Give the output of the following when num1 = 4, num2 = 3, num3 = 2
7(h)Give the output of the following when num1 = 4, num2 = 3, num3 = 2
7(i)Give the output of the following when num1 = 4, num2 = 3, num3 = 2
7(j)Give the output of the following when num1 = 4, num2 = 3, num3 = 2
7(k)Give the output of the following when num1 = 4, num2 = 3, num3 = 2
7(l)Give the output of the following when num1 = 4, num2 = 3, num3 = 2
7(m)Give the output of the following when num1 = 4, num2 = 3, num3 = 2
7(n)Give the output of the following when num1 = 4, num2 = 3, num3 = 2
8(a)Categorise the following as syntax error, logical
error or runtime error:
8(b)Categorise the following as syntax error, logical
error or runtime error:
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:
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:
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)
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.
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.
13Write a program to enter two integers and perform all arithmetic operations on them.
14Write a program to swap two numbers using a third variable.
15Write a program to swap two numbers without using a third variable.
16Write a program to repeat the string “GOOD MORNING” n times. Here ‘n’ is an integer entered by the user.
17Write a program to find average of three numbers.
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.
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.
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.
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

27 more solved questions in Getting Started with Python

Every remaining exercise is solved step by step in Super Tutor, plus practice quizzes and flashcards for this chapter. Free to start.

Stuck on a step?

Ask Super Tutor AI to explain any solution on this page in a simpler way — free, 24x7.

Ask a Doubt Free

Frequently Asked Questions

What are the important topics in Getting Started with Python for CBSE Class 11 Computer Science?
Getting Started with Python covers several key topics that are frequently asked in CBSE Class 11 board exams. Focus on the core concepts listed on this page and practise related questions to build confidence.
How to score full marks in Getting Started with Python — CBSE Class 11 Computer Science?
Understand the core concepts first, then work through the 50 practice questions available for this chapter. Revise formulas and definitions regularly, and use flashcards for quick recall before the exam.
Where can I get free NCERT Solutions for Getting Started with Python Class 11 Computer Science?
This page has free step-by-step NCERT Solutions for every exercise question in Getting Started with Python (CBSE Class 11 Computer Science) — written the way examiners award marks: given, formula, working, answer.

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 — for free.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan for CBSE Class 11 Computer Science.