Python Programming (136 Blogs) Become a Certified Professional
AWS Global Infrastructure

Data Science

Topics Covered
  • Business Analytics with R (26 Blogs)
  • Data Science (20 Blogs)
  • Mastering Python (86 Blogs)
  • Decision Tree Modeling Using R (1 Blogs)
SEE MORE

How To Run A Python Script?

Last updated on Nov 27,2019 2.5K Views


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.

installation-how to run a python program-edureka

  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.

installation-how to run a python program-edureka

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

.py file-how to run a python program-edureka

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

how to run a python program-edureka

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.

  • Running a program in IDLE

Idle-how to run a python program-edureka

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.

idle-how to run a python program-edureka

  • Running a program in Pycharm

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.

pycharm-how to run a python program-edureka

  • Running a program in jupyter notebook

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

jupyter-how to run a python program-edureka

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 30th November,2024

30th November

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

Class Starts on 28th December,2024

28th December

SAT&SUN (Weekend Batch)
View Details
Comments
0 Comments

Join the discussion

Browse Categories

webinar REGISTER FOR FREE WEBINAR
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP

Subscribe to our Newsletter, and get personalized recommendations.

image not found!
image not found!

How To Run A Python Script?

edureka.co