Plenty of π
Module 2: Python Basics - Data Types, Variables, I/O, and Operators
Lab: Lab 2.1: Variable Play & Simple Calculator

Create a program that takes two numbers (pre-defined in the code for this sandbox) and then prints their sum, difference, product, and quotient.

Tasks to Complete:

  • Two numbers are pre-defined as strings (`num1_str`, `num2_str`). Modify these string values to test different inputs.
  • Convert these string inputs to numerical types (e.g., `float` to handle decimals) and store them in `num1` and `num2`.
  • Calculate their sum, difference, product, and quotient.
  • Store these results in `sum_result`, `difference_result`, `product_result`, and `quotient_result`.
  • Print each result with a descriptive label (e.g., "Sum: ...").
  • Handle potential division by zero for the quotient (e.g., print "Cannot divide by zero" if `num2` is 0).

Python Sandbox

Python execution is powered by Pyodide, running directly in your browser. The `input()` function is not supported in this sandbox; please define variables directly in your code.