Programming fundamentals
16
0/2

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]

Programming fundamentals Questions

Practise OCR GCSE Computer Science Programming fundamentals with exam-style questions for GCSE Computer Science. 100 questions, matched to the OCR GCSE Computer Science (J277) specification and written in Component 01 and Component 02 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Programming fundamentals Questions

  1. GCSE
  2. /Computer Science
  3. /Programming fundamentals