Comp 1

0.0(0)
Studied by 1 person
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/41

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:00 AM on 4/30/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

42 Terms

1
New cards

Required as an input parameter

class Student():
	def __init__(self, name)

getting data in when the function is being called

2
New cards

Set at instantiation

class Student():
	def __init__(self, name)
	self.name = name

object has the data - required when class is created

3
New cards

Instance

An instance is a specific object created from a class or is part of a data type, with its own data and behaviour.

4
New cards

Instance Attribute

    def __init__(self, name, cid, year, tutor):
        super().__init__(str(name), int(cid))   #calling parent constructor
        self.year = year    #instance attribute
        self.tutor = tutor  #instance attribute
        self.ace_induction = False  #instance attribute

quality specific to that method relating to the class

An instance attribute is a variable defined in a class using self that stores data specific to each instance of the class.

5
New cards

Class Attribute

class DEStudent():
    '''class just for DesEng students'''
    Faculty = 'Engineering'

bf the def __init__(self) which is a method

A class attribute is a variable defined in a class that is shared by all instances (objects) of that class

6
New cards

Function

def greet(name):
	print("Hello", name)

Reusable block of code that performs a specific task

7
New cards

Method

class Student:
    def __init__(self, name):
        self.name = name

    def say_hello(self):   # ← this is a method
        print("Hi, I'm", self.name)

A method is a function defined inside a class that operates on instances of that class, typically using self.

8
New cards

Super()

class DEStudent(ImperialStudent):
	def__init__(self):
		super().__init__(name, cid)

where name and cid were defined in an earlier class.

req sub class to have the super class in its brackets

9
New cards

oop

object oriented programming - class, attributes and methods

10
New cards

ssh

secure shell - establishes a secure encrypted tunnel btwn client and a server over insecure networks.

prevents attacks and maintains confidentiality and integrity.

when Git is used to securely push code to a remote repository

11
New cards

seaborn

a Python data visualisation library built on top of Matplotlib that provides a higher-level interface for creating attractive and informative statistical graphics

12
New cards

pandas

an extension of Python to process and manipulate tabular data

13
New cards

matplotlib

a Python library that allows users to generate a wide range of static, animated, and interactive visualisations, such as line graphs, bar charts, and scatter plots, from numerical data

14
New cards

num.py

is a Python library used for efficient numerical computing, providing support for arrays, matrices, and mathematical operations on large datasets

Faster than standard Python lists

15
New cards

module

file containing Python definitions and statements; could contain one or more classes; the name of the module is the name of the file (with .py on the end)

can be imported to organise and reuse code.

16
New cards

isinstance

built-in Python function used to check whether an object is an instance of a specified class or data type

17
New cards

Boolean

can only have 2 values, True or False

18
New cards

Pass by reference

for mutable data, a method of passing arguments to a function where the function receives a reference to the original object, allowing it to modify the original data

19
New cards

pass by value

for immutable data, a method of passing arguments where a copy of the value is passed to the function, so changes made inside the function do not affect the original variable

20
New cards

mutable

object whose value can be changed after it is created

21
New cards

iterators

An iterator is something that lets you go through a collection one item at a time.

numbers = [10, 20, 30]

it = iter(numbers)   # create iterator

print(next(it))  # 10
print(next(it))  # 20
print(next(it))  # 30

22
New cards

.append

a list method in Python that adds a single element to the end of a list

23
New cards

df

DataFrame (df) is a two-dimensional data structure in Python (from the pandas library) used to store and manipulate tabular data with rows and columns

24
New cards

df.head()

Prints the first few rows of the data

brackets holds a number only

25
New cards

df.info()

Shows you the columns, if any columns have null data, and the variable type of each column

26
New cards

df.shape

Will give you the size of the data (number of rows x number of columns)

27
New cards

df.mean()/.median()

Gives you the average value of each column

28
New cards

df.std()

Gives you the standard deviation of each column

29
New cards

df.unique()

Gives you the different values that exist

30
New cards

whitespace sensitive

A language where spaces, indentation, and newlines affect the syntax. In Python, indentation defines code blocks.

31
New cards

Dictionaries

dictionary_name = { 'key_1': 'value_1', 'key_2': 'value_2', 'key_3': 'value_3'}

print(dictionary_name.get('key_1'))  # 'value_1'

dictionary_name['key_1'] = 20          # update
dictionary_name['key_4'] = "A"       # add new key-value pair

for key, value in dictionary_name.items():
    print(key, value)

student.keys()     # returns all keys
student.values()   # returns all values
student.items()    # returns (key, value) pairs
student.clear()    # empties dictionary

output:

‘value_1’

'key_1' 'value_1'

‘key_2' 'value_2'

'key_3' 'value_3'

‘key_4’ ‘A’

32
New cards

len()

for a string

len('hello') #5

gives number of characters

for a list

numbers = [1, 2, 3, 4]
len(numbers) #4

gives # items

for dictionaries

dict = { 'name': 'Sally', 'age': 19}
len(dict) #2	

gives number of key-value pairs

33
New cards

iterable object

A Python object with items that can be counted in a sequence. Examples

include lists, tuples, and dictionaries.

34
New cards

Version Control

Software used to track the changes made in a collection of code files. In

this module we have used git, which is an open-source version control

system that tracks code kept in repositories. We have used the

commercial service GitHub to manage our git repositories.

35
New cards

UML class diagram

  1. classes

  2. attributes

  3. methods

36
New cards

PEP8

python style guidelines

e.g. snakecase

37
New cards

Comparison of code

  • naming

  • style

  • clarity

  • functionality

  • whether one is preferable and why

38
New cards

Duck typing

Objects are used based on the methods/attributes they have, not their type. If an object behaves correctly (e.g. has __len__), it can be used.

39
New cards

Inheritance

A class (child) is created from another class (parent) and automatically gets its attributes and methods, with the option to override or extend them.

40
New cards

Encapsulation

Bundling data and methods inside a class while limiting direct access to some data (e.g. using _), to protect internal state.

41
New cards

Operator overloading

Defining special methods (e.g. __add__) to change how operators like +, -, == work for objects of a class.

42
New cards

Garbage collection

Automatic memory management where unused objects are removed, mainly using reference counting (and handling cycles).