Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is my syntax in python: def main(): developerInfo() #unit price unit_price = 99 #user purchase user_unit_purchase = int(input('Number of units purchased is:')) #discount rate

This is my syntax in python:

def main(): developerInfo() #unit price unit_price = 99

#user purchase user_unit_purchase = int(input('Number of units purchased is:')) #discount rate for different conditions if user_unit_purchase < 10: discount = '0%' elif user_unit_purchase < 20: discount = '20%' elif user_unit_purchase < 50: discount = '30%' elif user_unit_purchase < 70: discount = '35%' elif user_unit_purchase < 100: discount = '40%' else: discount = '50%'

#subtotal of the price subtotal_user = user_unit_purchase * unit_price discount_apply = discount * subtotal_user total_final = subtotal_user - discount_apply

#print the result print ( 'Discount applied is: ', discount) print ( 'Total saving due to discount is: ', format(discount_apply,',.2f'),sep='') print ( 'The total cost of the purchase is: ', format(total_final,',.2f'),sep='')

And it said has this problem: File "/Users/shadi/Downloads/programming 5 (1).py", line 60, in main total_final = subtotal_user - discount_apply TypeError: unsupported operand type(s) for -: 'int' and 'str'

My professor insistent me to use 35% in the coding, and he said: " Percentage is not displayed as .35 its 35%." how should i change my syntax?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions