Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python if

Num1=float
Num2=float
Ans=float
operator=int
print("These are the following operations available:
, 1 for addition.
 2 for subtraction.
 3 for multiplication.
 4 for division.")
operator = int(input("Enter the operator you wish to use"))
Num1 = float(input("Please enter your first number:"))
Num2 = float(input("Please enter your second number:"))
if operator ==1:
    Ans == Num1 + Num2
    else:
if operator ==2:
    Ans == Num1 - Num2
    else:
if operator ==3:
    Ans == Num1 * Num2
    else:
if operator ==4:
    Ans == Num1 / Num2
print("Your answer is: %f.2", Ans)
Source by ideone.com #
 
PREVIOUS NEXT
Tagged: #python
ADD COMMENT
Topic
Name
4+1 =