In this WSQ03 I ask the user to choose an operation i.e. sum, difference, product, division, or calculate the remainder, and then type in two integers for the code to solve.
The code prints the options and the user chooses by typing an integer (1,2,3,4,5). I assigned different numbers for each option and assigned somewhat similar values for each variable within the option.
if, elif, else
As you can see, the variable «c» does the actual operation of the variables «a» and «b» which are the integers typed by the user. If the user does not type an integer the code prints «Invalid Number».
FunWIntegers.py in action
Un comentario en “WSQ03”