PROBLEM 1:
Problem Statement Write a program to nd the factorial of a number using functions. Input
Format Input consists of 1 integer. Output Format Output consists of a single integer. Refer sample
output for formatting details.
PYTHON PROGRAM :
a=int(input())
b=1;
for i in range(1,a+1):
b*=i
print(b)
PROGRAM 2:
Problem Statement Write a program to nd the distance between 2 points using functions. Input Format Input consists of 4 integers. The rst and second integer corresponds to the x-coordinate and y-coordinate of the rst point. The third and fourth integer corresponds to the x-coordinate and y-coordinate of the second point. Output Format Output consists of a single oating point number (correct to 2 decimal places.) Refer sample output for formatting details.
PYTHON PROGRAM:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
x=(a-c)**2
y=(b-d)**2
print("Distance between the 2 points is %.2f"%(x+y)**(1/2))
Post a Comment