Python Data Types, User Input, and Positional Number Systems

Academic Course Information and Context

  • Student Name: Alexandra Lozano.
  • Course: Computing Safety Mini Course.
  • Platform and Curriculum: Digital Literacy - Safety and Security, hosted on edube.org.
  • Identified User Handles: @ILRO5212010 and Allr@05212010.
  • Session Dates Recorded: October 14, 2026 (10/14/202610/14/2026), October 15, 2026 (10/15/202610/15/2026), and October 19, 2026 (10/19/202610/19/2026).
  • Core Subject Matter: Input and Type Conversion (annotated as Input/Type Carasiam), scientific notation, and positional number systems in Python.

Python User Input Mechanisms

  • Definition of the input() Function:
    • Operates as a built-in function call designed to pause program execution and accept input from the user.
    • Behavior: Collects data entered by the user through the standard input console and automatically converts the entered data into a string data type (str).
  • Function Arguments and Syntax:
    • The argument passed into input() is optional.
    • When an argument is supplied, it acts as a prompt that displays a message directly to the user.
    • Syntax Example: input("What is your name: "), where the string "What is your name: " is the argument that prints to the console before user input is received.

Data Type Conversions and Operations

  • String Conversion (str()):
    • Takes an argument of a non-string or string type and converts it into a string (str).
    • Example: str(4) evaluates to the string '4'.
  • Integer Conversion (int()):
    • Converts a numeric value or a compatible string representation into a standard integer (int).
    • Examples of valid conversions:
    • int(4) evaluates to the integer 44.
    • int('41') evaluates to the integer 4141.
    • int('7') evaluates to the integer 77.
    • int('5') evaluates to the integer 55.
    • Error Handling on Non-Numeric Literals: Attempting an integer conversion on an alphabetical string such as int('Junely') causes a runtime error, as non-numeric string literals cannot be converted to an integer.
  • Floating-Point Conversion (float()):
    • Converts an integer, numeric value, or compatible string into a floating-point number (float).
    • Example: float(4) evaluates to 4.04.0.
  • Concatenation versus Arithmetic Addition Case Study:
    • Default behavior without type conversion:
    • Code:
      • x = input("Enter a number: ") (User enters 77, variable x stores '7')
      • y = input("Enter a number: ") (User enters 55, variable y stores '5')
      • print("The Sum of your number is: ", x + y)
    • Evaluation: Because x and y are string variables, the + operator executes string concatenation rather than numerical addition, yielding '75'.
    • Corrected behavior utilizing explicit type conversion:
    • Code:
      • x = int(x) (Converts '7' to the integer 77)
      • y = int(y) (Converts '5' to the integer 55)
      • print(x + y)
    • Evaluation: Because x and y are explicitly converted to integers, the + operator executes mathematical addition, yielding 7+5=127 + 5 = 12.

Scientific and Exponential Notations

  • Representation of Large Numerical Quantities:
    • Standard decimal notation: 156,000,000156,000,000 (annotated as 1.5600,000.).
    • Scientific E-notation: 1.56e8.
    • Standard scientific notation: 1.56×1081.56 \times 10^8.
  • Representation of Small Fractional Numerical Quantities:
    • Standard decimal notation: 0.000000230.00000023 (annotated as .0000002.3).
    • Scientific E-notation: 2.3e-7.
    • Standard scientific notation: 2.3×10−72.3 \times 10^{-7}.
  • Expression Fragment Notated: 6-23t56+00.

Number Systems and Representation Prefixes

  • Python Default Display Format:
    • Python prints numerical output in decimal (Base 1010) by default.
  • Positional Number Systems Overview:
    • Decimal:
    • Base 1010.
    • Utilizes digits: 0,1,2,3,4,5,6,7,8,90, 1, 2, 3, 4, 5, 6, 7, 8, 9.
    • Binary:
    • Base 22.
    • Prefix indicator in Python: 0b or 0B.
    • Utilizes digits: 0,10, 1.
    • Octal:
    • Base 88.
    • Prefix indicator in Python: 0o or 0O.
    • Utilizes digits: 0,1,2,3,4,5,6,70, 1, 2, 3, 4, 5, 6, 7.
    • Hexadecimal:
    • Base 1616.
    • Prefix indicator in Python: 0x or 0X.
    • Utilizes digits 00 through 99 and letters AA through FF (or lowercase aa through ff).
    • Alphanumeric character values:
      • A=10A = 10
      • B=11B = 11
      • C=12C = 12
      • D=13D = 13
      • E=14E = 14
      • F=15F = 15
  • Python Built-in Base Conversion Functions:
    • bin(): Converts an integer into a binary string literal with the 0b prefix.
    • oct(): Converts an integer into an octal string literal with the 0o prefix.
    • hex(): Converts an integer into a hexadecimal string literal with the 0x prefix.

