SYS: ONLINE • IMPORTANT DIFFERENCES

IMPORTANT DIFFERENCES (CS 12)

Difference: random(), randint(), randrange()

Function What it does Example Output example
random() Returns a float in [0.0, 1.0). random.random() 0.6723
randint(a, b) Returns an int in [a, b] (inclusive). random.randint(1, 10) 7
randrange(start, stop, step) Returns an int from range(start, stop, step). random.randrange(1, 10, 2) 3

Difference: sort() vs sorted()

Function What it does Example Output example
sort() Sorts list in place, returns None. lst=[3,1,4]; lst.sort() [1, 3, 4]
sorted() Returns a new sorted list. new_list = sorted([3,1,4]) [1, 3, 4]

Difference: lstrip() vs rstrip() vs strip()

Function What it does Example Output example
lstrip() Removes leading whitespace. " hi ".lstrip() "hi "
rstrip() Removes trailing whitespace. " hi ".rstrip() " hi"
strip() Removes both leading and trailing whitespace. " hi ".strip() "hi"

Difference: LAN, CAN, PAN, MAN, WAN

Network Type Full form Coverage area Example
LAN Local Area Network Small area: home, office, school Office/home Wi‑Fi
CAN Campus Area Network Campus or group of buildings College campus network
PAN Personal Area Network Very small, a few meters Bluetooth, wearables
MAN Metropolitan Area Network City‑wide City Wi‑Fi, cable TV
WAN Wide Area Network Large / global Internet, telecom backbones

Difference: seek() vs tell()

Function What it does Example Output example
seek() Moves file cursor to a position. f.seek(5) Cursor at pos 5
tell() Returns current cursor position. pos = f.tell() 5

Difference: read() vs readline() vs readlines()

Function What it does Example Output example
read() Reads entire file or N chars. f.read() Whole file as string
readline() Reads one line. f.readline() Single line string
readlines() Reads all lines to list. f.readlines() ["L1", "L2"]

Difference: write() vs writelines()

Function What it does Example Output example
write() Writes a single string. f.write("Hello") Writes “Hello”
writelines() Writes list of strings. f.writelines(["L1\n","L2\n"]) Writes multiple lines

Difference: dump() vs load()

Function What it does Example Output example
dump() Serialize object to file (JSON). json.dump(data, f) Writes JSON
load() Read JSON and deserialize. data = json.load(f) Python dict

Difference: MBps vs Mbps

Term Full form Measurement Common use
MBps Megabytes per second Data speed in megabytes File sizes, downloads
Mbps Megabits per second Data speed in megabits Internet speed, bandwidth

Difference: fetchone() vs fetchall()

Function What it does Example Output example
fetchone() Gets next row from result. cur.fetchone() Single tuple
fetchall() Gets all remaining rows. cur.fetchall() List of tuples

Difference: execute() vs executemany()

Function What it does Example Output example
execute() Executes single SQL statement. cur.execute("INSERT ...", (1,"John")) Inserts one row
executemany() Executes same SQL for multiple params. cur.executemany("INSERT ...", [(1,"J"),(2,"K")]) Inserts multiple rows
> Back to Blogs