CSC1015F Study Notes

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/111

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards related to Computer Science basics and Python programming.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

112 Terms

1
New cards

Computer Science

The study of computer software, algorithms, abstractions, and efficiency, as well as the theoretical foundation of computation.

2
New cards

Algorithm

A set of steps to complete a task; must be precise, repeatable, predictable, executable, and have an end.

3
New cards

Programming Process

Ingesting info from the real world, processing data, and sending data back to the real world.

4
New cards

Sequence

Steps flow in order.

5
New cards

Selection

A choice must be made.

6
New cards

Iteration

The repetition of steps.

7
New cards

Algorithms

Written in natural language.

8
New cards

Programming Languages

Written with strict rules.

9
New cards

Python

Uses .py file. A set of instructions executed by an interpreter. An Object-Oriented Programming language.

10
New cards

Compile

Take a piece of code that a human can understand and turn it into something a computer can run.

11
New cards

Compiler

Compiles all of the code of a computer at once.

12
New cards

Interpreter

Compiles code line by line.

13
New cards

IDE

An application used to help someone create code.

14
New cards

Literals

Actual data values.

15
New cards

Operators

+, -, *, /, %, **, etc.

16
New cards

Comment

A part of the code ignored by Python, intended to help a human reader.

17
New cards

Function

A named sequence of instructions that perform a collective purpose.

18
New cards

Argument

An argument is part of a function.

19
New cards

Identifier

A word used to name a function and variable.

20
New cards

Variable

A container for data named using the rules for identifiers.

21
New cards

Expression

Combines variables, literals, and operators.

22
New cards

Syntax

The fundamental rules of a programming language.

23
New cards

eval() Function

Evaluates a string as a python expression and returns the most appropriate type (e.g. int() or float() ).

24
New cards

Boolean_expression

Evaluates to either True or False.

25
New cards

Boolean

Stores either True or False.

26
New cards

AND

Returns True only if both operands are True.

27
New cards

OR

Returns True if at least one of the operands is True.

28
New cards

NOT

Inverts the boolean value.

29
New cards

Hierarchy

Operators are evaluated in a specific order. Higher precedence operators are evaluated before those with lower precedence.

30
New cards

Conditional expression

An expression that compares values using conditional operators, and which evaluates to a boolean.

31
New cards

Boolean expression

An expression that combines boolean operands using boolean operators, and which evaluates to a boolean.

32
New cards

Iteration

The process of executing the same block of code or a set of statements multiple times.

33
New cards

For Loop

Repeats a specific number of times. Also known as a definite loop.

34
New cards

While Loop

Repeats while a condition is true. It is an indefinite loops as it doesn't run a fixed number of times.

35
New cards

Continue

Skips the rest of the current iteration and returns to the top of the loop.

36
New cards

Break

Completely escapes from the loop.

37
New cards

Nested statements

Placing a statement inside another (e.g., if/else/for inside if/else/for ).

38
New cards

Nested loop

placing a for or while loop within another for/while loop.

39
New cards

Terminating Value / Sentinel

A value that indicates the end of a sequence of data or the termination of a loop.

40
New cards

Arrays

An indexed sequence of values associated with one variable.

41
New cards

Static array

Length cannot be changed (usually in compiled languages)

42
New cards

Dynamic array

Lengths can be changed (usually in interpreted languages)

43
New cards

'IndexError'

A runtime error that occurs when a list index is out of range.

44
New cards

In-place Function

Modifies the original list.

45
New cards

Mutability

Describes the ability to change the values within an object. Lists and dictionaries are mutable. Strings are immutable.

46
New cards

2D array

A list of lists. You need two indexes to access an element (e.g., arr[0][0] ).

47
New cards

Dictionaries

A set of key-value pairs.

48
New cards

String

A list of characters.

49
New cards

Objects

A datatype that combines data and functions (called methods).

50
New cards

ASCII

A more limited system for character representation.

51
New cards

len(string)

Returns the length of a string.

52
New cards

String Slicing

Extracts a portion of a string.

53
New cards

s.format()

Formats a string, using placeholders like {}.

54
New cards

Purpose

Make programs readable and modular; Refactor code to avoid duplication.

55
New cards

Parameter

Variables defined in a function's definition when creating the function.

56
New cards

Argument

Values that are provided for each parameter when a function is invoked.

57
New cards

Scope

