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
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
>>>
Previous :Python program to print sum, product , difference and average of two numbers
|
You May Also Like:
Python Program for Prime Number between lower and upper limits
Python Program of linear search / Sequential Search
Python Program to Find Factorial of Number Using Loop
C Language Program to Print Fibonacci Series
Python Program to check character is an alphabet or not
C Language Program for Prime Number
Tutorials | Technical Questions and Important programs | Interview Questions |
---|---|---|
C Programming C++ Programming Basic Python Tutorial Advanced Python Tutorial |
C Language C++ Programming Python programming C Important Programs |
C Interview Questions C++ Interview Questions Python Interview Questions HTML Interview Questions |