Skip to content

Course home

Develop code

Develop code

EasyMediumHard
1234567891011121314151617181920212223242526
Question 16

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]
Markscheme

Develop code Questions

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

62 exam-style questions on Edexcel IGCSE Computer Science Develop code. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank