Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Decimal places

My teacher has asked me to "Display all amounts in currency format with the $ sign right up against the first digit and two decimal places."

The code is:
Code
# program2_3.py
# by Will Patterson (SPC ID: 209479)

# Prompt user for the value of Kenny's estate
# For Stan, divide the value by 1/2
# For Kyle, use the value of Stan and multiply it by 0.66666666666
# For Butters & Wendy, take the estate value and then subtract the total of Kyle and Stan's total value.
# Take Kyle & Stan's subtracted value from the value of Kenny's Estate then divide it by 2.
# Print out each of there values

def main():
    # get the users input for the value of Kenny's estate.
    estate = float(input("What is the value of Kenny's estate?: "))
    # divide the value by 2 (1/2)
    stan = (estate) / 2
    # multiply Stan's value by 0.66666666666 (2/3)
    kyle = (stan * 2/3)
    # add the total the value of Stan & Kyle then subtract it from the estate value
    sk = estate - (stan + kyle)
    # divide the total of the variable sk by 2
    bw = (sk) / 2
    # print out Stan
    print('Stan receives a total of: $'+str(stan))
    # print out Kyle
    print('Kyle recieves a total of: $'+str(kyle))
    # print out Butters & Wendy's total
    print('Butters and Wendy each get $'+str(bw))

main()

How would I do what he asked?
like that

PHP Code

<?php 
def main
():
    
# get the users input for the value of Kenny's estate.
    
estate = float(input("What is the value of Kenny's estate?: "))
    print(
'Kenny\'s estate value is: ${0:.2f}'.format(estate))
    
# divide the value by 2 (1/2)
    
stan = estate / 2
    
print('stan\'s estate value is: ${0:.2f}'.format(stan))
    
# multiply Stan's value by 0.66666666666 (2/3)
    
kyle = (stan * 0.66666666666)
    print(
'Kyle\'s estate value is: ${0:.2f}'.format(kyle))
    
# add the total the value of Stan & Kyle then subtract it from the estate value
    
sk = estate - (stan + kyle)
    
# divide the total of the variable sk by 2
   
main() 
Knowledge is Power - Be Powerful!!!!!


LIFE IS A CHALLENGE SO ACCEPT IT!
https://docs.python.org/3/library/string...t-examples
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by coreqtNov 6, 2016 08:45 AM 3 132 Nov 6, 2016 08:45 AM
Last Post: Stealth™
[Python] by billybluiceezOct 28, 2016 04:58 PM 6 208 Oct 28, 2016 04:58 PM
Last Post: billybluiceez
[C] by D_MuLaSep 18, 2016 04:38 PM 15 476 Sep 18, 2016 04:38 PM
Last Post: Dostoevsky