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 a square.

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

## Area and Perimeter of square

```s=int(input("Enter side of square "))
a=s*s
p=4*s
print("Area = ",a)
print("Perimeter = ",p)
```

Output:

Enter side of square 5
Area = 25
Perimeter = 20
>>>

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

```#function definition
def square():
s=int(input("Enter side of square "))
a=s*s
p=4*s
print("Area = ",a)
print("Perimeter = ",p)

#function calling
square()```

Output:

Enter side of square 6
Area = 36
Perimeter = 24
>>>

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

```#function definition
def square(s):
a=s*s
p=4*s
print("Area = ",a)
print("Perimeter = ",p)

#function calling
s=int(input("Enter side of square "))
square(s)```

Output:

Enter side of square 9
Area = 81
Perimeter = 36
>>>

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

```#function definition
def square(s):
a=s*s
p=4*s
return a,p

#function calling
s=int(input("Enter side of square "))
a,p=square(s)
print("Area = ",a)
print("Perimeter = ",p)```

Output:

Enter side of square 2
Area = 4
Perimeter = 8
>>>

### Interview Questions

C Programming
C++ Programming
Basic Python Tutorial