In: Computer Science
python
Create a new file name condition_quiz.py.
Add a comment with your name and the date.
Prompt the user to enter the cost. Convert the input to a float.
Prompt the user for a status. Convert the status to an integer
Compute the special_fee based on the status.
If the status is 0, the special_fee will be 0.03 of the cost.
Else if the status is 1, the special_fee will be 0.04 of the cost.
Else if the status is 2, the special_fee will be 0.06 of the cost.
Else if the status is 3 or 4, the special_fee, the discount will be 0.07 of the cost.
Otherwise, the special_fee will be 0.10 of the cost.
Compute the total_cost as the cost plus the special_fee. Print out the total_cost with two decimal places of precision.
code :
output :
raw_code :
#taking inputs
cost = float(input('Enter the cost : '))
status = int(input('Enter the status :'))
#checking for given conditions
if(status==0):
special_fee = 0.03*cost
elif(status==1):
special_fee = 0.04*cost
elif(status==2):
special_fee = 0.06*cost
elif(status == 3 or status==4):
special_fee = -0.07*cost
else:
special_fee = 0.10*cost
#printing total cost
total_cost = cost + special_fee
print('Total cost is {:.2f}'.format(total_cost))
***do comment for queries and rate me up****