Page 287 - CTS - CSA TP - Volume 2
P. 287

COMPUTER SOFTWARE APPLICATION - CITS




                      return”Cannot divide by zero”
                    # main_script.py
                    importmy_module
                    # Getting user input for numbers
                    num1=float(input(“Enter the first number: “))

                    num2=float(input(“Enter the second number: “))
                    # Using arithmetic functions from my_module
                    sum_result=my_module.add(num1, num2)
                    difference_result=my_module.subtract(num1, num2)

                    product_result=my_module.multiply(num1, num2)
                    quotient_result=my_module.divide(num1, num2)
                    # Displaying the results
                    print(f”Sum: {sum_result}”)
                    print(f”Difference: {difference_result}”)
                    print(f”Product: {product_result}”)

                    print(f”Quotient: {quotient_result}”)
              Output:















           Related Exercises:
           Exercise 1: Celsius to Fahrenheit Converter
           Create a module temperature_converter.py with a function to convert Celsius to Fahrenheit and use it in a script.
           Exercise 2: List Reverser

           Create a module list_operations.py with a function to reverse a list and use it in a script.
           Exercise 3: Palindrome Checker
           Create a module palindrome_checker.py with a function to check if a given string is a palindrome and use it in a
           script.

           Exercise 4: Date Formatter
           Create a module date_formatter.py with a function to format a given date and use it in a script.
           Exercise 5: Word Counter
           Create a module word_counter.py with a function to count the number of words in a given text and use it in a
           script.










                                                           272
                              CITS : IT & ITES - Computer Software Application - Exercise 130
   282   283   284   285   286   287   288   289   290   291   292