In: Computer Science
Detect the errors in the following program? How many errors do you observe in the following line of code? Clearly explain what these errors are and how they can be fixed? (Note that this program has only three lines of code). Please type your program in the following textbox.
for i in Range(1,20.0):
if i%2=0:
print(i)
This is a python program
Answer
Given code:
for i in Range(1,20.0):
if i%2=0:
print(i)
In this small program ,the errors are given below:
for i in range(1,20.0).
this error can be fixed by taking 20 as an Integer.
2. SyntaxError: expected an indented block
so there is a concept of Indentation in Python, which used as to indicate a block of code by using some spaces in the begining of the statement. for example:
for i in range(1,20):
if i%2==0:
print(i)
output
***Please encourage me by your valaubale feedback ***
thank you.....!