Main Menu

friends

Latest articles

Hello World in BASH
01/11/2009 | mad mad mod

This article describes how to write and execute a "Hello World" bash script on Linux (Fedora).  1. the prerequisitesa text editor of your choice (e.g. vi)the bash shell
make sure you have installe [ ... ]


Upgrade your Fedora System to a new major release with preupgrade
08/03/2011 | mad mad mod

If you plan to upgrade your Fedora system to the latest release, you should have a look at PreUpgrade. It downloads all the necessary packages required to upgrade to a newer release of Fedora.I upgrad [ ... ]


Other Articles
Facebook MySpace Twitter Digg Delicious Stumbleupon Google Bookmarks 

Designed by:
SiteGround web hosting Joomla Templates
Hello World in python E-mail
programming

This article describes how to write and execute a "Hello World" program in Python on Linux (Fedora).

 

1. the prerequisites

  • a text editor of your choice (e.g. vi)
  • a python interpreter


make sure you have installed the python rpm:

# rpm -qa python
python-2.5.1-26.fc8.2

 

If it is not installed yet, you can install it with yum (you need to be root to do that):

# yum install python

 

 

 

2. write the code


open an empty file with a text editor (e.g. vi):


# vi helloworld.py



now write the following code into the sourcefile:


#!/usr/bin/python
print "Hello World!";


save the file and exit vi with ":wq + enter"

 

explanation


#!/usr/bin/python

This tells the system to use the /usr/bin/python interpreter to execute the script. You can find out the full path of your python interpreter by entering the following command:


# which python
/usr/bin/python





print "Hello World!";

This prints out the string "Hello World!".

 

 

 

3. make the script executable



# chmod u+x helloworld.py




4. run the program


you can now execute the script program with:


# ./helloworld.py
Hello World!

 

- or -

 


# python helloworld.py

Hello World!

 

 

Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

 
mad mad mod, Powered by Joomla! and designed by SiteGround web hosting