Unit 8 (Unit 3) Computer Science Flashcards

1
Q

What are the three main building blocks of programming? (3)

A
  • Sequence
  • Selection
  • Iteration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is sequence in programming?

A

The specific order in which instructions or statements are executed in a program. It ensures operations happen in a logical and predictable order

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

What are data types?

A

Data types define the kind of data a variable can hold, such as numbers, text, or boolean values. They ensure data is processed and stored correctly by the system

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

How do data types enable appropriate storage?

A

Data types allow data to be stored in the right format, e.g. numbers as integers, characters as strings, etc

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

What is automatic validation in the context of data types?

A

The system automatically checks if the data matches the expected type and prevents errors

Note: This is a trick word in exams for CS they use validation which sounds confusing but it just means CHECKING

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

What is an integer in Pseudocode?

A

An integer is a positive or negative WHOLE number that can be used with mathematical operators (MUST be a whole number, cant be a decimal number)

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

What is a real number (float) in Pseudocode?

A

A real number is a positive or negative number WITH A DECIMAL and it can be used with mathematical operators (MUST be a decimal number, cant be a whole number)

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

What is a char in Pseudocode?

A

A char is a variable or constant that HOLDS a SINGLE character which can be letters, digits, or any printable symbol

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

What is a string in Pseudocode?

A

A string is a variable or constant that HOLDS MULTIPLE characters, which can be letters, digits, or any printable symbol. Strings can also be empty

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

What is a boolean in Pseudocode?

A

A boolean is a variable or constant that can have only two values: TRUE or FALSE

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

How do you get an integer input from a user with python (use age as an example)?

A

age = int(input(“Enter your age: “))

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

How do you get a real number (float) input from a user with python (use price as an example)?

A

price = float(input(“Enter the price: “))

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

What is Selection in programming?

A

Selection is a programming flow concept that allows the program to make decisions based on conditions

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

What is an If Statement?

A

It is a conditional statement that executes a block of code if its condition is true, otherwise it skips that block

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

What is an Else Statement?

A

An else statement provides an alternative to an if statement. It executes a block of code when the if condition is false

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

What is a Nested Statement?

A

Nested if statements allow one if statement inside another to check multiple conditions. They provide structure but can make code more complex.

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

What is a Case Statement?

A

Case statement checks a variable for different values and runs the code that matches the value

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

What is Selection in programming?

A

Selection allows a program to make decisions and choose different paths based on whether conditions are true or false

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

What do If Statements in programming allow?

A

It allows for branching outcomes in programs

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

What do Else Statements in programming allow?

A

It creates two possible paths, allowing the program to handle different scenarios efficiently

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

What do Case Statements in programming allow?

A

Helps people test a variable against several possible values. When a match is found, the corresponding code block executes

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

What are the benefits of selection in programming?

A
  • Enables decision-making in programs.
  • Makes applications user-responsive.
  • Helps programmers create logical and efficient solutions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is Iteration in programming?

A

Iteration is the repetition of a block of instructions in a program. It can repeat a set number of times or until a condition is met, helping avoid repetitive code

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

What is a For Loop (Count Controlled)?

A

A for loop is a control flow statement that repeatedly executes a block of code a specified number of times, often used when you know how many times you want the code to run

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

What is a Repeat Until (Condition Controlled) loop?

A

A Repeat Until loop executes at least once. The condition is checked after the statements, and it stops when the condition is true

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

What is a While (Condition Controlled) loop?

A

While loop tests a condition before executing statements. The loop runs only if the condition is true and repeats the check after each execution. It ends when the condition becomes false.

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

What is Totalling in programming?

A

Totalling is the process of adding up values, often using a loop. A total variable is set to 0 at the beginning and updated during each loop iteration

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

What is Counting in programming?

A

Counting keeps track of how many times an event happens. A count variable is set to 0 and updated in each loop iteration based on the event

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

What is String HANDLING?

A

