Midterm Flashcards

Learn for midterm

1
Q

Define:

Int
Float
Type

A

Int is an integer
Float is a decimal point
Type is for datatypd

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

Operator vs operand

Does programming follow operator precedence

A

Operators are +, ×, ÷, etc
Operands are numbers
Yes it follows operator precedencd

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

Define:

**
/
//
\

A

** is to the power
/ is float division
// is integer division
\ is line continuation

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

Decimal vs binary

A

Decimal is base 10

Binary is base 2

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

Base 2 vs base 10

A

Base10 is decimal

Base 2 is binary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
()
[]
{}
>>>
#
A
() are parentheses 
[] are brakets
{} are braces
>>> is a prompt
# is a comment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Syntax error vs semantic error

A

Syntaxes error: type smt that is not valid

Semantic error: you tell python to do smt it can’t do

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

Why do software updates occur?

A
  1. New features were added

2. Bugs were fixed

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

How many symbols does base 10 and base 2 have?

A

Base 10 has 10 symbols

Base 2 has 2 symbols

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

Which is positive and negative?

A

0 is positive

1 is negative

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

8 bits is a ____

4 bits is a___

A

8 is a byte

4 is a nibble

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

How is data stored I a computer?

A

Data is stored in binary digits (bits) I fixed-size cells

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

How to do binary to decimal?

A

5432

5x2^3 +4×2^2 + 3×2^1 +2×2^0 = all added up

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

What numbers do cells contain?

A

Patterns of 0 and 1. So if we add 1+1 it gets added up to 0 and the 1 gets carried

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

Define

EOL
len()
Ord()

A

EOL is end of line
Len() is length of a string that can be added and multiplied.
Ord() converts characters to numbers

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

Which one is a space and which one of not a space?

A

+ is no space

, is a space

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

FDR

A
  1. Examples
  2. Header
  3. Description
  4. Body
  5. Test
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a string?

A

A sequences of characters, digits and symbols. String always has ‘’ around the string.

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

Paramter vs argument

A

parameter: the variable in the function’s definition
argument: The actual value that gets passed to the function when it is called

20
Q

How many spaces are in an indent?

What is the result of no return function

A

4 spaces

result = none

21
Q

What is a Concention?

A

written in caps and underscores for names of constants defined outside there function

22
Q

what must variables beguin with?

A

Variable names must begin with a letter or underscores and are made up of letters, numbers and underscores

23
Q

Give an example of a Augmented assigned statement.

A

x+=4

24
Q
// vs / and rounding
%
A
// is integer division (round down)
/ is float division
% is the remainder (will match the sign of the second operand)
25
Q

The first line of a function definition is called the

A

function header

26
Q

The function’s return statement is part of the function’s____

A

body

27
Q

Function definition vs Function call

A

Function definition: header and body of a function

Function call: Invocation of a function to execute it

28
Q

What are the three components of a floating point number, when stored in binary?

A

exponent, mantissa, sign bit

29
Q

What is a bug?

A

An error that causes the program to abort (or crash)

An error that does not cause the program to abort, but produces incorrect results.

30
Q

Unsigned range

A

0 to 2^k -1

31
Q

signed magniture

- how many representations of 0?

A

2 representations of zero

32
Q

2’s compliment range

- how many representations of 0?

A

-2^(k-1) to 2^(k-1) -1

1 representation of zero.

33
Q

How to find the different amount of possible values?

A

2^k

34
Q

what does ord(_) do?

what does str(_) do?

A

it converts characters to numbers

it converts numbers to str

35
Q

What are boolean operators/logical operator?

A

and, not, or

36
Q

Relation vs arithmetric operators

A

relation: =, <=, >=
arithmetic: x, %, /, //, etc

37
Q

What is the order of precedence between operators?

A
  1. Arithmetic
  2. relation
  3. boolean
38
Q

How do the indices of lists work?

A

it starts from 0 to n-1

39
Q

what is the symbol for:

1. empty list

A
  1. []
40
Q
Indicate which Python data types are mutable:
int
float
str
list
A

string

41
Q
Which of the following are iterable data?
int
float
Boolean
list 
str
A

lst + str

42
Q

What do while-loops do?

A

Repeat a chunk of code until a condition is false

43
Q

To repeat a fixed number of times, use:

A

for-loops

44
Q

To repeat until a particular condition is False, use:

A

while-loops

45
Q

is 1 and 0 true or false?

A
true = 1
false = 0