Skip to content

Course home

Develop code

Develop code

EasyMediumHard
1234567891011121314151617181920212223242526
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]
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