SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Y Daniel Lang
Chapter:
.loops
Exercise:
Check Point
Question:10 | ISBN:978013274719 | Edition: 6

Question

Count the number of iterations in the following loops:

(a)
count = 0
while count < n:
      count += 1

(b)
for count in range(n):
     print(count)
(c)

count = 5
while count < n:
      count += 1

(d)
count = 5
while count < n:
      count = count + 3

 

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

The number of iterations in the given loops are :

(a) n iterations

(b)  n iterations

(c) n-5 iterations

(d) [n-6]/3 iterations

0 0

Discussions

Post the discussion to improve the above solution.