• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Start selling Create your account
Document preview thumbnail
Preview 2 out of 7 pages
Summary

Summary Python Programming Complete Study Guide - From Zero to Exam-Ready (Concepts, Worked Examples & Practice Questions)

Document preview thumbnail
Preview 2 out of 7 pages

Original study guide covering Python fundamentals: data types, strings, collections, control flow, functions (scope, lambda, recursion), OOP (classes, inheritance), exceptions, file handling, modules - plus 10 exam-style practice questions with answers and a quick-reference cheat sheet. Ideal for introductory programming courses and exam prep.

Content preview

Python Programming — Complete Study
Guide
From Zero to Exam-Ready: Core Concepts, Worked
Examples & Practice Questions
Original study material. Covers: data types, control flow, functions, OOP, file handling, errors,
modules, and exam-style practice with answers.




Part 1 — Foundations

1. Variables and Data Types
Python is dynamically typed: you never declare a type; the interpreter infers it.

name = "Ada" # str
age = 36 # int
pi = 3.14159 # float
is_valid = True # bool
nothing = None # NoneType


Key exam facts:
• int has arbitrary precision (no overflow like C/Java).
• float follows IEEE-754 double precision — 0.1 + 0.2 != 0.3 exactly.
• str is immutable; every "modification" creates a new string.
• None is a singleton; always test with is None, never == None.



Type conversion (casting)

int("42") # 42
float("3.5") # 3.5
str(42) # "42"
bool(0) # False — 0, "", [], {}, None are all falsy




2. Strings in Depth
s = "Python"
s[0] # 'P' (indexing)
s[-1] # 'n' (negative index = from the end)
s[1:4] # 'yth' (slice: start inclusive, end exclusive)
s[::-1] # 'nohtyP' (reverse idiom — favourite exam question)


Essential methods: upper(), lower(), strip(), split(","), join(list), replace(a, b), startswi


Page 1/7

, Python Programming - Complete Study Guide


th(), find() (returns -1 if missing; index() raises).

f-strings (Python 3.6+):
name, score = "Ada", 97.5
f"{name} scored {score:.1f}" # 'Ada scored 97.5'




3. Collections

Type Literal Mutable? Ordered? Duplicates?

list `[1, 2]` yes yes yes

tuple `(1, 2)` no yes yes

set `{1, 2}` yes no no

dict `{"a": 1}` yes insertion-ordered (3.7+)
keys unique


nums = [3, 1, 4, 1, 5]
nums.append(9); nums.sort(); nums.pop() # list idioms
t = (1, 2) # tuple unpacking:
a, b = t
s = {1, 2, 3}; s.add(4); s | {5} # set union
d = {"a": 1}; d.get("z", 0) # safe lookup with default


List comprehensions (very common in exams):
squares = [x**2 for x in range(10) if x % 2 == 0]
# dict comprehension:
word_len = {w: len(w) for w in ["hi", "hello"]}


Exam traps:
• list * n repeats references: [[0]] * 3 shares one inner list — use [ [0] for _ in
range(3) ].
• Default mutable arguments: def f(x=[]) keeps ONE list across calls — use x=None.



4. Control Flow
for i in range(5): # 0..4
if i % 2: continue
print(i)


n = 0
while n < 3:
n += 1
else: # runs if loop wasn't broken
print("done")


range(start, stop, step) — stop is exclusive. enumerate() gives index+value; zip() pairs
iterables (stops at shortest).



Page 2/7

Document information

Study
Unknown
Uploaded on
October 6, 2026
Number of pages
7
Written in
2026/2027
Type
Summary
£4.57

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
1
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions