PCEP-30-02 Exam

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

1/170

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 5:10 AM on 9/30/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

171 Terms

1
New cards

What is the main function of an interpreter in Python?

An interpreter runs your code, translating and executing it line by line.

2
New cards

What happens if there is an error in the code while using an interpreter?

The interpreter stops execution at the point of the error.

3
New cards

What is a key advantage of using an interpreter?

Easier debugging and no separate compile step.

4
New cards

What is a disadvantage of using an interpreter?

Slower execution overall compared to compiled languages.

5
New cards

What does a compiler do?

A compiler translates the entire program into machine code before execution.

6
New cards

What is a key advantage of using a compiler?

Faster execution and optimized code.

7
New cards

What is a disadvantage of using a compiler?

Slower to test since the code must be compiled first.

8
New cards

Define 'Lexis' in programming languages.

Lexis refers to the 'words' or tokens of the language, such as keywords and identifiers.

9
New cards

What is the role of syntax in programming?

Syntax defines the rules for how code must be written, similar to grammar in English.

10
New cards

What error occurs if syntax rules are broken in Python?

A SyntaxError is raised.

11
New cards

What does semantics refer to in programming?

Semantics is the meaning of the code and what it does.

12
New cards

What type of error occurs if the meaning of the code is incorrect?

A semantic (logic) issue may cause a TypeError or incorrect output.

13
New cards

What are keywords in Python?

Keywords are reserved words with special meaning that cannot be used as variable names.

14
New cards

Give an example of a Python keyword.

Examples include 'if', 'else', 'while', 'def', 'True', 'False'.

15
New cards

What is an instruction in Python?

An instruction is a single command that Python executes.

16
New cards

What is the purpose of indentation in Python?

Indentation defines code blocks and is required for proper structure.

17
New cards

What happens if indentation is incorrect in Python?

An IndentationError is raised.

18
New cards

What are comments in Python?

Comments are notes in your code that Python ignores, helping humans understand the code.

19
New cards

What is the syntax for a single-line comment in Python?

A single-line comment starts with a '#' symbol.

20
New cards

What is a multi-line comment in Python?

A multi-line comment is enclosed in triple quotes ("""...""").

21
New cards

Why are comments important in programming?

They explain logic, make code readable, and assist with debugging and collaboration.

22
New cards

What is the Boolean data type in Python?

A data type that represents truth values, either True or False.

23
New cards

How are integers defined in Python?

Integers (int) are whole numbers without decimals, e.g., x = 10, y = -3.

24
New cards

What is a floating-point number in Python?

A float is a number that includes decimals, e.g., pi = 3.14, temp = -5.5.

25
New cards

What is scientific notation used for in Python?

It is used for very large or very small numbers, e.g., a = 1e3 (1000.0).

26
New cards

What is a string in Python?

A string (str) is text enclosed in quotes, e.g., name = 'Amber'.

27
New cards

What numeral systems does Python support?

Python supports decimal (base 10), binary (base 2), octal (base 8), and hexadecimal (base 16).

28
New cards

What is the prefix for binary numbers in Python?

The prefix for binary numbers is '0b', e.g., 0b1010.

29
New cards

What is the prefix for octal numbers in Python?

The prefix for octal numbers is '0o', e.g., 0o12.

30
New cards

What is the prefix for hexadecimal numbers in Python?

The prefix for hexadecimal numbers is '0x', e.g., 0xA.

31
New cards

What is a variable in Python?

A variable is a named container for data, e.g., age = 17.

32
New cards

What are the rules for naming variables in Python?

Variable names must start with a letter or underscore, and cannot use keywords or start with a number.

33
New cards

What is PEP 8 in Python?

PEP 8 is the official style guide for writing clean Python code.

34
New cards

What is the purpose of snake_case in variable naming?

Snake_case is used to improve readability in variable names, e.g., user_name.

35
New cards

What is the result of the expression '10 / 3' in Python?

The result is a float: 3.3333...

36
New cards

What does the '//' operator do in Python?

The '//' operator performs floor division, returning the largest whole number less than or equal to the result.

37
New cards

What are the two types of operators based on the number of operands?

Unary operators (one operand) and binary operators (two operands).

38
New cards

What is the order of operations in Python?

Python follows the order similar to PEMDAS: Parentheses, Exponents, Multiplication/Division, Addition/Subtraction.

39
New cards

What does the '&' operator do in Python?

The '&' operator performs a bitwise AND operation.

40
New cards

What does the '|' operator do in Python?

The '|' operator performs a bitwise OR operation.

41
New cards

What does the '^' operator do in Python?

The '^' operator performs a bitwise XOR operation.

42
New cards

What does the '~' operator do in Python?

The '~' operator performs a bitwise NOT operation.

43
New cards

What does the '<<' operator do in Python?

The '<<' operator shifts bits to the left.

44
New cards

What does the '>>' operator do in Python?

The '>>' operator shifts bits to the right.

45
New cards

