How do you convert user input data collected as an integer into a percentage and then have that converted percentage data into a running sum total stored in a variable? I need the "Tax percentage to be collected" input data converted into a percent and somehow added to the "t" variable.
Here is how I am collecting the data:
b = 0
b += int(input("Acquisition cost?"))
b += int(input("Misc Expenses?"))
t = 0
t += int(input("Processing fee"))
t += int(input("Tax percentage to be collected"))
s = 0
s += int(input("Sell price?"))
net_profit = (b + t) - s
cost_to_buyer = s + t
Again, I need the "Tax percentage to be collected" input question data that is collected as an integer converted to a percent and added to the running total "t" variable.
First I'd start out by making the code more readable:
acquisition_cost = int(input("Acquisition cost?"))
expenses = int(input("Misc Expenses?"))
total_cost = acquisition_cost + expenses
tax = int(input("Processing fee"))
# Is this what you were looking for?
tax_band = float(input("Tax percentage to be collected"))/100
total_tax = tax * tax_band
sell_price = int(input("Sell price?"))
net_profit = (total_cost + total_tax) - sell_price
cost_to_buyer = sell_price + total_tax
You could use something like :
t *= 1+int(input("Tax percentage to be collected"))/100
Example
t = 0
t += int(input("Processing fee")) # input 100
t *= 1+int(input("Tax percentage to be collected"))/100 # input 5
print(t) # result 105.0
Do you mean
t = 0
t += int(input("Processing fee"))
t += t / 100 * int(input("Tax percentage to be collected"))
? I'm not sure if I fully understand your question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.