<< Chapter < Page Chapter >> Page >

Command line versus GUI

The text in Figure 4 was produced using the Python (command line) interface. I don't get exactly the same behavior (with respect to prompts) when I use the Python GUI interface. Rather, what I get is shown in Figure 3 . (Note the missing ... prompt.)

The difference between the ... prompt and the>>>prompt is discussed in section 2.1.2. Interactive Mode of The Python Tutorial . (Note that the tutorial is also accessible in a different format from the Start/All Programs/Python 3.4 selection in Windows.)

Apparently the command-line interface creates the ... prompt when it thinks that the next line is a continuation line. The example given in the tutorial isshown in Figure 5 . (Don't be concerned if you don't understand the code in Figure 5 . I will explain similar code in a future module.)

Figure 5 . Example prompts from The Python Tutorial.
>>>the_world_is_flat = True>>>if the_world_is_flat: ... print("Be careful not to fall off!")... Be careful not to fall off!

Apparently for the case of Figure 4 , the system became confused by the comment and treated the line after the comment as a continuation line.

The IDLE GUI did not become confused in Figure 3 . I believe that it accomplishes line continuation by automatically indenting the next line and nocontinuation was required in either Figure 3 or Figure 4 .

Let's get technical

But not too technical. Computer programs are made up of statements.

Statements are composed of expressions.

(Later we will learn that large Python programs are made up of smaller programs called modules, which are made up of statements, which are composed ofexpressions.)

Statement ends at the end of the line

In Python, a statement normally ends at the end of the line that contains it (although there are exceptions to this rule) .

For the time being, suffice it to say that expressions are made up of

  • literal values
  • variables
  • operators
  • parentheses

Literal values and variables

Literal values are simply numbers that are included in an expression such as the 2 and the 5 shown in Figure 3 .

I will defer a discussion of variables until a future module, and will discuss operators and parentheses in the following paragraphs.

Operators

If you have ever used a hand calculator, you already know what operators are. The plus key on a hand calculator is an operator. The plus sign (+) in the expression shown in Figure 6 is also an operator.

Figure 6 . A Python addition operator.
>>>2+5

In programming jargon, operators are said to operate on operands ..

Operands

In Figure 6 , the 2 is the left operand and the 5 is the right operand of the + operator.

Unary and binary operators

Normally, operators are said to be either unary or binary .

A unary operator has only one operand while a binary operator has two operands.

Some can be either

Some operators, such as the minus sign (-), can be either unary or binary operators.

In its unary mode with a single operand, a minus sign is usually a sign changing operator, while in its binary mode with two operands, a minus sign is usually a subtraction operator.

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
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