-01 Introduction To Programming Science

Created by Jacqueline

p.2

How should a binary number be pronounced?

Click to see answer

p.2

A binary number should be pronounced as ones and zeros. For example, 1010₂ is pronounced as 'one zero one zero', not 'one thousand and ten'.

Click to see question

1 / 68
p.2
1
Binary Terms and Notation

How should a binary number be pronounced?

A binary number should be pronounced as ones and zeros. For example, 1010₂ is pronounced as 'one zero one zero', not 'one thousand and ten'.

p.1
4
Decimal, Binary, and Hexadecimal Systems

What is the base of the Decimal System and how many basic digits does it have?

The Decimal System has a base of 10 and includes 10 basic digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

p.1
4
Decimal, Binary, and Hexadecimal Systems

In the number 1,495, what are the most significant digit (MSD) and the least significant digit (LSD)?

In the number 1,495, the most significant digit (MSD) is 1 and the least significant digit (LSD) is 5.

p.1
4
Decimal, Binary, and Hexadecimal Systems

What is a binary digit called and what is its base?

A binary digit is called a bit and the binary system has a base of 2.

p.1
2
Binary Terms and Notation

What is a group of four bits called in binary terminology?

A group of four bits is called a nibble.

p.1
2
Binary Terms and Notation

What is the difference between high-order byte and low-order byte in a binary number?

The high-order byte contains higher significant bits, while the low-order byte contains less significant bits.

p.1
4
Decimal, Binary, and Hexadecimal Systems

In binary counting, what is the binary representation of the decimal number 5?

The binary representation of the decimal number 5 is 101.

p.1
2
Binary Terms and Notation

What is the term used for a group of eight bits?

A group of eight bits is called a byte.

p.1
2
Binary Terms and Notation

What are the most significant bit (MSB) and least significant bit (LSB) in binary?

The most significant bit (MSB) is the left-most bit, while the least significant bit (LSB) is the right-most bit.

p.2
1
Binary Terms and Notation

What does the MSB represent in the binary number 01001100₂?

The MSB (Most Significant Bit) for 01001100₂ is 0. In some binary notations, the leading 0 has important meaning, indicating that the MSB is 0 when leading 0's are included.

p.2
1
Binary Terms and Notation

How is a binary number typically denoted in programming?

In computer programming, a binary number is often written with the prefix 0b. For example, the binary number 1001₂ is represented as 0b1001.

p.2
1
Binary Terms and Notation

What is the difference between SI and IEC notation for data storage?

SI notation uses decimal (powers of 10) units (e.g., 1 K = 1000), while IEC notation uses binary multiples (e.g., 1 Ki = 1024). The IEC prefixes (Ki, Mi, Gi, ...) make the binary-based quantities unambiguous compared with SI.

p.2
1
Binary Terms and Notation

What does 1K mean in the context of computer storage?

In computer storage, 1K can mean either 1024 bytes (e.g., 16KByte = 16 × 1024 = 16,384 bytes) or 1000 bytes (e.g., 16KByte = 16 × 1000 = 16,000 bytes), depending on the context.

p.2
1
Binary Terms and Notation

What is the significance of the prefixes Ki, Mi, Gi in IEC notation?

In IEC notation, 1Ki (kibi) = 2¹⁰ = 1024, 1Mi (mebi) = 2²⁰ = 1,048,576 (1024²), and 1Gi (gibi) = 2³⁰ = 1,073,741,824 (1024³). These distinguish binary-based sizes from SI powers-of-ten units.

p.3
Hexadecimal System

What is the base of the hexadecimal number system?

The base of the hexadecimal number system is 16.

p.3
Hexadecimal System

What are the digits used in the hexadecimal system?

The hexadecimal system uses the digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

p.3
Hexadecimal System

How is a hexadecimal number represented in computer programming?

In computer programming, hexadecimal numbers are written with a prefix 0x, for example, 0x1F34.

p.3
4
5
Conversion Between Number Systems

What is the conversion relationship between hexadecimal and binary digits?

One hexadecimal digit corresponds to 4 binary digits.

p.3
4
5
Conversion Between Number Systems

What is the first step in the conversion procedure from hexadecimal to binary?

The first step is to write the hexadecimal number as separated digits.

p.3
4
5
Conversion Between Number Systems

What is the result of converting the hexadecimal number 1FB9 to binary?

The result of converting the hexadecimal number 1FB9 to binary is 0001111110111001.

p.3
4
5
Conversion Between Number Systems

What is the significance of representing every hexadecimal digit as 4 binary digits?

Every hexadecimal digit should be represented exactly as 4 binary digits to maintain the correct conversion and representation.

p.4
3
5
Conversion Between Number Systems

