In: Computer Science
Python
Please debug each python block. Do not change the algorithm. You can add statements or you can modify existing python statements.
#2) The below code prints all numbers from 5 to 20. Modify the
below while loop to print odd numbers from 5 to 21,
# including 21. Correct syntax errors as well.
i = 5
while(i<21):
print(i)
i = i+1
1 PYTHON CODE TO PRINT ALL NUMBERS FROM 5 TO 20 ===>
# CODE TO PRINT INTEGERS FROM 5 TO 20
i = 5 # initialize value i = 5
while(i<21): # run loop until i = 21
print(i) # print all i
i = i+1 # increment i
CODE SCREENSHOT ====>
OUTPUT SCREENSHOT ===>
2 . MODIFIED CODE ( INCLUDE 21 ) ====>
# CODE TO PRINT INTEGERS FROM 5 TO 20
i = 5 # initialize value i = 5
while(i<=21): # run loop until i = 21
print(i) # print all i
i = i+1 # increment i
CODE SCREENSHOT ====>
OUTPUT SCREENSHOT ====>