First Python Program (Script Mode)

First Python Program (Script Mode)

In this lesson, we will learn how to run our first Python program using script mode. Previously we saw how to run python program using Interactive Mode.

Create a folder in any of your directory. Here all the python programs will get stored. We have created a folder, MyPython  and the directory is D:

Now you need to create a .py extension file to save your code in it.

But, before creating a text file with the extension .py, let us set the folder (MyPython) path.

Set Path for project folder in Python

To set the above shown folder path, go to Start, and type Environment Variables, click Edit the system Environment Variables. 

Now, you will reach the System Properties dialog box.

Click Environment Variables, then a new dialog box will open.

Environment Variables for Python


Click Edit after selecting Path variable or you can also double click Path and add the D:/MyPython path in it like the following:

Path set for Python

Press Save for all the three dialog boxes and our folder path will set successfully.

Now create a text file and save it as .py, since python code gets saved in the same extension. Our file is named, and saved in the same folder, MyPython,

Python file location

Add the following demo code and save it,

Now go to Command Prompt and reach the following path,

Open cmd and reach Python folder location

Now type the following and press enter to get the output,

The following is the output,

Python script mode code example

We learned how to run our first program.

In the upcoming lessons, we will follow the same Script Mode approach.

First Python Program (Interactive Mode)
Python Variables
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create free tutorials for all.

No Comments

Post A Comment