How To Run A Python Script?

Last updated on Nov 27,2019 2.5K Views

How To Run A Python Script?

edureka.co

Python Programming language has become one of the most popular programming language in recent times. It promises results and out of the box features for top notch technological applications in every domain. The need to learn python is evident enough from the number of developers who are switching to python from their respective programming languages. Python is extremely easy to learn due to its easy syntax and readability. In this blog, we will learn how we can run a python script. Following are the topics discussed in this article.

Environment Setup – Installation

To start with python, follow the steps below to install python on your system.

  1. Go to python.org
  2. Download the latest version
  3. Install the setup
  4. Click on the set path checkbox.

Once you complete the above steps, go to command prompt and run the following command.

If you get the similar window, you are good to go.

Hello World Program

One of the salient features of python is its syntax and readability. It becomes extremely easy to write a code in python compared to other programming languages. Following is the simple code for printing hello world in python.


print('hello world')

As you can see, its effortless and almost equivalent to writing a python script in simple English language.

Python Interpreter

The interpreter is a program that we need to run our python code or scripts. It basically provides an interface between the code and the computer hardware to get the results of the code.

No matter in which programming language the code is written, it goes through an interpreter when it comes to python. For example pypy is used to execute the code written in python.

Running A .py File

To understand how we execute a .py file in python. Follow the steps written below.

  1. Make a text file and save it with the name of your choice with an extension .py.
  2. Write the code to print hello world in the .py file and save your file
  3. Open command prompt.
  4. Run the command – python filename.py

There is one more approach to run a python program. We can access the python interactive session using command prompt.

Different IDEs

It becomes slightly different when it comes to different IDEs for python. Running a particular script includes slightly different approach but it is same in terms of code running through an interpreter.

There is one more approach where we make a new file and save it with an extension .py, and the rest of the process is same.

When you are using pycharm, make a python file and write your code. When you are done, run the program and it will execute the code.

You can simply type your code in the block and press run, it will execute your program.

In this blog, we have learnt how we can run a python script. We have learnt about different approaches including interactive python session and running a simple python program in different IDEs like Pycharm and Jupyter notebook. Python programming language is a pinnacle when it comes to data science and machine learning.

With different applications and trending technological advances in the market, it becomes necessary to get familiar with programming languages of tomorrow. To kick-start your learning and to master the skills required to become a python developer, enroll into edureka’s python programming certification program and built the applications of tomorrow.

have any questions? mention them in the comments section, we will get back to you as soon as possible.

Upcoming Batches For Python Programming Certification Course
Course NameDateDetails
Python Programming Certification Course

Class Starts on 28th December,2024

28th December

SAT&SUN (Weekend Batch)
View Details
Python Programming Certification Course

Class Starts on 25th January,2025

25th January

SAT&SUN (Weekend Batch)
View Details
BROWSE COURSES
REGISTER FOR FREE WEBINAR Data Science Applications for Real-World Analysis