top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Writer's pictureAlaa Mohamed

simple arithmetic calculator by python


Everyone need simple calculator in his daily life so in this program we calculate simple calculation like addition, subtraction …


In this program I start by taking two number from the user and the operator that he need

fnum=float(input("Enter Your First Number"))
snum=float(input("Enter Your Second Number"))
op=input("Enter Your Operator")

then I use if condition to calculate the Arithmetic operation :

*addition operation:

if op =="+":
add=fnum+snum
print("The Result is"+ str(add))

*subtraction operation:

elif op=="-":
sub=fnum-snum
print("The Result is"+ str(sub))

*multiplication operation:

elif op=="*":
multi=fnum*snum
print("The Result is"+ str(multi))

*division operation:
elif op=="/":
div=fnum/snum
print("The Result is"+ str(div))
 

* reminder operation:

elif op=="%":
rem=fnum%snum
print("The Result is"+ str(rem))

program code:

fnum=float(input("Enter Your First Number"))
snum=float(input("Enter Your Second Number"))
op=input("Enter Your Operator")
if op =="+":
add=fnum+snum
print("The Result is"+ str(add))
elif op=="-":
sub=fnum-snum
print("The Result is"+ str(sub))
elif op=="*":
multi=fnum*snum
print("The Result is"+ str(multi))
elif op=="/":
div=fnum/snum
print("The Result is"+ str(div))
elif op=="%":
rem=fnum%snum
print("The Result is"+ str(rem))
0 comments

Recent Posts

See All

Comments


bottom of page