Flow of control NCERT Solution || Flow of control Class 11 Solution || Flow of control Python Class 11 CS Solution || Flow of control Computer Science Solution || NCERT Flow of control Solution || Flow of control in Python Class 11 CS || Flow of control in Python Solution


Note :- Please Click on Question to get Answer of  that Question !!


Exercise



Q1. What is the difference between else and elif construct of if statement?


Q2. What is the purpose of range() function? Give one example.


Q3. Differentiate between break and continue statements using examples.


Q4. What is an infinite loop? Give one example.



Q5. Find the output of the following program segments:

(i)
a = 110
while a > 100:
      print(a)
      a -= 2

(ii)
for i in range(20,30,2):
       print(i)

(iii)
country = 'INDIA'
for i in country:
       print (i)

(iv)
i = 0; sum = 0
while i < 9:
     if i % 4 == 0:
              sum = sum + i
     i = i + 2
     print (sum)

(v)
for x in range(1,4):
      for y in range(2,5):
              if x * y > 10:
                     break
              print (x * y)
             
(vi)
var = 7
while var > 0:
      print ('Current variable value: ', var)
      var = var -1
      if var == 3:
             break
      else:
             if var == 6:
                    var = var -1
                    continue
       print ("Good bye!")




Programming Exercises



Q1. Write a program that takes the name and age of the user as input and displays a message whether the user is eligible to apply for a driving license or not. (The eligible age is 18 years).


Q2. Write a function to print the table of a given number. The number has to be entered by the user.


Q3. Write a program that prints minimum and maximum of five numbers entered by the user.


Q4. Write a program to check if the year entered by the user is a leap year or not.


Q5. Write a program to generate the sequence: –5, 10, –15, 20, –25….. upto n, where n is an integer input by the user.


Q6. Write a program to find the sum of 1+ 1/8 + 1/27......1/n3, where n is the number input by the user.


Q7. Write a program to find the sum of digits of an integer number, input by the user.


Q8. Write a function that checks whether an input number is a palindrome or not.



Q9. Write a program to print the following patterns:
(i)
  *   
 * *  
* * *
 * *  
  *  

(ii)
        1    
      212   
    32123  
  4321234
543212345

(iii)

12345
  1234
    123
       12
         1

(iv)

  *  
 * *
*   *
 * *
  *  




Q10. Write a program to find the grade of a student when grades are allocated as given in the table below.

Percentage of the marks obtained by the student is input to the program.


5 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Sir thank you vry mch for answer but sir I want ask question that in first * program what to do if we want print 5 star in middle

    ReplyDelete
    Replies
    1. Ok Just Write it : )

      for i in range(8):
      for j in range(8):
      if i < 5 :
      if j >= 3 - i and j <= 3 + i :
      if i % 2 == j % 2 :
      print(" ", end = "")
      else :
      print("*", end = "")
      else :
      print(" ", end = "")
      else :
      if j <= 10 - i and j >= i - 4 :
      if i % 2 == j % 2 :
      print(" ", end = "")
      else :
      print("*", end = "")
      else :
      print(" ", end = "")
      print()

      Delete
    2. Thank you very much

      Delete
  2. Sir I also want ask that in NCERT there star pattern go from 1-3-5 but sir you program give 1-2-3 so sir how print answer of ncert

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post