Skip to content
MathsGenie logo
Open app

Course home

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

Develop code

EasyMediumHard
123456789101112131415161718192021222324252627
Question 8

The Python program below is designed to take the base and height of a triangle as inputs from the user, calculate its area using the formula:

Area=base×height2 \text{Area} = \frac{\text{base} \times \text{height}}{2} Area=2base×height​

and output the calculated area.

There are three errors in the code.

1 base = input("Enter the base: ")
2 height = float(input("Enter the height: "))
3 area == (base * height) / 2
4 print("The area is " + area)

Identify the line number of each error and write the amended, correct line of code.

[3]

Develop code Questions

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