Neural Sync Active
jan-2026-python-week-1-comprehensive-notes
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,0).
- float: Floating-point numbers (3.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.pythontype(10) # <class 'int'> type(10.0) # <class 'float'> type("10") # <class 'str'>
2. Arithmetic Operations
2.1 Operators
| Operator | Description | Result Type |
|---|---|---|
+, - | Add, Subtract | int or float |
* | Multiply | int or float |
/ | True Division | Always float |
// | Floor Division | Quotient (int if inputs are int) |
% | Modulo | Remainder |
** | Exponentiation | Power |
2.2 Operator Precedence (BEDMAS)
- Parantheses
() - Exponentiation
**(Right-associative: 2∗∗3∗∗2=232=29=512) - Multiplication/Division
*,/,//,%(Left-associative) - 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.
pythons = "Python" s[0] # 'P' s[-1] # 'n' (negative indexing)
3.2 Slicing [start : stop : step]
start: Inclusivestop: Exclusivestep: Interval
pythons = "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
endis\n(newline). - Default
sepis" "(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)andor(Lowest precedence)
5.2 Truthiness
Everything is
True except:NoneFalse0(int),0.0(float)""(Empty string)[],{},set()(Empty collections)
Tip
Short-Circuiting
- In
A and B, if A is False, Python doesn't look at B. - In
A or B, if A is True, Python doesn't look at B.
6. Abbreviations & Mnemonics
- Please Excuse My Dear Aunt Sally (PEMDAS)
- STU (String index starts at 0): String The zero-Up.