Python Classroom image

Anil  Bist / Professional / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9|Last
Lessons:-INTRODUCTION

1.2. THE PYTHON INTERPRETER AND IDLE, PART I 7
examples. The local file to open in your browser in in handsonHtml folder you unzipped and the
main web page file to open is called handson.html.
• The PDF version of the tutorial for printing http://cs.luc.edu/anh/python/hands-on/3.0/
handson.pdf.
The disadvantage of a local copy is that the tutorial may be updated online after you get your download.
The change log file http://www.cs.luc.edu/~anh/python/hands-on/changelog.html will show when the
latest update was made and a summary of any major changes.
1.2.2. Running A Sample Program.
This section assumes Python, version at least 3.1, is already on your computer. Windows does not come
with Python. (To load Python see Section 1.1.2) On a Mac or Linux computer enough of Python comes
installed to be able to run the sample program.
If you are in a Windows lab with Python 3.1 installed, but not set up as the default version, see the
footnote.1
Before getting to the individual details of Python, you will run a simple text-based sample program.
Find madlib.py in your Python folder (Section 1.2.1).
Options for running the program:
• In Windows, you can display your folder contents, and double click on madlib.py to start the
program.
• In Linux or on a Mac you can open a terminal window, change into your python directory, and
enter the command
python madlib.py
The latter approach only works in a Windows command window if your operating system execution path is
set up to find Python.
In whatever manner you start the program, run it, responding to the prompts on the screen. Be sure to
press the enter key at the end of each response requested from you.
Try the program a second time and make different responses.
1.2.3. A Sample Program, Explained. If you want to get right to the detailed explanations of
writing your own Python, you can skip to the next section 1.2.4. If you would like an overview of a working
program, even if all the explanations do not make total sense yet, read on.
Here is the text of the madlib.py program, followed by line-by-line brief explanations. Do not worry if
you not totally understand the explanations! Try to get the gist now and the details later. The numbers on
the right are not part of the program file. They are added for reference in the comments below.
""" 1
String Substitution for a Mad Lib 2
Adapted from code by Kirby Urner 3
""" 4
5
storyFormat = """ 6
Once upon a time, deep in an ancient jungle, 7
there lived a {animal}. This {animal} 8
liked to eat {food}, but the jungle had 9
very little {food} to offer. One day, an 10
explorer found the {animal} and discovered 11
it liked {food}. The explorer took the 12
{animal} back to {city}, where it could 13
eat as much {food} as it wanted. However, 14
the {animal} became homesick, so the 15
1If an earlier version of Python is the default in your lab (for instance Python 2,6), you can open the examples folder and
double-click on the program default31.cmd. This will make Python 3.1 be the default version until you log out or reboot. This
is only actually important when you run a Python program directly from a Windows folder. You will shortly see how to start
a program from inside the Idle interactive environment, and as long as you run all your programs inside that environment, the
system default version is not important.

 
 
 
image
Anil  Bist

Skills    Python

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)