Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Compute the Square of a Number n

Python Compute the Square of a Number n

Document Object Reference Manual Python3 Examples

This simple Python program computes the square of a number n. Squaring means multiplying a number by itself.

Example

def

calculate_square

(

n

)

:

   

return

n * n

Example usage

number

=

4

result

=

calculate_square

(

number

)

print

(

f

"The square of {number} is {result}"

)

Code analysis:

Output result:

The square of 4 is 16

Document Object Reference Manual Python3 Examples