0% found this document useful (0 votes)
41 views4 pages

Python Class X Exercise Answers

The document provides exercise answers for Chapter 8 on Python for Class X at The New Indian School, covering topics such as constants, variables, operators, and control structures. It includes fill-in-the-blank questions, true/false statements with corrections, and answers to various programming questions. Additionally, it outlines rules for variable naming, the purpose of comments, and details about looping statements and the range() function.

Uploaded by

asim2110841
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views4 pages

Python Class X Exercise Answers

The document provides exercise answers for Chapter 8 on Python for Class X at The New Indian School, covering topics such as constants, variables, operators, and control structures. It includes fill-in-the-blank questions, true/false statements with corrections, and answers to various programming questions. Additionally, it outlines rules for variable naming, the purpose of comments, and details about looping statements and the range() function.

Uploaded by

asim2110841
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

THE NEW INDIAN SCHOOL W.L.L.

KINGDOM OF BAHRAIN
COMPUTER SCIENCE
CLASS X
CHAPTER 8 – PYTHON
EXERCISE ANSWERS
Fill in the blanks:

1. The constant values cannot be changed in a program.


2. The 2 types of constants are numeric and string constants.
3. A variable value can be stored and retrieved as and when required.
4. Punctuation and blanks are not allowed in a variable name
5. Keywords are reserved words that have a pre-defined meaning.
6. The input statement is required to take input value from the user.
7. The print statement is used to display information on the screen.
8. In print statement the variables are separated by comma and are enclosed within
parentheses.
9. A comment line in a python program begins with # character.
[Link] == is an equality operator.
11.-12, 67.8 and 897 are examples of numeric constants.
12.‘Hello’ is a string constant.
13. The default value of the increment in the range() is 1.
14. range(n) iterates through the numbers from start to n-1.

Write T for true statement and F for the false one. Write the correct
statement:

1. The else clause in the if..elif..else is executed when none of the conditions is true
–T
2. The else clause in the if…else is executed when the condition is true – F
Ans: The else clause in the if…else is executed when the condition is false.
3. An if statement cannot be nested within another if statement – F
Ans: An if statement can be nested within another if statement.
4. An else statement cannot be used without the corresponding if statement – T
5. In Python, Pass and pass are two different variable names – F
Ans: In Python, Pass is a variable name and pass is a keyword.
6. There are two looping structures in Python – for and while – T

Answer the following:

1. What are the three forms of if statement in Python?


Ans: The three forms of if statement in Python are ‘if’, ‘if…else’, ‘if…elif..else’.
2. Define Variables.
Ans: A variable is a named location in the memory where a value can be stored
and retrieved from as and when required.
3. Mention the different operators used in python.
Ans: The different operators used in Python are:
(a) Arithmetic operators (+,-,/,*,**,%,//)
(b) Relational or comparison operators (==,!=,<,>,<=,>=)
(c) Logical operators (and, or, not)
(d) Assignment operator (=)
(e) Compound operators (+=,-=,*=,/=,//=,%=)
(f) Membership operators (in, not in)
(g) Identity operators(is, is not)
4. Write the rules to be observed while creating a variable name in Python.
Ans: Rules to be observed while creating a variable name are:
(a) It can be of any length.
(b) It can contain letters, digits or underscore.
(c) The first character must be a capital or a small case letter or an underscore.
(d) It cannot start with a digit.
(e) Punctuation and blanks are not allowed in a variable name.
(f) It is case-sensitive. The names total, Total and TOTAL are different
variables.
(g) Keywords (reserved words) cannot be used as a variable name.
5. Define constants and mention the 2 types of constants used in Python.
Ans: Constants are fixed values which cannot be changed in a program. The 2
types of constants used in Python are Numeric constants such as 4503, -98, 32.7
and String Constants such as ‘Hello’ and “Good Morning”.
6. What is a comment statement?
Ans: A comment in Python starts with the hash ‘#’ character. It is a part of the
source code but it is ignored by the interpreter while compiling the program. It is
used to give a brief description of the source code.
7. What is a loop? What are the two-looping statements in Python?
Ans: Loop is a sequence of instructions that are repeated until a certain specified
condition is met. The two-looping statements in Python are For loop and While
loop.
8. What is range() function in Python? Mention any 2 examples.
Ans: The range() function produces a sequence of number from start to end-1(end
is not included in the sequence).
Examples: 1) for i in range(1,10):
print(i, end = ‘ ‘)
Output: 1 2 3 4 5 6 7 8 9
2) for num in range(1, 10, 2):
print(num, end = ‘ ‘)
Output: 1 3 5 7 9
9. Write the for statement to get the following output?
(i) 2, 7, 12, 17, 22
Ans: for i in range(2, 27, 5):
print(i)
(ii) -25, -20, -15, -10, -5, 0
Ans: for i in range(-25, 1, 5):
print(i)
Write the output for the following programming codes:
1. A= 10
if A >= 10:
print(A + 15)
else:
print(A – 15)
Output: 25
2. A=5
if A >= 10:
print(A + 15)
else:
print(A - 15)
Output: -10
3. X = 25
if X>15:
print(X * 3)
else:
print(X % 5)
Output: 75
4. X= 12
If X<15:
print (“X is lesser than 15”)
else:
print(“X is greater than 15”)
Output: X is lesser than 15.
5. N1 = 3
N2 = 6
T=N1*N2
print(‘The value is:’, T)

Output: The value is 18.

6. for i in range(0):
print(i)
print(“The loop has ended”)

Output: The loop has ended


7. for i in range(20, 2, -6):
print(i, end = ‘ ‘)
Output: 20 14 6 0
8. for i in range(5):
print(i)
Output: 0 1 2 3 4
9. for y in range(2, 7):
print(y)
Output: 2 3 4 5 6
10. for c in range(1, 6):
print(c)
Output: 1 2 3 4 5
11. for A in range (2, 3, 10):
print(A)
Output: 2 5 8
12. for i in range (2, 20, 2):
print(i)
Output: 2 4 6 8 10 12 14 16 18
13. for x in range (1, 20, 2):
print(x)
Output : 1 3 5 7 9 11 13 15 17 19
14. for X in range (-12, 2, 3):
print(X)
Output: -12 -9 -6 -3 0
15. for X in range (10, 25, 4):
print(X)
Output: 10 14 18 22
Programs from the textbook:

Page numbers: 171(Fig 8.3, 8.5), 172(Fig 8.7, 8.9), 173(Practice Time),

175 – for loop Table, 176(Fig 8.13), 176(Practice Time), 178(Fig 8.17)

You might also like