The part of a program where a variable is accessible or modifiable. Variables created in a function are local.

58
New cards

Lifetime

Duration for which a variable exists (e.g., local variables are deleted at the end of a function).

59
New cards

Docstrings

Specify the purpose in a string immediately after the function header (ideally a multiline string – """ """).

60
New cards

Modules

Any python program with functions can be imported and used by another program.

61
New cards

Testing

Checking if there are any errors; It only demonstrates that no errors have been found; there could still be errors.

62
New cards

Debugging

To find the cause of a known error and repair it.

63
New cards

Compile-time errors

Errors picked up by the compiler during compilation; usually syntax errors.

64
New cards

Runtime errors

Errors that occur when code is executed.

65
New cards

Syntax error

Program does not pass checking/compiling due to improper use of python language (e.g. typo, incorrect indentation, division by zero).

66
New cards

Logic errors

Program passes checking/compiling and runs, but produces incorrect output (or no output) due to flaws in algorithm or implementation.

67
New cards

Exhaustive testing

Run program using all possible input and compare actual output to expected. Ideal, but unrealistic.

68
New cards

Random testing

Testing a random subset of values in the input domain (using a random number generator). It is important to ensure values are distributed over the input domain. Unreliable so should be avoided.

69
New cards

Equivalence Classes

Group values into sets of values with similar expected behavior.

70
New cards

Boundary Values

Choose values at the boundaries of equivalence classes.

71
New cards

Path Testing

Create test cases to cover *all paths of execution of the program at least ones. Hence every combination of statements is executed.

72
New cards

Statement Coverage

Create test cases to ensure that all statements are executed at least once.

73
New cards

Black Box Testing

You cannot access the actual code.

74
New cards

Glass Box Testing

You can access the actual code.

75
New cards

Tracing

Insert temporary print statements into code to output values during calculation ("trace instructions").

76
New cards

Debugging

The process of finding errors in code (using a debugger).

77
New cards

Debugger

A tool for executing an application where the programmer can carefully control execution and inspect data.

78
New cards

Recursion

A recursive function is a function that calls itself based on the problem- solving technique of breaking down a task into subtasks.

79
New cards

Stopping condition (or base case)

Ensures the function eventually stops recursing.

80
New cards

Cons

Recursion is not absolutely necessary – any recursive task can be done non- recursively using loops.

81
New cards

Data Storage

Data in a computer is stored in files.

82
New cards

File Extensions

All files have a file extension (e.g., .py, .txt) which indicates the file's contents or intended use.

83
New cards

Text Files (.txt)

Made of strings that end with a newline ( \n ).

84
New cards

Binary Files

Store info in application-specific formats (e.g., .pdf, .jpg).

85
New cards

Encoding

The encoding method indicates how the symbols were converted to binary (e.g. 'ASCII', unicode ('utf-8')).

86
New cards

"r" : Read mode

Reads existing file (IOError if file doesn't exist).

87
New cards

"w" : Write mode

Overwrites existing file (or creates new file) for writing.

88
New cards

"a" : Append mode

Opens file (or creates new one) and moves cursor to end for writing.

89
New cards

"x" : Exclusive creation mode

Exclusive creation mode for writing (IOError if file exists).

90
New cards

f.close()

Always close the file after interacting with it! This saves releases the file so that others can interact with the file.

91
New cards

f.read(n)

Reads at most n bytes or the entire contents of the file into a string; n is optional.

92
New cards

print("…" , file=f)

Outputs a string to a file, adding \n by default.Works just like normal print (but doesn't print to console). Can take multiple expressions.

93
New cards

Exceptions

Unexpected events or conditions that disrupt the normal flow of execution in a program.

94
New cards

FileNotFoundError

file doesn't exist (e.g. when using "r" mode)

95
New cards

FileExistsError

file already exists (e.g. when using "x" mode)

96
New cards

Linear Search

Starts at one end of the list and checks each element until either the target is found or the list ends.

97
New cards

Binary Search

Only works on sorted lists. Divides the search interval in half repeatedly - divide & conquer.

98
New cards

Selection Sort

Selects the smallest item in the list and swaps it with the first item, then repeats for the rest of the list until fully processed.

99
New cards

Merge Sort

Divides the list into n sublists and repeatedly merges them producing sorted sublists until one sorted sublist remains.

100
New cards

Quick Sort

Partitions the list based on a pivot value, then sorts each partition recursively.