Chapter 2 flashcards

function

A piece of prewritten code that performs an operation.

String

a sequence of characters that is used as data.

String literal

When a string appears in actual code of a program.

Variable

a name that represents a value stored in the computer's memory

Why do programs use variables?

To access and manipulate data that is stored in memory.

What is an assignment statement used to create

a variable and make it reference a piece of data.

The equal sign (=) is known as what?

assignment operator

Naming variables have another popular style called camelCase. How is camelCase done?

The variable name begins with lowercase letters. The first character of the second and subsequent words are written in uppercase.

Variable names may only use

letters, digits, or underscores.

garbage collection

When a value in memory is no longer used because it isn't referenced by a variable the python interpreter automatically removes it from memory through a process.

When an integer is stored in memory it is clssified as a

int

When a real number is stored in memory it is classified as a

float

numeric literal

A number that is written into a program's code is called a

In numeric literals

You can't write currency symbols ,spaces or commas in numeric literals.

exception

an unexpected error that occurs while a program is running, causing the program to halt if the error is not properly dealt with

Algorithm

a set of well-defined logical steps that must be taken to perform a task.

operands

the value on the left and right of the +operator

// integer division

Divides one number by another and gives the result as a whole number.

mixed expression

An expression that uses operands of different data types.

ivalue =2
fvalue = float(ivalue)

2.0

fvalue = -2.9
ivalue = int(fvalue)

-2

fvalue =2.6
ivalue =int(fvalue)

2

my_number = 5*2.0

implicit conversion to a float 10.0

explicit conversion

fvalue=2.6
ivalue = int(fvalue)

\ line continuation

Python allows you to break a statement into multiple lines

sep=' '

If you don't want a space printed between the items.

sep'*'

You can also use this special argument to specify a character other than the space to separate multiple items.

escape character

A special character that is preceded with a backlash (\) appearing inside a string literal

\n

causes output to advance to the next line

\t

causes out put to skip over to the next horizontal tab position