Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+2 votes
249k views
in Computer by (46.3k points)
closed by

Rewrite the following code in Python after removing all syntax error(s). Underline each correction done in the code. 

Value=30 

for VAL in range(0,Value) 

If val%4==0: 

print (VAL*4) 

Elseif val%5==0: 

print (VAL+3) 

else 

print(VAL+10)

2 Answers

+5 votes
by (49.3k points)
selected by
 
Best answer

CORRECTED CODE: 

Value = 30 

for VAL in range(0,Value) :   # Error 1 

    if val%4==0:                     # Error 2 

        print (VAL*4) 

    elif val%5==0:                  # Error 3 

        print (VAL+3) 

    else:                                # Error 4 

        print(VAL+10)

+3 votes
by (3.7k points)

Here's the corrected Python code:

value = 30

for val in range(0, value):
    if val % 4 == 0:
        print(val * 4)
    elif val % 5 == 0:
        print(val + 3)
    else:
        print(val + 10)

Corrections made:

  1. Value -> value
  2. If -> if
  3. Elseif -> elif
  4. else missing a colon at the end
  5. VAL -> val

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...