1.4 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

1.4.1: Signed Binary
What is the difference between the sign and magnitude approach and two’s complement approach for representing signed numbers in binary.

A
  1. Approach 1: Sign and Magnitude
    MSB (the left bit) is used to represent the sign with 0 = +ve, 1 = -ve. To store a negative version of a number, you just set the MSB to 1.
    It is logical but not used due to processing issues including two zeros, eg. 00000000 - positive 0, 10000000 - negative zero.
  2. Approach 2: Two’s Complement
    To change from denary to two’s complement, first flip all of the binary digits, then add the binary digit 1. To convert from two’s complement to denary, flip the binary digits and subtract binary 1.
    There is only one zero - 00000000, but there is an imbalance in the range: -8 to +7 for a nibble. You can do normal addition but it could lead to an overflow error.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

1.4.1
1. How to represent signed integers using two’s complement?
2. How to convert from binary two’s complement to denary?
3. How do you find the negative equivalent of a positive number?
4. What is the difference between unsigned and signed binary?

A
  1. To represent a positive number using two’s complement, the MSB must be 0. For a negative number, the MSB must be 1.
  2. To convert from binary to two’s complement to denary, you van simply add up the denary place values. If the the MSB is 1, subtract 128.
  3. To find the negative equivalent of a positive number: flip the bits and add 1.
  4. Unsigned binary is positive only, while signed binary is positive or negative.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

1.4.2: Data Structures - Arrays up to 2 dimensions
1. What is an array?
2. What does contiguous mean?
3. Explain the properties of the array.

A
  1. An array is a variable which can store more than one data item. This is done by allocating a contiguous part of memory for the purpose of storing that data.
  2. Contiguous means all the data is stored together, one element after the other
  3. Arrays are a static data structure, so you can’t change the size of an array once you have set it up. Items in an array start at index zero. Arrays, usually only support one data type.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

1.4.2
1. What is a record?
2. How do you use a record?

A
  1. A record is a collection of related fields of field is a variable in each field in the record can have a different data type.
  2. To use a record:
    First you define the field names and the data types the store. Then, you declare the variables that you will use and the sign the variable to the record name. Finally, you assign a value to each fieldname within the record.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

1.4.2
1. What are tuples?
2. What is the difference between a list and array?

A
  1. Tuples are lists that cannot be changed, but can store multiple different data types.
  2. A list is changeable, and can store more than one datatype. An array is changeable, but can only store one datatype.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

1.4.1: Signed integers in binary
1. How do you find the negative equivalent of a positive number?
2. How do you convert from denary to binary two’s complement?
3. How do you add and subtract integers represented in two’s complement?

A
  1. Converting from denary to binary two’s complement: positive numbers are the same as in unsigned binary. For negative numbers: first write the positive version, then flip the digits and add 1.
  2. To add integers represented in two’s complement, you do it the same as you would with unsigned binary. However, an overflow error may result in the wrong number as the answer.
  3. To subtract integers using two’s complement: subtracting a number from the other is the same as adding to the negative version of the number. Eg, 93-34 = 93 + (-34). So convert the number you are subtracting into a negative binary, then add.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

1.4.1
1) What are the case conversion commands?
2) What are the ASCII conversion commands?

A

1) String.upper : Returns the string in upper case.
String.lower : Returns the string in lower case.
String.isUpper : Returns True, if all the characters are upper case.
String.isLower : Returns True, if all the characters are lower case.

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

1.4.1
1) How does the binary number line method work?
2) How can you convert from binary to denary?

A

1) Binary number line method: Write out the binary number line, consider whether the number you want to store is more than or equal to the value in the column heading. If it is, write a 1 and reduced and number by the amount.
2) Convert from binary to denary: Write out in binary number line binary digits underneath. Add up the denary of the columns with a number 1.

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

1.4.1
1) How to convert from denary to hex?
2) How to convert from hex to denary?

A

1) How to convert between denary and 2 digit hexadecimal: First convert from denary to binary. Then, group the nibbles and find the number 1-16 that the two nibbles represent, and convert this into two hex digits.
2) How to convert between hex and denary: Convert each hex digits into two binary nibbles. Then, convert the binary into denary.

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

1.4.1
1) What is the MSB?
2) What is the LSB?

A

1) The most significant bit (MSB) is the left most bit, representing the largest value.
2) The least significant bit (LSB) is the right most bit, representing the least value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. What is a parameter?
  2. What is an argument?
A
  1. Parameters are the names of the information that is used in a function or procedure.
  2. An argument is a value that is passed into a function or procedure.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. What is branching?
  2. What is switch and case?
A
  1. Branching is where a certain block of code is run ​if a specific condition is met​, using IF statements, also known as selection.
  2. Switch and case is comparing the same variable to multiple different conditions, and running the code if the conditions are met.
    Example:
    Switch Number
    Case 1: print(‘First’)
    Case 2: print(‘Second’)
    Case 3: print(‘Third’)
    default: print(‘Number not recognised’)
    End Switch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. What is a data structure?
  2. What is a data type?
  3. What is an array?
A
  1. Data structure: a way of storing and managing data.
  2. Data type: a classification that specifies which type of value a variable has.
  3. Array: a set of data items of the same data type grouped together using a single identifier.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly