programming concepts
使用闪卡高效复习COMPUTER-SCIENCE科目知识点
共计闪卡
124张
8 programming
闪卡自测
What is a variable?
所有闪卡
闪卡 1
问题
What is a variable?
查看答案
答案
A variable is an identifier that can change in the lifetime of a program.
闪卡 2
问题
Define the term constant.
查看答案
答案
A constant is an identifier set once in the lifetime of a program.
闪卡 3
问题
True or False? Variables can start with a number.
查看答案
答案
False. Variables must start with a capital letter and not a number.
闪卡 4
问题
What does Pascal case mean for identifiers?
查看答案
答案
Pascal case means identifiers should be in mixed case, starting with a capital letter.
闪卡 5
问题
State the pseudocode for declaring a variable.
查看答案
答案
DECLARE : E.g. DECLARE Age: Integer.
闪卡 6
问题
How are constants named?
查看答案
答案
Constants are named in all uppercase characters.
闪卡 7
问题
What is the purpose of using constants?
查看答案
答案
Constants aid the readability and maintainability of programs.
闪卡 8
问题
True or False? Constants can be changed during program execution.
查看答案
答案
False. Constants are set once in the lifetime of a program and cannot be changed.
闪卡 9
问题
State the pseudocode for declaring a constant.
查看答案
答案
CONSTANT ← E.g. CONSTANT Password ← "letmein".
闪卡 10
问题
What is casting?
查看答案
答案
Casting is changing data types within a program.
闪卡 11
问题
What is a data type?
查看答案
答案
A data type is a classification of data into groups according to the kind of data they represent.
闪卡 12
问题
Define the term Integer.
查看答案
答案
Integer is a data type used for whole numbers.
闪卡 13
问题
What does the Real data type represent?
查看答案
答案
The Real data type represents numbers with a fractional part (decimal).
闪卡 14
问题
True or False? The Character data type can store multiple characters.
查看答案
答案
False. The Character data type stores a single character.
闪卡 15
问题
What is the Boolean data type used for?
查看答案
答案
The Boolean data type is used for true or false values.
闪卡 16
问题
State the pseudocode for assigning the value 3.142 to variable named Pi.
查看答案
答案
Pi ← 3.142
闪卡 17
问题
What is the purpose of choosing the correct data type?
查看答案
答案
Choosing the correct data type ensures accuracy and efficiency in the program.
闪卡 18
问题
Define the term String.
查看答案
答案
String is a data type used for a sequence of characters.
闪卡 19
问题
True or False? The Integer data type can store decimal numbers.
查看答案
答案
False. The Integer data type stores whole numbers only.
闪卡 20
问题
What is the difference between CHAR and STRING data types?
查看答案
答案
CHAR stores a single character, while STRING stores a sequence of characters.
闪卡 21
问题
What is an input?
查看答案
答案
An input is a value that is read from an input device and then processed by a computer program.
闪卡 22
问题
Define the term output.
查看答案
答案
An output is a value sent to an output device from a computer program.
闪卡 23
问题
What is considered the standard for user input in programming?
查看答案
答案
The keyboard is considered the standard for user input in programming.
闪卡 24
问题
True or False? The monitor is considered the standard for user output.
查看答案
答案
True. The monitor is considered the standard for user output.
闪卡 25
问题
State the pseudocode for an input with the identifier Age.
查看答案
答案
INPUT Age
闪卡 26
问题
What does the OUTPUT command do in pseudocode?
查看答案
答案
The OUTPUT command in pseudocode sends data to the screen.
闪卡 27
问题
True or False? Inputs are only received from keyboards.
查看答案
答案
False. Inputs can be received from various devices including mice, sensors, and microphones.
闪卡 28
问题
State two examples of output devices?
查看答案
答案
Examples of output devices include: monitors, speakers, printers.
闪卡 29
问题
What happens when the INPUT command is executed?
查看答案
答案
When the INPUT command is executed, a program will wait for the user to type a sequence of characters.
闪卡 30
问题
Why are inputs important in programming?
查看答案
答案
Inputs are important because without them, programs can't interact with the outside world and always produce the same result.
闪卡 31
问题
What is sequence in programming?
查看答案
答案
Sequence refers to lines of code which are run one line at a time in the order that they are written.
闪卡 32
问题
True or False? The order of instructions in a sequence doesn't matter.
查看答案
答案
False. The order of instructions in a sequence is crucial to the flow of a program.
闪卡 33
问题
What can happen if instructions are out of sequence?
查看答案
答案
If instructions are out of sequence, it can lead to unexpected behaviour or errors.
闪卡 34
问题
Why is sequence important in programming?
查看答案
答案
Sequence is important because it determines the flow of a program and ensures instructions are executed in the correct order.
闪卡 35
问题
What is the first step in ensuring correct sequence?
查看答案
答案
The first step in ensuring correct sequence is to plan the logical order of instructions before writing the code.
闪卡 36
问题
True or False? In Python, indentation affects the sequence of code execution.
查看答案
答案
True. ** In Python, indentation affects the sequence **of code execution by defining code blocks.
闪卡 37
问题
What is the output of the following pseudocode? INPUT1 ← 4 INPUT2 ← 5 Number ← INPUT2 - INPUT1 OUTPUT Number
查看答案
答案
The output would be: 1
闪卡 38
问题
What is the output of the following pseudocode? INPUT1 ← 3 INPUT2 ← 2 INPUT3 ← 7 Number ← INPUT2 * INPUT1 Number ← Number + INPUT3 OUTPUT Number
查看答案
答案
The output would be: 13
闪卡 39
问题
What is selection in programming?
查看答案
答案
Selection is when the flow of a program is changed, depending on a set of conditions.
闪卡 40
问题
Define the term IF statement.
查看答案
答案
An IF statement is a selection statement that allows you to execute a set of instructions if a condition is true.
闪卡 41
问题
What are the two ways to write selection statements?
查看答案
答案
The two ways to write selection statements are: if... then... else... and case...
闪卡 42
问题
True or False? IF statements always require an ELSE clause.
查看答案
答案
False. IF statements do not always require an ELSE clause.
闪卡 43
问题
What is nested selection?
查看答案
答案
Nested selection is a selection statement within a selection statement, e.g., an If inside of another If.
闪卡 44
问题
What is a CASE statement?
查看答案
答案
A CASE statement is a selection statement used when comparing multiple values of the same variable.
闪卡 45
问题
True or False? CASE statements are more flexible than IF statements.
查看答案
答案
False. IF statements are more flexible and are generally used more in languages such as Python.
闪卡 46
问题
What is the purpose of selection in programming?
查看答案
答案
The purpose of selection in programming is to allow different code to be executed based on certain conditions.
闪卡 47
问题
State the basic syntax of an IF statement in pseudocode.
查看答案
答案
IF THEN ENDIF E.g. IF Age < 18 THEN OUTPUT "Too young"ENDIF
闪卡 48
问题
What is the difference between IF-THEN and IF-THEN-ELSE statements?
查看答案
答案
IF-THEN statements execute code only if the condition is true, while IF-THEN-ELSE statements provide an alternative action if the condition is false.
闪卡 49
问题
What is iteration in programming?
查看答案
答案
Iteration is repeating a line or a block of code using a loop.
闪卡 50
问题
Define the term count controlled loop.
查看答案
答案
A count controlled loop is when the code is repeated a fixed number of times (e.g., using a for loop).
闪卡 51
问题
What is a condition controlled loop?
查看答案
答案
A condition controlled loop is when the code is repeated until a condition is met.
闪卡 52
问题
True or False? FOR loops are always count controlled.
查看答案
答案
True. FOR loops are always count controlled.
闪卡 53
问题
What are the two types of condition controlled loops?
查看答案
答案
The two types of condition controlled loops are: post-condition (REPEAT) and pre-condition (WHILE).
闪卡 54
问题
What is the difference between WHILE and REPEAT loops?
查看答案
答案
WHILE loops test the condition before executing the loop, while REPEAT loops execute the loop at least once before testing the condition.
闪卡 55
问题
Define nested iteration.
查看答案
答案
Nested iteration is a loop within a loop, e.g., a FOR inside of another FOR.
闪卡 56
问题
State the data type that must be used for all identifiers in a count-controlled loop.
查看答案
答案
Integer
闪卡 57
问题
State the basic syntax of a FOR loop in pseudocode.
查看答案
答案
FOR ← TO NEXT E.g. FOR Score ← 1 TO 10 ....NEXT Score
闪卡 58
问题
What is the purpose of the STEP keyword in a FOR loop?
查看答案
答案
The STEP keyword in a FOR loop determines the increment or decrement value for each iteration.
闪卡 59
问题
What is totalling in programming?
查看答案
答案
Totalling involves adding up values, often in a loop.
闪卡 60
问题
Define the term counting in programming.
查看答案
答案
Counting involves keeping track of the number of times a particular event occurs.
闪卡 61
问题
How is a total variable typically initialised?
查看答案
答案
A total variable is typically initialised to 0 at the beginning of the program. E.g. Total ← 0
闪卡 62
问题
True or False? Counting and totalling always occur in loops.
查看答案
答案
False. While counting and totalling often occur in loops, they can also be done outside of loops.
闪卡 63
问题
How is a count variable typically updated?
查看答案
答案
A count variable is typically updated by incrementing it by 1 (Count ← Count + 1).
闪卡 64
问题
True or False? ** A total variable can only be used for adding numbers**.
查看答案
答案
False. A total variable can be used for various types of accumulation, not just adding numbers.
闪卡 65
问题
In what situations would you typically use totalling?
查看答案
答案
You would use totalling when you need to accumulate values, such as calculating a sum or average.
闪卡 66
问题
In what situations would you typically use counting?
查看答案
答案
You would use counting when you need to keep track of occurrences, such as counting the number of times a condition is met.
闪卡 67
问题
What is string manipulation?
查看答案
答案
String manipulation is the use of programming techniques to modify, analyse or extract information from a string.
闪卡 68
问题
Define the term case conversion.
查看答案
答案
Case conversion is the ability to change a string from one case to another, for example, lower case to upper case.
闪卡 69
问题
What does the LENGTH function do?
查看答案
答案
The LENGTH function counts the number of characters in a string.
闪卡 70
问题
True or False? Substring extraction always starts at the first character of a string.
查看答案
答案
False. Substring extraction can start at any position within the string.
闪卡 71
问题
How does slicing work in string manipulation?
查看答案
答案
Slicing in string manipulation uses specific start and end positions to extract the desired characters from a string.
闪卡 72
问题
True or False? In pseudocode, the first character of a string is at position 0.
查看答案
答案
False. ** In pseudocode, the first character of a string is at position 1**.
闪卡 73
问题
What is the difference between UCASE and LCASE functions?
查看答案
答案
UCASE converts a string to uppercase, while LCASE converts a string to lowercase.
闪卡 74
问题
State the pseudocode for extracting the first three letters from a string named "Book" and outputting to the screen.
查看答案
答案
Book ← "An Inspector Calls" OUTPUT SUBSTRING(Book, 1, 3)
闪卡 75
问题
What is the purpose of the LENGTH function in the following pseudocode? Password ← "letmein" IF LENGTH(Password) >= 8 THEN OUTPUT "Password accepted" ELSE OUTPUT "Password too short" ENDIF
查看答案
答案
To count how many characters are in the password.
闪卡 76
问题
What is the output of this pseudocode? Name ← "Michael J Fox" OUTPUT SUBSTRING(Name, 7, 11)
查看答案
答案
l J F (with spaces)
闪卡 77
问题
What is an operator in programming?
查看答案
答案
An operator is a symbol used to instruct a computer to perform a specific operation on one or more values.
闪卡 78
问题
Define the term arithmetic operator.
查看答案
答案
An arithmetic operator is a symbol used for mathematical operations such as addition, subtraction, multiplication, and division.
闪卡 79
问题
What does the modulus operator do?
查看答案
答案
The modulus operator returns the remainder after division.
闪卡 80
问题
True or False? ** The '=**' symbol is used for both assignment and comparison.
查看答案
答案
False. ** In most programming languages, '=' is used for assignment, while '==**' is used for comparison.
闪卡 81
问题
What are the three main Boolean operators?
查看答案
答案
The three main Boolean operators are: AND, OR, and NOT.
闪卡 82
问题
How does the AND operator work?
查看答案
答案
The AND operator returns True if both conditions are True.
闪卡 83
问题
True or False? The OR operator returns True if at least one condition is True.
查看答案
答案
True. The OR operator returns True if at least one condition is True.
闪卡 84
问题
What is the difference between '/' and '//' in Python?
查看答案
答案
In Python, '/' performs floating-point division, while '//' performs integer division (quotient).
闪卡 85
问题
State the symbol for exponentiation in pseudocode and Python.
查看答案
答案
In pseudocode: ^, in Python: **.
闪卡 86
问题
What does the NOT operator do?
查看答案
答案
The NOT operator returns the opposite of the condition (True if False, False if True).
闪卡 87
问题
What is a sub program in programming?
查看答案
答案
A sub program is a sequence of instructions that perform a specific task or set of tasks.
闪卡 88
问题
Define the term procedure.
查看答案
答案
A procedure is a type of sub program that performs a specific task but does not return a value.
闪卡 89
问题
What is a function in programming?
查看答案
答案
A function is a type of sub program that performs a specific task and returns a value.
闪卡 90
问题
True or False? Parameters are always required in sub programs.
查看答案
答案
False. ** Sub programs can be defined with or without** parameters.
闪卡 91
问题
What is the purpose of using sub programs?
查看答案
答案
The purpose of using sub programs is to simplify a program by breaking it into smaller, more manageable parts and to avoid duplicating code.
闪卡 92
问题
How do you call a procedure in pseudocode?
查看答案
答案
You call a procedure in pseudocode using the CALL keyword, E.g. CALL Login
闪卡 93
问题
True or False? Functions are always called within an expression.
查看答案
答案
True. Functions are always called within an expression because they return a value.
闪卡 94
问题
What is the difference between a function and a procedure?
查看答案
答案
A function returns a value, whereas a procedure does not.
闪卡 95
问题
State the basic syntax for defining a function in pseudocode.
查看答案
答案
FUNCTION function_name(parameters) .... RETURN ....
闪卡 96
问题
What does it mean to 'call' a sub program?
查看答案
答案
To 'call' a sub program means to execute it from the main program.
闪卡 97
问题
What is a local variable?
查看答案
答案
A local variable is a variable declared within a specific scope, such as a function or a code block.
闪卡 98
问题
True or False? Local variables can be accessed from anywhere in the program.
查看答案
答案
False. Local variables are accessible only within the block in which they are defined.
闪卡 99
问题
What happens to a local variable when the execution of its block ends?
查看答案
答案
When the execution of the block ends, the local variable is destroyed and its memory is released.
闪卡 100
问题
Define the term global variable.
查看答案
答案
A global variable is a variable declared at the outermost level of a program, outside any modules such as functions or procedures.
闪卡 101
问题
What is the scope of a global variable?
查看答案
答案
The scope of a global variable is global, meaning it can be accessed and modified from any part of the program.
闪卡 102
问题
True or False? Local variables have a longer lifetime than global variables.
查看答案
答案
False. Local variables have a limited lifetime to the block in which they are defined, while global variables exist for the entire duration of the program.
闪卡 103
问题
In Python, how do you declare a variable as global inside a function?
查看答案
答案
global VariableName
闪卡 104
问题
What is the main difference between local and global variables in terms of accessibility?
查看答案
答案
The main difference between local and global variables in terms of accessibility is that local variables can only be accessed within their defined block, while global variables can be accessed from any part of the program.
闪卡 105
问题
Variable scope
查看答案
答案
Variable scope refers to the area of a program where a variable can be accessed and modified.
闪卡 106
问题
True or False? In Python, you need to use the 'global' keyword to access a global variable inside a function.
查看答案
答案
False. In Python, you can access a global variable inside a function without using the 'global' keyword, but you need to use it if you want to modify the global variable.
闪卡 107
问题
What are library routines?
查看答案
答案
Library routines are reusable code that can be used throughout a program, made public through reusable modules or functions.
闪卡 108
问题
True or False? Using library routines increases development time for programmers.
查看答案
答案
False. ** Using library routines saves programmers time** by using working code that has already been tested.
闪卡 109
问题
Random library
查看答案
答案
The random library is a library of code which allows users to make use of 'random' in their programs, such as generating random choices or random numbers.
闪卡 110
问题
What is random number generation used for in programming?
查看答案
答案
Random number generation is used to add an element of unpredictability in programs, such as simulating dice rolls, selecting random questions, or in cryptography.
闪卡 111
问题
In Python, how do you import the random library?
查看答案
答案
In Python, you import the random library by using the statement: import random
闪卡 112
问题
What does the randint() function do in Python's random library?
查看答案
答案
The randint() function in Python's random library generates a random integer within a specified range.
闪卡 113
问题
Round library
查看答案
答案
The round library is a library of code which allows users to round numerical values to a set amount of decimal places.
闪卡 114
问题
True or False? The round function in Python can only round to the nearest whole number.
查看答案
答案
False. The round function in Python can round to a specified number of decimal places.
闪卡 115
问题
What is the syntax for the round function in pseudocode?
查看答案
答案
The syntax for the round function in pseudocode is: ROUND(, )
闪卡 116
问题
In Python, how would you round the number 3.14159 to 2 decimal places?
查看答案
答案
In Python, you would round 3.14159 to 2 decimal places using: round(3.14159, 2)
闪卡 117
问题
What is the main goal of writing easy-to-maintain programs?
查看答案
答案
The main goal is to make code easy to read using consistent techniques.
闪卡 118
问题
Define code Layout.
查看答案
答案
Layout refers to the spacing between sections of code, which helps improve readability and maintainability.
闪卡 119
问题
What does indentation contribute to in programming?
查看答案
答案
Indentation contributes to clearly defining sections of code, making it easier to read and maintain.
闪卡 120
问题
What are code comments?
查看答案
答案
Comments are explanations of key parts of the code, which help other programmers understand the code's purpose and functionality.
闪卡 121
问题
True or False? Using meaningless variable names improves code maintainability.
查看答案
答案
False. Using meaningful variable names that describe what is being stored improves code maintainability.
闪卡 122
问题
White space
查看答案
答案
White space refers to adding suitable spaces in the code to make it easier to read and understand.
闪卡 123
问题
What are sub-programs in the context of maintainable code?
查看答案
答案
Sub-programs are functions or procedures used where possible to organise and modularise code, making it more maintainable.
闪卡 124
问题
True or False? Consistency in coding techniques leads to easier program maintenance.
查看答案
答案
True. When consistency is applied in coding techniques, programs are easier to maintain.