Scripting Exam

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

1/121

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:13 PM on 6/24/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

122 Terms

1
New cards

Compiler

A compiler translates the whole source program into another form, often machine code or bytecode, before the program runs. After compilation, the resulting program can usually run faster because the translation is already done.

2
New cards

Interpreter

An interpreter executes code step by step. Python is commonly described as interpreted because code can be run interactively and executed line by line by the python runtime.

3
New cards

Translation

  • Compiler: Usually translates the entire program before execution

  • Interpreter: Executes statements as the program runs

4
New cards

Error Discovery

  • Compiler: May report many syntax errors before running

  • Interpreter: May stop when it reaches the error

5
New cards

Speed

  • Compiler: Often faster after compilation

  • Interpreter: often slower because execution includes interpretation

6
New cards

Python Identifier Rules

  • Can contain letters, digits, and underscores

  • cannot start with a digit (number)

  • cannot contain spaces or symbols like @, %, -, or $

  • cannot be a python keyword such as if, else, for, import, class, or while

  • identifiers are case-sensitive: name, Name, and NAME are different

7
New cards

Comments

a comment is ignored by Python and is used to explain code

8
New cards

Single, double, and triple quotes

Single quotes and double quotes both create strings. Triple quotes are useful for multi-line strings

9
New cards

Escape Sequences

An escape sequence begins with a backlash. The exam review specifically mentions the difference between n and \n

10
New cards

n

  • Meaning: just the letter n

  • Example output: HellonWorld

11
New cards

\n

  • Meaning: Newline character

  • Example output: Hello then World on the next line

12
New cards

\t

  • Meaning: Tab character

  • Ex: Adds spacing like a tab

13
New cards

\\

  • Meaning: Literal backslash

  • Ex: Prints one backslash

14
New cards

+

addition (10+3=13)

15
New cards

-

Subtraction

16
New cards

*

Multiplication

17
New cards

/

Regular division (10/3=3.333)

18
New cards

//

Floor division 10//3=3

19
New cards

%

Modulus/Remainder (10%3=1)

20
New cards

**

Exponent (2**3=8)

21
New cards

==

Equal to

22
New cards

!=

Not equal to

23
New cards

>

greater than

24
New cards

<

Less than

25
New cards

>=

Greater than or equal to

26
New cards

<=

Less than or equal to

27
New cards

and

  • Meaning: Both conditions must be true

  • Ex: age > 18 and age < 30

28
New cards

or

  • Meaning: At least one condition must be true

  • Ex: x == 1 or x == 2

29
New cards

not

  • Meaning: reverses the Boolean value

  • Ex: not True is False

30
New cards

string

  • Key idea: text, indexed and sliceable

  • Ex: “hello”

31
New cards

integer

  • Key idea: Whole number

  • Ex: 20

32
New cards

float

  • Key idea: Decimal

  • Ex: 19.99

33
New cards

Boolean

  • Key idea: represent truth values

  • Ex: True/False

34
New cards

list

  • Key idea: Ordered and Mutable

  • Ex: [1,2,3]

35
New cards

tuple

  • Key idea: Ordered and immutable

  • Example: (1,2,3)

36
New cards

dictionary

  • Key idea: key value pairs

  • Ex: {“name”: “Chris”}

37
New cards

set

  • Key idea: Unordered, no duplicates; can contain different data types

  • Ex: {1,2,3}

38
New cards

List vs. Tuple

A list can be changed after it is created. A tuple cannot be changed after its created

39
New cards

Indexing

Python Indexing starts at 0. Negative indexing starts from the end

40
New cards

Slicing

Slice format is [start:stop:step]. The start index is included, but the stop index is not included.

41
New cards

Dictionary

A dictionary stores data as key value pairs. You use the key to access the value

42
New cards

keys()

  • returns all keys

  • ex: student.keys()

43
New cards

values()

  • returns all values

  • Ex: student.values()

44
New cards

items()

  • returns key value pairs

  • Ex: student.items()

45
New cards

update()

  • Updates or adds data

  • Ex: student.update({"age": 21})

46
New cards

pop()

  • Removes a key and returns its value

  • student.pop(“age”)

47
New cards

setdefault()

  • Gets value if key exists; otherwise inserts default

  • Ex: student.setdefault(“school”. “UMB”)