String handling is when you perform tasks on strings, such as joining two strings, slicing a string into parts, or finding out how many characters it contains

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

What is the Length method in string handling?

A

The Length method counts the number of characters in a string.

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

What is the Case Conversion method in string handling?

A

The Case Conversion method changes a string from one case to another, such as converting all characters to uppercase or lowercase

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

What is the Substring method in string handling and whats its use?

A

The Substring method allows you to extract a sequence of characters from a larger string. This can be useful for tasks like data validation or combining parts of strings

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

How is Substring extraction performed in Python?

A

Substring extraction is done using slicing. You specify a start and end position to get the desired characters from the string

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

In pseudocode, what is the starting position for extracting a Substring?

A

In pseudocode, the Substring starts at position 1 (not 0 as in Python)

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

What are Arithmetic Operators?

A

Arithmetic operators are used to perform basic mathematical operations in programming

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

What is the Addition operator and its pseudocode equivalent (how is it represented in pseudocode)?

A

Addition operator is used to add two numbers and in pseudocode it is written as +

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

What is the Subtraction operator and its pseudocode equivalent?

A

Subtraction operator is used to subtract one number from another and in pseudocode, it is written as -

38
Q

What is the Multiplication operator and its pseudocode equivalent?

A

Multiplication operator is used to multiply two numbers and in pseudocode, it is written as *

39
Q

What is the Division operator and its pseudocode equivalent?

A

Division operator is used to divide one number by another and in pseudocode, it is written as /

40
Q

What is the Modulus operator and its pseudocode and python equivalent (how is it represented in pseudocode and python)?

A

Modulus operator returns the remainder after division. In Python, it is written as %. In pseudocode, it is written as MOD

41
Q

What is the Quotient operator and its pseudocode and python equivalent?

A

Quotient operator returns the whole number result of division. In Python, it is written as //. In pseudocode, it is written as DIV

42
Q

What is Exponentiation, and its pseudocode equivalent?

A

Exponentiation makes a number to the power of another number. In Python, it is written as **. In pseudocode, it is written as ^

43
Q

What are the examples of Comparison operators?

A
  • ==
  • <>
  • <
  • <=
  • >
  • > =
44
Q

What is the Equal to operator and its pseudocode equivalent?

A

The Equal to operator checks if two values are the same and in pseudocode, it is written as ==.

45
Q

What is the Not equal to operator and its pseudocode equivalent?

A

The Not equal to operator checks if two values are different and in pseudocode, it is written as <>

46
Q

What is the Less than operator and its pseudocode equivalent?

A

The Less than operator checks if one value is smaller than another and in pseudocode, it is written as <

47
Q

What is the Less than or equal to operator and its pseudocode equivalent?

A

The Less than or equal to operator checks if one value is smaller than or equal to another and in pseudocode, it is written as <=

48
Q

What is the Greater than operator and its pseudocode equivalent?

A

The Greater than operator checks if one value is larger than another and in pseudocode, it is written as >

49
Q

What is the Greater than or equal to operator and its pseudocode equivalent?

A

The Greater than or equal to operator checks if one value is larger than or equal to another and in pseudocode, it is written as >=

50
Q

How many main Boolean operators are there, and what are they (name them)?

A

There are three main Boolean operators: AND, OR, and NOT

51
Q

What does the AND operator do in Boolean logic?

A

The AND operator checks if two conditions are both true. If both conditions are true, the result will be True

52
Q

What does the OR operator do in Boolean logic?

A

The OR operator makes the statement True if at least one of the conditions is true. If both conditions are false, only then will the result be False

53
Q

What does the NOT operator do in Boolean logic?

A

The NOT operator reverses the condition, making the statement True if the condition is False, and making the statement False if the condition is True

54
Q

What does “return” mean in a function?

A

“Return” sends the result of the function back to where it was called so it can be used later

55
Q

What is a Function?

A

A function is a subprogram that performs a specific task and returns a value. It is used to carry out calculations, retrieve data, or process information based on input

56
Q

