Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword or section
Like this
0 of .
Results for:
No results containing your search query
P. 1


Ratings: (0)|Views: 140|Likes:
Published by Dragoljub Zivanovic

More info:

Categories:Types, Brochures
Published by: Dragoljub Zivanovic on Jan 31, 2013
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Full Circle Magazine is neither affiliated, with nor endorsed by, Canonical Ltd.
Full Circle Magazine SpecialsFull Circle Magazine
The articles contained in this magazine are released under the Creative Commons Attribution-Share Alike 3.0Unported license. This means you can adapt, copy, distribute and transmit the articles but only under the following conditions:You must attribute the work to the original author in some way (at least a name, email or URL) and to this magazine by name ('full circle magazine') andthe URL www.fullcirclemagazine.org (but not attribute the article(s) in any way that suggests that they endorse you or your use of the work). If you alter,transform, or build upon this work, you must distribute the resulting work under the same, similar or a compatible license.
Full Circle Magazine is entirely independent of Canonical, the sponsor of Ubuntu projects and the views and opinions in the magazine should in noway be assumed to have Canonical endorsement.
Please note:
this SpecialEdition is provided withabsolutely no warrantywhatsoever; neither thecontributors nor Full CircleMagazine accept anyresponsibility or liability forloss or damage resulting fromreaders choosing to apply thiscontent to theirs or otherscomputers and equipment.
About Full Circle
Full Circle is a free,independent, magazinededicated to the Ubuntufamily of Linux operatingsystems. Each month, itcontains helpful how-toarticles and reader-submitted stories.Full Circle also features acompanion podcast, the FullCircle Podcast which coversthe magazine, along withother news of interest.
Welcome to another 'single-topic special'
In response to reader requests, we are assembling thecontent of some of our serialised articles into dedicatededitions.For now, this is a straight reprint of the series
'Programming in Python', Parts 1-8
from issues #27through #34; nothing fancy, just the facts.Please bear in mind the original publication date; currentversions of hardware and software may differ from thoseillustrated, so check your hardware and software versionsbefore attempting to emulate the tutorials in these specialeditions. You may have later versions of software installedor available in your distributions' repositories.
Find Us
#fullcirclemagazine onchat.freenode.net
Editorial Team
Editor: Ronnie Tucker(aka: RonnieTucker)ronnie@fullcirclemagazine.orgWebmaster: Rob Kerfia(aka: admin / linuxgeekery-admin@fullcirclemagazine.orgPodcaster: Robin Catling(aka RobinCatling)podcast@fullcirclemagazine.orgCommunications Manager:Robert Clipsham(aka: mrmonday) -mrmonday@fullcirclemagazine.org
full circle magazine #27
contents ^
HOW-TOProgram In Python - Part 1
mong the manyprogramminglanguages currentlyavailable, Python isone of the easiest to learn.Python was created in the late1980's, and has maturedgreatly since then. It comes pre-installed with most Linuxdistributions, and is often oneof the most overlooked whenpicking a language to learn.We'll deal with command-lineprogramming in this article. Ina future one, we'll play with GUI(Graphical User Interface)programming. Let's jump rightin, creating a simpleapplication.
Our First Program
Using a text editor such asgedit, let's type some code. Then we'll see what each linedoes and go from there. Type the following 4 lines.
#!/usr/bin/env pythonprint 'Hello. I am a pythonprogram.'name = raw_input("What isyour name? ")print "Hello there, " + name+ "!"
 That's all there is to it. Savethe file as hello.py whereveryou would like. I'd suggestputting it in your homedirectory in a folder namedpython_examples. This simpleexample shows how easy it isto code in Python. Before wecan run the program, we needto set it to be executable. Dothis by typing
chmod +x hello.py
in the folder where you savedyour python file. Now let's runthe program.
./hello.pyHello. I am a pythonprogram. What is your name? FerdBurphelHello there, Ferd Burphel!greg@earth:~/python_examples$
 That was simple. Now, let'slook at what each line of theprogram does.
#!/usr/bin/env python
 This line tells the systemthat this is a python program,and to use the default pythoninterpreter to run the program.
print 'Hello. I am a pythonprogram.'
Simply put, this prints thefirst line "Hello. I am a pythonprogram." on the terminal.
name = raw_input("What isyour name? ")
 This one is a bit morecomplex. There are two partsto this line. The first is name =,and the second israw_input("What is your name?"). We'll look at the second partfirst. The command raw_inputwill print out the prompt in theterminal ("What is your name?"), and then will wait for theuser (you) to type something(followed by {Enter}). Nowlet's look at the first part: name=. This part of the commandassigns a variable named"name". What's a variable? Think of a variable as a shoe-box. You can use a shoe-box tostore things -- shoes, computerparts, papers, whatever. To theshoe-box, it doesn't reallymatter what's in there -- it's just stored there. In this case, itstores whatever you type. Inthe case of my entry, I typedFerd Burphel. Python, in this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->