An **area of a rectangle** is the measurement of the space that the rectangle occupies which can be in the form of square units such as square meters (m²), or square feet (ft²).

You can simply multiply the width of the rectangle by its height.

```
Area = Width * Height
```

In the code below, we have given default values to the variables of width and height to calculate the area.

#you can give default input to the variableswidth = 4height = 5# Now we are using the formula to calculate the AreaArea = width * height# after calculating, simple print it in stringprint("Area of rectangle = "+str(Area))

In the code below, we can take input from the user and then apply the formula of an area on the values.

# In this way, you can take 2 separate inputs from user on console# Wrtie 2 inputs in 2 separate lineswidth = float(input())height = float(input())# Now we are using the formula to calculate the AreaArea = width * height# after calculating, simple print it in stringprint("Area of rectangle = " + str(Area))

Enter the input below

Copyright ©2024 Educative, Inc. All rights reserved

TRENDING TOPICS