Introduction to Python – Say Hello World!

Why this category?

Now-a-days we do not have much time to spend for repeated works. We all are busy with learning new things. And we required some automation tools to reduce the work load and save the time. Python is a good and simple language for this purpose. Bookmark the Index page and read more about Python.

If you are a system administrator, it is likely that you have encountered Perl, Bash, or some other scripting language. You may have even used one or more yourself. There are a lot of websites available on internet to study Python. Most of them have a lot of things to read and study.

Here in Crybit.com, going to introduce Python along with Linux command line tools & examples which will be helpful for Linux SysAdmins. You can directly integrate Python with your Shell, LOL!!

I also try to compare Python with Bash.

Okay lets start with “Hello World!” scripts..

Here, the command line tool we used to compute the script is “ipython.” By using “ipython” you can simply test your Python scripts before executing it on your production server.

How to install ipython on CentOS?

The installation is simple. You can simply install it using YUM. Please see the snippet pasted below:

yum install ipython

Now you can use the command “ipython” to enter into the interface.

See the example pasted below:

ipython

Here we go!

First we are going o print the string “Hello World!” as we are thinking this is the first code in programming!! LOL 😛

To print something in Python, you can use “print” option in your code:

To execute in your Shell as .py script, please do the following steps:

Step 1 : SSH to server.
Step 2 : Create a file with extension “.py”
Step 3 : Make sure the file has executable permission.

chmod +x filename.py

Step 4 : Add the following code into it.

#!/usr/bin/python

print "Hello World!"

Step 5 : Execute the file.

python filename.py

As you all know, we use the command “echo” instead of print.
That’s it!

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

One thought on “Introduction to Python – Say Hello World!

Leave a Reply

Your email address will not be published. Required fields are marked *