Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Resumen

Summary OCR GCSE Computer Science - 2.2 Programming Fundamentals Complete Notes

Puntuación
-
Vendido
-
Páginas
6
Subido en
18-07-2025
Escrito en
2023/2024

OCR GCSE Computer Science notes for 2.2 Programming Fundamentals - including all of the information you need to know and questions to practice your recall skills - which helped me to get a 9 at GCSE!

Institución
Grado

Vista previa del contenido

Uses of Variables, Constants, Questions
Inputs, Outputs & Assignments o Define variable, constant, assignment, casting, input, output, integer,
real, float, character and string.
o Variable - a value stored in memory that can change while the program is running. o What is the difference between a variable and a constant?
• The MAR contains the address of an instruction or data to be fetched or o Why are constants easier to use than variables?
written to memory. Similarly, a variable is a pointer to a memory address o Why is casting necessary in a program?
which we’re able to give a user-friendly label/name. o Why might integers be more useful than float in a program?
o Constant - a value that does not change while the program is running, and is
assigned when the program is designed.
• Makes programs easier to read as they’re usually declared and assigned
Three Programming Constructs
at the top of the program. o Sequence is executing one instruction after another.
• Can easily be changed by the programmer in one place in a program, o Selection is a program branching depending on a condition.
instead of changing every instance of a value throughout a program; leads
• If statement - if a statement is true, execute this line of code,
to less chance of errors.
otherwise, or else, execute this line of code instead.
• The compiler can optimise the code; this makes a program run more
• Some programming languages support switch/select… case
quickly if constants are used instead of variables.
statements, where a program can branch in several directions
o Assignment - giving a variable or a constant a value.
depending on the value of a variable with each “case” placed after a
o Casting - converting a variable from one data type to another (e.g. from an integer
single “switch”.
to a string); a variable can be an integer, character, string, real (float) or Boolean. o Iteration, sometimes called looping, is repeating sections of code.
• The ALU must use numbers for addition, so a string has to be "cast" to a
• For loops (known as 'counter-controlled loops') are used when the
number.
number of iterations needed is known ahead of the iteration
• Integers require less memory than float numbers; integers can make a
executing.
program more memory efficient. However, it may be necessary to cast an
• While loops (also known as 'condition-controlled loops') are used
integer to real in a program, and some commands may require a specific
when the number of iterations is not known because the variable
data type.
used to determine when the iteration ends is changing within the
o Input - a value that is read from an input device, like a keyboard.
iteration itself.
o Output - data generated by the computer and displayed to the user.
• Do… until loops are an alternative to while where the code
o Integer - a whole number; positive or negative; used only when arithmetic on the
executes at least once before the condition is checked.
data is required - e.g. 6 - Use: total = total + score – can’t be used for telephone
numbers.
o Real - number with a decimal part; sometimes called float/floating-point number Three Programming Constructs Questions
- e.g. 6.5 - Use: cost = total + vat. o What are the three programming constructs?
o Character - a single alphanumeric - used for menu choices - e.g., 1 or a - Use: o What is the difference between for, while, and do… until loops?
choice = input("Enter your choice:"). o What are the alternative names for 'for' and 'while' loops?
o String - multiple alphanumeric characters - used for words and telephone numbers o How do 'if' and 'switch/select… case' statements work? How are they
- e.g. Craig - Use: forename = Craig. different?

, Arithmetic and Comparison Operators Boolean Operators
o The Arithmetic Logic Unit (ALU) performs: arithmetic o There’re three Boolean operators: and, not and or.
calculations, logical comparisons and binary shifts. • And - execute code if both statements are true.
o Arithmetic Operators: • Not - execute code if one statement is true but not the other.
• Addition (+) • Or - execute code if one statement or the other statement is true.
• Subtraction (-) o An infinite loop can be created by executing 'while True'.
• Multiplication (*) o It’s called a Boolean expression because that expression equates or evaluates to either
• Division (/) true or false.
• Exponentiation (^) • 0 AND 1 = 0
• Modulus (MOD) – how many whole numbers are left • 0 OR 1 = 1
once you fit the number on the right into the number on • NOT 0 = 1
the left as many times as you can
• Integers Division (DIV) – how many whole times does Boolean Operators Questions
the number on the right fit into the number on the left
o Why is a Boolean expression called that?
o Comparison Operators:
o What are the three Boolean operators? How does
• Equal to (==)
• Not equal to (!=) each one work?
o How can you create an infinite loop?
• Less than (<)
• Less than or equal to (<=)
• Greater than (>) o Variables and constants can hold: integer, real (float), character, string and Boolean.
• Greater than or equal to (>=) o Each data type uses a different amount of memory; to optimise the program the correct
data type should be used.
o What is the purpose of the MOD and DIV arithmetic operators? • e.g. The number 22 should be stored as an integer rather than float, as it takes less
o What do the != , == , <= and >= comparison operators mean? memory and isn't a decimal - 22 takes up less than 22.0.
o Concatenating numbers stored as an integer requires conversion to the string data type,
as by remaining in the integer data type, the program will instead add the two numbers.
o What is casting? Why is it o It's easy to convert string data types back into integers (or other data types) so we can
necessary?
o What data types can variables Data Types o
perform arithmetic calculations, by simply putting "int" before the variable it is stored in.
We can ask the user to input numbers but as characters, even though we want them to be
and constants hold?
o How would you cast a variable and Casting o
stored as integers. Therefore, we can cast them (convert them) into integers.
Changing a data type from one to another is called casting.
to a string or an integer? Why o Casting is necessary so that sub-problems receive data in a format they are expecting.
might this be useful in a o Casting allows numbers to be manipulated as strings, and allows inputs that are always
program? string to become numbers.
o Why should telephone numbers • x = str(x) casts the variable x to a string.
be stored as strings and not • x = int(x) casts the variable x to an integer.
integers?

Escuela, estudio y materia

Institución
Estudio
Grado
Año escolar
200

Información del documento

Subido en
18 de julio de 2025
Número de páginas
6
Escrito en
2023/2024
Tipo
RESUMEN

Temas

$5.50
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor
Seller avatar
kuromouse

Documento también disponible en un lote

Conoce al vendedor

Seller avatar
kuromouse
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
-
Miembro desde
1 año
Número de seguidores
0
Documentos
48
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes