Coding class New admission Open!!
Project base Courses: ✅
*1️⃣ What is the purpose of the divide() function in the calculator?*
A. To multiply two numbers
B. To add two numbers
C. To avoid division by zero errors ✅
D. To subtract two numbers
✔ Explanation: The divide() function includes a check to prevent dividing by zero, which would otherwise raise a runtime error. It returns a custom error message instead.
2️⃣ Which Python function is used to take input from the user?
A. get()
B. *input()* ✅
C. read()
D. scanf()
✔ Explanation: input() is a built-in Python function that takes user input from the console and returns it as a string.
3️⃣ What type of error does the code handle explicitly?
A. Syntax error
B. Value error
C. Division by zero ✅
D. Type mismatch
✔ Explanation: The code checks if y == 0 in the divide() function to handle division by zero safely.
4️⃣ What data type is used to store user-entered numbers?
A. int
B. str
C. *float* ✅
D. bool
✔ Explanation: The code uses float() to convert user input so it can handle decimal numbers as well.
5️⃣ What happens if an invalid operator is entered?
A. Code crashes
B. Adds numbers by default
C. Shows "Invalid operator" ✅
D. Skips the calculation
✔ Explanation: The else block handles invalid operators by setting the result to "Invalid operator".
National Computer Education,
Above Axis Bank,Nagar RD,Wagholi.
phono 8805027930
www.nationalskillinstitute.com