What is the procedure for converting binary to hexadecimal?

  1. Group the bits into groups of 4 bits starting from the right.
  2. If the left-most group has fewer than 4 bits, pad it with leading zeros.
  3. Convert each 4-bit group to its hexadecimal digit and concatenate the results.
p.4
3
5
Conversion Between Number Systems

How do you convert the binary number 011001000010110011111011 to hexadecimal?

  1. Group the digits: 0110 0100 0010 1100 1111 1011.
  2. Convert each group of 4 digits into one hex digit:
    • 0110 => 6
    • 0100 => 4
    • 0010 => 2
    • 1100 => C
    • 1111 => F
    • 1011 => B
  3. Combine all hex digits to form the complete hex number: 642CFB.
p.4
3
5
Conversion Between Number Systems

What is the conversion result of the binary number 011101101010011110 to hexadecimal?

  1. Group the digits: 0001 1101 1010 1001 1110.
  2. Convert each group of 4 digits into one hex digit:
    • 0001 => 1
    • 1101 => D
    • 1010 => A
    • 1001 => 9
    • 1110 => E
  3. Combine all hex digits to form the complete hex number: 1DA9E.
p.4
1
Decimal, Binary, and Hexadecimal Systems

What is the base of the octal number system and its digits?

The octal number system has a base of 8 and consists of the digits: 0, 1, 2, 3, 4, 5, 6, 7.

p.4
3
5
Conversion Between Number Systems

How can octal digits be converted to/from binary?

Each octal digit can be converted to/from a group of 3 bits.

p.4
1
Decimal, Binary, and Hexadecimal Systems

How is an octal number represented in computer programming languages like C/C++ and Python?

In C/C++, an octal number is written with a leading 0. In Python, it is written with a prefix '0o'.

p.5
3
4
Conversion Between Number Systems

How can a decimal number be expressed in its base-10 expansion?

A decimal number can be expressed in base-10 expansion as follows: For example, 1,234 = 1 x 10³ + 2 x 10² + 3 x 10¹ + 4 x 10⁰.

p.5
3
4
Conversion Between Number Systems

What is the binary expansion of the binary number 101101₂?

The binary number 101101₂ can be expressed as: 101101₂ = 1 x 2⁵ + 0 x 2⁴ + 1 x 2³ + 1 x 2² + 0 x 2¹ + 1 x 2⁰.

p.5
3
4
Conversion Between Number Systems

What is the decimal equivalent of the binary number 101001₂?

The decimal equivalent of 101001₂ is calculated as: 101001₂ = 1 x 2⁵ + 0 x 2⁴ + 1 x 2³ + 0 x 2² + 0 x 2¹ + 1 x 2⁰ = 32 + 0 + 8 + 0 + 0 + 1 = 41₁₀.

p.5
Conversion Between Number Systems

How do you convert the binary number 1000011₂ to decimal?

To convert 1000011₂ to decimal, use the binary expansion: 1000011₂ = 1 x 2⁶ + 0 + 0 + 0 + 0 + 1 x 2¹ + 1 x 2⁰ = 64 + 0 + 0 + 0 + 2 + 1 = 67₁₀.

p.5
Conversion Between Number Systems

What is the procedure for converting a decimal number to binary?

The procedure for converting a decimal number to binary involves:

  1. Divide the given number by 2 and record the integer quotient and remainder.
  2. Continue dividing the integer quotient by 2 until the quotient is 0, recording the results.
  3. Combine the remainders from bottom to top to form the binary number.
p.5
Conversion Between Number Systems

What is the binary equivalent of the decimal number 23?

To convert 23 to binary:

  1. 23 ÷ 2 = 11 remainder 1 (LSB)
  2. 11 ÷ 2 = 5 remainder 1
  3. 5 ÷ 2 = 2 remainder 1
  4. 2 ÷ 2 = 1 remainder 0
  5. 1 ÷ 2 = 0 remainder 1 (MSB) Thus, 23₁₀ = 10111₂.
p.6
Conversion Between Number Systems

What is the method to convert a hexadecimal number to decimal?

To convert a hexadecimal number to decimal, use the formula:

Hexadecimal Number = (digit₁ × 16^n) + (digit₂ × 16^(n-1)) + ... + (digitₖ × 16^0)

where each digit is multiplied by 16 raised to the power of its position from the right, starting at 0.

p.6
Conversion Between Number Systems

How do you convert the hexadecimal number 1A2C₁₆ to decimal?

To convert 1A2C₁₆ to decimal:

  1. Break it down: 1 × 16³ + 10 × 16² + 2 × 16¹ + 12 × 16⁰
  2. Calculate: 4096 + 2560 + 32 + 12 = 6700

Thus, 1A2C₁₆ = 6700 in decimal.

p.6
Conversion Between Number Systems

What is the hexadecimal form of the decimal number 451?

