Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: Calculator (argv)

  • Create a script called basic2_calculator_argv.py that accepts 2 numbers and an operator (+, -, *, /), on the command line and prints the result of the operation.
  • python basic2_calculator_argv.py 2 + 3
  • python basic2_calculator_argv.py 6 / 2
  • python basic2_calculator_argv.py 6 * 2