Skip to content

Course home

Develop code

Develop code

EasyMediumHard
1234567891011121314151617181920212223242526
Question 17

A local juice bar uses a program to determine if they have enough orange juice in stock for a large catering event, or how many more litres they need to order.

Each Large cocktail requires 0.2 litres of orange juice. Each Regular cocktail requires 0.1 litres of orange juice.

Here is the buggy program:

stock = float(input('Juice in stock (litres): '))
large = int(input('Number of large: '))
regular = int(input('Number of regular: '))

needed = (large * 2.0) + (regular * 0.1)

if stock < needed:
    print('Juice in stock sufficient')
else:
    shortfall = stock - needed
    print('Order ' + shortfall + ' litres')

There are four errors in the code.

Amend the code to correct the four errors.

Use this test data to help you find the errors:

Juice in stock (litres)Number of largeNumber of regularExpected output
2880120Juice in stock sufficient
2280120Order 6.0 litres
[4]
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