What is the output of `print(not True)`?

False

46
New cards

What does the `and` operator require for the result to be True?

Both conditions must be True.

47
New cards

What does the `or` operator require for the result to be True?

At least one condition must be True.

48
New cards

What is a Boolean expression?

An expression that evaluates to True or False.

49
New cards

What is the output of `print(5 > 3)`?

True

50
New cards

What is the output of `print(10 == 7)`?

False

51
New cards

What do relational operators do?

They compare values.

52
New cards

What is the output of `print(5 != 3)`?

True

53
New cards

What is the output of `print(2 < 4)`?

True

54
New cards

What is the output of `print(2 <= 1)`?

False

55
New cards

What is a common issue with floating-point numbers in Python?

They are not perfectly precise.

56
New cards

What is the result of `print(0.1 + 0.2 == 0.3)`?

False (due to floating-point precision errors)

57
New cards

What is type casting?

Converting between data types.

58
New cards

How do you convert a string to an integer in Python?

Using `int()`, e.g., `x = int('5')`.

59
New cards

What does the `input()` function do?

It gets data from the user.

60
New cards

What does `input()` always return?

A string.

61
New cards

What is the purpose of the `sep` parameter in the `print()` function?

It controls what goes between multiple values.

62
New cards

What does the `end` parameter in the `print()` function control?

What is printed at the end of the output.

63
New cards

What is the syntax for an if statement in Python?

if condition: code to execute

64
New cards

What does an if-else statement provide?

Two possible paths of execution.

65
New cards

What is the purpose of the `elif` statement?

To check multiple conditions in order.

66
New cards

What does an if-elif-else statement handle?

All possible cases.

67
New cards

What is nesting in conditional statements?

Putting an if statement inside another if statement.

68
New cards

What is the common mistake when using comparison operators?

Using `=` instead of `==`.

69
New cards

What is the purpose of the `pass` statement?

It acts as a placeholder that does nothing.

70
New cards

What happens if you do not indent your code properly in Python?

It will result in an indentation error.

71
New cards

What is the output of `print(5 + 3)`?

8

72
New cards

What does the `float()` function do?

Converts a string to a floating-point number.

73
New cards

What is the purpose of a while loop?

To repeat a block of code while a condition is True.

74
New cards

What will the following code output? `x = 1 while x <= 3: print(x); x += 1`

1 2 3

75
New cards

What is an infinite loop?

A loop that runs forever unless stopped, e.g., `while True: print('Forever')`.

76
New cards

What is the purpose of a for loop?

To iterate over a sequence or a range a fixed number of times.

77
New cards

What does `for i in range(3): print(i)` output?

0 1 2

78
New cards

What does `range(5)` generate?

0, 1, 2, 3, 4

79
New cards

What is the output of `for letter in 'Hi': print(letter)`?

H i

80
New cards

What does the else block do in a for loop?

It runs if the loop finishes normally without hitting a break.

81
New cards

What happens when you use `break` in a loop?

It stops the loop completely.

82
New cards

What does `continue` do in a loop?

It skips the current iteration and continues with the next one.

83
New cards

What is the output of `for i in range(5): if i == 3: break; print(i)`?

0 1 2

84
New cards

What is the output of `for i in range(5): if i == 3: continue; print(i)`?

0 1 2 4

85
New cards

What is a list in Python?

A collection of values that can store different data types.

86
New cards

How do you access the first element of a list `nums = [10, 20, 30]`?

Using indexing: `nums[0]`.

87
New cards

What does slicing a list `nums[1:3]` return?

Elements from index 1 to 2, excluding 3.

88
New cards

What is the function of `len()`?

It returns the number of elements in a list.

89
New cards

What does `nums.append(4)` do?

Adds the value 4 to the end of the list nums.

90
New cards

What is the difference between `list.sort()` and `sorted(list)`?

`list.sort()` sorts the list in place, while `sorted(list)` returns a new sorted list.

91
New cards

What is a tuple in Python?

An ordered collection of values that is immutable (cannot be changed).

92
New cards

How do you create a single-element tuple?

By including a comma, e.g., `(5,)`.

93
New cards

What happens if you try to modify a tuple?

It raises an error because tuples are immutable.

94
New cards

What is a dictionary in Python?

A collection of key-value pairs, defined using curly braces.

95
New cards

What must dictionary keys be?

Unique and immutable (e.g., strings, numbers, tuples).

96
New cards

What is the output of `empty = {}; person = {'name': 'Alex', 'age': 18}`?

An empty dictionary and a dictionary with two key-value pairs.

97
New cards

What is the difference between a list and a tuple?

A list is mutable (can change), while a tuple is immutable (cannot change).

98
New cards

What does `del` do in the context of lists?

It deletes elements or entire lists.

99
New cards

What is the significance of nesting lists or tuples?

You can create complex data structures like matrices (2D lists) or cubes (3D lists).

100
New cards

How do you access a value in a dictionary?

Using the syntax dict[key].