A bit about me:
- I am studying Computing and IT at the Open University
- I live in the UK
- I am 44 years old (yes, quite old for a student, actually in the process of changing careers)
- I am quite geeky, enjoying Sci-Fi, Fantasy, dinosaurs, natural history and military history
- Windows 10 on a desktop as OS
- IDLE as shell/environment
- Python 3.5 as current version
#!/usr/bin/python
This means should the script find itself on a Linux system, it has a chance of actually running (that line is ignored by the Python interpreter but tells the Unix shell what program is used to run it).
As I save my Python scripts to my Dropbox folder, crossing between operating systems is a possibility.
Note to self - ought to start changing that header to
#!/usr/bin/python3
When I was first looking at Python on Linux, I used the default version, which is Python 2.7. Then I switched to Windows and downloaded IDLE and Python for Windows - that shifted me unexpectedly to Python 3.x - mostly the same but with enough differences that I need to be careful which script is for which version.
Very simple. About as minimal as you can get. And the output is traditional for first programs.#!/usr/bin/python# comments hereprint ("Hello World")
Note that in Python the hash sign # is for comments, and anything after it on the same line is not interpreted by Python.
Also print in Python 3.5 requires round brackets (parentheses)
The results when I run it in IDLE are:
>>>It works!!
RESTART: C:\Users\John\Dropbox\Misc Programming\Python\python3\test01_hello_world.py
Hello World
>>>
No comments:
Post a Comment