Search CSNewbs
286 items found for ""
- 5.1 - Languages & Translators - OCR GCSE (J277 Spec) | CSNewbs
Learn about the two types of language levels - high level languages and low level languages , as well as the use of interpreters and compilers. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 5.1: Languages & Translators Exam Board: OCR Specification: J277 There are two types of programming languages used within computer systems: High-Level Languages Why do programmers use high-level languages? H igh-level programming languages use code written in a way that is similar to a natural human language , such as English, making it easier to understand and use the language. Using high-level languages leads to fewer errors and allows for more powerful and complex commands compared to low-level languages. However, a high-level language must be translated into machine code (binary) before it can be run, as high-level languages cannot be executed directly by the CPU . Popular high-level languages: PYT HON C++ Ja v a Visual Basic Low-Level Languages Low-level languages do not closely resemble a natural human language , making it harder for humans to understand and write in. Low-level languages are used when a program must be executed quickly or when programmers need to write code that interacts directly with the hardware , such as device drivers. There are two types of low-level language : Machine Code This is the pure binary code that computers can directly process and execute . It is extremely tedious and difficult for humans to understand and write machine code. However, machine code can be used when a programmer needs to perform a very specific command that can't be done in a high-level language. Machine code will be executed faster than high-level programs because it is already in a format the CPU can execute and does not need to be translated . 0010 1011 0101 0101 0110 0111 0101 0001 0101 0101 0101 0100 1010 1010 1010 1010 1111 1110 0010 1001 0100 1001 0010 0111 0111 0101 0011 1010 1000 0101 0110 0111 0000 1010 1010 0011 1101 1001 0010 1101 0010 0100 1001 0011 1010 1001 0101 0101 0010 0101 0111 0101 0101 1000 1011 0111 Assembly Language Assembly language uses specialised command mnemonics to perform actions . See the Assembly Language section in the programming tab for a list of mnemonics such as INP , OUT and HLT . Assembly language is preferred by many programmers over machine code because it is easier to understand and spot errors . It is faster to execute than high-level languages and, like machine code, can be used to directly control the CPU . INP STA Number1 OUT HLT Number1 DAT Translators A translator changes (translates) a program written in one language into another language (usually machine code ). There are two main types of translator : Interpreter An interpreter converts high-level language one line at a time into machine code and executes it. Compiler A compiler converts high-level language into machine code for execution at a later time. The entire program is converted at once . PYT HON PYT HON 0010 1011 0101 0101 0110 0111 0101 0001 0101 0101 0010 1011 0101 0101 0110 0111 0101 0001 0101 0101 Interpreters vs Compilers Interpreter Compiler Execution Method: An interpreter translates source code (high level code) into machine code one line at a time . Execution Speed: An interpreter is slower than a compiler because the code must be reinterpreted each time the program is run. Complexity: Interpreters are smaller, simpler programs . Error Reporting: In error reporting, the interpreter would encounter the errors and report it to the user immediately and stops the program from running. Repetition: Interpreted programs can be edited and run without translating the whole program . Interpreters must reinterpret the program every time it is run. Execution Method: A compiler translates all the source code (high level code) into machine code in one go . A compiler produces an executable file that will run on other machines without the compiler needing to be installed. Execution Speed: Compilers can produce much more efficient code than interpreters making the compiled programs run faster . Complexity: Compilers tend to be large complex programs . Error Reporting: The compiler would analyse the entire program , taking note of where errors have occurred and record them in an error file . Repetition: Compilation requires analysis and the generation of the code only once , whereas interpreters must re-interpret each time. However, compiled programs have to be re-compiled after any changes have been made. x1 ∞ x1 Q uesto's Q uestions 5.1 - Languages & Translators: 1a. Describe three reasons why programmers use high-level languages . [ 3 ] 1b. Explain one limitation of using high-level languages . [2 ] 2a. Describe a key difference between low-level languages and high-level languages . [ 2 ] 2b. Describe when a low-level language would be used instead of a high-level language . [2 ] 2c. Describe an advantage and a disadvantage of writing directly in machine code . [2 ] 2d. Describe what assembly language is. Give one benefit to using assembly language instead of machine code and one benefit to using it instead of a high-level language . [3 ] 3. Compare high-level and low-level languages by stating which is: a. Easier to understand [ 1 ] b. Requiring translation [ 1 ] c. Quicker to execute [ 1 ] 4. Compare interpreters and compilers for each of the following features : a. Execution Method b. Execution Speed c. Complexity d. Error Reporting e. Repetition [ 10 total ] 4.1 - Boolean Logic Theory Topics 5.2 - IDE
- 4.1 - Boolean Logic - OCR GCSE (J277 Spec) | CSNewbs
Learn about the three logical operators - NOT, AND and OR - as well as truth tables. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 4.1: Boolean Logic Exam Board: OCR Specification: J277 What is a logical operator? Inside of each computer system are millions of transistors . These are tiny switches that can either be turned on (represented in binary by the number 1 ) or turned off (represented by 0 ). Logical operators are symbols used to represent circuits of transistors within a computer. The three most common operators are: NOT AND OR What is a truth table? Truth tables are used to show all possible inputs and the associated output for each input . The input and output values in a truth table must be a Boolean value - usually 0 or 1 but occasionally True or False. NOT AND OR A NOT logical operator will produce an output which is the opposite of the input . NOT is also known as Negation . The symbol for NOT is ¬ An AND logical operator will output 1 only if both inputs are also 1 . AND is also known as Conjunction . The symbol for AND is ∧ An OR logical operator will output 1 if either input is 1 . OR is also known as Disjunction . The symbol for OR is ∨ NOT Logic Gate AND Logic Gate Symbol OR Logic Gate Symbol Truth Table Truth Table Truth Table Multiple Operators Exam questions could ask you complete truth tables that use more than one logical operator . Work out each column in turn from left to right and look carefully at which preceding column you need to use. NOT B A AND NOT B A OR (A AND NOT B) As binary is a base-2 number system , the number of rows required in a truth table will double with each new input in the expression in order to show the unique combinations of inputs. The examples above use just two inputs (A + B) so 4 rows are required. e.g. A = 2 rows / A + B = 4 rows / A, B + C = 8 rows / A, B, C + D = 16 rows Logic Diagrams You may be asked in an exam to d raw a logic diagram when given a logical expression . Draw any NOT symbols or expressions in brackets first. A logic diagram for C = ¬A ∧ B A logic diagram for D = C ∨ (A ∧ B) Q uesto's Q uestions 4.1 - Boolean Logic: 1. Copy and complete the following truth tables: 1b. Simplify the expression in the second truth table. 2a. A cinema uses a computer system to monitor how many seats have been allocated for upcoming movies. If both the premium seats and the standard seats are sold out then the system will display a message. State the type of logical operator in this example. 2b. For the more popular movies, the cinema's computer system will also display a message if either the premium seats or the standard seats have exclusively been sold out. However, it will not output a message when both have been sold out. State the type of logical operator in this example. 3. Draw a logic diagram for C = (¬B v A) ∧ A . 3.2 - Testing Theory Topics 5.1 - Languages & Translators
- 5.2 - Integrated Development Environment - OCR GCSE (J277 Spec) | CSNewbs
Learn about the tools of an integrated development environment (IDE) including the editor, error diagnostics and run-time environment. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). Exam Board: OCR Specification: J277 5.2: Integrated Development Environment An IDE (Integrated Development Environment ) provides programmers with the following facilities (tools ) to help create programs : Editor The editor is software that allows a programmer to enter and edit source code . Editor features may include: Automatic formatting (e.g. automatic indentation). Automatic line numbering (this helps to identify exactly where an error has occurred). Automatic colour coding (e.g. Python IDLE turns loop commands orange and print commands purple). Statement completion (e.g. offering to auto-complete a command as the user is typing.) Error Diagnostics & Debugger Break point The programmer selects a specific line and the program displays the variable values at that point . The code can then be executed one line at a time to find exactly where the error occurs. This process is called single-stepping . Variable Watch / Watch Window cost Displays the current value of a selected variable . A variable can be watched line-by-line to see how the value changes . Trace Logs the values of variables and outputs of the program a s the code is executed line by line . Both tools are used to display information about an error when it occurs, such as the line it occurred on and the error type (e.g. syntax ). These tools may also suggest solutions to help the programmer to find and fix the error . Compilers & Interpreters Both tools convert the source code written by a programmer into machine code to be executed by the CPU. A compiler converts the entire source code into executable machine code at once . After compilation, the program can be run again without having to recompile each time. An interpreter converts source code into machine code line by line . An interpreter must reinterpret the code each time the program is required to run . See 5.1 for both types of translators. A runtime environment allows a program to run on a computer system. It checks for runtime errors and allows users to test the program . A runtime error occurs as the program is being executed , such as dividing a number by zero . A commonly used example is the Java Runtime Environment . This allows programmers to design a program on one platform ( using the programming language Java ) which allows the finished program to then be run on many others systems . A runtime environment enables the tools above such as a trace and breakpoint to be used. Run Time Environment Q uesto's Q uestions 5.2 - Integrated Development Environment: 1. Describe the purpose of each type of IDE tool : a. Editor b. Interpreter c. Compiler d. Error Diagnostics / Debugger e. Break point f. Variable Watch / Watch Window g. Trace h. Runtime Environment [ 2 each ] 5.1 - Languages & Translators Theory Topics
- 3.2 - Testing - OCR GCSE (J277 Spec) | CSNewbs
Learn about why testing is needed, types of testing, types of test data and types of error. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 3.2: Testing Exam Board: OCR Specification: J277 The main purpose of testing is to ensure that a program works correctly no matter what input has been entered by the user. Other reasons to test a program include ensuring the user requirements have been met , errors have been removed and the program doesn't crash while running . Types of Testing Iterative Testing Iterative testing takes place during program development . The programmer develops a module , tests it and repeats this process until the module works as expected . Final Testing Final testing, also known as terminal testing , takes place after development and before the program is released to the end user. This testing takes place once all modules have been individually tested to ensure the whole program works as originally expected. Programming Errors Syntax Error Logical Error A syntax error is a mistake in the grammatical rules of the programming language , such as an incorrect spelling of a command word. A syntax error will prevent the program from being compiled and executed . Examples: Incorrect Spelling: pront ( "hello" ) Incorrect punctuation: print ( "hello" ( A logic error is a mistake made by the programmer - the program runs without crashing but will display the wrong output . Examples: Incorrect calculation: total = num1 - num2 print (total) Incorrect variable printed: age = 16 name = "Steve" print ( "Nice to meet you" , age) Test Data Test data is used to test whether a program is functioning correctly . It should cover a range of possible and incorrect inputs , each designed to prove a program works or to highlight any flaws . Four types of test data are: Q uesto's Q uestions 3.2 - Testing: 1. Give 3 reasons why programs are tested . [ 3 ] 2. What is the difference between iterative and final testing ? [ 2 ] 3a. What is a syntax error ? Give an example . [ 2 ] 3b. What is a logical error ? Give an example . [ 2 ] 4. State and describe the four types of test data . [ 6 ] Normal data - Sensible data that the program should accept and be able to process . Boundary data - Data at the extreme boundary of any data ranges. Invalid data - Data of the correct data type that does not meet the validation rules (e.g. outside of the range). It should not be accepted . Erroneous data - Data of the wrong data type that the program cannot process and should not accept . 3.1 - Defensive Design Theory Topics 4.1 - Boolean Logic
- 3.1 - Defensive Design - OCR GCSE (J277 Spec) | CSNewbs
Learn about defensive design considerations including validation checks, verification, anticipating misuse, maintainable code, authentication and input sanitisation. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 3.1: Defensive Design Exam Board: OCR Specification: J277 Defensive Design Considerations There are several things to consider when creating a program that is secure and robust , including: Anticipating Misuse Planning ahead to take steps against potential misuse (e.g the app X prevents the same tweet sent twice in a row as it might be spam ). Input Sanitisation Checking and cleaning up data that has been input , (e.g. removing special characters to prevent a SQL injection ). Validation Checking whether input data follows specific criteria and should be accepted (e.g. a length check on a password). Verification Checking whether data that has been entered is correct (e.g. double entry ). Authentication Ensuring only authorised users can gain access to a system (e.g. usernames and strong passwords ) . Maintainable code Allowing other programmers to easily read and quickly understand code that has been written (e.g. using comments , indentation and appropriate variable names ). Input Validation Validation is a process to check that data is reasonable or sensible before it is accepted . Range Check Checks data is within a certain range . Age: 34 203 Type Check Checks data is a certain data type . Height (in cm): 182 Two metres Format Check Checks data is entered in a certain way . Date of Birth (DD/MM/YYYY) 25/03/2011 25th March 11 Presence Check Checks that data has actually been entered and not left blank . Password: fluffythecat123 Lookup Table A table of acceptable entries , also known as a list . Length Check Checks the length of the input is within a certain amount. Telephone Number 08323877319 07383 Maintainability Programs should be written in a way that makes maintaining and understanding them as straightforward as possible. Examples of making a program maintainable include: Using subprograms to reuse code and make them easier to test . This is called modularisation . Appropriate variable names , using a naming convention , ensure the purpose of a variable is immediately understood. Using indentation to improve readability and clearly show each ‘block’ of code. Comments enable a programmer to understand the purpose of each line of code. Crucial when working in a team . Using constants is another method of improving maintainability. This keeps the program code consistent , which makes it easier to read and debug a program. Q uesto's Q uestions 3.1 - Defensive Design: 1. Describe the different considerations a programmer should make for a defensive design . [ 6 ] 2. Describe the each validation check and give a suitable example . [ 12 ] 3. Explain the different ways a program can be maintained . [ 5 ] 2.3 Additional Programming Theory Topics 3.2 - Testing
- 2.1 - Programming Fundamentals - OCR GCSE (J277 Spec) | CSNewbs
Learn about the fundamentals of programming - selection, sequence and iteration. Also find out the difference between local and global variables and constants. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 2.1: Programming Fundamentals Exam Board: OCR Specification: J277 Programming Constructs There are three constructs ( ideas of programming ) that are used to control the flow of a program : Sequence Structuring code into a logical, sequential order . Selection Decision making using if statements . Iteration Repeating code using for or while loops . Variables Variables are used to store data in programs. They can be changed as the program runs . A variable has two parts - the data value such as "Emily" and an identifier such as First_Name . An efficient program will use variables with sensible identifiers that immediately state their purpose in the program. Using variable names like 'TotalNum' and 'Profit' rather than 'num1' and 'num2' mean that other programmers will be able to work out the purpose of the code without the need for extensive comments. Local & Global Variables Large programs are often modular - split into subroutines with each subroutine having a dedicated purpose. Local variables are declared within a specific subroutine and can only be used within that subroutine . Global variables can be used at any point within the whole program . Local variable advantages Saves memory - only uses memory when that local variable is needed - global variables use memory whether they are used or not. Easier to debug local variables as they can only be changed within one subroutine. You can reuse subroutines with local variables in other programs. Global variable advantages Variables can be used anywhere in the whole program (and in multiple subroutines). Makes maintenance easier as they are only declared once. Can be used for constants - values that remain the same. Constants π As specified before, a variable is data that can change in value as a program is being run. A constant is data that does not change in value as the program is run - it is fixed and remains the same. An example of a constant in maths programs is pi - it will constantly remain at 3.14159 and never change. Operators Comparison Operators Comparison operators are used to compare two data values . A table of common comparison operators used in programs are below: Arithmetic Operators Arithmetic operators are used to mathematically manipulate values . The most common arithmetic operators are add (+ ), subtract (- ), multiply (* ) and divide (/ ). Further arithmetic operators are shown below: Modulo division (also known as modulus ) reveals the remainder from the last whole number . For example: 9 % 4 = 1 (4 goes into 9 twice (8) with a remainder of 1) Integer division (also known as quotient ) reveals the ‘whole number of times ’ a number can be divided into another number : 9 // 4 = 2 (4 goes into 9 fully, twice) The symbol ^ represents exponentiation . However, Python uses ** to represent exponentiation. For example '2^3 = 8' is equivalent to '2³ = 8'. Logical Operators Logical operators typically use TRUE and FALSE values which is known as Boolean . You can find more information about Boolean values in section 4.1 . Q uesto's Q uestions 2.1 - Programming Fundamentals: Programming Constructs 1. Describe and draw a diagram for the 3 programming constructs . [6 ] Variables 1. What is the difference between local and global variables ? [4 ] 2. Describe two advantages of using local variables . [2 ] 3. Describe two advantages of using global variables . [2 ] 4. What is a constant ? Give an example . [2 ] 1.3 - Searching & Sorting Theory Topics 2.2 - Data Types
- 2.3 - Additional Programming Techniques - OCR GCSE (J277 Spec) | CSNewbs
Learn about arrays, records and SQL (structured query language) including the SELECT, FROM and WHERE commands. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 2.3: Additional Programming Techniques Exam Board: OCR Specification: J277 This section of the specification includes programming topics that are outlined in 1.2 (Designing Algorithms). You must have an understanding of more complex programming techniques , such as how to manipulate strings , handle files and use subprograms . The best practice for learning is to try the tasks in the Python pages on this website (see the link to the right). Visit the Python section of CSNewbs ---> Subprograms What is a subprogram? Large programs are often broken down into smaller subprograms (also called subroutines ). Each subprogram focuses on a specific function of the code, helping to decompose a complex problem into more manageable chunks . Defining subprograms A subprogram is defined (identified) using the def command in Python. A program may use many subprograms , which are usually defined at the start of the code . Calling subprograms Running a line of code that includes the name of a subprogram will call (activate) it. When called , the program will run the subprogram code before returning back to the line that called it . Subprograms are only run when called , so depending on decisions made, a program may end without calling every (or any) subroutine. Parameters A parameter is a value that is passed into a subprogram when it is called , allowing the value to be used within the subprogram . A subprogram may not use a parameter , e.g. multiply() , or one parameter , e.g. multiply(num) , or several e.g. multiply(num1,num2) . Any parameters must be identified when the subprogram is defined , e.g. def multiply(num): Return The return command will send a value back to the line the subprogram was called on, allowing it to be used there . For example, the 'quad' subprogram in the example below returns the value of the 'result' variable back to the main program, allowing it to be printed . A subprogram will end either by reaching the last line of code within it, or when it reaches a return command . Subprograms that return a value are called functions . Subprogram example This subprogram is defined using the identifier 'quad ' with a parameter named number . The subprogram is called in the main program, multiplies the number passed in as a parameter by 4 and returns a value back to the main program to be printed. def quad (number): result = number * 4 return result #Main Program number = int ( input ( "Enter a number: " )) print ( "The number quadrupled is" , quad(number)) Enter a number: 5 The number quadrupled is 20 Functions and Procedures There are two types of subprograms . A function is a subprogram that returns a value , using the return command, which allows the value to be used in the line of code the function was called in. The 'divide' function below returns the value of the variable 'total' to the main program to be printed. A procedure is a subprogram that does not return a value . Example of a Procedure def multiply (num): total = num * 2 print ( "The number doubled is" , total) #Main Program num = int ( input ( "Enter a number: " )) multiply(num) Enter a number: 4 The number doubled is 8 Example of a Function def divide (num): total = num / 2 return total #Main Program num = int ( input ( "Enter a number: " )) print ( "The number halved is" , divide(num)) Enter a number: 9 The number halved is 4.5 Advantages of using subprograms Subprograms break a complex program down into smaller parts , making it easier to design and test . Each subroutine can be tested separately and abstraction can be used to simplify a complicated problem . Using subprograms allows code to be easily reused in other programs , as it has already been written , making it quicker to develop new programs or build on existing work. Using subprograms avoids code repetition , as they can be called as many times as necessary . This makes programs shorter and quicker to develop , making them easier to maintain and debug . Work can easily be split up between team members to work on different subprograms at the same time . Array An array is a static data structure that can hold a fixed number of data elements . Each data element must be of the same data type i.e. real, integer, string. The elements in an array are identified by a number that indicates their position in the array. This number is known as the index. The first element in an array always has an index of 0 . You should know how to write pseudo code that manipulates arrays to traverse , add , remove and search for data . The following steps use Python as an example, although Python does not use arrays and uses a similar data structure called a list (that can change in size as the program runs ). See the 8a and 8b Python pages for tasks on how to use lists . What Traversing an Array To traverse (' move through ') an array a for loop can be used to display each data element in order. Example code for traversing: Output: 'Inserting' a value In an array the size is fixed so you cannot insert new values, but you can change the value of elements that already exist. Overwriting the fourth element (Daphne) with a new value (Laura) will change it from Daphne to Laura. Example code for inserting: Output: 'Deleting' a value In an array the size is fixed so you cannot delete values, but you can overwrite them as blank . Overwriting the second element (Shaggy) with a blank space makes it appear deleted. Example code for deleting: Output: Searching an Array For large arrays a for loop is needed to search through each element for a specific value . This example checks each name to see if it is equal to Velma. Example code for searching: Output: Two-Dimensional Array Often the data we want to process comes in the form of a table . The data in a two dimensional array must still all be of the same data type , but can have multiple rows and columns . The two-dimensional array to the right shows the characters from Scooby Doo along with their associated colour and their species. Each value in the array is represented by an index still, but now the index has two values . For example [3] [0] is 'Daphne'. Unless stated in an exam , measure row first , then column . Searching a two-dimensional array: To print a specific data element you can just use the index number like Daphne above. To search for a specific value you will need two for loops , one for the row and another for the values of each row . The example to the right is looking for the value of ' Velma ' and when it is found it prints the associated data from the whole row . Example code for printing: Output: Example code for searching: Output: Records Unlike arrays, records can store data of different data types . Each record is made up of information about one person or thing . Each piece of information in the record is called a field (each row name). Records should have a key field - this is unique data that identifies each record . For example Student ID is a good key field for a record on students as no two students can have the same Student ID. A 2D array may be used to represent database tables of records and fields . SQL SQL (structured query language ) is a language that can be used to search for data in a database . The format of an SQL statement is: SELECT field1, field2, field3… FROM table WHERE criteria Example of an SQL statement using the Cars table: SELECT Make, Colour FROM Cars WHERE Miles > 1000 AND Age > 8 Cars table SQL uses wildcards which are symbols used to substitute characters . The * symbol represents ALL fields . Example: SELECT * FROM Cars WHERE Colour = “blue” Click the banner above to try a self-marking quiz (Google Form) on this topic. Q uesto's Q uestions 2.3a - Additional Programming Techniques: 1a. Describe what the following terms mean: subprogram , parameter , function , procedure . [ 2 each ] 1b. Describe three advantages of using subprograms . [ 6 ] 2. Describe the differences between a 1D array , 2D array and record . [ 3 ] 3. A one-dimensional array looks like this: TigerBreeds("Sumatran","Indian","Malayan,"Amur") Write the code to: a. Print the element with the index of 3. [ 2 ] b. Change Indian to South China. [ 2 ] c. Remove the Amur element. [ 2 ] d. Search through the array for 'Malayan'. [ 2 ] 4a. Use the Cars table above to write the SQL statement to display the make and miles for cars that are grey OR blue . [ 3 ] 4b. Write an SQL statement to display all fields for cars that are 10 years old or less . [ 3 ] 2.2 Data Types Theory Topics 3.1 - Defensive Design
- 2.2 - Data Types - OCR (J277 Spec) | CSNewbs
Learn about the five data types - character, string, integer, real and Boolean. Also learn about casting. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 2.2: Data Types Exam Board: OCR Specification: J277 What are the different data types? When programming, variables should be given appropriate data types . Character A single character , such as a letter, number or punctuation symbol. Examples: T 8 ? String A sequence of characters , including letters, numbers and punctuation. Examples: Harry Waters 14:50pm Ice Age 4 Integer A whole number . Examples: 475 -8432 56732 Real Boolean A decimal number . Examples: 65.3 -321.1234 909.135 An answer that only has two possible values . Examples: True / False Yes / No 0 / 1 Telephone numbers are always stored as a string , not an integer. Casting Converting the value of a variable from one data type into another is known as casting . Python automatically assumes an input is a string so the int() command is used to cast an input into an integer . Other Python commands for casting include str() and float() . For example: age = int(input("Enter your age: ")) Q uesto's Q uestions 2.2 - Data Types: 1. List the five data types , giving an example of each . [ 5 ] 2. State which data type is most suitable for the following variables: a. Age [ 1 ] b. Surname [ 1 ] c. Height (in metres) [ 1 ] d. First Initial [ 1 ] e. Phone number [ 1 ] f. Right-Handed? [ 1 ] 3. Explain what casting is and give a programming situation in which it would be used . [ 2 ] 2.1 - Programming Fundamentals Theory Topics 2.3 - Additional Techniques
- 5.2 - Utility Software - OCR GCSE (J277 Spec) | CSNewbs
Learn about different types of utility software including anti-virus, firewall and defragmentation. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 5.2: Utility Software What is utility software? Utility software are dedicated programs used for the maintenance and organisation of a computer system (this is known an 'housekeeping '). Utilities are required to run additional tasks not performed by the operating system . Anti-malware (such as an anti-virus or anti-spyware ), firewall and encryption software are examples of utilities and have been explained in section 4.2 . Data Compression is another utility that has been explained in section 2.5 . Other utility software include backup software , disk checkers , disk formatters and auto-updaters . Exam Board: OCR Specification: J277 Defragmentation What is fragmentation and how does it happen? Over time files stored on a hard disk drive may become fragmented - this is when the file is split into parts that are saved in different storage locations . Fragmentation occurs when there is limited contiguous space in which to store a file . This may happen as data is stored and then later deleted on the hard drive . New files are created which may be bigger than the spaces left by the deleted files . The new files are then split up . Fragmentation increases access time - files that are fragmented take longer to load and read because of the distance between the fragments of the file. How does defragmentation work? Empty spaces are collected together on the hard disk drive and file fragments are moved to be stored together. This means that fewer disc accesses are needed (requiring less physical movement ) as file fragments can be read consecutively . What are the effects of defragmentation? A defragmented file takes less time to read and access because the data is stored contiguously . The read/write head of the hard drive does not need to move as far to read the next piece of data because it is in the adjacent memory location , saving time . It also quicker to save new files because there is more free space together so it does not need to split the file and can store the data contiguously . Q uesto's Q uestions 5.2 - Utility Software: 1. Explain what fragmentation is and how a file may become fragmented . [ 3 ] 2. Describe the process of defragmentation . [ 3 ] 3. Explain the effects of defragmenting a hard disk drive. [ 3 ] 5.1 - Operating Systems Theory Topics 6.1a - Impacts of Technology
- 1.1 - Computational Thinking - OCR GCSE (J277 Spec) | CSNewbs
Learn about the three elements of computational thinking - abstraction, decomposition and algorithmic thinking. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 1.1: Computational Thinking Exam Board: OCR Specification: J277 There are three key components to computational thinking (smart problem solving): Abstraction is when you ignore unnecessary information and focus only on the important facts . Abstraction is used because it simplifies a problem to make it less complex . This makes it more straightforward to understand the problem and create a solution . Decomposition is when you break a problem down into smaller tasks so that it is easier to solve . Each individual problem can be separately tested and solved . Decomposition also enables different people to work on the different parts of a larger problem that can later be recombined to produce a full solution . Algorithmic thinking is the final stage as logical steps are followed to solve the problem . The problem is broken down using decomposition into smaller problems . The required data and relevant data structures are considered using abstraction . Q uesto's Q uestions 1.1 - Computational Thinking: 1. What does the term 'abstraction ' mean? Why is it important ? [2 ] 2. What is meant by ' decomposition '? Why is it important ? [ 2 ] 3. What is algorithmic thinking ? What does it involve? [3 ] Theory Topics 1.2 - Designing Algorithms
- 1.2 - Designing Algorithms - OCR GCSE (J277 Spec) | CSNewbs
Learn about designing algorithms including constructing pseudocode and flowcharts. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 1.2: Designing Algorithms Exam Board: OCR Specification: J277 What is an algorithm? An algorithm is a set of instructions , presented in a logical sequence . In an exam you may be asked to read and understand an algorithm that has been written. To prove your understanding you may be asked to respond by actions such as listing the outputs of the algorithm, correcting errors or identifying an error within it. Programmers create algorithm designs as a method of planning a program before writing any code. This helps them to consider the potential problems of the program and makes it easier to start creating source code. There are two main methods of defining algorithms are pseudocode and flowcharts . In exams , OCR will display algorithms in their own 'OCR Exam Reference Language '. Visit the Python section of CSNewbs ---> OCR Exam Reference Language T he OCR exams require specific questions to be written either in OCR Exam Reference Language (shown below) or a high-level programming language such as Python . Basic Commands Annotation // Comments are written using two slashes Assignment name = "Harold" age = 49 Constants and Global Variables constant tax = 15 global name = "Admin" Input / Output name = input ( "Enter your name") print ("Transaction Complete") Casting str (29) int ("102") float (30) bool ("False") Random Number number = random (1,100) Selection Selection (if - then - else) if firstname == "Steven" then print("Hello" + firstname) elif firstname == "Steve" then print("Please use full name") else print("Who are you?") end if Selection (case select) switch day: case “Sat”: print(“It is Saturday”) case “Sun”: print(“It is Sunday”) default : print(“It is a Weekday”) endswitch Iteration Iteration (for loop) for i = 1 to 10 step 1 input item next i Iteration (while loop) while firstname ! = "Steven" firstname = input("Try again:") endwhile Iteration (do while loop) do firstname = input("Guess name:") until firstname == "Steven" String Handling Length of a String word = "dictionary" print(word.length ) outputs 10 Substrings word = "dinosaurs" print(word.substring (2,3)) outputs nos print(word.left (3)) outputs din print(word.right (4)) outputs aurs Concatenation name = "Penelope" surname = "Sunflower" print(name + surname) String Cases phrase = "The Cat Sat On The Mat" print(phrase .lower ) print(phrase .upper ) ASCII Conversion ASC ("C") returns 67 CHR (100) r eturns "d" File Handling File Handling - Reading Lines file1 = open ("Customers.txt") while NOT file1.endOfFile() print(file1.readLine() ) endwhile file1.close() File Handling - Writing to a (New) File newFile ("paint.txt") file2 = open ("paint.txt") paint = input("Enter a paint colour:") file.writeLine (paint) file2.close() Arrays Declare Array array names[3] array names = "Ella", "Sam", "Ali" Declare 2D Array array grid[4,5] Assign Values names[2] = "Samantha" grid[1,3] = "X" More Programming Keywords Connecting strings together using the + symbol is called concatenation . Extracting certain parts of a string (e.g. using .substring() ) is called slicing . An if statement within an if statement or a loop within a loop is called nesting . Flowcharts A flowchart can be used to visually represent an algorithm. It is more likely you will need to be able to interpret a flowchart rather than draw one. The flowchart symbols are: The terminator symbol is also known as a terminal . Algorithm Examples Below are two different methods for representing the same algorithm - a program to encourage people to buy items cheaply at a supermarket. The program allows the price of items in a supermarket to be entered until the total reaches 100. The total price and the number of items entered are tracked as the program loops. Once the total reaches 100 or more, an if statement checks how many items have been entered and a different message is printed if there are 20 or more items, 30 or more items or less than 20 items. Pseudocode // This is a program to see how many items you can buy in a supermarket before you spend over £100} total = 0 itemsentered = 0 while total < 100 itemprice = input ("enter the price of the next item") total = total + itemprice itemsentered = itemsentered + 1 endwhile if itemsentered >= 20 then print ("You are on your way to saving money.") elif itemsentered => 30 then print ("You're a real money saver.") else print ("Look for better deals next time.") endif Flowchart Reading Algorithms In an exam you may be asked to read an algorithm and prove your understanding , most commonly by listing the outputs . Start from the first line and follow the program line by line , recording the value of variables as you go . When you encounter a for loop , repeat the indented code as many times as stated in the range . Example Algorithm: procedure NewProgram() maxvalue = input() for i = 1 to maxvalue output (i * i) ??????? print("program finished") endprocedure Example Questions: 1. List the outputs produced by the algorithm if the 'maxvalue' input is 5 . 2. State the code that has been replaced by '???????' and what the code's purpose is. Example Answers: 1. Outputs: 1 4 9 16 25 program finished 2. Missing Code: next i Purpose: Moves the loop to the next iteration. Watch on YouTube Structure Diagrams Structure diagrams display the organisation (structure ) of a problem in a visual format , showing the subsections to a problem and how they link to other subsections . The noughts and crosses structure diagram below has subsections in light yellow. Each subsection could be coded by a different person . Structure diagrams are different to flowcharts (those show how data is input, processed and output within a program or system). You may be asked in an exam to draw or fill in a simple structure diagram . Trace Tables Trace tables are used to track the value of variables as a program is run . They can be used to manually track the values in order to investigate why the program isn't working as intended . Each row in the trace table represents another iteration . Each column stores the value of a variable as it changes. See below how the trace table is updated for the simple algorithm on the left. num1 = 2 num2 = 5 for i = 1 to 3 output (num1 + num2) num2 = num2 - 1 next i print("complete") For most algorithms, not every variable will be updated in each iteration . Values may not be entered in the order of the trace table either. For example, each iteration outputs num1 + num2 and then decreases the value of num2 by 1. Q uesto's Q uestions 1.2 - Designing Algorithms: 1. What is the definition of an algorithm ? Name two ways an algorithm can be designed . [ 3 ] 2. Using a high-level programming language such as Python , or the OCR Exam Reference Language , write an algorithm that inputs 6 decimal numbers and outputs the total , largest , smallest and average values. [ 8 ] For example, entering 3.1 , 5.3 , 2.3 , 5.4 , 2.9 and 4.4 would output 23.3 (total), 5.4 (largest), 2.3 (smallest) and 3.9 (average). 3. Draw and label the flowchart symbols . [ 6 ] 4. What is the purpose of a structure diagram ? [ 2 ] 5. Create a trace table for the NewProgram() algorithm in the Reading Algorithms section on this page. [ 7 ] 1.1 - Computational Thinking Theory Topics 1.3 - Searching & Sorting
- 6.1b - Legislation - OCR GCSE (J277 Spec) | CSNewbs
Learn about key computing laws including the Data Protection Act (2018), Computer Misuse Act (1990), Copyright, Designs and Patents Act (1988) and software licences. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 6.1b: Legislation Exam Board: OCR Specification: J277 Data Protection Act (2018) In 2018 the European Union introduced GDPR (General Data Protection Regulation ) to protect the privacy of data for people in the EU. The UK matched this by updating the Data Protection Act introduced in 1998 to become the Data Protection Act (2018) . This act protects the data of individuals that is stored on computers and processed by organisations. How the Data Protection Act works: Each person who has their data stored is known as a data subject . An employee within an organisation must be appointed as a data controller and it is they who are responsible for registering with the Information Commissioner . The Information Commissioner is the person in the UK who is responsible for managing several laws , most significantly the Data Protection Act. When registering with the Information Commissioner, the organisation's data controller must be clear on exactly: What information they are collecting, Why it is being collected, What the data will be used for . The six principles of the Data Protection Act state that data must be: 1. Collected lawfully and processed fairly. 4. Data must be accurate and up-to-date. 2. Only used for the reasons specified. Principles of the Data Protection Act (2018) 5. Data must not be stored for longer than necessary, 3. Data must be relevant and not excessive. 6. Data must be stored and processed securely. Computer Misuse Act (1990) This act was introduced as computers became cheaper and more common at home and work . The act attempts to stop and punish those who use computers inappropriately . Breaking any of the three principles could result in fines and a jail sentence but only if it can be proved it was done on purpose and not by accident. The Computer Misuse Act (1990 ) includes three main principles : 1. No unauthorised access to data. Example: Hacking a computer system. 2. No unauthorised access to data that could be used for further illegal activities. Example: Accessing personal data to use as blackmail or identity theft. 3. No unauthorised modification of data. Example: Spreading a virus to change data. Copyright, Designs & Patents Act (1988) This act makes it a criminal offence to copy work that is not your own without the permission of the creator or the copyright holder. This can refer to text, images, music, videos or software. Owning the copyright of an image might not prevent others from copying and using it but this act means that the owner can bring legal proceedings in court to those who have stolen their work . However, it is difficult to trace who has stolen work once it has been uploaded to the internet and copies can easily spread, especially television shows and movies. This act specifically prohibits the following actions: Making copies of copyrighted material to sell to others . Importing and downloading illegally copied material (except for personal use). Distributing enough copyrighted material to have a noticeable effect on the copyright holder . Possessing equipment used to copy copyrighted material , as part of a business. Software Licences A software licence refers to how a user can legally use the software , there are two main types: Open Source Licence Source code is the software code written by programmers . If the software is open source it means that users can view and modify the source code . Linux, Python and Firefox are examples of open source software. Benefits Drawbacks Because the source code is available to edit , it can be customised to the organisation's needs . Often shared in the public domain so users can work together to modify, debug and improve a product. Unwanted features can be removed to make the software run faster . There are security risks - some editors may add malicious code to the program. Open source software is often low in price and sometimes free. It may be difficult to receive support as development is often distributed between people in different locations. The code may be prone to errors as it may not have been tested fully. It requires technical skills to be able to adapt source code efficiently and to maintain the code . Proprietary Licence Another term for a proprietary licence is closed source because the code is restricted - users are prevented from being able to view or modify the source code . You buy the right to use the software but you don't actually own it. Microsoft Office, Fortnite and Spotify are examples of closed source software. Benefits Drawbacks The code is well tested and has been professionally developed. Updates will generally be secure . Users must rely on the company to provide updates and fix issues. This might be infrequent or stop completely. The company can be held to account if it does not perform as listed in the terms and conditions upon purchase. Often not free and may be expensive. Most developers will provide some form of help/support . Users cannot modify, debug or improve the code for their own benefit. Q uesto's Q uestions 6.1b - Legislation: 1a. State the 6 principles of the Data Protection Act (2018) . [ 6 ] 1b. Explain how the Data Protection Act works . In your answer, you should include definitions of a data subject , the data controller and the Data Commissioner . [ 6 ] 2. Describe the 4 principles of the Computer Misuse Act (1990) . [3 ] 3a. What is the purpose of the Copyright, Designs & Patents Act (1988) ? [ 2 ] 3b. Describe 3 actions that CDPA (1988) prohibits . [ 3 ] 4a. Describe the difference between an open source and a proprietary licence . [ 2 ] 4b. State two benefits and two drawbacks of using software with a: Open source licence [ 4 ] Proprietary licence [ 4 ] 6.1a - Impacts of Technology Theory Topics