Udit Vashisht
Author: Udit Vashisht


Chapter 3 - Executing a Python Script

Chapter 3 - Executing a Python Script

  • 2 minutes read
  • 86 Views
Chapter 3 - Executing a Python Script

In our previous chapter, we have strongly recommended you to ditch IDLE and use some code-editor and terminal(MacOS/Linux) or Powershell(Windows) to write and execute your python script. In this chapter we will tell you how to do that.

First and foremost for the purpose of this tutorial, create a new directory say ‘python_for_beginners’ at your desired location.

$ mkdir python_for_beginners

Now let’s create a new file in this folder and name it ‘hello_world.py’. Open that file in the editor you are using and write down the following code and save it:-

print("hello world!")

Now open your terminal and cd to the ‘python_for_beginners’ folder. Alternatively on MacOS you can right click on the folder and select ‘New Terminal at Folder’. To run the script you will have to write:-

$ python hello_world.py

and you will get the output like this:-

hello world!

SaralGyaan_learn_python_in_hindi_for_absolute_beginners.png

saralgyaan_learn_python_for_absolute_beginners_in_hindi.PNG

Note- Some of the users probably on MacOS might need to use python3 instead of python to run the script in Python 3 version, though I will be using python in my tutorial, but I urge you to check you version and use python3 or python accordingly.

If you have any question till now, feel free to ask in the comment section.

Table of Contents

Chapter 2 - Quick Setup

Chapter 4 - Print function



Related Posts

Plot Time Series in Python | Matplotlib Tutorial | Chapter 8
By Udit Vashisht

Plot Time Series in Python using Matplotlib

Plot Time Series in Python | Chapter 8

In this tutorial we will learn to plot time series data in Python using Matplotlib. We will also be using pandas dataframe to plot time series data in python from ...

Read More
Python Histograms | Matplotlib Tutorial in Python | Chapter 6
By Udit Vashisht

Matplotlib Tutorial in Python

Python Histograms | Chapter 6

A Python Histogram/Matplotlib Histogram is an accurate representation of the distribution of numerical data. Bar graphsrelates to two variables, however a Python Histogram relates to only one variable and shows it distribution in different range of the ...

Read More
How to host and schedule your python script on PythonAnywhere?
By Udit Vashisht

In our last post here, we learned how to create a python script which will automatically delete your messages from gmail account based on a query.

The complete ready-to-use code can be found here.

Follow the steps in the above tutorial to download the ‘credentials.json’ file and ...

Read More
Search