Page 180 - Information_Practice_Fliipbook_Class11
P. 180
Case-based Questions
1. Sumita is teaching her younger brother about dividends and divisors. To make him practice the concept, she wants to write
a program in Python that can quickly generate all divisors of a given number. Can you help her in this task?
n_
2. Nusrat has just studied Mersenne numbers. He knows that numbers in the form of 2 1 are called Mersenne numbers.
For example
3
1
2
2 –1 = 1, 2 –1 = 3, 2 –1 = 7, and so on.
He now wants to write a program in Python that displays the first n Mersenne numbers, where n is provided by the user at
execution time. Help him to do that.
NCERT Exercise Solutions
1. Which of the following identifier names are invalid and why?
a. Serial_no. e. Total_Marks
b. 1st_Room f. total-Marks
c. Hundred$ g. _Percentage
d. Total Marks h. True
Ans. a. Serial_no. = invalid as we can't use '.' in variable names
b. 1st_Room = invalid as we can't begin variable names with digits
f. total-Marks = invalid as '-' is not allowed in variable names
d. Total Marks = invalid as there are two separate words in the variable name
h. True = invalid as it is a keyword
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.
Ans. 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
3. 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
166 Touchpad Informatics Practices-XI

