All Programs

#### Basic Python Programs

Simple Python programs

#### If Condition Programs

If condition based Python Programs

#### Looping based programs

program based on for loop, while loop, range

#### Searching and Sorting

Python Searching Programs
Python Sorting Programs

# Python program to calculate and print the area and perimeter of the rectangle.

Solution with out using functions
Solution using functions without passing arguments
Solution using functions and by passing arguments
Solution using functions by passing arguments and returing multiple values

### Solution : Without using function Program/Source Code

```l=int(input("Enter length of rectangle "))
a=l*b
p=2*(l+b)
print("Area = ",a)
print("Perimeter = ",p)
```

Output:

Enter length of rectangle 2
Area = 6
Perimeter = 10
>>>

### Solution : Using function Without Passing Arguments Program/Source Code

```#function definition
def rectangle():
l=int(input("Enter length of rectangle "))
a=l*b
p=2*(l+b)
print("Area = ",a)
print("Perimeter = ",p)

#function definition
rectangle()
```

Output:

Enter length of rectangle 3
Area = 18
Perimeter = 18
>>>

### Solution : Using function Passing Arguments Program/Source Code

```#function definition
def rectangle(l,b):
a=l*b
p=2*(l+b)
print("Area = ",a)
print("Perimeter = ",p)

#function definition
l=int(input("Enter length of rectangle "))
rectangle(l,b)
```

Output:

Enter length of rectangle 4
Area = 20
Perimeter = 18
>>>

### Solution : Using function Passing Arguments and returing multiple values Program/Source Code

```#function definition
def rectangle(l,b):
a=l*b
p=2*(l+b)
return a,p

#function definition
l=int(input("Enter length of rectangle "))
a,p=rectangle(l,b)
print("Area = ",a)
print("Perimeter = ",p)
```

Output:

Enter length of rectangle 5
Area = 30
Perimeter = 22
>>>

### Interview Questions

C Programming
C++ Programming
Basic Python Tutorial