Quiz 1 Material Flashcards

1
Q

sequence

A
  • we start with the instruction written at the top
  • we go in order, one instruction at a time
  • each line is “one” thing to do
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

repetition

A

repeat something - LOOP
(- repeat a fixed number of times
- repeat until something happens)

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

conditions/decisions

A

maybe do something - IF
(- check something first)

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

Named Actions

A
  • grouping many lower level actions in to one higher level name
  • FUNCTION
  • we think of a named action in 2 ways
    • definition of the name action
    • use of the named action
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

pseudocode

A

not quite in the computer’s language
(- it’s still specific, detailed, and followable
- no specific syntax)

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

algorithm

A
  • a step by step list of instructions to solve a problem
    (these steps must be followed EXACTLY)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

good algorithm

A
  • unambiguous
  • executable
  • terminating
  • correct
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

statement

A

a single action to perform

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

execute

A

follow an instruction or sequence of instructions

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

program

A

the sequence of statements to be executed

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

keyword

A

a word that guides how to execute your program

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

variable

A

a name for a values, the value it is naming may change during execution - the name cannot be a keyword

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

expression

A

a portion of a statement describing a value

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

loops

A

statements that we might execute over and over again

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

every value has a _____

A

type

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

type casting

A

“reshape” a value of one type into a value of a different type

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

how would you typecast an integer 7 to a string?

A

str(7)

18
Q

does a type casted function change the type of the preexisting value?

A

no, it just returns a value of the new type

19
Q

integer

A

int - a whole number

20
Q

float

A

float - a number that may contain a decimal part

21
Q

+

A

add

22
Q

-

A

subtract

23
Q

*

A

multiply

24
Q

**

A

exponent

25
Q

/

A

divide
- always produces a FLOAT

26
Q

//

A

integer division
- produces the INTEGER part of the answer

27
Q

%

A

modulus
- produces just the remainder

28
Q

what does this produce? -> float and float

A

float

29
Q

what does this produce and when is there an exception? -> int and int

A

int
- exception /

30
Q

what does this produce and when is there an exception? -> float and int

A

float
- exception /

31
Q

comments

A

notes for the programmer that Python ignores

32
Q

input

A

input(prompt)
- a function that gets user input as a ‘str’

33
Q

print

A

print(object)
- a function when we want to print something to the screen

34
Q

what is x? -> x = ‘20’ + ‘30’

A

‘2030’

35
Q

escape sequences

A
  • the \ character followed by another letter
  • says to python “don’t do what you would normally do with that character”
36
Q

'
"
\n
\

A
  • single quote, don’t end the string
  • double quote, don’t end the string
  • newline character (like hitting enter)
  • the backlash character
37
Q

can you print a str and an integer together in the same line?

A

no, the integer has to be typecasted to a string

38
Q

syntax error

A

code violates the rules of the programming language, and thus can’t be run

39
Q

runtime error

A

code runs, but enters an illegal state or tries to do something impossible (ex. int divide by zero)

40
Q

logical error

A

this causes your program to operate incorrectly, but not crash, the output is incorrect