Skip to content
MathsGenie logo
Quick links
Open app

Course home

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

Develop code

EasyMediumHard
123456789101112131415161718192021222324252627
Question 18

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]

Develop code Questions

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