To convert 451 to hexadecimal:

  1. Divide 451 by 16: 451 ÷ 16 = 28 remainder 3 (LSD)
  2. Divide 28 by 16: 28 ÷ 16 = 1 remainder 12 (which is C)
  3. Divide 1 by 16: 1 ÷ 16 = 0 remainder 1

Thus, the hexadecimal form is 1C3.

p.6
Conversion Between Number Systems

What should hexadecimal digits A to F be written as during conversion to decimal?

During conversion from hexadecimal to decimal, the digits A to F should be written as their corresponding decimal values:

  • A = 10
  • B = 11
  • C = 12
  • D = 13
  • E = 14
  • F = 15
p.7
Hexadecimal Systems

What are the advantages of using hexadecimal over binary for data representation?

Hexadecimal has several advantages:

  • Easier to read and remember than binary.
  • Shorter representation of numbers compared to binary.
  • Simple conversion between hex and binary, making it useful in debuggers.
  • A byte of data can be perfectly represented as a two-digit hexadecimal number (00 to FF).
  • Commonly used to represent colors in web pages, e.g., #9C00FF.
p.7
Signed and Unsigned Numbers

What is the difference between signed and unsigned numbers?

  • Unsigned numbers:

    • Can only represent non-negative values (zero and positive integers).
    • Uses all bits to represent the magnitude of the number.
  • Signed numbers:

    • Can represent both positive and negative integers.
p.7
Representation of Signed Numbers

How is a signed number represented in sign and magnitude notation?

In sign and magnitude notation:

  • The most significant bit (MSB) represents the sign:
    • 0 means positive
    • 1 means negative (known as the sign bit)
  • The remaining (n - 1) bits represent the magnitude of the number.

Example in 8-bit S&M notation:

  • 00001100 means 12
  • 10001100 means -12

Note: There are two representations for zero: 00000000 (+0) and 10000000 (-0).

p.7
Representation of Signed Numbers

What are the common methods to represent signed numbers?

The two common methods to represent signed numbers are:

  1. Sign and Magnitude
  2. One's Complement
  3. Two's Complement

When representing signed numbers, the number of bits used is important, and it is essential to specify the size (number of bits) when discussing signed numbers.

p.8
Representation of Signed Numbers

What is One's Complement Notation and how is it used to represent negative numbers?

One's Complement Notation, also known simply as complement, represents negative numbers by taking the bit-wise complement of a given binary number. The complement of 0 is 1, and the complement of 1 is 0. For example, the negative of 01101111 is 10010000, and the negative of 11110001 is 00001110. In an 8-bit one's complement system, there are two zeros: 00000000 (+0) and 11111111 (-0), with the MSB serving as the sign bit.

p.8
Two's Complement Notation

How is the decimal value of an n-bit Two's Complement binary number calculated?

The decimal value of an n-bit two's complement binary number bn-1bn-2bn-3…b1b0 can be calculated using the formula:

(bn-1 × 2^n-1) + bn-2 × 2^n-2 + bn-3 × 2^n-3 + ... + b1 × 2^1 + b0 × 2^0. The MSB is also the sign bit, indicating whether the number is positive or negative. For example, 00001100 represents 12, while 10001100 represents -116.

p.8
Two's Complement Notation

What is the procedure for negating a two's complement number?

To negate a two's complement number, follow these steps:

  1. Take the complement of the number (change all 1's to 0's and all 0's to 1's).
  2. Add 1 to the result.

For example, for the number 00001100:

  1. Take its complement: 00001100 --> 11110011
  2. Add 1: 11110011 + 00000001 = 11110100 (which is decimal -12). For 10001100:
  3. Take its complement: 10001100 --> 01110011
  4. Add 1: 01110011 + 00000001 = 01110100 (which is decimal 116).
p.9
Two's Complement Notation

What is the actual operation performed in the expression (15)+(-2) using two's complement?

The actual operation performed is subtraction.

p.9
Two's Complement Notation

How does two's complement allow operations to be performed according to the operator regardless of the signs of the operands?

In two's complement, operations are carried out according to the written operators and disregard the signs of the operands.

p.9
Representation of Signed Numbers

What is the range of signed numbers for an 8-bit binary number?

The range of signed numbers for an 8-bit binary number is -128 to +127.

p.9
Two's Complement Notation

What happens during arithmetic overflow in 8-bit two's complement numbers?

During arithmetic overflow, the result exceeds the maximum representable value, leading to incorrect results, such as 01110000 + 00100000 = 10010000 (decimal -110).

p.9
Representation of Signed Numbers

What is the range of values that can be represented by a binary number dependent on?

The range of values that can be represented by a binary number is highly dependent on the number of bits used to represent the number.

p.9
Representation of Signed Numbers

