Skip to content

Course home

Data types

Data types

Easy
1234567891011121314151617181920212223242526
Question 3

An automated sorting system processes package information. The weight of the package is entered as a text string and must be converted to a numerical value to perform a comparison.

01 product_id = input("Enter product ID")
02 weight_entry = input("Enter package weight")
03 numeric_weight = float(weight_entry)
04 if numeric_weight > 20.0 then
05     charge = 15.50
06 else
07     charge = 7.25
08 endif
09 print("Shipping charge: £" + str(charge))

Define the term casting and state the line number where casting is used to convert a string into a real (float) value.

[2]
Markscheme

Data types Questions

  1. GCSE
  2. /Computer Science
  3. /Data types

26 exam-style questions on OCR GCSE Computer Science Data types. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank