Area of rectangle in python. print the area of rectangle program in python programming language to understand how the program functions for mathematical operations in python programming language.
print("Enter Length of Rectangle ") l = float(input()) print("Enter Breadth of Rectangle") b = float(input()) a = l*b print("\nArea = ", a)
Enter length of rectangle 45
Enter breadth of rectangle 45
input() Method in Python
The input() built-in method in Python can read user input from the keyboard. The user’s input is read as a string, which can then be assigned to a variable. We must press the “Enter” button after entering the value from the keyboard. The user’s value is then read by the input() function.
float() Function in Python
The float() function in Python converts a number in a string or integer to a floating point number, or a decimal value. In Python, there are two sorts of numbers: floating-point numbers and integers. Integers cannot contain decimals, although floats may.
Area of Rectangle in Python
A rectangle is a four-right-angle parallelogram. The perimeter P of a rectangle is calculated using the formula P=2l+2w, where l is the rectangle’s length and w is its width. The formula A=lw gives the area A of a rectangle, where l is the length and w is the width.