write a program to calculate the SI with if and else condition in python
Answers
Answered by
7
The following codes will have to be typed in script mode, saved and then executed.
CODE:
p = float(input("Enter the Principal amount:"))
time = float(input("Enter the Time period [in years]:"))
if time > 10:
print((p*0.08*time)/100, "is your simple interest.")
else:
print((p*0.12*time)/100, "is your simple interest.")
Here, we've made use the of the IF - ELSE conditional statement.
Once the user inputs the number of years, it checks if the value is greater than 10. If it is true, it runs the IF part. If it isn't greater than 10, the ELSE part gets executed.
The IF - ELSE statement can be used to check for validation of a statement.
Similar questions