How do I make a simple program
Create an executable Python program
To create an executable Python program (Python script), we need a file. The special thing about this file is the file extension. Here ".py" is used for Python.
It doesn't matter which operating system we work with. In the example, the “notepad” editor in the operating system is used under Windows.
The easiest way is to click on Start and then just start typing. As soon as we have typed in the first letters of "editor", we already receive the suggestion for the standard editor.
Select this editor.
And now we can type in our Python program directly in the editor.
In our text editor we enter:
Pay attention to the file extension ".py" when saving! I use “hallowelt.py” as the filename for our first program.
I save my Python program in the folder “python-kurs.de” under “C:”.
Now our folder should have this content:
To start the Python program
Start Python on Windows
To start the Python program, we need a DOS console. We call this up under Windows by clicking on the start button again and simply typing in "cmd". We can then use the suggested DOS console.
If the path has been correctly stored in the operating system when installing Python, you can start Python directly in the DOS console. For testing purposes, Python can be started without our written program. Simply type in “python” directly in the DOS console.
If that works, we can start our Python program "hallowelt.py". For this purpose, the path and the file name are specified after the program has been called.
By executing the program, we now receive the output in the console of "Hello World".
If we don't want to type in the long path name, we can change to the directory once using the DOS instructions and then run the program without specifying the path. Just take a look at the following screenshot. At the beginning the program is executed with the path and then the folder "Python-Kurs.de" is changed (looks like an Internet address, but you can also use it as a directory (a bit of advertising and copy protection)).
Running Python programs with the Mac OSx
On the Mac, we start the terminal. Here we have the special feature that the old version of Python is already delivered in the operating system. We can enter it directly in the terminal and receive the Python version number as a response - in the example this is "Python 2.7.10". If we have installed the current Python3, we can call it up in Terminal and receive the corresponding version number as feedback.
To start our program, we enter the path and the file name in the terminal after the start command for Python:
The program will then be executed.
Recommend • Social Bookmarks • Thank you
- What is your Quora requirement limit
- Why does Guinness take longer to pour?
- What made Jawaharlal join politics?
- Which word means less than mild
- What is the use of capacitor 4
- Was popular with Shakespeare when he was alive
- What is the cheapest cell phone in India
- How to remove a serpentine belt
- What are open online courses for
- What is kernel in the kernel density estimate
- What is automation accounting software
- Which is better city or suburban living
- What are hippos and sharks
- How can I buy my first camera
- What are some air pump suppliers
- How many verticals does Cognizant have
- Is Islamic National Socialism a thing?
- What makes me separate
- What is river degradation
- How applied mechanics helps electrical engineers
- Can I ever be forgiven for cheating?
- How good is a Dell E210882 motherboard
- Google phones overtake the iPhone
- Is Vishwanathan better than Carlsen
- One antibody can act against several proteins
- Have you joined TCS?
- What are the best wedding planning books
- When is it okay to be average?
- Why do markets fail
- Uber is safe for minors
- Is modu Chanyu Turkic
- Is there math on the lsat
- How is Battlestar Galactica like Star Trek