Open
file = open(“quick.txt”, “_”)
Read
file = open(“quick.txt”, “r”)
quicktext = file.read()
Close
Write (overwrite)
file = open(“quick.txt”, “w”)
Append (add to)
file = open(“quick.txt”, “r”)
Turtle commands
All on the PLS.
Import turtle with import turtle
List
a type of data structure that can be used to manipulate the elements they contain.
Array
a kind of data structure that can hold a number of items grouped together. it contains a number of items grouped together, and named using a single identifier, however can only hold the same data type.
Procedures
Carries out an action but doesn’t return a value
Functions
Carries out an action and returns a value
Data structure
store data in an organised and accessible way. They can be static or dynamic.
Dynamic data structure
more flexible. The memory capacity is not fixed.
Static data structure
reserves memory locations for a set amount of data. Their size cannot change.
String format
print(”Alice has {} cupcakes.”.format(5))
Record
Stores a collection of attributes/fields for a single entity.
Static data structure
Database
Stores many records for a single entity
How to do a record in python
Use a dictionary to represent a record
player1 = {“username” : “rockstar”,
“password” : “6goatsEating”,
“score” : 5328}
player2 = {“username” : “dynomouse”,
“password” : “Skibidi”,
“score” : 8594}
player3 = {“username” : “australiahead”,
“password” : “FanumTax”,
“score” : 9999}
players = [player1, player2, player3]
print (players)
Linear search
Goes through every item in a list to see if it’s correct
Binary search
Bubble sort
Bubble sort works by repeatedly going through a list, comparing adjacent items and swapping the items if in the wrong order.
Merge sort