Convert the given for loop to while loop and find the output of the program assuming the
value entered for num is 15.
num = int (input ("Enter a value"))
sum =0
count=0
for i in range (1, num):
if i%2 == 0:
count += 1
sum += i
print(sum)
print(count)

Respuesta :

Answer:

Explanation:

num = int (input ("Enter a value"))

sum =0

count=0

i = 1

while i < num:

 if i%2 == 0:

        count += 1

        sum += i

        i += 1

 i += 1

print(sum)

print(count)

The output assuming num is 15 would be

56

7