Write a function that takes a list of dollar values separated by commas, converts each number from dollars to pounds (at an exchange rate 0.667 dollars per pound) and prints the results in a com- ma-separated list. Each converted value should have the £ symbol in front of it. This symbol can be obtained by passing the ASCII value of the symbol 156 to the chr function, which returns a string
composed of that character. Ambitious programmers can attempt to do the conversion all in one statement.
What will be an ideal response?
```
# Convert comma-separated list of dollar values to comma-
# separated list of pound values.
# convert dollar value to pounds
def convertToPound( dollar ):
return chr( 156 ) + str( dollar / 0.667 )
dollars = raw_input( \
"Input comma-separated list of dollar values: " )
dollars = dollars.split( "," )
poundsList = []
for dollar in dollars:
pounds = convertToPound( float( dollar ) )
poundsList.append( pounds )
print "List of values in pounds: %s " % ",".join( poundsList )
```
Input comma-separated list of dollar values: 8, 16, 12
List of values in pounds: £11.9940029985,£23.988005997,
£17.9910044978
You might also like to view...
Information in a PivotTable report can be made easier to read by visually separating the data using ________
Indicate whether the statement is true or false.
Which light property controls the amount of surface reflection on the lighted surface?
A. Gloss B. Material C. Ambience D. Exposure