Skip to content

Latest commit

 

History

History
65 lines (36 loc) · 1.84 KB

Q1-Q9_solutions.md

File metadata and controls

65 lines (36 loc) · 1.84 KB

[CBSE] Solutions for Chapter 1 (Back Exercise) Q1 to Q9 [Page 24-26]

Q1 Write the output from the following code:

  • a) Output: 10

  • b) Output: Inspirational stores \n for \t Children

  • c) Output: sum= 28

  • d) Output: i= 55 & in next line sum= 125

  • e) Output: error OR Leap Year (if i in line 2 is changed to y)

Q4 How many times are the following loop executed?

  • a) 9 times --> 100, 90, 80, 70, 60, 50, 40, 30, 20

  • b) 5 times --> 100, 120, 140, 160, 180

  • c) 2 times --> 1, 10

  • d) infinite loop --> 4, 14, 24, 34, 44, 54, 64, ...

  • e) infinite loop --> 2, 2, 2, 2, 2, ...

Q5 Rewrite the following for loop into while loop:

  • a) a=25 <next line> while a<500: <next line> print a <next line> a=a+25

  • b) a=90 <next line> while a>9: <next line> print a <next line> a=a-9

Q6 Rewrite the following for while loop into for loop

  • a) for i in range(10,250,50): <next line> print i

  • b) for i in range(88,7,-8): <next line> print i

Q7 Which command is used to convert text into integer value?

  • int(x) or float(x) can be used to convert text into integer value.

Q8 Find the errors from the following code :

  • a) Error: name 'a' is not defined.

  • b) Invalid Syntax (for i in range is to be used.

  • c) Invalid Syntax Indentation issue.

  • d) Invalid Syntax Indentation issue & wrong placement of ":"

Q9 Find the output from the following code :

  • print L1 will print [300, 400]

  • print L2 will print [200, 300, 400, 500]

  • print L2 (after L2.extend(L1) code) will print [200, 300, 400, 500, 300, 400]