Aug-14-2019, 12:35 PM
One thing to ask from yourself - is your objective to meet deadline and move on with your life or learn to program?
If first then (based on your moral values) cheating is an option. However, if you intend to learn to program then you should start yourself from scratch.
jefsummers provided one way how to split 'big task' into smaller chunks. It doesn't matter if you use this or create your own 'algorithm' - you have to solve all these small tasks one after another.
Just and idea:
You should test your code as you go. For beginner 'testing' means that you write small chunk of code, run it and observe if it's working as expected. If so you add new lines of code and repeat.
Write code into .py file, run it from terminal in interactive mode and check whether all names, values etc are as you excpect them to be. You should be able to understand error messages as well.
Lets write two first lines of code into file (guessing_game.py) and observe what happens:
This will run the file and keep Python interactive session alive. But in this case it doesnt matter. You will see:
Instead of .py file and terminal one can use Jupyter Notebook / JupyterLab.
If first then (based on your moral values) cheating is an option. However, if you intend to learn to program then you should start yourself from scratch.
jefsummers provided one way how to split 'big task' into smaller chunks. It doesn't matter if you use this or create your own 'algorithm' - you have to solve all these small tasks one after another.
Just and idea:
You should test your code as you go. For beginner 'testing' means that you write small chunk of code, run it and observe if it's working as expected. If so you add new lines of code and repeat.
Write code into .py file, run it from terminal in interactive mode and check whether all names, values etc are as you excpect them to be. You should be able to understand error messages as well.
Lets write two first lines of code into file (guessing_game.py) and observe what happens:
import random player_win == FalseNow from terminal cd into directory where your guessing_game.py is. Then enter:
python -i guessing_game.py
(or python3 or something else depending how Python is set up on your computer)This will run the file and keep Python interactive session alive. But in this case it doesnt matter. You will see:
Output:Traceback (most recent call last):
File "guessing_game.py", line 4, in <module>
player_win == False
NameError: name 'player_win' is not defined
What did happen? You check whether player_win is False. As player_win is not defined you will get NameError. If you intend to assing False to player_win then you should write player_win = False
. If you make changes in file and run it again then nothing happens except Python interactive prompt appears in terminal. You can check the value of player_win:>>> player_win FalseNow you take next step and repeat process until you have working code.
Instead of .py file and terminal one can use Jupyter Notebook / JupyterLab.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.