Nov-09-2016, 09:17 PM
Hello,
I've learnt the absolute basics of python and I am writing a script for my computing homework. The idea is that it asks you to think of a number between 1 and 10, before asking you to double it, add 10, halve it and take away the number you started with. Because it goes through the sequence n --> 2n --> 2n + 10 --> n + 5 --> 5 the computer can tell you the number you are thinking of, that is 5. Here is what I've tried so far, could anyone find where I went wrong and why it isn't working?
I've learnt the absolute basics of python and I am writing a script for my computing homework. The idea is that it asks you to think of a number between 1 and 10, before asking you to double it, add 10, halve it and take away the number you started with. Because it goes through the sequence n --> 2n --> 2n + 10 --> n + 5 --> 5 the computer can tell you the number you are thinking of, that is 5. Here is what I've tried so far, could anyone find where I went wrong and why it isn't working?
number=(input("Think of a number between 1 and 10. Reply with an Ok when you have it.")) if number==Ok: nextstep==(input("Double it, then add 10 ")) else print("Must try harder ...") if nextstep==Ok: stepafterthat==(input("Halve it")) else print("Must try harder") if stepafterthat==Ok: laststep==(input("Take away the number you started with.")) else print("Must try harder ...") if laststep==Ok: print("You are thinking of 5!") else print("Must try harder ...")