Udit Vashisht
Author: Udit Vashisht


Chapter 3 - Executing a Python Script

Chapter 3 - Executing a Python Script

  • Feb. 4, 2019, 12:12 p.m.
  • 2 minutes read
  • 81 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

Python Candlestick Chart | Matplotlib Tutorial | Chapter 11
By Udit Vashisht | 1 month, 3 weeks ago

Python Candlestick Chart in Matplotlib

Python Candlestick Chart | Chapter 11

A candlestick chart or Japanese candlestick chart is a financial chart used to depict the price movement of securities, derivatives etc. in financial market. In this tutorial we will use Python to plot Candlestick Chart.

A Candlestick Chart ...

Read More
Python Histograms | Matplotlib Tutorial in Python | Chapter 6
By Udit Vashisht | 2 months, 2 weeks ago

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
If __name__ == '__main__' in Python
By Udit Vashisht | 2 months, 3 weeks ago

What does if __name__ == ‘__main__‘in python means?

In python, you must have come accross the following code :-

if __name__ == '__main__': main() 

In this tutorial, we will learn in detail what does the above statement means. As per official documentation:

‘__main__‘ is the name of the ...

Read More
Search