PCEP • Practice Test 31
Free PCEP practice test — 15 questions with explanations. Set 31. No signup required.
A developer is building a simple calculator that accepts two numbers and an operator string. The code:
x = float(input("First: ")) y = float(input("Second: ")) op = input("Operator (+, -, *, /): ")
if op == "+":result = x + y elif op == "-": result = x - y elif op == "*": result = x * y elif op == "/": result = x / y
print("Result:", result)When the user enters 10, 3, and "/", the output is "Result: 3.3333333333333335". The developer wants to display only two decimal places. Which code change will achieve this without introducing errors?