Numerical Base Conversions and Algorithms

  • Binary to Decimal Conversion:
    • Instruction: print(0b1101010).
    • Binary Value: 1101010.
    • Positional place value weights (powers of 22 from right to left):
    • 26=642^6 = 64
    • 25=322^5 = 32
    • 24=162^4 = 16
    • 23=82^3 = 8
    • 22=42^2 = 4
    • 21=22^1 = 2
    • 20=12^0 = 1
    • Step-by-step expansion:
    • (1×64)+(1×32)+(0×16)+(1×8)+(0×4)+(1×2)+(0×1)(1 \times 64) + (1 \times 32) + (0 \times 16) + (1 \times 8) + (0 \times 4) + (1 \times 2) + (0 \times 1)
    • 64+32+8+2=10664 + 32 + 8 + 2 = 106
    • Subtotal calculation check: 64+32=9664 + 32 = 96; 8+2=108 + 2 = 10; 96+10=10696 + 10 = 106.
  • Decimal to Binary Conversion via Repeated Division by 22:
    • Evaluated command: print(bin(100)).
    • Division steps recording quotients and remainders (R):
    • 100÷2=50 R 0100 \div 2 = 50\text{ R }0
    • 50÷2=25 R 050 \div 2 = 25\text{ R }0
    • 25÷2=12 R 125 \div 2 = 12\text{ R }1
    • 12÷2=6 R 012 \div 2 = 6\text{ R }0
    • 6÷2=3 R 06 \div 2 = 3\text{ R }0
    • 3÷2=1 R 13 \div 2 = 1\text{ R }1
    • 1÷2=0 R 11 \div 2 = 0\text{ R }1
    • Reading the remainders sequentially from the last operation to the first (bottom to top): 1100100.
    • Binary result: 0b1100100.
  • Hexadecimal to Decimal Conversion:
    • Instruction: print(0x3b).
    • Hexadecimal Value: 3b.
    • Positional place values (powers of 1616):
    • 161=1616^1 = 16
    • 160=116^0 = 1
    • Character mapping: b=11b = 11.
    • Step-by-step expansion:
    • (3×16)+(11×1)(3 \times 16) + (11 \times 1)
    • 48+11=5948 + 11 = 59
    • Decimal output: 5959.
    • Hexadecimal multi-digit positional weights (e.g., representation for AAA):
    • 162=25616^2 = 256
    • 161=1616^1 = 16
    • 160=116^0 = 1
  • Decimal to Hexadecimal Conversion via Repeated Division by 1616:
    • Conversion of decimal 10001000:
    • 1000÷16=62 R 81000 \div 16 = 62\text{ R }8
    • 62÷16=3 R 1462 \div 16 = 3\text{ R }14 (decimal remainder 1414 maps to hexadecimal digit e or E)
    • 3÷16=0 R 33 \div 16 = 0\text{ R }3
    • Reading remainders from bottom to top: 3e8.
    • Hexadecimal representation: 0x3e8.
  • Octal to Decimal Conversion:
    • Instruction: print(0o457).
    • Octal Value: 457.
    • Positional place value weights (powers of 88):
    • 82=648^2 = 64
    • 81=88^1 = 8
    • 80=18^0 = 1
    • Step-by-step expansion:
    • (4×64)+(5×8)+(7×1)(4 \times 64) + (5 \times 8) + (7 \times 1)
    • 256+40+7256 + 40 + 7
    • Intermediate step: 256+40=296256 + 40 = 296
    • Final sum: 296+7=303296 + 7 = 303
    • Decimal output: 303303.
  • Decimal to Octal Conversion via Repeated Division by 88:
    • Evaluated command: print(oct(99)).
    • Division steps recording quotients and remainders (R):
    • 99÷8=12 R 399 \div 8 = 12\text{ R }3
    • 12÷8=1 R 412 \div 8 = 1\text{ R }4
    • 1÷8=0 R 11 \div 8 = 0\text{ R }1
    • Reading remainders from bottom to top: 143.
    • Octal result: 0o143.
    • Verification via positional expansion:
    • (1×64)+(4×8)+(3×1)(1 \times 64) + (4 \times 8) + (3 \times 1)
    • 64+32+3=9964 + 32 + 3 = 99.