Comp 1312 Programming 1 Flashcards

(80 cards)

1
Q

What does an f string do?

A

An f string tells python to sub in all the variables, placed inside the curly brackets into the string

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

What are the concepts for quality code?

A

Duplication
Coupling
Cohesion

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

What is duplication?

A

An indicator of bad design where code has been copied, harder to maintain.

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

What is coupling?

A

Links between separate modules of a program
We aim for loose coupling.

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

What is loose coupling?

A

Understanding one item without reading another so we can change one function without changing another.

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

What is the Noun/Verb method?

A

Identifying nouns to reveal potential identifiers.

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

What is C?

A

Imperative procedural programming language, compiled, statically typed with low-level access.

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

What is a header file?

A

How extra modules are imported in C

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

List some default types in C

A

INT
FLOAT
DOUBLE
CHAR
_Bool

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

What are type specifiers?

A

Keywords that change the amount of data associated with a type

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

What happens if we initialise a variable at it’s highest value and then add one?

A

An overflow

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

What is implicit type conversion?

A

When a type can be converted to another without specific instructions to do so, e.g integer to float.

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

What does the Const keyword do?

A

Makes the variable constant and thus read only

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

What is the difference between ++n and n++?

A

Pre-increment and post-increment

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

What are strings really?

A

Arrays of chars

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

What is the placeholder symbol for a string?

A

%s

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

What is a structure?

A

Group elements of different types into one object

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

What can a structure be considered to be?

A

A data template

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

How can a structure be accessed?

A

structure_name.structure_item;

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

What does typedef do?

A

Assigns a new name to existing types and new data types, including structures

typedef int counter;
counter x,y;

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

T/F A function can return an array.

A

False

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

T/F A function can return an structure.

A

True

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

T/F You can have nested structures

A

True

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

What is a pointer?

A

A variable that stores a memory address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What could be an issue when memory is not cleared correctly?
Any variables declared get whatever value is at the location they are assigned
26
What does the sizeof function return?
The number of bytes taken up by the type submitted as it's operand.
27
How can you calculate the length of an array?
sizeof(array)/sizeof(type)
28
What is the symbol for the address operator?
&
29
What would &var return?
The address the var variable is being stored at.
30
How can a pointer be declared?
double *p = &var;
31
Why is a type declared with a pointer?
So the pointer knows how many bytes belong to the variable.
32
What is the dereference operator?
*p This is the same as just accessing a variable
33
Why can a pointer be incremented?
To access multiple elements in an array.
34
What does the malloc function do?
Allocate a specific amount of bytes in memory and returns the base address of these bytes.
35
What does the free function do?
Returns the pointer and associated memory back to the heap
36
What does the realloc function do?
Changes the size of previous allocated memory by inputting a pointer and a new size
37
What does the calloc function do?
Allocates a certain amount of blocks to the size specified calloc(n_blocks,sizeof(int))
38
When do memory leaks occur?
When memory isn't correctly returned to the heap. Or when a pointer is reinitialised without freeing the original memory
39
How can we output to a file?
./myfile > data
40
How can we input from a file?
./myfile < data
41
What does EOF stand for?
End of File Returned by getchar and scanf when the reach the end of their inputs?
42
What are the f functions?
Function for reading and writing to files, such as: fopen fclose fprint fscanf fgets
43
How are preprocessor statements indicated?
#
44
What does #define do?
#define PI 3.14159268 Replaces every instance of PI with constant 3.14
45
What happens if you place a hash in front of of the parameter in a preprocessor statement?
It will create a constant string out of the macro-argument #define str(x) # x
46
What is a local variable?
Variables only accessible from the scope they are defined in.
47
T/F Does python support multiple return arguments?
True
48
What does the global keyword do?
Tells python to look for a global variable and make it accessible from this function
49
How can list comprehension be accomplished?
[expression for item in collection if condition] squares = [x**2 for x in range(5)] [0,1,4,9,16]
50
What is aliasing?
When two or more variables refer to the same object within memory, instead of copying the list another variable is given the memory address for the list The copy method solves this problem
51
What is a ragged list?
A multidimensional list where the sublists have varying lengths
52
What is a dictionary?
A collection of key-value pairs where each key is unique
53
How is a file opened in python?
with open(file,mode) as file: content=file.read()
54
List some of the possible file access modes
r - read w - write a - append r+ - read and write, file starts at beginning w+ - read and write, create file if not exists x - exclusive creation b - binary file t - text file
55
What does the strip function do?
Removes any leading or trailing whitespace characters
56
How can a csv file be opened?
Using the csv module and csv.reader csv.dictreader csv.writer
57
What are the characteristics of an algorithm?
Performance Efficiency Understandability Scalability Reusability Reliability Elegance
58
What happens if the specification for a program is inadequate?
Assumptions
59
What is UML?
Unified Modelling Language
60
What is a synchronous message?
Requires a response before the interaction can continue?
61
What is a reflexive message?
A message an object sends to itself
62
What is an alternative fragment?
When a choice needs to be made between two or more message sequences
63
What is a loop fragment?
Represents a repetitive sequence
64
What is an IDE?
Integrated Development Environment.
65
What could an IDE contain?
A code editor Build automation A debugger Version control
66
What are common features of a source code editor?
Syntax highlighting Code completion Refactoring Version control Code search
67
What are the coding styles for python?
PEP8 PEP257
68
Give some general good practise coding points
Avoid over doing whitespace Documentation strings
69
What are the testing strategies?
Blackbox Equivalence classes Boundary value Cause-effect Error guessing Whitebox Statement coverage
70
What are some human-based testing methods?
Walkthroughs Code inspections User testing
71
What are some computer-based testing methods?
Print statements Logging Pytest
72
What are the error-locating principles?
Review your code Describe your problem to others Debugging tools Avoid code experimentation
73
What are the fundamental software engineering activities?
Specification: Define the functionality Development: Produce the software Validation: Validate it does as client expected Evolutions: Meet the client's changing needs
74
What is DevOps?
Developers write software Operators maintain it DevOps is combining these teams to improve efficiency A set of processes, ideas and technologies to make software delivery more efficient.
75
What is continuous integration?
Frequently committing code to a central repository, automate building and testing
76
What is continuous delivery?
Release software update to end users using automation Follow continuous integration
77
What is continuous deployment?
Automates the deployment of code releases
78
How does Github support continuous integration?
Through github actions Adding actions that run on every push for testing and other
79
What are equivalence classes?
The set of input values that have the same result.
80
What is cohesion?
The degree of which elements of a module are related to each other