unknowns so far Flashcards

1
Q

compare = “Python” * 3
print (compare)

A

PythonPythonPython

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

compare = “Python” > “Java”
print (compare)

A

True
(Python comes first in the alphabet and is at a lower index/would come first)

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

compare = “Python” + “Java”
print(compare)

A

PythonJava

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

word = “python”
firstletter = word[0]
print(firstletter)

A

p

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

word = sheep
for letter in word:
print (letter)

A

S
H
E
E
P

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

compare = “Hello”
len(compare) =

A

5

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

compare = “Hello”
compare.isalpha()

A

True

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

compare = 12345
compare.isalpha()

A

False

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

compare = “Hello”
compare.upper()

A

HELLO

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

compare = 12345
compare.upper()

A

TypeError - The two data types conflict.

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

compare = 12345
compare.isalnum()

A

True

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

compare = “Hello”
compare.isalnum()

A

False

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

What is a data structure?

A

a container that can hold several items at the same time.

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

What is an array?

A

A data structure that can hold a number of items grouped together.
It contains a number of items grouped together, and named using a single identifier, however can only hold the same data type.

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

What is a syntax error?

A

When code written does not follow the rules of the programming language

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

What is a runtime error?

A

If something unexpected is typed in by the user, the code will crash, eg. A string where a bool/real is expected.

It occurs WHILE the program is running.

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

What is a type error?

A

TypeError = When the two data types conflict

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

How can you convert types?

A

int() -> Turns into a number as long as the input is acceptable
str() -> Can turn anything into a string.
float() -> 7 = 7.0
bool() -> True / False

19
Q

What is the most significant bit?

A

Left most number

20
Q

What is the least significant bit?

A

Right most number

21
Q

What is a signed integer?

A

signed = assigned as positive or negative

22
Q

What is an unsigned integer?

A

positive integer including 0 that hasn’t been assigned as positive or negative

23
Q

What is an overflow error?

A

when the result of a calculation is too large to be represented in the number of bits allocated

when you have a carry on the end of a sum and it overflows
eg. your result being a 9 bit number and your calculation being 8 extra carry has nowhere to go

a computer handles this by:
- crashing and reporting the overflow error
- truncating the answer and leaving off the extra one, resulting in an unexpected answer
- wrapping the number back around to 0

24
Q

What is two’s complement?

A
  • the whole number when added makes the intended denary, as the MSB is negative.
  • most common way of representing signed binary integers
  • ARITHMETIC WORKS IN TWO’S COMPLEMENT!!! doesn’t work in sign and magnitude.
25
Q

What is sign and magnitude?

A
  • sign is the left most bit
  • 0 = positive and 1 = negative
  • the rest represents the actual numerical value
  • sign and magnitude has two ways of representing zero.
  • arithmetic doesn’t work
26
Q

How do you convert two’s complement into denary?

A

The MSB is negative. Calculate as normal but with that one as negative.

27
Q

How do you convert a negative integer from decimal to binary? (Two’s complement)

A

1) Write down the normal binary value.
2) Flip every bit.
3) Perform binary addition with your flip, adding 1.

28
Q

What is a bit

A

Smallest bit. 0 or 1.

29
Q

What is a nibble

A

4 bits

30
Q

What is a byte

A

8 bits (2 nibbles)

31
Q

What is a digital computer

A

a device that is capable of performing multiple tasks and does not have a specific function, eg. A PC.

32
Q

What is an embedded system

A

An embedded system is a computer that has a specific function and does not do anything else, eg. A microwave.

33
Q

What are the golden rules of binary addition

A

0+0=0
0+1=1
1+1= 0 carry 1
1+1+1 = 1 carry 1

34
Q

What are the golden rules of binary addition

A

0+0=0
0+1=1
1+1= 0 carry 1
1+1+1 = 1 carry 1

35
Q

How do you multiply a binary number?

A

Left shift!
MSB shifted left, along with every other bit.
A shift by 1 is multiplying by 2.
A shift by 2 is multiplying by 4.

36
Q

How do you divide a binary number?

A

Right shift!
LSB shifted right, out of the pattern.
This causes a loss of precision sometimes, as 23/2 = 11.5, but only 11 is represented.
A shift by 1 is dividing by 2.
A shift by 2 is dividing by 4.

37
Q

What is a bitwise operation?

A

Operates on each bit in a pattern one at a time

38
Q

How do you convert from binary to hexadecimal?

A

1) Split the binary number into nibbles.
2) Convert to hexadecimal.
hex()

39
Q

Why is hexadecimal used?

A

It is compact and uses less memory.

40
Q

What is ASCII?

A

A 7-bit (128 bit patterned) standard to encode text on early computers
Extended ASCII uses 8 bits.

ASCII (American Standard Code for Information Interchange)
Enables computer devices to connect with each other and translate their communication into identical information.

An ASCII character set lookup table translates all the binary/hexadecimal into numbers and digits.

41
Q

What are some limitations of ASCII?

A
  • Limited to 128 characters.
  • Suitable for English and English characters only. No additional characters, eg. Spanish, Mandarin, Russian, German.
  • Extended ASCII was created to include more characters - 8 bits, 256, to represent more European languages.
  • Unicode represents 120,000 characters.
42
Q

What is lossy?

A

When data is compressed and quality is reduced.

43
Q

What is lossless?

A

When data is stored in a different format meaning no data is lost in compression

44
Q

Why does data need compressing?

A

Reduces file sizes that it takes up less space and is quicker to download and transfer.