Page 561 - ComputerScience_Class_11
P. 561

33              elif choice == "3":
                   34                  print("Result:", num1 * num2)

                   35
                   36              elif choice == "4":

                   37                  if num2 == 0:
                   38                      print("Error: Division by zero is not allowed.")

                   39                  else:
                   40                      print("Result:", num1 / num2)

                   41
                   42              elif choice == "5":

                   43                  if num2 == 0:
                   44                      print("Error: Division by zero is not allowed.")
                   45                  else:

                   46                      print("Result:", num1 // num2)

                   47
                   48              elif choice == "6":
                   49                  if num2 == 0:

                   50                      print("Error: Modulus by zero is not allowed.")
                   51                  else:

                   52                      print("Result:", num1 % num2)
                   53

                   54              elif choice == "7":
                   55                  print("Result:", num1 ** num2)

                   56
                   57          else:

                   58              print("Invalid choice. Please enter a number from 1 to 8.")
                 Output

                 Choose an option:
                 1. Addition (+)
                 2. Subtraction (-)
                 3. Multiplication (*)
                 4. Division (/)
                 5. Floor Division (//)
                 6. Modulus (%)
                 7. Power (**)
                 8. Exit
                 Enter your choice (1-8): 1
                 Enter first number: 10



                                                                                                   Sample Projects  559
   556   557   558   559   560   561   562   563   564   565   566