CPIT 110 - (Chapter 2/Elementary Programming)

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/55

encourage image

There's no tags or description

Looks like no tags are added yet.

56 Terms

1
New cards

Tracing a program

Helps you to understand how programs work

2
New cards

If an item is a number,

The number is automatically converted to a string for displaying

3
New cards

Variable

Represents a value stored in the computer’s memory

4
New cards

Every variable has a

Name and value

5
New cards

Every value has a

Data type

6
New cards

Data type

Used to specify what type of the value are being used, such as integers or strings

7
New cards

Python provides

Basic (built-in) data types for integers, real numbers, string, and Boolean types

8
New cards

Input function

Used to ask the user to input a value, and then return the value entered as a string

9
New cards

Eval

Used to evaluate and convert the passed value (string) to a numeric value

10
New cards

If the user enters something other than a number,

The program will terminate with a runtime error

11
New cards

\

Used at the end of a line to tell the interpreter that the statement is continued on the next line

12
New cards

The three steps a program run on:

Input (input from the user),

Process (produce results using the input),

Output (displays the results)

13
New cards

Identifier

The names that identify the elements such as variables and functions in a program

14
New cards

Rule of an indentifier

Sequence of characters that consists of letters, digits, and underscores (_), and cannot be a keyword

15
New cards

Keyword

Reserved words, have special meanings in Python

16
New cards

Import

A keyword which tells the Python interpreter to import a module to the program

17
New cards

Variables

Used to reference (represent) values that may be changed in the program

18
New cards

Assignment statement

The statement for assigning a value to a variable

19
New cards

=

Used as the assignment operator

20
New cards

Expression

Represents a computation involving values, variables, and operators that, taken together, evaluate to a value

21
New cards

A variable can also be used

In both sides of the = operator.

22
New cards

Scope of a variable

The part of the program where the variable can be referenced (used)

23
New cards

A variable must be assigned a value before it can

Be used in an expression

24
New cards

Simultaneous assignment

It tells Python to evaluate all the expressions on the right and assign them to the corresponding variable on the left simultaneously

25
New cards

Swapping variable values

A common operation in programming and simultaneous assignment is very useful to perform this operation

26
New cards

A named constant is an identifier that represents

A permanent value

27
New cards

The value of a variable can change

During execution of a program

28
New cards

A named constant

Represents a permanent data that never changes

29
New cards

Data

What the information stored in a computer is generally referred to

30
New cards

Two types of numeric data

Integers and real numbers

31
New cards

Integer types (int for short)

Are for representing whole numbers

32
New cards

Real types

Representing numbers with a fractional part

33
New cards

Real numbers

Represented as floating-point (or float) values

34
New cards

Literal

A constant value that appears directly in a program (such as 1.0 or 1)

35
New cards

+

Addition

36
New cards

-

Subtraction

37
New cards

*

Multiplication

38
New cards

/

Float division

39
New cards

//

Integer division

40
New cards

**

Exponentiation

41
New cards

%

Remainder

42
New cards

The +, -, and * operators are straightforward, but note that the
+ and - operators can be both

Unary and binary

43
New cards

Unary operator

Only one operand

44
New cards

Binary operator

Has two operands

45
New cards

% operator (known as remainder)

Yields the remainder after division

46
New cards

Left-side operand

The dividend

47
New cards

Right-side operand

The divisor

48
New cards

Calculations involving floating-point numbers are approximated

Because these numbers are not stored with complete accuracy

49
New cards

Overflow

When a variable is assigned a value that is too large (in size) to
be stored

50
New cards

Underflow

When a floating-point number is too small (for example, too
close to zero) to be stored

51
New cards

There are no spaces in

The augmented assignment operators

52
New cards

The augmented assignment operator

Performed last after all the other operators in the expression are evaluated

53
New cards

Type conversion

The process of changing a value from one data type to another

54
New cards

If you would like to change the variable being converted by the
functions int and round,

Reset the variable after invoking the function

55
New cards

The int function can also be used to convert

An integer string into an integer

56
New cards

You can use the str(value) function to convert

The numeric value to a string