
Doug C. answered 01/22/17
Tutor
5.0
(1,554)
Math Tutor with Reputation to make difficult concepts understandable
Hi Maximilian,
So do you have a book that teaches you Python? You can also do "google" searches to help locate sample code. I will get you started.
For example her is a snippet from a google search result:
'''Conversion of strings to int before addition'''
xString = input("Enter a number: ")
x = int(xString)
yString = input("Enter a second number: ")
y = int(yString)
print('The sum of ', x, ' and ', y, ' is ', x+y, '.', sep='')
xString = input("Enter a number: ")
x = int(xString)
yString = input("Enter a second number: ")
y = int(yString)
print('The sum of ', x, ' and ', y, ' is ', x+y, '.', sep='')
That shows you how to capture the original price, converting to integer.
For your purposes let's say you captured in the variable: orig.
The original price is reduced by 20%. Another way to say that is 80% of the original is what the new price will be.
So, newprice = .8 * orig
Now calculate the commission:
commission = .05 * newprice
The brokerage gets 1/2 of the commission:
broker = .5 * commission
And Peggy gets 1/2 of that:
peggy = .5 * broker
As far as printing the output, you will be using a print statement for the reduced selling price and Peggy's commission. Perhaps you can print on one line (or two separate if you want). But you have to figure out how to format it with a $ sign and two decimal places. Let's have you research how to do that.

Doug C.
Hi Max,
First note that "int" is only required to convert the input string to an integer. After that you do not have to use int.
So, you 2nd line becomes:
discopr = .8 * origpr
Here is what I came up with regarding formatting the output:
import locale
locale.setlocale(locale.LC_ALL,"")
'en_US.UTF-8'
currency_symbol = locale.localeconv()['currency_symbol']
locale.setlocale(locale.LC_ALL,"")
'en_US.UTF-8'
currency_symbol = locale.localeconv()['currency_symbol']
....
print ("New Price: " + currency_symbol + locale.format("%.2f", newp, 1)) # insert commas
Here is some output from the program I wrote:
C:\Python34>python peggy.py
New Price: $25,919.90
Peggy's Commission: $324.00
New Price: $25,919.90
Peggy's Commission: $324.00
For the above my origp was
orig = 32399.87
I have not done a complete validation of the code, but this should give you the idea.
Report
01/22/17

Doug C.
Also found this, but did not try it (looks cleaner):
>>> import locale
>>> locale.setlocale( locale.LC_ALL, '' )
'English_United States.1252'
>>> locale.currency( 188518982.18 )
'$188518982.18'
>>> locale.currency( 188518982.18, grouping=True )
'$188,518,982.18'
>>> locale.setlocale( locale.LC_ALL, '' )
'English_United States.1252'
>>> locale.currency( 188518982.18 )
'$188518982.18'
>>> locale.currency( 188518982.18, grouping=True )
'$188,518,982.18'
Report
01/22/17
Maximilian S.
origpr = input('what is the original price')# original full price
discopr = int(origpr * 0.80) #answer to the property sells when reduced by 20%
comish = int(discopr * 0.05#newprice times .05
broker = int(broker *.5)#brokers half the comission
peggy = int(broker *.5) #peggys comissih
print 'the discounted price is $'+format(discopr,'.2f')#print the reduced
print 'peggys commission is $'+format(peggy,'.2f')#Peggy’s commission
01/22/17