Programming - python Flashcards

(27 cards)

1
Q

Are lists mutable or immutable?

A

Mutable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Are tuples mutable or immutable?

A

Immutable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What type of language is python?

A

Interpreted, object oriented

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the first item’s index in a list?

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What defines scope in python?

A

Indentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a function?

A

A block of code used to perform a single, well-defined task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are some advantages of using functions?

A

Simpler program design, Simpler testing of small units of code, Simpler development, Simpler code sharing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

If inn the function environment the parameters are assigned values from the data that is passed, what is this termed?

A

Call by value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If in the function environment the reference to the list is assigned, what is this termed?

A

Call by reference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is recursion?

A

Recursion is a method where the solution to a problem is calculated from solutions of smaller instances of the same problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the three rules of recursive functions?

A

A recursive function must have a base case
A recursive function must call itself (recursive case)
The recursive case must approach the base case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the main steps of reading data from a file?

A

Opening the file
Getting the data out & into some sensible structure
Validating and cleaning data
Closing the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does cleaning the data mean?

A

Removing any trailing whitespace and newline (\n)
Extracting data from each (comma-separated) line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the process of writing data to a file?

A

Open the file
Ensure data is in the right format
Write the data
Close the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an object?

A

An object is a specific instance of a class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a class?

A

A class is a description, or template, for an object

17
Q

What is abstraction?

A

We define a class using the minimum necessary data (state). We define the minimum set of methods as interface to the class

18
Q

What is encapsulation?

A

We store data that represents the object (state) inside the class. We define methods that operate on that state inside the class

19
Q

What is association?

A

A “uses” B
For general relationships described by one class using the functionalities provided by another class
Typically no strong relationship between the objects

20
Q

What is composition?

A

A “has a” B
Composition is used more strictly, for the relationship between a whole thing and its component parts

21
Q

What is inheritance?

A

A “is a” B
a class specialises a previously defined class

21
Q

What is a library?

A

A library is an external source of code which you can import and reuse

22
Q

What is a framework?

A

Frameworks are similar to libraries in that they contain external code
But, frameworks interact with your code in a different way: frameworks are much more structured and prescriptive, your code only implements defined parts of the framework

23
Q

What does an API do?

A

An Application Programming Interface (API):
- Defines how separate software systems interact
- Enables communication between software systems
- Provides rules for how requests and responses are exchanged

24
What is REST architecture?
Representational State Transfer (REST) - Defines the standards for developing web applications - Defines the protocol (http) for communication - Uses stateless communication - Messages are sent and received But not stored
25
What is JSON?
JavaScript Object Notation A lightweight object-format for data exchange A subset of Javascript but designed to be language-independent Used in most modern APIs ata represented as key-Value pairs
26
What are common scripting tasks?
File manipulation Document text processing Access to system information