Chapter 1 Variables, expressions, and statements Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

assignment

A

A statement that assigns a value to a variable.

An assignment statement creates new variables and gives them values:
»> message = ‘And now for something completely different’
»> n = 17
»> pi = 3.1415926535897931
This example makes three assignments

The assignment statement produces no output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

concatenate

A

To join two operands end to end.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

comment

A

Information in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

comment

A

Information in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

evaluate

A

To simplify an expression by performing the operations (in order of precedence) in order to yield a single value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

expression

A

A combination of variables, operators, and values that represents a single result value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

floating point

A

A type that represents numbers with fractional parts.
/ for floating point division

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

integer

A

A type that represents whole numbers.

// for integer division

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

keyword

A

A reserved word that is used by the compiler to parse a program; you cannot use keywords like if, def, and while as variable names.

Python reserves 35 keywords:

False await else import pass
None break except in raise
True class finally is return
and continue for lambda try
as def from nonlocal while
assert del global not with
async elif if or yield

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

mnemonic
PEMDAS

A

A memory aid. We often give variables mnemonic names to help us remember what is stored in the variable.

PEMDAS for operators order of precedence in Python

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

modulus operator

A

An operator, denoted with a percent sign (%), that works on integers and yields the remainder when one number is divided by another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

operand

A

One of the values on which an operator operates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

operator

A

A special symbol that represents a simple computation like addition, multiplication, or string concatenation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

rules of precedence

A

The set of rules governing the order in which expressions involving multiple operators and operands are evaluated.

P
E
M, D
A, S

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

statement

A

A section of code that represents a command or action. So far, the statements we have seen are assignments and print expression statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

string

A

A type that represents sequences of characters.

17
Q

type

A

A category of values. The types we have seen so far are integers (type int), floating-point numbers (type float), and strings (type str).

18
Q

value

A

One of the basic units of data, like a number or string, that a program manipulates.

19
Q

variable

A

A name that refers to a value.