# Class 12 PYTHON : Functions With Arguments And Not Returning Any Value

## Functions with arguments and not returning any value

In this we pass arguments to the function , but function does not return any value.

Example:

### Question:1Python script to calculate and print sum of two numbersSol:

```#function definition

def sum(p,q):
s=p+q
print("Sum = ",s)

#function calling
a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
sum(a,b)```

Enter 1st no 10
Enter 2nd no 20
Sum = 30
>>>

### Question:2Python script to calculate and print square of a numberSol:

```#function definition

def square(n):
s=n*n
print("Square = ",s)

#function calling
a=int(input("Enter 1st no "))
square(a)```

Enter 1st no 2
Square = 4
>>>

### Question:3Python script to calculate and print cube of a numberSol:

```#function definition

def cube(n):
s=n*n*n
print("Cube = ",s)

#function calling
a=int(input("Enter 1st no "))
cube(a)```

Enter 1st no 5
Cube = 125
>>>

### Question:4Python script to calculate and print square and cube of a number(Multiple functions)Sol:

```#function definition

def square(n):
s=n*n
print("square = ",s)

def cube(n):
s=n*n*n
print("Cube = ",s)

#function calling
a=int(input("Enter 1st no "))
square(a)
cube(a)```

Enter 1st no 5
square = 25
Cube = 125
>>>

### Question:5Python script to calculate and print sum , product difference and average of two numbersSol:

```#function definition

def calculate(n1,n2):
s=n1+n2
p=n1*n2
if(n1>n2):
d=n1-n2
else:
d=n2-n1
av=(n1+n2)/2
print("sum = ",s)
print("Prod = ",p)
print("Diff = ",d)
print("average = ",av)

#function calling
a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
calculate(a,b)```

Enter 1st no 10
Enter 2nd no 20
sum = 30
Prod = 200
Diff = 10
average = 15.0
>>>

### Question:6Python script to calculate and print sum , product difference and average of two numbers(Multiple functions)Sol:

```#function definition

def sum(n1,n2):
s=n1+n2
print("sum = ",s)

def prod(n1,n2):
p=n1*n2
print("Prod = ",p)

def diff(n1,n2):
if(n1>n2):
d=n1-n2
else:
d=n2-n1
print("Diff = ",d)
def average(n1,n2):
av=(n1+n2)/2
print("average = ",av)

#function calling
a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
sum(a,b)
prod(a,b)
diff(a,b)
average(a,b)```

Enter 1st no 10
Enter 2nd no 20
sum = 30
Prod = 200
Diff = 10
average = 15.0
>>>