Save
...
OCR Computing
Paper 2
Topic 2: Programming fundamentals
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Connor McKeown
Visit profile
Cards (44)
What is the purpose of variables in programming?
Variables store data in memory locations that can change during program execution.
View source
How does the value of a variable change during program execution?
The
value
of a
variable
can
change
as the program
runs
and
processes
data.
View source
What is an identifier in programming?
An identifier is a unique name that refers to a location in memory where data is stored.
View source
What defines the type of data that can be stored in a variable?
The
data type
defines the type of data that can be stored at the
memory location
and the
operations
that can be performed on it.
View source
Why can't you multiply two words in programming?
You cannot
multiply
two words because
multiplication
is not defined for
string
data types.
View source
In some programming languages, when are variables declared?
Variables
are declared at the
start
of a program to
reserve
the appropriate amount of
memory.
View source
How does variable declaration differ in Python compared to other languages?
In Python, variables do not need to be declared; the data type is inferred from the assigned value.
View source
What happens when you assign a value like -23 to a variable in Python?
The variable will be stored as an integer.
View source
Why is it important to understand different data types in programming?
Understanding
different data types is
crucial
for
effectively
working with
variables
in programs.
View source
What are the typical memory requirements for different data types?
Integer: 2 or 4 bytes
Single: 4 or 8 bytes
Character: 1 byte
String: 1 byte per character
Boolean: 1 byte
View source
What type of data does an integer variable store?
An integer variable stores whole numbers such as 3, 45, or -453.
View source
What type of data does a single variable store?
A single variable stores
numbers
with a
fractional
part such as 34.450 or
4.0.
View source
What does a character variable store?
A character variable stores a single character, which can be a letter, digit, punctuation mark, or symbol.
View source
What does a string variable store?
A string variable stores zero or more characters and can be empty, just one character, or several characters.
View source
What values can a Boolean variable have?
A Boolean variable can have the value
True
or
False.
View source
What is the focus of section 7.1 in the study material?
Programming fundamentals
View source
Why might different programming languages have different names for data types?
Because each programming language has its own
syntax
and
conventions
View source
How many bytes might an integer require in different programming languages?
It can require either
2
bytes or
4
bytes
View source
What is the purpose of assignment statements in programming?
To assign
values
to
variables
View source
What is an example of a
constant
in programming?
VAT_RATE =
0.2
View source
What are the two main benefits of declaring a constant?
Easier
to
update values
in one place;
2. Code
is easier to
read
and
understand
View source
How are constants typically declared in Python?
By using an
assignment statement
View source
What convention is used in Python to indicate a constant?
Identifiers
for
constants
are written in
uppercase
View source
What is the general structure of input and output statements in programming?
Input
statement
prompts
the user for
data
Output
statement
displays results
to the user
View source
What pseudocode would you write to ask the user for their name and display a greeting?
my_name =
input
("Please enter your name: "); print("
Hello
",
my_name
)
View source
What types of operations can be performed on numerical data types?
Arithmetic operations and comparison operations
View source
What are the arithmetic operations that can be performed on numerical data types?
Addition
Subtraction
Multiplication
Division
Exponentiation
Integer division
(DIV)
Modulus
(MOD)
View source
What is the result of the operation
25
+
25 +
25
+
3
3
3
?
28
28
28
View source
What does the DIV operator do?
Performs integer division
View source
What does the MOD operator return?
The remainder of integer division
View source
How do you declare variables for integer and real
numbers
in Pascal?
Var
num1, num2: integer;
Var
answer:
real
;
View source
What is casting in programming?
Changing
the
type
of a
variable
value from one
type
to
another
View source
How would you convert a string to an integer in Python?
Using the int() function
View source
What happens when you add two
strings
in Python?
They are
concatenated
View source
What is the corrected pseudocode to add two numbers input as strings?
num1 =
int
(
input
("Please
enter first number
")); num2 =
int
(
input
("Please
enter second number
"));
sum
=
num1 + num2
View source
What does the float() function do?
Changes a
string
variable to a
floating-point
number
View source
What are the built-in functions for string manipulation in programming?
Get
length
:
stringname.length
Get substring: stringname.substring(startingPosition,
numberOfCharacters
)
Convert
cases:
stringname.upper
,
stringname.lower
Find position:
stringname.index
("
character
")
View source
How do you get the leftmost four characters of a
string
in OCR Exam Reference Language?
Using
stringname.left(4)
View source
What does the ASC function do?
Converts
a character to its ASCII
decimal
number
View source
What does the CHR function do?
Converts
an ASCII
decimal
number to its corresponding
character
View source
See all 44 cards