학습 자료

How to Calculate Squares in Python

The exponentiation operator ** returns the value of the number on the left raised to the power of the number on the right.

For example, a ** b returns a raised to the power of b.

Exponentiation Example
squared = 2 ** 3 print(squared) # 8

The ** operator is useful in math for calculating powers, such as areas and volumes.

Calculating the Area of a Square
side = 5 # Length of one side of the square area_of_square = side ** 2 # Area of the square print(area_of_square) # 25
Quiz
0 / 1

Using the Power Operator in Python

Run the following code to calculate the area of a square. The expected output is 49.

side = 7

area_of_square = side 
 2

print(area_of_square)

학습 자료

AI 튜터

디자인

업로드

수업 노트

즐겨찾기

도움말

코드 에디터

코드 실행
코드 생성

실행 결과