Registry Synced

jan-2026-python-week-1-comprehensive-notes

444 words
2 min read
Course: Jan 2026 - Programming in Python Topic: Fundamentals of Computing

1. Variables and Data Types

1.1 Core Types

  • int: Whole numbers (5,42,05, -42, 0).
  • float: Floating-point numbers (3.14,2.0,0.0013.14, 2.0, -0.001).
  • str: Text sequences enclosed in quotes ("Hello", 'Python').
  • bool: Logical values (True, False).

1.2 Type Identification

Use the type() function to check an object's class.
python
type(10)      # <class 'int'>
type(10.0)    # <class 'float'>
type("10")    # <class 'str'>

2. Arithmetic Operations

2.1 Operators

OperatorDescriptionResult Type
+, -Add, Subtractint or float
*Multiplyint or float
/True DivisionAlways float
//Floor DivisionQuotient (int if inputs are int)
%ModuloRemainder
**ExponentiationPower

2.2 Operator Precedence (BEDMAS)

  1. Parantheses ()
  2. Exponentiation ** (Right-associative: 232=232=29=5122**3**2 = 2^{3^2} = 2^9 = 512)
  3. Multiplication/Division *, /, //, % (Left-associative)
  4. Addition/Subtraction +, - (Left-associative)
Warning
Right Association Trap 2 ** 3 ** 2 is NOT (2 ** 3) ** 2. In Python, powers are evaluated from right to left.

3. String Basics

3.1 Indexing

Strings index starts from 0.
python
s = "Python"
s[0]  # 'P'
s[-1] # 'n' (negative indexing)

3.2 Slicing [start : stop : step]

  • start: Inclusive
  • stop: Exclusive
  • step: Interval
python
s = "123456"
s[1:4]   # "234"
s[::2]   # "135" (Every 2nd char)
s[::-1]  # "654321" (Reverse)

4. Input and Output

4.1 print()

  • Can display any data type (converts to string internally).
  • Default end is \n (newline).
  • Default sep is " " (space).

4.2 input()

  • Always returns a string.
  • To get numbers, you must cast it: x = int(input()).

5. Logical Operators & Truthiness

5.1 Operators

  • not (Highest precedence)
  • and
  • or (Lowest precedence)

5.2 Truthiness

Everything is True except:
  • None
  • False
  • 0 (int), 0.0 (float)
  • "" (Empty string)
  • [], {}, set() (Empty collections)
Tip
Short-Circuiting
  • In A and B, if AA is False, Python doesn't look at BB.
  • In A or B, if AA is True, Python doesn't look at BB.

6. Abbreviations & Mnemonics

  • Please Excuse My Dear Aunt Sally (PEMDAS)
  • STU (String index starts at 0): String The zero-Up.

Document Outline
Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.