What is a Procedure?

A

A procedure is a subprogram that performs a specific task but does not return a value. It is used to carry out actions like printing output or modifying data

57
Q

Why are Functions & Procedures used in programming (3 reasons and explain)?

A
  • Organise code: Break the program into more manageable parts.
  • Avoid repeating code: Can be reused throughout the program to avoid repeating code.
  • Perform tasks: Used for calculations, retrieving data, or making decisions based on inputs.
58
Q

What are parameters in programming?

A

Parameters are values that are passed into a subprogram to be used within that subprogram

59
Q

What can parameters be in a subprogram?

A

Parameters can be variables or values that are placed in brackets after the subprogram’s name

60
Q

How are functions defined in pseudocode and Python?

A

In pseudocode, functions are defined using the FUNCTION keyword, and in Python, they are defined using the def keyword

61
Q

What is a local variable?

A

A local variable is a variable created inside a specific part of the program

62
Q

Where can a local variable be used?

A

A local variable can only be used inside the part of the program where it was created

63
Q

What happens to a local variable after its part of the program ends?

A

When the program moves past the section, the local variable is deleted and the space it used is freed

64
Q

What is a global variable?

A

A global variable is a variable that is declared outside of any functions or procedures, at the outermost level of the program (ususally at the start)

65
Q

Where can a global variable be used?

A

A global variable can be accessed and modified from anywhere in the program, including inside functions and procedures

66
Q

What does a global scope mean?

A

It is a variable that can be accessed and modified from any part of the program

67
Q

Do global variables have a global scope?

68
Q

What is a Library Routine?

A

A library routine is reusable code that can be used throughout a program

69
Q

Why are Library Routines Useful?

A

Saves time by allowing people to use pre-written code which reducing the need to write the same code repeatedly making it EFFICIENT

70
Q

Examples of Library Routines: (2)

A
  • Random (for generating random numbers)
  • Round (for rounding numbers)
71
Q

What is the Random library?

A

The random library allows the user to make use of ‘random’ in their programs, such as generating random numbers or making random choices

72
Q

What is random number generation?

A

When a computer generates a random number to be used in a program

73
Q

Examples of using the Random library:

A
  • Simulating a dice roll
  • Selecting a random question
  • National lottery
  • Cryptography
74
Q

What is the Round library?

A

It allows people to round numbers to a set amount of decimal places

75
Q

How are easy-to-maintain programs written?

A

Easy-to-maintain programs are written using techniques that make code easy to read and understand. These techniques include layout, indentation, comments, and more

76
Q

What is the layout technique?

A

It is when you have spacing between sections

77
Q

What is the indentation technique?

A

It is when you have clearly defined sections of code

78
Q

What is the use of comments in programming?

A

Comments are used to explain key parts of the code.

(They do not affect the execution but help people understand what the code does)

79
Q

What is the use of Intuitive Variable names?

A

It is to describe what is being stored

80
Q

What is the use of white space?

A

To make the code easy to read

81
Q

What is the use of Sub-programs?

A

to add functions or procedures used where possible

82
Q

What is an array?

A

An array is an ordered, static set of elements stored in a fixed-size memory location

83
Q

How many types of data can an array store?

84
Q

What is a 1-dimensional array?

A

It is a linear array where elements are stored in a single line

85
Q

What does it mean when an array is zero-indexed?

A

Zero-indexed means that the indexes of the array elements start at 0

86
Q

What is a 2D array?

A

A 2D array has 2 dimensions, creating a table with rows and columns

87
Q

How can a 2D array be visualised?

A

A 2D array can be visualised as a table with rows and columns

88
Q

How do you navigate through a 2D array?

A

To navigate through a 2D array, you first go down the rows and then across the columns to find a position

89
Q

What is file handling?

A

File handling refers to using programming techniques to work with information stored in text files

90
Q

What are examples of file handling techniques?

A

Examples of file handling techniques include opening text files, reading text files, writing text files, and closing text files