python quiz 5

 







  Start date :- 12/05/2021                                End date :- 25/05/2021


PYTHON QUIZ 5..

_____________________________________________________________________________________

Q.1. What does the following Python3 code do? (using python 3.X version): n = int (input('Enter a number?'))
i = 1
while i <= n:
  i = i+1
  print (i)

1.
2.
3.
4.
ANSWER :- (4) it will dispay all integers from 2 to n+1 as i=1 & i=i+1 is increasing its value by 1.
___________________________________________________________________________________

Q.2. What will the output of the following Python3 program (using python 3.X version)? n = 13
sum = 0
while (n > 1):
  n = n//2
  sum = sum + n
print(sum)
1.
2.
3.
4.
________________________________________________________________________________

Comments