Latest Awards
Complete 10 python programs which focus on loops.

morgan

Score over 100 points in total

vincebanter10

Complete any 5 python programs

vincebanter10

Complete 3 python list based tasks

vincebanter10

Complete 5 python list based tasks

vincebanter10

Complete 10 python list based tasks

dman12

Score over 1000 points in total

april-logan

Complete any pygame task

april-logan

Complete any 3 pygame tasks

april-logan

You have to complete 5 pygame tasks

april-logan

Score over 500 points in total

sam-edmund

Complete any pygame task

sam-edmund

Complete any 3 pygame tasks

sam-edmund

You have to complete 5 pygame tasks

sam-edmund

Complete any pygame task

12wrigleyf

Complete any 3 pygame tasks

12wrigleyf

You have to complete 5 pygame tasks

12wrigleyf

Score over 500 points in total

jhoughton12

Complete any 10 python prograns

jhoughton12

Complete 10 python programs which focus on loops.

jhoughton12

Python Score
tasks = 0
achivements = 0
freestyle = 0
Total = 0
Top 5 Scores
114gilo 3440
2alexdawkins 2495
3joss-nolan-2 2470
4byrnebrian 2020
512wattsl 1730
Click to view all scores
Who else completed this task?
52 people have completed this task! Below are some of those users!

hulmet harimittal
dman12 12boonhamf
12wattsl april-logan
joe-henry 12campbellm
alexdawkins 14gilo

Do I have enough cash?

Jeepers, this recession is hurting my wallet. I better write a program to see if I can afford some items.

Start off with this code –

c = [1.99, 5.99, 4.50, 12.43, 99.99]
d = ["cookies", "cake", "chocolates", "posh chocs", "very posh chocs"]

a = 0
cash = 5.00
while a < len(c):
    print "Item -",a ,"name", d[a], "costs",c[a]
    a = a + 1
i = raw_input("Which item do you want to buy?")

Finish the code so it will say if you have enough money or not. Also it should say how much you have left if you managed to buy the item.

Sample output


Item - 0 name cookies costs 1.99
Item - 1 name cake costs 5.99
Item - 2 name chocolates costs 4.5
Item - 3 name posh chocs costs 12.43
Item - 4 name very posh chocs costs 99.99
Which item do you want to buy? 2
You can afford chocolates! You will have 0.5 left over

You need to log in or create an account to submit code!

Leave a Reply

You must be logged in to post a comment.