Question

In: Computer Science

Detect the errors in the following program? How many errors do you observe in the following...

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

Solutions

Expert Solution

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:

  1. TypeError: a ' Float object cannot be interpreted as an integer, which i is in the first line

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.....!


Related Solutions

How do you detect billing scheme fraud
How do you detect billing scheme fraud
How do you use errors in mass and velocity to find the errors in starting and...
How do you use errors in mass and velocity to find the errors in starting and ending kinetic energy? Equation for KE = 1/2mv^2 Error in m = 0.179kg +/- 0.005 kg Error in velocity starting = -0.0648m/s +/- 0.011 m/s Error in velocity ending = 0.259m/s +/- 0.020 m/s
Differentiate between the auditors' responsibilities to detect errors, fraud, and illegal acts. How would you assess...
Differentiate between the auditors' responsibilities to detect errors, fraud, and illegal acts. How would you assess the ethics of a company that has experienced each event with respect to motivation and the integrity of those who go along with such events?
1. How are Sampling Errors and Nonsampling Errors different? 2. What types of errors do you...
1. How are Sampling Errors and Nonsampling Errors different? 2. What types of errors do you feel are most critical? (It needs to be about 2 paragraphs)
11. What’s wrong with this picture? In the following discussion see how many errors you can...
11. What’s wrong with this picture? In the following discussion see how many errors you can spot and explain briefly why each is an error. You do not need to correct the error. “Natalie, I think we’ve got a winner here. Take a look at these numbers! Year Initial cost Units sold Price/unit 15 ($ thousand 0 1 2 3 ... 10 ??1,000 100 100 100 ... 100 15 15 ... 15 Total revenue Cost of goods sold Gross profit...
The JAVA program should do the following: –Ask the user for how many lines of text...
The JAVA program should do the following: –Ask the user for how many lines of text they wish to enter –Declare and initialize an array of Strings to hold the user’s input –Use a while loop to prompt for and read the Strings (lines of text) from the user at the command line. Typically, this would be a 'for' loop since we know the number of times to execute the loop based upon the number supplied by the user, but...
What trend do you observe in GDP at market prices? What trend do you observe in...
What trend do you observe in GDP at market prices? What trend do you observe in GDP at constant prices? How and why do the two series differ? Explain your answer
if you meet the assumption that the errors are random, how do you justify the rest...
if you meet the assumption that the errors are random, how do you justify the rest of the assumption?
There are at least 10 errors in the following C program. For each error you can...
There are at least 10 errors in the following C program. For each error you can find you should list the location of the error, describe what the error is, and state how the error can be fixed (write updated code for that line if necessary). Each error you find is worth 1.5 marks. Note that missing brackets, braces, etc count as only one error, even though the missing brackets may occur at two places. The program is supposed to...
There are at least 10 errors in the following C program. For each error you can...
There are at least 10 errors in the following C program. For each error you can find you should list the location of the error, describe what the error is, and state how the error can be fixed (write updated code for that line if necessary). Each error you find is worth 1.5 marks. Note that missing brackets, braces, etc count as only one error, even though the missing brackets may occur at two places. The program is supposed to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT