100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4,6 TrustPilot
logo-home
Resumen

Summary OCR A-Level Computer Science topic 2.2

Puntuación
-
Vendido
-
Páginas
8
Subido en
15-05-2024
Escrito en
2022/2023

Notes for point 2.2 in the ocr computer science specification focusing on programming techniques and computational methods

Institución
Grado









Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Nivel de Estudio
Editores
Tema
Curso

Información del documento

Subido en
15 de mayo de 2024
Número de páginas
8
Escrito en
2022/2023
Tipo
Resumen

Temas

Vista previa del contenido

Reading to and
Writing from files


openRead + open a file to read

readline return line of text
from the file
->
a



myfile-openRead ("sample .
Ext")
X= file readline
my
.




file
. close
my
↳ makes
X first line of ext file


endOffile() determines end of a
file
file openRead ("sample
It'l
my
: .




while NOT
my
file. end
Of file )
print (myfile . readLine()
endwhile

myfile . close)

prints contents of sample Ixt .




openWrite -> open a file to write to

writeline add line
of text to file
-




my Gle
=

open Write ("sample Ixt") .




file WriteLine ("Hello
S

World"
my .




file close
my .




↳ hello world is made the contents . It
of sample (previous contents are overwritten

, 2 2 1 . .


Programming techniques
programmingconstruc
its are used to represent a
program's control flow in the
popular subsection of procedural programming called structured
programming
:

Sequence
↳ code executed
line-by-line , top to bottom

Branching
certain block of code is if specific condition is met
If
using
↳ a run a
,


statements.


also known as selection

Iteration a block of code is executed a certain number ofhimes or while a

condition is met
↳ Iteration uses COR ,
WHILE or REPEAT UNTIL loops
↳ Iteration can be either :
count-controlled : iteration number of times
is
given a
-




for i in (0 10
range ,




print i

next i
↳ condition-controlled : iteration continues until condition is
a
given
met
While i = 20 :

print "Not true" :

i = i + 1

endwhile
Recursion :
↳ construct in which a subroutine calls itself during its execution
condition-called the
until
stopping
↳ continues a certain condition is met
↳ suited to certain problems which
produces the same result as iteration , but more are

more
easily expressed using recursion

Advantage:
they can be represented using fewer lines of code so less prone to errors

,



However it is essential that recursive subroutines are to
defined clearly
↳ so as

reach a
stopping condition after a
finite number of
function calls



Common example of a
naturally recursive
function factorial (number
functionisfactoria function calls itself
,
number == O or I stack is created within
if a new frame
return / the call stack , where parameters
,
else : local variables and return addresses

return number # factorial (number-1) ; are .
stored
end if
end function
$5.53
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
nikitabilla-patel

Conoce al vendedor

Seller avatar
nikitabilla-patel The University of Warwick
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
0
Miembro desde
1 año
Número de seguidores
0
Documentos
6
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

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