48
New cards

if, elif, and else

Conditional statements allow a program to make decisions. Python checks the conditions from top to bottom and stops after the first true condition.

49
New cards

Order Matters

if a condition is true, then python skips the remaining elif and else blocks

50
New cards

os

Work with directories, paths, and the operating systems

51
New cards

sys

interact with the Python runtime; common example is sys.exit()

52
New cards

Import and Modules

the import keyword loads code from another module so you can use its functions, constants, or classes

53
New cards

pprint

pretty-print complex structures like dictionaries

54
New cards

shutil

Higher-level file operations such as copying files

55
New cards

random

Generate random numbers

56
New cards

for Loops

A for loop repeats code for each item in a sequence, such as a list, string, or range

57
New cards

range()

generates an immutable sequence of numbers

58
New cards

range(5)

  • 0 through stop

  • values produed: 0,1,2,3,4

59
New cards

range(1, 5)

  • start through stop

  • 1,2,3,4

60
New cards

range(1, 10, 2)

  • start, stop, step

  • 1,3,5,7,9

61
New cards

break

stops the loop completely

62
New cards

continue

skips the rest of the current iteration and moves to the next one

63
New cards

Strings

immutable sequences of characters

64
New cards

len(s)

  • returns length

  • len(“abc”) is 3

65
New cards

s.upper()

  • Uppercase copy

  • Original string is not changed unless reassigned

66
New cards

s.lower()

  • Lowercase copy

  • useful for case-insensitive checks

67
New cards

s.find()

  • first index of x

  • returns -1 if not found

68
New cards

s.rfind()

  • last index of x

  • searches from the right

69
New cards

s.index(x)

  • first index of x

  • raises ValueError if not found

70
New cards

s.startswith(x)

  • checks beginning

  • returns true or false

71
New cards

s.endswith(x)

  • checks ending

  • returns True or False

72
New cards

s.split(sep)

  • Splits string into list

  • Default split separates on whitespace

73
New cards

sep.join(list)

  • Joins list into string

  • the separator goes between items

74
New cards

Random Module

The random module generates pseudo-random values

75
New cards

random.random()

  • Returns: Float from 0.0 up to but not including 1.0.

  • Ex: 0.72834

76
New cards

random.uniform(a, b)

  • Returns: Float between a and b

  • random.uniform(1,10)

77
New cards

random.randint(a,b)

  • returns: integer from a through b, including both endpoints

  • Ex: random.randint(1, 10) can return 1 or 10.

78
New cards

OS Module

is central for cybersecurity scripting because scripts often need to inspect folders, check file types, build paths, and collect evidence files

79
New cards

os.chdir(path)

Changes the current working directory.

80
New cards

os.getcwd()

Returns the current working directory

81
New cards

os.listdir(path)

Lists files and folders inside a directory

82
New cards

os.path.getsize(path)

Returns size in bytes.

83
New cards

os.path.isfile(path)

True if path is a file

84
New cards

os.path.isdir(path)

True if path is a directory.

85
New cards

os.path.exists(path)

True if path exists.

86
New cards

os.path.basename(path)

Returns final file/folder name from a path

87
New cards

os.path.dirname(path)

Returns the directory portion of a path.

88
New cards

os.path.relpath(path)

Returns a relative path.

89
New cards

os.path.abspath(path)

Returns an absolute/full path.

90
New cards

os.path.join(a, b, ...)

Safely combines path parts.

91
New cards

os.mkdir(path)

Creates one directory level.

92
New cards

os.makedirs(path)

Creates nested directories.

93
New cards

Windows File Path Separator

  • Backslash \

  • C:\Users\Chris\Desktop\file.txt

94
New cards

Linux/macOS File Path Separator

  • Forward slash /

  • /home/chris/Desktop/file.txt

95
New cards

File pointer

is the current position inside a file. Reading and writing start from the pointer position

96
New cards

r (read)

  • pointer position: Beginning

  • reads an existing file

97
New cards

w (write)

  • pointer position: beginning after file is erased

  • overwrites existing file or creates a new file

98
New cards

a (append)

  • pointer position: end

  • appends new data to the end

99
New cards

Binary File Modes

are used for non text files such as images, PDFs, executables, disk images, and other forensic evidence files

100
New cards

rb (read binary)

  • open image/evidence file for reading