Write a function named square that accepts a number as an argument and returns the square of that number.

computer science

Description

Use the IDLE editor to write a Python program with three functions:

  • Write a function named square that accepts a number as an argument and returns the square of that number.  (Remember, the square of a number is the number multiplied by itself.  For example, 2 squared is 2 x 2 = 4.)
  • Write a function named cube that accepts a number as an argument and returns the cube of that number.  (Remember, the cube of a number is the number multiplied by itself twice.  For example, 2 cubed is 2 x 2 x 2 = 8.)
  • Write a main function that uses a loop to display the numbers from 1 to 10, and their squares, and their cubes.  The output should be formatted as a table as shown below.

    • The main function must call the square function and the cube function to calculate the square and cube of each number.
    • The output must be printed from the main function with column headings as shown below.
    • The numbers in the columns should be right-aligned .


Related Questions in computer science category