What is the range of signed numbers for a 16-bit binary number?

The range of signed numbers for a 16-bit binary number is -32,768 to +32,767.

p.9
Representation of Signed Numbers

What is the range of unsigned numbers for a 4-bit binary number?

The range of unsigned numbers for a 4-bit binary number is 0 to 15.

p.9
Two's Complement Notation

What is the result of the operation 11111100 - 00000011 in 8-bit two's complement?

The result of the operation 11111100 - 00000011 is 11111001 (decimal -7).

p.10
Representation of Signed Numbers

What is the range of decimal values represented in a 4-bit 2's complement signed number system?

The range of decimal values in a 4-bit 2's complement signed number system is from -8 to +7.

p.10
Signed and Unsigned Numbers

How does Little-endian storage differ from Big-endian storage in terms of byte arrangement?

In Little-endian storage, the least significant byte (LSB) is stored at the smallest memory address, while in Big-endian storage, the most significant byte (MSB) is stored at the smallest memory address.

p.10
Binary Terms and Notation

Given the hex word 4B5A112F, how would it be stored in Little-endian format?

In Little-endian format, the hex word 4B5A112F is stored as:

addressbyte
n2F
n+111
n+25A
n+34B

Normal display form: 2F 11 5A 4B

p.10
Binary Terms and Notation

Given the hex word 4B5A112F, how would it be stored in Big-endian format?

In Big-endian format, the hex word 4B5A112F is stored as:

addressbyte
n4B
n+15A
n+211
n+32F

Normal display form: 4B 5A 11 2F

p.11
Representation of Signed Numbers

How is the real number 0.15625 represented in IEEE 754 floating-point notation?

The real number 0.15625 is represented in IEEE 754 floating-point notation as the binary sequence 00111110001000000000000000000000.

p.11
Programming Languages Overview

What are the different levels of programming languages?

The levels of programming languages include:

  1. Hardwiring
  2. Machine language
  3. Assembly language
  4. High-level language
p.11
Machine Language

What is machine language and its significance in programming?

Machine language, also known as machine code, is the fundamental language of computers. It consists of binary instructions that a computer's hardware can execute directly without translation. Each instruction is represented by a sequence of bits corresponding to specific operations that the CPU can perform.

p.12
Programming Languages Overview

What is assembly language and its primary purpose?

Assembly language is a low-level programming language used to write programs for computer processors. It serves as a bridge between high-level programming languages and machine code, making it easier for programmers to write and understand code that interacts directly with the hardware.

p.12
13
Programming Languages Overview

What are the key characteristics of assembly language?

The key characteristics of assembly language include:

  1. Human-readable mnemonics that represent machine instructions.
  2. One-to-one mapping between an assembly instruction and a single machine code instruction.
  3. Specific to a processor family — different CPUs have different instruction sets.
p.12
13
Programming Languages Overview

What defines high-level programming languages?

High-level programming languages are more abstract than low-level languages. They let programmers focus on solving problems instead of managing hardware details, provide clearer syntax, and often offer portability across platforms.

p.12
13
Programming Languages Overview

List the characteristics of high-level programming languages.

The characteristics of high-level programming languages include:

  1. Abstraction: Hide hardware details.
  2. Readability: Use natural-language-like syntax and structure.
  3. Portability: Easier to run on different platforms.
  4. Built-in functions and libraries: Provide common functionality out of the box.
  5. Memory management: Often automatic (e.g., garbage collection).
  6. Type safety: Helps catch errors early through type checks.
p.13
12
Programming Languages Overview

What are the main differences between natural language and programming language?

Natural LanguageProgramming Language
ExampleEnglishC/C++, Python
GrammarFlexible, context-dependentSyntax: rigid, unambiguous
VocabularyVery largeSmall set of keywords
p.13
Algorithms and Logic in Programming

What is an algorithm in the context of programming?

An algorithm is a well-defined, finite sequence of instructions or steps that, when followed, accomplishes a specific task or solves a particular problem. Algorithms provide a clear procedure for computation or problem solving.

p.13
Algorithms and Logic in Programming

What is the main difficulty of programming according to the text?

The main difficulty of programming is expressing your solution as simple, precise steps that the computer can follow.

p.14
Errors in Programming

What is a syntax error in programming?

A syntax error occurs when code violates the rules of a programming language. It is usually detected at compile or parse time, and the compiler or interpreter reports an error indicating where the violation occurred. Syntax errors are typically easy to fix.

p.14
Errors in Programming

What is a logic error in programming?

A logic error occurs when a program runs without crashing but produces incorrect or unexpected results due to a mistake in the algorithm or program logic. These errors are harder to detect because they often produce no explicit error messages and require testing, debugging, or code review to find.

Study Smarter, Not Harder
Study Smarter, Not Harder