[Tutor] Coding

Awais Idris 2010-3902 at slougheton.com
Sun Dec 7 16:27:42 CET 2014


Hi there, I'm currently in secondary school yr 11 studying the computing
course and I've been set a task in creating a vending machine code. I found
some coding online and I have changed some of it, but it still doesn't
work. I think theres a problem with the loops and a few other things that I
cant put my finger on. I was wondering if you could help me by fixing the
code for me. this would be a massive help.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141207/7ee61580/attachment.html>
-------------- next part --------------
##Vending Machine

print ("Welcome to the Awais's Vending Machine\n")

total = 0
drinks = 4
snacks = 4

print ("Prices: Drinks: £4, Snacks: £4\n")
print ("If you want to be surprised, and have a random choice, type: 'random'\n")

Drinks = {'Coke','Sprite','Water'}
Snacks = {'Hershey', 'Snickers','Twix','Maltesers','Crisps'}



print (Drinks)
print (Snacks)




FirstChoice = input ("Enter the item of your choice: ")  ##First Choices
if FirstChoice == 'Coke' or 'Pepsi' or 'Water':
    print ("That will be a total of £",drinks)
    
elif FirstChoice == 'Hershey' or 'Snickers' or 'Twix' or 'Maltesers' or 'Crisps':
    print ("That ^will be a total of £",snacks)
else:
    print ("****er")


SecondChoice = input ("Would you like anything else? Yes/No ")  ##Second Choices
if SecondChoice == "Yes" or "yes":
    print (Drinks)
    print (Snacks)
    if SecondChoice == (Drinks):
        print ("That will be a total of £",drinks)
    elif SecondChoice == (Snacks):
        print ("That will be a total of £",snacks)
else:
    print ("****er")

if SecondChoice == "no" or "No":
    print ("Excellent! Have a good day!") 





More information about the Tutor mailing list