Q 3. Predict the output of the following program.
i=0;sum=0
n=int(input("Enter n value : '))
while i<=n:
if(i%21=0);
sum=sum+i
=i+1
print("Sum: "sum)
Q 4. Predict the output of the following program.
i=0;sum=0
n=int(input("Enter n value :'))
while i<=n:
if(i%2==0);
sum=sum +
print("Sum: "sum)
Q 5. Write a program to print the series 12+2+3+...n
in python while loop problem plz
Answers
Answered by
1
Answer:
Q.3) if u take first value of n=21
Output:
21
As if n=21 the first value which satisfy the condition i%n==0 is the value of i equal to n.
So sum= sum+i = 0+21 = 21
Q. 4) I cannot understand what u wrote in sum= sum+
Q.5)
n=int(input("Enter any number")
i=1
while (i<=n):
print(i,"+")
i=i+1
Similar questions
Hindi,
4 months ago
Math,
4 months ago
Environmental Sciences,
9 months ago
Chemistry,
9 months ago
Biology,
1 year ago
Social Sciences,
1 year ago