Computer Science, asked by deveshlahori, 9 months ago

a. Write a Python program to find area of a rectangle. Make use of functions in Python.
b. Write a Python program to find sum of given numbers. Make use of functions in Python.

Answers

Answered by akshayamca14
3

Answer:

a.

def calculatearea(length,width):

   print("Area of rectangle is "+str(length*width))

 

calculatearea(4,5)    

b.

def sumofnumbers():

   print("Sum of how many numbers")

   number=input()

   sum=0

   for x in range(1,int(number)+1):

       print("Enter "+str(x)+" number")

       sum=sum+int(input())

       

   print("sum of number is "+str(sum))

   

   

sumofnumbers()

Explanation:

Answered by Equestriadash
39

The following codes must be typed in script mode, saved and then executed.

a. CODE:

l = float(input("Enter the length of the rectangle:"))

b = float(input("Enter the breadth of the rectangle:"))

area = l*b

print("The area of the rectangle is", area)

b. CODE:

a = float(input("Enter the first number:"))

b = float(input("Enter the second number:"))

c = float(input("Enter the third number:"))

d = float(input("Enter the fourth number:"))

s = a + b + c + d

print("The sum of the numbers is", s)

Output (a), Output (b):

Attachments:
Similar questions