platypus-platypus-platypus
platypus-platypus-platypus
Untitled
38 posts
Don't wanna be here? Send us removal request.
platypus-platypus-platypus · 2 months ago
Text
equilibrium solution / equilibrium
phase plot
dx/dt = instantaneous rate of change
dx/dt = 0 => function is a horizontal line
e.g. dx/dt = 3x-2, dx/dt changes on X-T graph => graph is a curve
In short:
x(0) = 2/3, dx/dt = 0, x(1) = 2/3, dx/dt = 0, ...
x(0) = 1, dx/dt > 0, x(1) = larger, dx/dt = larger, ...
x(0) = 1, dx/dt > 0, x(-1) = smaller, dx/dt = smaller, ....
0 notes
platypus-platypus-platypus · 2 months ago
Text
14/05/25
CSV Files
text = open(FILENAME).read() # string
lines = open(FILENAME).relines() # a list of strings separated after # '\n'
---
fp = open(FILENAME) # create a file object (iterator & iterable)
for line in fp: print(line, end="")
...
---
import csv
FNAME = "text.csv" table = [] FOBJ = open(FNAME) # file object lst_of_dict = csv.DictReader(FOBJ) # DictReader object
# csv.DictReader(open(FNAME))
for line in lst_of_dict: # rows as dictionaries: {column header: value} table.append(line)
for row in table: print(row['Year'], row['Model'])
1997 Falcon 2006 Odyssey
---
for row in csv.reader(open(FNAME)): # rows as lists table.append(row) # nested list
[['Year', 'Make', 'Model'], ['1997', 'Ford', 'Falcon']
---
list()
0 notes
platypus-platypus-platypus · 2 months ago
Text
Remember
If you don’t study hard now, you might have to become a full-time tutor.
0 notes
platypus-platypus-platypus · 2 months ago
Text
ughhh new start
i mean now
0 notes
platypus-platypus-platypus · 2 months ago
Text
5/5/25
Local & global namespaces
scope
dereference
local namespaces of given function call are inaccessible from any other function call.
Except in nested functions
Attempt to assign new value to a global variable within function -> local variable created
Cannot edit global variable in local context
Call by object
For mutable objects: can be pointed at by multiple variable names & editing from one name edits it for all
e.g. lst = ..., lst2 = lst # Call by object
lst += [1] # Creating new object
map, filter -> map object
key = function
stable sort
0 notes
platypus-platypus-platypus · 3 months ago
Text
29/04/25
'abc' - 4 empty strings...
1st way:
import math
area = math.pi
2nd way:
From math import pi as MY_PI
random.seed(0)
no real random, same order of int every time
os - interacting with operating system
defaultdict in collection library
(must initialise counter??)
from collections import Counter
0 notes
platypus-platypus-platypus · 3 months ago
Text
28/04/25
text.split(".") != text.split(". ")?? Why
What's the hidden testcase supposed to be
0 notes
platypus-platypus-platypus · 3 months ago
Text
the hidden test killed me. now i know why ppl say coding is frustrating
Update: ... the 1st word is supposed to be the leading white space... crazy
0 notes
platypus-platypus-platypus · 3 months ago
Text
25/04/25
.insert(index, object) 
.isalnum()
zip()
print(sorted(randlist, reverse=True))
.reverse() modifies in-place
just don't use .sort()
tuple tiebreaking: [(1, "bye"), (1, "hi")]
sorted(str) returns sorted(list(str))
0 notes
platypus-platypus-platypus · 3 months ago
Text
Games
Cube Escape
Ace Attorney
0 notes
platypus-platypus-platypus · 3 months ago
Text
15/4/25
for num in nums: # num is the value at an index of nums
---
Tumblr media
unnecessarily long as always. the flowchart was much more simple
---
Tumblr media
0 notes
platypus-platypus-platypus · 3 months ago
Text
completely messed up my science report... hope i won't fail bc of it... guess it's a lesson I probably won't internalise...
0 notes
platypus-platypus-platypus · 3 months ago
Text
have a feeling they're going to make the exam extremely difficult to compensate for the MST...
0 notes
platypus-platypus-platypus · 3 months ago
Text
STR
str.split() #method
return: new list
modify: no
used for: str
str.split("any character/s in str") #used to split str into lists. Returns a value but does not change the original iterable
str.upper()
return: no
modify: yes
str.lower()
return: no
modify: yes
str.strip()
return: no
modify: yes
removes leading & trailing characters (defaults to white space)
.isdigit()
return: bool
modify: no
CONVERSION & OTHERS:
int()
float()
str()
list()
tuple()
dict()
set()
abs()
rount()
ORDER OF OPERATIONS:
arithmetic:
* / % //
+ -
comparison:
== > < >= <= !=
membership:
in
logical (evaluated lazily):
not
and
or
0 notes
platypus-platypus-platypus · 3 months ago
Text
ITERABLES
GENERAL (list, tuple, dictionary, set, view object):
sum() #function
return: new object
modify: no
used for: iterable with int, float & bool / iterable w/h non-str iterables of same type
sum() is actually sum(iterable , int() / float()) #adding element of iterable to the int / float object
sum(dict) #returns sum of keys
sum(dict.values()) #returns sum of values
sum(dict.items(), ()) also works
max() min() #functions
return: max element
modify: no
used for: iterables w/h data type w/h ttl ordering
"".join(iterable) #method
return: new string
modify: no
used for: iterable w/h data type w/h ttl ordering
"character between elements / keys".join(iterable) #used to join lists, tuples, dictionaries and sets w/h only str
sorted()
return: new string
modify: no
used for: iterable w/h data type w/h ttl ordering
SEQUENCE (list, tuple):
sequence.index(index)
return: yes
modify: no
if not found: Error
returns element with index
sequence.count(value)
return: yes
modify: no
if not found: Error
returns index of 1st instance of element with value
MUTABLE (list, dictionary, set):
.pop()
return: returns removed element
modify: removes element
list.pop(index) #pops index, defaults to last element
dict.pop(key, default value) #returns default value if key not found
LIST & SET:
set.remove(element)
return: None
modify: yes
DICT & SET:
.update(another_set / dictionaey)
return: None
modify: yes
existing keys are overwritten
LIST:
.append() vs .extend(iterable)
return: None
modify: yes
.append() appends any single object
.extend(iterable) adds each item of the iterable
.reverse()
return: None
modify: yes
DICT (because unindexed, key must be immutable):
dict[key]
return: value / None if key doesn't exist
modify: no
dict.get[key]
return: value / Error if key doesn't exist
modify: no
dict[key] = value #add element
SET (because unindexed, element must be immutable):
set.add(element)
.union() #|
.intersection() #&
.difference() #-
0 notes
platypus-platypus-platypus · 3 months ago
Text
9/4/25
How to join a list of strings:
sum(lst) #wrong
list.join() #wrong
separator.join(iterable)
"".join(lst)
---
sorted(dicti)[0] #returns list of sorted keys
min(dicti) #if dicti changes, min(dicti) can also change
---
True is equivalent to 1 & False is equivalent to 0 in arithmetic expressions
---
arithmetic > comparison = membership = identity > logical operators
---
Tumblr media
---
Merging dictionaries:
.update()
---
Tumblr media
......
0 notes
platypus-platypus-platypus · 3 months ago
Text
8/4/25
Tumblr media
not wrong but not right either
Tumblr media
remember to use .values()
Tumblr media
---
Tip: do not use nested loops
0 notes