Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
Python fundamentals (2) — saving Python programs as files
IDLE has a mode in which the user can write multiple lines of code, save them in a file, and execute them whenever he/she chooses. This is, well, pretty handy if you are programming:
Here you can see that I am in a New File (right window)- and that the executed code is running in the left window. Quirk of Python — writing 17 + 9 and 67–14 is absolutely fine; it returns no error message. However it does not display in the shell (also known as the console*) — you need to actually issue Python with a print command in order to see the results of the calculation. So Python will obediently hold onto the results of calculations — possibly storing them in variables or as arrays or something — but will steadfastly keep hold of them until you issue a display command such as print.
The New File window is where you start to really get to grips with the interpreter. An interpreter in a programming language is a facility that allows you to program, save the code, and run the code. An interpreter will work its way through the code line by line, and it will not produce any executable (.exe) object code without any prompting. For that you will need a compiler, but that is for another discussion. Either way, with the New File interpreter, you can start to get to grips with proper programming.
*Nothing to do with Xboxes or PS4s. Unlucky.
Python fundamentals (2) — saving Python programs as files was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.