100% tevredenheidsgarantie Direct beschikbaar na betaling Zowel online als in PDF Je zit nergens aan vast
logo-home
Summary OCR A-Level Computer Science topic 2.2 €4,32   In winkelwagen

Samenvatting

Summary OCR A-Level Computer Science topic 2.2

 5 keer bekeken  0 keer verkocht
  • Vak
  • Instelling

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

Voorbeeld 2 van de 8  pagina's

  • 15 mei 2024
  • 8
  • 2022/2023
  • Samenvatting
avatar-seller
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

Voordelen van het kopen van samenvattingen bij Stuvia op een rij:

Verzekerd van kwaliteit door reviews

Verzekerd van kwaliteit door reviews

Stuvia-klanten hebben meer dan 700.000 samenvattingen beoordeeld. Zo weet je zeker dat je de beste documenten koopt!

Snel en makkelijk kopen

Snel en makkelijk kopen

Je betaalt supersnel en eenmalig met iDeal, creditcard of Stuvia-tegoed voor de samenvatting. Zonder lidmaatschap.

Focus op de essentie

Focus op de essentie

Samenvattingen worden geschreven voor en door anderen. Daarom zijn de samenvattingen altijd betrouwbaar en actueel. Zo kom je snel tot de kern!

Veelgestelde vragen

Wat krijg ik als ik dit document koop?

Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.

Tevredenheidsgarantie: hoe werkt dat?

Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.

Van wie koop ik deze samenvatting?

Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper nikitabilla-patel. Stuvia faciliteert de betaling aan de verkoper.

Zit ik meteen vast aan een abonnement?

Nee, je koopt alleen deze samenvatting voor €4,32. Je zit daarna nergens aan vast.

Is Stuvia te vertrouwen?

4,6 sterren op Google & Trustpilot (+1000 reviews)

Afgelopen 30 dagen zijn er 83750 samenvattingen verkocht

Opgericht in 2010, al 14 jaar dé plek om samenvattingen te kopen

Start met verkopen
€4,32
  • (0)
  Kopen