CS Vocab Review

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Use of the dot operator,

, to access functions inside a module, or to access methods and attributes of an object.

What is a chained conditional?

A conditional branch with more than two possible flows of execution. In Python chained conditionals are written with if ... elif ... else statements.

What is a boolean function?

A function that returns a boolean value. The only possible values of the bool type are False and True.

What is a pure function?

A function with no side effects.

What is a block?

A group of consecutive statements with the same indentation.

What is a tuple?

A sequential collection of items, similar to a list. Any python object can be an element of a tuple. However, unlike a list, tuples are immutable.

What is a conditional statement?

A statement that controls the flow of execution depending on some condition. In Python the keywords if, elif, and else are used for conditional statements.

A data type in which the elements can be modified

All mutable types are compound types. Lists are mutable data types; strings are not.

What is a boolean expression?

An expression that is either true or false.

A sequential collection of items, similar to a list

Any python object can be an element of a tuple. However, unlike a list, tuples are immutable.

There are exactly two boolean values: True and False

Boolean values result when a boolean expression is evaluated by the Python interepreter. They have type bool.

A style of using Python where we type expressions at the command prompt, and the results are shown immediately

Contrast with source code, and see the entry under Python shell.

To create a new object that has the same value as an existing object

Copying a reference to an object creates an alias but doesn't clone the object.

Access a single character in a string using its position (starting from 0)

Example: 'This'[2] evaluates to 'i'.

A combination of operators and operands (variables and values) that represents a single result value

Expressions are evaluated to give that result.

A Python data type which stores floating-point numbers

Floating-point numbers are stored internally in two parts: a base and an exponent. When printed in the standard format, they look like decimal numbers. Beware of rounding errors when you use floats, and remember that they are only approximate values.

Also called remainder operator or integer remainder operator

Gives the remainder after performing integer division.

A conditional branch with more than two possible flows of execution

In Python chained conditionals are written with if ... elif ... else statements.

A statement that controls the flow of execution depending on some condition

In Python the keywords if, elif, and else are used for conditional statements.

An operation that divides one integer by another and yields an integer

Integer division yields only the whole number of times that the numerator is divisible by the denominator and discards any remainder.

Number of characters in a string

It can be found by (len) function Example: len('happy') evaluates to 5.

A collection of objects, where each object is identified by an index

Like other types str, int, float, etc. there is also a list type-converter function that tries to turn its argument into a list.

An intermediate language between source code and object code

Many modern languages first compile source code into byte code and then interpret the byte code with a program called a virtual machine.

A data type whose values cannot be changed

Modifying functions create a totally new object that does not change the original one.

A part of a string (substring) specified by a range of indices

More generally, a subsequence of any sequence type in Python can be created using the slice operator (sequence[start:stop]). Example: 'bananas and cream'[3:6] evaluates to ana (so does 'bananas and cream'[1:4]).

n plays a very different role on each side of the =

On the right it is a value and makes up part of the expression which will be evaluated by the Python interpreter before assigning it to the name on the left.

What is a logical operator?

One of the operators that combines boolean expressions: and, or, and not.

What is a comparison operator?

One of the operators that compares two values: ==, !=, >, <, >=, and <=.

What is a branch?

One of the possible paths of the flow of execution determined by conditional execution.

A function which changes its arguments inside the function body

Only mutable types can be changed by modifiers.

A sequence of statements, or a style of coding something that has general applicability in a number of different situations

Part of becoming a mature Computer Scientist is to learn and establish the patterns and algorithms that form your toolkit. Patterns often correspond to your "mental chunking".

A function which has no side effects

Pure functions only make changes to the calling program through their return values.

A picture showing a variable with an arrow pointing to the value (object) that the variable refers to

See also state snapshot.

A change in the state of a program made by calling a function that is not a result of reading the return value from the function

Side effects can only be produced by modifiers.

To initialize a variable is to give it an initial value

Since in Python variables don't exist until they are assigned values, they are initialized when they are created. In other programming languages this is not the case, and variables can be created without being initialized, in which case they have either default or garbage values.

An instruction that the Python interpreter can execute

So far we have only seen the assignment statement, but we will soon meet the import statement and the for statement.

What is a body?

The block of statements in a compound statement that follows the header.

What is a condition?

The boolean expression in a conditional statement that determines which branch is executed.

One of the values in a list (or other sequence)

The bracket operator selects elements of a list.

Any of the characters that move the cursor without printing visible characters

The constant string.whitespace contains all the white-space characters.

Also known as a data object (or data value)

The fundamental things that programs are designed to manipulate (or that programmers ask to do things for them).

A function that returns a boolean value

The only possible values of the bool type are False and True.

A set of values

The type of a value determines how it can be used in expressions. So far, the types you have seen are integers (int), floating-point numbers (float), and strings (str).

An interactive user interface to the Python interpreter

The user of a Python shell types commands at the prompt (>>>), and presses the return key to send these commands immediately to the interpreter for processing.

What are boolean values?

There are exactly two boolean values: True and False. Boolean values result when a boolean expression is evaluated by the Python interpreter. They have type bool.

A statement that assigns a value to a name (variable)

To the left of the assignment operator, =, is a name. To the right of the assignment token is an expression which is evaluated by the Python interpreter and then assigned to the name. The difference between the left and right hand sides of the assignment statement is often confusing to new programmers. In the following assignment:

A name given to a variable

Variable names in Python consist of a sequence of letters (a..z, A..Z, and _) and digits (0..9) that begins with a letter. In best programming practice, variable names should be chosen so that they describe their use in the program, making the program self documenting.


Kaugnay na mga set ng pag-aaral

Women's Health - Chapter 3 - Prep U

View Set

10 Real Estate Finance - Chapter 3: The Secondary Mortgage Market

View Set

ANAPHY LEC: CHAPTER 6 SKELETAL SYSTEM

View Set

speech midterm (chapters 1,2,3,4,5,6,11)

View Set

Chapter 2 Test your understanding

View Set

Management Science 590 - Chapter 08

View Set