<< Chapter < Page Chapter >> Page >

The>>>that you see on the last line is the Python interactive prompt, which I will refer to simply as the prompt.

Program comments

Before we go any further, I need to introduce you to the concept of program comments .

In programming jargon, a comment is text that you insert into the program that is intended for human consumption only. Comments provide a quick and easyform of documentation. They are ignored by the computer and are intended to explain what you are doing.

How useful are comments ?

Comments aren't terribly useful when doing interactive programming. Presumably you already know what you are doing and don't need to explain it toyourself using comments.

However, comments are very useful when you are writing scripts that you will store in files and use again later after you have forgotten how you did what youdid.

In these modules, I will use comments occasionally to explain what I am doing for your benefit, even in interactive mode.

A Python comment

According to the Python Language Reference -- 2.1.3 Comments :

"A comment starts with a hash character (#) that is not part of a string literal, and ends at the end of the physical line.A comment signifies the end of the logical line unless the implicit line joining rules are invoked. Comments are ignored by the syntax; they are not tokens."

Figure 2 shows a Python comment, taken from the Python command-line interface, along with a new kind of prompt.

Figure 2 . A Python comment.
>>># This is a comment ...

Using the interactive mode

What is that ... prompt ?

The interactive mode actually uses two different kinds of prompts.

  • One is>>>
  • The other is ...

I will explain the difference a little later For now, just pretend like they both mean the same thing. That will suffice until we get into morecomplicated material.

The sum of 2 and 5

Enter 2+5 at the prompt in the IDLE GUI interface and press the Enter key. You should see something like Figure 3 on your screen.

Figure 3 . The sum of 2 and 5.
>>># This is a comment in Python GUI shell>>>2+5 7>>>

Input and output

We need to differentiate between input and output. Everything that appears on a line with one of the prompts is input to the Pythoninterpreter. (You typed it, so you know that it is input.)

Everything that appears on a line without a prompt is output from the interpreter. (You didn't type it. The interpreter produced it, so it was output.)

What was the input in this case ?

Your input was the expression 2+5.

What was the output ?

Python evaluated that expression and produced an output, which was the sum of 2 and 5, or 7.

Then Python presented you with a new prompt to allow you to provide more input.

Mixing comments and expressions

Now using the Python command-line window, try entering the comment, followed by the expression that you see in Figure 4 , and note the difference in the prompts as compared to Figure 3 ..

Figure 4 . Mixing comments and expressions on the command line interface.
>>># This is a comment in Python command-line interface ... 2+57>>>

My only reason for showing you this at this time is to give you some experience in mixing comments and expressions and to attempt to explain thedifference between the>>>prompt and the ... prompt.

Questions & Answers

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Itse 1359 introduction to scripting languages: python. OpenStax CNX. Jan 22, 2016 Download for free at https://legacy.cnx.org/content/col11713/1.32
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Itse 1359 introduction to scripting languages: python' conversation and receive update notifications?

Ask