Week 2 Flashcards

1
Q

What is a value

A

A number or string that can be stored in a variable or computed in an expression.

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

What is an object

A

Something that can be used. i.e. kez = turtle.Turtle(). kez is an object and that object has all of the method and attributes associated with the class turtle.

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

What are classes

A
define objects (i.e car is an object of the class vehicles)
Classes are a group of objects (i.e. turtle is a class and within that class are held all the methods and attributes associated with the class turtle, i.e. all the things it can do).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What function would you use to change one type to a different type?

A

int( to change it to whole numbers)
str( to change it to a string)
float(to change it to decimal point numbers)

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

What is a variable

A

A name that refers to a value

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

What does an assignment statement do

A

Creates a new variable and gives it a name.

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

What is the assignment token/operator

A

=

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

What is illegal in a variable name

A

It can’t start with a number, but digits can be in the name.
Can not be any of the keywords.
Can not have any white space, but can contain _
For convention purposes programmers generally use lower case.

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

What is a statement

A

It is an instruction that python can interpret and execute.

Example: while, for, if and import

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

What is an expression

A

Combination of values, variables & operators.

Expressions need to be executed.

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

What does the len() function do

A

returns the number of characters in the string.

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

What is an operator

A

They are special tokens that represent computation.

Example: + - * / ** // %

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

What does the operator // do?

A

It is called an integer division. divides and then rounds down to the nearest integer.

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

What does the operator % do?

A

The modulus operator or remainder. After dividing it will return the value of the integer remaining.
Example: 11/4 = 2.75. 11%4 = 3 (11-8)

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

What does the input() function do?

A

It asks the user what value they want to use.

The answer from the users will always in a string.

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

What is the order or operation or operator precedence?

A

first - ()
second - **
third - * & /
forth - + & -

Order of precedence goes from left to right.
Except ** which goes right to left.

17
Q

What does reassignment do?

A

It gives a new reference/value to the variable

18
Q

What is imperative programming. And what are the 5 types of imperative programming.

A
Imperative programming changes the state of the program.
5 imperative programming:
   Sequence
   Selection or Conditional
   Iteration or Repetition
   Abstraction
   Data
19
Q

What is a sequence, what does it mean?

A

It mean one line is executed than the next, than the next.