Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Develop code

EasyMediumHard
123456789101112131415161718192021222324252627
Question 17

A programmer has written a Python program that is intended to compare two integer inputs, output which one is larger, and then calculate and store their sum in a variable called total_sum.

However, the code contains three errors.

Line 1: num1 = int(input("Enter first number: "))
Line 2: num2 = input("Enter second number: ")
Line 3: if num1 > num2:
Line 4:     print("First number is larger")
Line 5: else
Line 6:     print("Second number is larger or equal")
Line 7: total_sum = num1 - num2

Identify the line number and write the complete corrected line of code for each of the three errors.

[3]

Develop code Questions

  1. IGCSE
  2. /Computer Science
  3. /Develop code