Hi Guys,
Today's target is to write program for basic arithmetic in Python. We will take four inputs from user and we will try to output sum, subtraction, multiplication and division. Here we go.
#program for basic arithmetic
a=input("Enter the value of a:")
b=input("Enter the value of b:")
c,d= input("Enter value of c and d (separated by comma)\n")
s=a+b+c+d
m= a-b+c-d
mu = a*b*c*d
d_int= a/b/c/d
d_float= float(a)/float(b)/float(c)/float(d)
#python allows you to take multiple input separated by comma
#Keep in mind float/float= float and int/int= int
print("\nResults")
print("**********")
print("sum=%f\nsubraction=%f\nmultiplication=%f\nd_int=%f\nd_float=%f\n"%(s,m,mu, d_int, d_float))
output :
No comments:
Post a Comment