OCR (J277)

Casting (2 marks)

Study the code below. Identify where casting is used and why it might be useful in this context. quantity = input(“Enter number of products: “) total_cost = input(“Enter total cost of products: “) average_cost = float(total_cost) / int(quantity) print(“Average Cost:”, average_cost)

Casting (2 marks) Read More »

Substrings (3 marks)

Given the string s = “ComputerScience”, explain what s.substring(3,6) would output. In this question the string manipulation method .substring(x , i) should be interpreted as: x is starting index, i is number of characters, index begins at 0)

Substrings (3 marks) Read More »

Shopping Cart
Scroll to Top