Search CSNewbs
282 results found with an empty search
- 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). Exam Board: OCR Specification: J277 2.3: Additional Programming Techniques Watch on YouTube : String Manipulation File Handling Arrays Subprograms Random Numbers SQL 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 to try a self-marking quiz (Google Form) about records and SQL. Q uesto's Q uestions 2.3 - 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
- Greenfoot Guide #2 | Arrow Key Movement | CSNewbs
Learn how to edit code in Greenfoot to make objects move using the arrow keys. Use methods such as isKeyDown, setRotation and move. Part 2 of the Greenfoot Tutorial for the Eduqas / WJEC GCSE 2016 specification. Right-click on your main character class and select ' Open editor '. The editor allows you to write different methods - actions that the class can perform. The act() method will repeat whenever the Run button is pressed. 1. Open the Code Editor 2. Movement with the Arrow Keys Greenfoot Tutorial Watch on YouTube: 2. Copy the Code CAREFULLY You need to use an if statement to check if a certain key (like the right arrow key) is being pressed down . An if statement must be contained in standard brackets . After each if statement, the proceeding code must be typed within curly brackets - see the image on the left . Tip - If the brackets are on the same line then use the standard brackets ( and ) If the brackets are on different lines then use curly brackets { and } Your code must be perfect or it won't work. 'Greenfoot ' requires a capital G and the isKeyDown method most be written with a lowercase i but uppercase K and D . When the right arrow key is pressed the object will change its rotation to 0° which is right . It will also move 1 place in this direction. Rotations in Greenfoot: 3. Code the Other Arrow Keys Directly underneath the if statement for turning and moving right, add the code for turning and moving down . You can see in the diagram above the degrees to rotate in each of the four directions . Write the code to move in all four directions. Ensure you have the correct number of brackets or the program won't start. Remember brackets that start and end on the same line are ( ) and brackets over multiple lines are { } . 4. Compile and Run Click the Compile button at the top of the code editor . Then you can go back to the main Greenfoot window and click Run . Press the arrow keys to test your main character moves . Click on me if you've got an error that you're stuck with. < Part 1 - Setup & Populating the World Part 3 - Movement (Random) >
- App Inventor 2 | Variables | CSNewbs
Learn how to use App Inventor 2 to create simple programs. Try to complete tasks 4, 5 and 6 on this page. Perfect for Key Stage 3 students to experiment with block coding, objects and properties. App Inventor Tasks 4, 5 & 6 - Using Variables This page will teach you how to make three simple apps that use variables . These apps will prepare you for the final program - the Pop-up Blob game. App #4 - Button Masher The first app to make is a simple program that counts how many times a button is pressed (but don't press it too much! ) This app will introduce you to using variables in App Inventor. Open App Inventor 2 (use the button below) and create a new project. You will need to log in with a Google account. App Inventor 2 Firstly, grab a button and two labels and place them in the Viewer . Using the Properties tab, you need to make the following changes: Button Text to 'Press Me!' Button Height to 60 pixels and Width to 'Fill parent...' Label 1 Text to 'Number of Presses' Label 2 Text to '0' Both Label 1 and Label 2 Width to 'Fill parent...' Both Label 1 and Label 2 TextAlignment to 'centre : 1' In the Components tab change the component names to be easier to code later. Switch to Blocks layout and drag an initialize global to block into the centre. In the blank space type 'Presses' - this is the name of the variable that will store how many times the button has been pressed. Drag a 0 block from Math. This will set the number of presses to 0 when the app starts. Drag a when ButtonPresses Clicked from the ButtonPresses section and add the necessary code inside. This code increases the variable value of Presses by 1 every time the button is clicked. It also changes the LabelPresses text to display the number of presses. Improve Your App As you will have seen in the video at the top, I programmed the app to go a bit crazy when 35 presses were recorded. In the code below I have shown how to use an if then block to check if the number of presses is 35. If it is then I have made the button invisible - this is an important feature we will use in later programs. Copy this code and add the following features to the then part of the if statement: Set the background colour to black. Change the Label1 Text Colour to white. Change the Label1 Text Size to 40. Change the Label1 Text to 'You broke it...' Program 4 Complete! App #5 - Timer The second app to make is a timer that counts up one second at a time. It also needs a reset button that sets the timer back to 0 again. It will introduce you to the clock component and enabling / disabling components. Open App Inventor 2 (use the button below) and create a new project. You will need to log in with a Google account. App Inventor 2 The code for this program is straightforward; it will take more effort getting the layout right. In the Palette tab, drag a HorizontalArrangement from the Layout section. It will look like an empty grey box at first. Grab a Button as well and place it underneath. Now drag two labels into the grey box and place the second one directly after the first, it may take a few attempts to get them to appear side by side like below: The last component to drag over is Clock (it is in the Sensors section in the Palette tab). It will go into its own section underneath: Change the name of some of the components so that they make more sense. Now to make some changes in the Properties tab. You should know enough by now to work out how to change your components so that it looks like this in your Viewer : Change your layout to Blocks and add the code blocks to the right. This code makes the Label named Seconds update by 1 every second, just like a timer. The code to the left will make the Label named Seconds reset to 0 when the button is pressed. Improve Your App As you will have seen in the video at the top of this task, I added a pause/unpause button that will set the enabled feature of the timer to true or false. You will need to complete the following steps (I've been deliberately vague to make it a challenge - break it down into small steps and use the colours to help you): Add a new button. Add code that, when the new button is clicked , checks if the TimerEnabled is true . If it is, then change TimerEnabled to false . Else change it to true . Now you also need to change the Text of the Button to read either "Pause" or "Unpause" . Program 5 Complete! App #6 - Windy Day The third app to make is an app that blows leaves around your screen. It will introduce you to random numbers, the canvas and coordinates . Open App Inventor 2 (use the button below) and create a new project. You will need to log in with a Google account. App Inventor 2 In the Palette tab, drag a Canvas from the Drawing and Animation section. A Canvas allows sprites (objects) to move around inside of it. In Properties , change the Height and Width of Canvas to 'Fill parent...' for both, so it fills the whole screen. In the Palette tab, drag over five ImageSprites from the Drawing and Animation section and drop them anywhere inside the canvas. Download the leaf picture with all App Inventor images on the basics page here . Upload the leaf image it in the Media tab. In the Components tab change the names of your ImageSprites to be leaf1, leaf 2 etc. For each leaf sprite, in the Properties tab, change the Picture to the leaf you just uploaded and change Height and Width to 30 pixels each. Finally, in the Palette tab, in the Sensors section, drag over a Clock . Your Viewer should look like the image to the left. X axis Y axis 0 300 500 Now for an explanation of coordinates. Each sprite (leaf) has an x coordinate (horizontal) and a y coordinate (vertical). For example, the leaf in the top right would have coordinates of x = 270 and y = 100. Can you work out approximately what the other leaves coordinates would be? What the code blocks below do is randomise the x and y coordinates for leaf1 every second. The word integer means a whole number . Use this code and add to it to make all 5 leaves randomly change coordinates. Improve Your App Add a pause / unpause button, just like in the Timer app that pauses the timer so that the leaves stop blowing (and starts them blowing around again too). Find a nice picture (maybe of a park?) online and upload it in the Media tab. Set this as the Canvas BackgroundImage . Add an audio file of some whooshing (why not record it yourself?). Program 6 Complete! Task 7 KS3 Home
- Python | 7b - Functions | CSNewbs
Learn how to create and use functions in Python. Try practice tasks and learn through text and images. Perfect for students learning GCSE Computer Science in UK schools. top Python 7b - Functions What is a Function? A function is a subroutine that takes one or more values from the main program and returns a value back. For example, transferring over a sphere’s radius from the main program for the function to calculate a surface area and then return that value to the main program. The two key differences between procedures and functions are: A function uses parameters to transfer data from the main program into the function. A function returns a value to the main program. Writing Functions A function is written the same way as a procedure but it uses parameters . In the example below the parameters are num1 and num2 which are sent from the main program to be used in the function . The return command is used to send a value back to the main program . Below is another example of a function that takes the radius of a sphere and works out the area in a separate function . The area is returned to the main program and printed. Subroutines can be reused and called with different parameters . The program below repeatedly takes an integer input and adds it to a total in a function that is then returned and printed. Practice Task Create a program similar to the sphere example above, this time to work out the volume of a cylinder. In the main program ask the user to enter the cylinder's radius and then its height. The actual calculation should be done in a function and returned to the main program. The calculation for a cylinder's volume is: pi x (radius x radius) x height Extension: Use the round command from section 9b to round the number to 2 decimal places. Example solution: Using Subroutines as a Menu Subroutines are often used to split programs up and give users a selection of options . Subroutines are used for this purpose because they are separate , making it easier to code and manage a program . The example below for a simplified online banking system uses separate subroutines accessible within a while true loop . Depending on the option chosen by the user, the appropriate subroutine will be called . Instead of a further practice task here, Task 4 of the Section 7 Practice tasks page challenges you to make a similar program using multiple subroutines. ⬅ 7a - Proced ures Section 7 Practice Tasks ➡
- Python | Extended Task 7 | CSNewbs
Test your ability to create a more complex program in Python based on a given scenario. Perfect for students learning GCSE Computer Science in UK schools. Extended Task 7 'Guess the Number' Multiplayer Game A primary school teacher wants to create a fun activity for their students to play when it is raining and they have to stay inside during break and lunch. Five pupils can play the game at once. Each player chooses a number between 1 and 100 . Then a random number is generated. Whoever was furthest from the random number is out of the game . The four remaining players then pick a new number . This continues with one player being removed each round until only one player is left and they are the winner. Add your own flair and additional features to your program as an extension, including preventing the same number being chosen by multiple players . For this task, you will need to create a document and include the following sections (with screenshots where appropriate): An introduction to explain the Purpose of your program . A List of Requirements for a successful program. Screenshots of your code (with comments in your code to show understanding). Testing – Create a plan to show how you will test your program and then explanations of any errors that you found and how they were fixed . An Evaluation of what worked, what didn’t, and how you met each of your requirements from your original list. Also, discuss further improvements that you could have made to improve your program. Reminders for this task: You will need to use loops to allow the users to enter their numbers. You may wish to use subroutines to decompose the problem into separate rounds. You will need to import the random library to generate a random number in each round. You will need to compare each number to the randomly selected answer using comparison operators such as > and <. There are multiple ways to approach this program, and your solution might look different from the example. Break the problem down and focus on one part at a time. Example solution: Introduction & Round One Round Two ⬅ Extended Task 6 (Word Game)
- OCR CTech IT | Unit 1 | 2.6 - Software Troubleshooting | CSNewbs
Learn about software errors and troubleshooting methods of solving them. Based on the 2016 OCR Cambridge Technicals Level 3 IT specification. 2.6 - Software Troubleshooting Exam Board: OCR Specification: 2016 - Unit 1 A software error occurs when a program or process stops working as expected. Software errors usually occur when programs are badly written or if a user inputs unexpected data . Common Faults System Freeze The computer freezes and pressing keys or moving the mouse gives no response . Commonly caused by having too many applications running simultaneously or a virus using too much memory . Unexpected Reboot To try and fix errors, a computer might get stuck in an endless loop of booting and rebooting . Other systems may frequently restart without warning . Stop Error This occurs after a fatal system error when the operating system stops , usually because of a driver software issue . Commonly known as the 'blue screen of death ' on Windows-based systems. Update Error While designed to fix errors, updates can sometimes bring more problems if they interfere with the current software . Troubleshooting Tools for Software Errors Event Viewer (Logs) If a software error does occur, then the same characteristics as a hardware error should be logged , such as the time and date of the error , the user logged in , and the device's problem history . Memory Dump Copies and displays the contents of RAM at the time of a crash to help a technician discover what happened . Baselines Before After A comparison of what the system is like after a crash compared to a fixed point in time beforehand. The baseline can be used to see differences which may have caused the computer to fail . Anti-Virus Checks if malware is running on a device, using up resources and slowing the system down. It could then be quarantined and deleted by the anti-virus. Installable tools can also be downloaded to investigate the system and find the cause of the problem . They may help detect corrupted files , uncover deleted files , and resolve other general hardware or software issues . Q uesto's Q uestions 2.6 - Software Troubleshooting: 1. Describe each of the four common types of software error : a. System Freeze b. Stop Error c. Unexpected Reboot d. Update Error [2 each ] 2. Describe each type of troubleshooting tool and explain how it can be used to discover and fix software errors. a. Event Viewer b. Memory Dump c. Baselines d. Antivirus Software e. Installable Tools [ 2 each ] 2.5 Communication Methods Topic List 2.7 - Protocols
- 3.2 & 3.3 - Information Categories | Unit 2 | OCR Cambridge Technicals | CSNewbs
Learn about how information can be categorised for both individuals and organisations. Based on the 2016 OCR Cambridge Technicals Level 3 IT specification for Unit 2 (Global Information). 3.2 & 3.3 - Information Categories Exam Board: OCR Specification: 2016 - Unit 2 Categories of Information for Individuals Communication Texting a friend about dinner plans, sending an email to a family member in another country, ringing work because trains are delayed. Education and Training Revision textbooks, logging into a virtual learning environment to upload a completed worksheet, hand-written feedback sheets from a teacher after an exam. Planning Using a shared document to arrange meeting dates, using a webpage hosting a bus timetable, a calendar app. Financial Using a bank statement to plan holiday saving, creating a spreadsheet of expenditure this month, logging in to a secure web page to buy a present online. Entertainment Reading a film review in a magazine, listening to a podcast about trains, watching a tutorial on DIY. Research Using online encyclopedias for a school project, searching for research articles to write an essay, using a recipe book Location Dependent Find local pizza restaurants, searching for emergency dental care on holiday, Pokemon GO Categories of Information for Organisations Knowledge Management & Creation Managing information across an organisation e.g. sharing information between branches in different cities. Management Information Systems (MIS) A system that provides an overview of key information e.g. the location and contact details of each charity worker in a disaster area. A decision can be made on overall figures or individual data as appropriate. Financial Analysis & Modelling Analysing trends e.g. determining the top selling products in a year or weekly cash flow, to create models of customer/user behaviour. Contact Management Managing contact between a business and the customer e.g. tracking appointments at a doctor’s surgery. Internal and External Communication Providing a communication medium to staff and/or customers e.g. posting Christmas opening times on the website, or sending a staff email invite to the Christmas party. Big Data Any data too large or complex for traditional data analysis techniques to be used e.g health data on the population of an entire country. Marketing, Promotion & Sales Identifying patterns or trends in sales figures, so that certain products or areas can be targeted, e.g. to plan marketing campaigns. Decision Making Using available information to make decisions, e.g. a charity deciding on the amount of aid to be sent to a disaster area based on local data. Q uesto's Q uestions 3.2 & 3.3 - Information Categories: 1. Describe two examples of each category of information used by individuals : Communication Education & Training Entertainment Planning Financial Research Location Dependent [2 each ] 2. Describe two examples of each category of information used by organisations : Knowledge Management & Creation Management Information Systems (MIS) Marketing, Promotion & Sales Financial Analysis & Modelling Contact Management Decision Making Internal & External Communication Big Data [2 each ] 3.1 - Data vs. Information Topic List 3.4 - Stages of Data Analysis
- 1.3 - Primary Storage - Eduqas GCSE (2020 spec) | CSNewbs
Learn about the five types of primary storage - RAM, ROM, cache, flash and virtual memory. Based on the 2020 Eduqas (WJEC) GCSE specification. 1.3: Primary Storage (Memory) Exam Board: Eduqas / WJEC Specification: 2020 + Storage in a computer system is split into two categories. Primary Storage: Very quick to access because it is attached to the motherboard . Typically smaller in storage size . Sometimes called ‘main memory’ . Secondary Storage: Slower to access because it is not directly embedded on the motherboard . Typically larger in storage size . Sometimes called ‘backing storage’ . Storage is also split into two types - volatile and non-volatile . Volatile storage is temporary - data is lost whenever the power is turned off . Example: RAM Non-volatile storage saves the data even when not being powered . Data can be stored long-term and accessed when the computer is switched on . Example: ROM Types of Primary Storage (Memory) Random Access Memory (RAM) RAM is volatile (temporary) storage that stores all programs that are currently running . RAM also stores parts of the operating system to be accessed by the CPU. RAM is made up of a large number of storage locations, each can be identified by a unique address . Read-Only Memory (ROM) Cache Memory ROM is non-volatile storage that cannot be changed . ROM stores the boot program / BIOS for when the computer is switched on. The BIOS then loads up the operating system to take over managing the computer. Cache memory is volatile (temporary) storage that stores data that is frequently accessed . It is very quick to access because it is closer to the CPU than other types of memory like RAM. The three levels of cache memory are explained in more detail in 1.5 . RAM ( R andom A ccess M emory) ROM ( R ead O nly M emory) Cache Memory Flash Memory Flash memory is editable so it can be read and written to . It is also non-volatile so it can be used for long-term data storage even when the system is not powered on. Flash memory is also used for secondary storage devices like USB sticks and solid-state drives - see 1.4 . Virtual Memory When a computer system is running slowly and RAM is near full capacity , the operating system will convert storage space on the drive into temporary memory . This virtual memory slows the system down because it takes longer to access the drive than it does to manage RAM. Transferring data between RAM and virtual memory is called paging . Q uesto's Q uestions 1.3 - Primary Storage (Memory): 1. Describe the differences between primary and secondary storage . This could be done in a table with the column headings 'access speed' , 'storage size' and 'also known as' . [ 6 ] 2. Explain the difference between volatile and non-volatile storage . State an example of both types. [ 4 ] 3. For each type of memory below, describe it and state what information is stored within it: a . Random Access Memory (RAM) [3 ] b. Read-Only Memory (ROM) [ 3 ] c. Cache memory [ 3 ] d. Flash memory [ 3 ] e. Virtual memory [ 3 ] 1.2 - FDE Cycle 1.4 - Secondary Storage Theory Topics
- 5.1 - Data Structures - Eduqas GCSE (2020 Spec) | CSNewbs
Learn about different data structures such as arrays, lists and records. Also, the difference between static and dynamic data structures and how to design files. Based on the 2020 Eduqas (WJEC) GCSE specification. 5.1: Data Structures & File Design Exam Board: Eduqas / WJEC Specification: 2020 + What is a Data Structure? A data structure is a way of efficiently organising data . There are two general forms of data structures: Static Data Structures The size of a static data structure cannot change e.g. if a data structure has 20 elements, no additional elements can be added or removed. The values of the data elements can be changed, but memory size is fixed when allocated at compile time. Because a static data structure holds a certain number of data elements they are easier to program because the size of the structure and the number of elements never change. An array is an example of a static data structure. Examples: A static data structure could be an array of teams in the Premier League. The data elements will change each year when teams are relegated and promoted but there will always be 20 teams. Dynamic Data Structures The size of a dynamic data structure can change as the program is being run , it is possible to add or remove data elements. Dynamic data structures make the most efficient use of memory but are more difficult to program , as you have to check the size of the data structure and the location of the data items each time you use the data. A list is an example of a dynamic data structure. A dynamic data structure could be a list of all teams in the Premier League that won their last match. Data elements (teams) will be added or removed across the season. Types of Data Structures List A list is a dynamic data structure that has the data elements stored in the order they were originally added to memory . Every data structure starts at 0, not 1 . Lists store data elements in the order they were added, so the first doctor is 0 and the most recent doctor is 12. An example list of the main Doctor Who actors 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 data. The following steps uses Python as an example. Traversing an Array To traverse (' move through ') an array a for loop can be used to display each data element in order. '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 traversing: Example code for inserting: Output: 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'. We 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 round 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. Data files are made up of records with the same structure. It would be most efficient for the fields in a record to be stored next to each other so that the data can be read into the record data structure in memory for processing by the CPU. In an exam you may be asked to state and design a data structure for a given scenario. If the data structure can hold values of the same data type you should draw an array , usually a 2D array for multiple rows and columns. Remember that a record is required to store values of different data types . Example questions: "A video gamer has recorded their three lap times in four Mario Kart courses." " State and design the most suitable data structure for this data." A two-dimensional array is most suitable because only one data type ( real ) is stored. "A vet surgery stores data on all dogs and cats including the animal's name, age (in years), weight (in kg) and whether or not it has been vaccinated." " State and design the most suitable data structure for this data for four animals ." A record is most suitable because the data structure requires different data types . Q uesto's Q uestions 5.1 - Data Structures: 1. Give two differences between static and dynamic data structures . [ 4 ] 2. Describe the differences between a list , 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 ] 4. State and design the most suitable data structure for these scenarios: a. For each book in a bookshop, the staff need to record the title, author, number of pages and whether or not it is a signed copy. Include data for three books. [ 3 ] b. Four dieters are recording how many kilograms they have lost each month for 5 months. [ 4 ] 5. Design a file that stores the first initial, surname, age and hair colour of each member of a family. [ 8 ] Designing Data Structures Data is stored in files when it needs to be kept after the program has stopped running . To learn how to write code for file handling (e.g. opening, writing to, reading from and closing files) in Python click here . Designing a file requires more than just the field name (e.g. Name) and data values (e.g. Rebecca). The data type (e.g. string) and any validation checks (e.g. format check) should also be considered. Below is an example file design for a bakery. Designing Files 4.8 Compression Theory Topics 6.1 - Operating Systems
- OCR CTech IT | Unit 1 | 5.1 - Ethical Issues | CSNewbs
Learn about ethical issues of IT including whistleblowing, discrimination, online safety and bias. Based on the 2016 OCR Cambridge Technicals Level 3 IT specification. 5.1 - Ethical Issues Exam Board: OCR Specification: 2016 - Unit 1 What are ethics? Ethics refers to what is right and wrong . The following issues are often linked to or backed up by legislation. Whistle Blowing Definition: When a member of staff reveals that the organisation they work for are engaging in unlawful practices . This could include breaking privacy laws , threatening staff or environmental damage . In the UK , whistleblowers are protected by the Public Interest Disclosures Act (1988) . Under this law, whistleblowers are protected from being fired or being victimised (e.g. ignored for promotion ) as a result of their whistleblowing. Large organisations should consider establishing a whistleblowing policy that would outline how employees can raise concerns , who they should speak to and the support available to concerned staff. A famous whistleblower is Edward Snowden , who revealed in 2013 that many governments, including the USA and the UK, were spying on their civilians with widespread undocumented surveillance. Should Martin reveal that his company is dumping old computers into a lake or just stay quiet? Graham feels that, because of his disability, he is being ignored for a promotion that he deserves. Discrimination Definition: When an employee is treated unfairly because of a personal or physical characteristic over which they have no control . The Equality Act (2010) ensures equal treatment for all people irrespective of: race sexuality gender disability marital status (and many more) Examples of discrimination include offensive talk, harassment, unequal pay and being ignored for promotion. Use of Information Definition: Laws such as GDPR (General Data Protection Regulation ) and specifically the Data Protection Act (2018) ensure that organisations must responsibly process personal data. Organisations have a legal obligation to keep their employee and customer personal data secure and out of reach from unauthorised viewers. Considerations should be made about how the information is ethically collected , stored and processed . DataDyne backs up customer information on cloud storage - what if this data is compromised ? As part of quality assurance, Selside Bank double check performance reviews before submission. Codes of Practice Definition: A set of rules which explains how people working in certain professions are required to behave . Organisations may have a code of practice for: Confidentiality (rules on what data can and cannot be shared with others), Quality assurance (ensuring high quality is maintained for all products/services), Behaviour (setting out how employees are expected to behave at work and in communication with each other and customers), Equality and discrimination (being understanding and providing fair access to all employees). Employees must agree to the codes of practice so they are clear on their expectations of what is and isn't acceptable at work. The organisation can then discipline employees that broke the codes of practice they formerly agreed to. Online Safety Definition: Often companies will provide an induction (training ) to new employees about the organisation’s code of practice for using the internet whilst at work . If an individual does not behave safely online or breaks the organisation's codes of practice (by gambling at work for example) then they may be punished (e.g. fined or fired). Employees can ensure that they are safe online by using secure passwords that are regularly updated and preventing web browsers from remembering login details . Miriam changes her password each month to minimise the chance of hackers accessing her account. The CEO of Honey Media apologies in public after biased information led to a lawsuit and loss of reputation. Bias Definition: This is technically correct, but slanted , information that presents a one-sided view . For example, end-of year financial data that focuses on profits and ignores significant losses. Poor quality information may lead to an organisation being misinformed and not sufficiently responding to their customers' needs - for example if a survey was only completed by a small number of people it could generate biased results. As a result of poor quality information, organisations may suffer from damage to their reputation due to negative feedback and reviews from customers, possibly posted online. A lack of trust can occur if customers feel neglected because of decisions made using biased information of a poor quality, therefore reputational damage may lead to loss of customers . Q uesto's Q uestions 5.1 - Ethical Issues: 1. Describe what whistleblowing is and give 3 examples . [4 ] 2. Describe what discrimination is and give 4 examples . [5 ] 3. Which law relates to the use of information ? [1 ] 4a. Describe 2 things that may be included in an organisation's codes of practice . [4 ] 4b. Explain why employees must agree to their company's codes of practice [4 ]. 5. Describe 2 things an employee should do to stay safe online . [2 ] 6a. What is biased information ? [2 ] 6b. Describe 3 possible effects to a company if they use biased information . [6 ] 4.6 & 4.7 - Bodies & Certification Topic List 5.2 - Operational Issues
- Python | 4b - Mathematical Operators | CSNewbs
Learn how to use mathematical operators in Python. Try practice tasks and learn through text and images. Perfect for students learning GCSE Computer Science in UK schools. top Python 4b - Mathematical Operators Modulo Division The modulo operator - the percentage symbol % - will work out the remainder left over when one value is divided by another. print (30 % 6) = 0 30 ÷ 6 = 5, which is a whole number, so there is no remainder and 0 is output . print (30 % 7) = 2 30 ÷ 7 = 4 remainder 2 ; so the remainder is output . You can use modulo with variables too: num1 = 33 num2 = 4 print ( "The remainder is" , num1 % num2) The remainder is 1 = A common use of modulo is to check if a number is odd or even . If a number has no remainder when divided by 2 then it is even . = num = int ( input ( "Enter a number: " )) if num % 2 == 0: print (num, "is even." ) else : print (num , "is odd." ) Enter a number: 400 400 is even. Enter a number: 191 191 is odd. = Modulo Div i sion Task 1 ( Remainder) Ask the user to input a whole number . Use the modulo operator ( % ) to check if there is a remainder when the user's number is divided by 5 . Print the re mainder. Example solution: Enter a number: 123 The remainder when divided by 5 is 3 Modulo Div i sion Task 2 ( Rollercoaster) Use the odd/even program above to help solve this problem: A rollercoaster only lets people on in groups of 4 . Ask the user to input a number for how many people are in their group. Check if that number is directly divisible by 4 using modulo division ( % ). If it is then print “Perfect groups of four!” Else print “You will be split up” . Example solutions: Welcome to the Hyper Coaster! How many in your group? 6 You will be split up! Welcome to the Hyper Coaster! How many in your group? 12 Perfect groups of four! Integer Division Integer division removes any decimal numbers when performing division , leaving just the integer (whole number ). In Python integer division is performed using // . print (20 / 3) print (20 // 3) = 6.666666666666667 6 Integer Div i sion Task 1 ( Integer Division by 5 ) Use an input line with int to ask the user to enter a number . Use integer division ( // ) to divide the number by 5 without keeping any decimal values . Challenge: Improve your solution by altering the print line to be more user friendly . Example solutions: Enter a number: 27 5 Enter a number: 27 5 goes into 27 5 times. Integer Div i sion Task 2 ( Plane Rows) A large plane has 6 seats in each row. Input the number of passengers on the plane and use integer division to work out how many full rows will be filled. Example solution: How many passengers are there in total? 174 There will be 29 full rows on the plane. Exponent (Powers) An exponent is the number of times a value is multiplied by itself , for example 2 = 2 x 2 x 2 = 8 . The symbol to represent an exponent in Python is ** . For example: 4**2 represents 4 which is also 4 x 4 . 3 2 print (4**4) = 256 base = 5 exponent = 4 print (base**exponent) 625 = Exponent Task 1 ( Square Number) Use an input line with int to ask the user to enter a number . Output the square of this number. Example solution: Enter a number: 12 12 squared is 144 Exponent Task 2 ( Custom Exponent) Use an input line with int to ask the user to enter a number, this will be the base . Make another input line with int to ask for the exponent . Use ** between the base and the exponent and print it. Challenge: Make your solution better by including the base and exponent in the print line. Example solutions: Enter the base: 7 Enter the exponent: 3 343 Enter the base: 7 Enter the exponent: 3 7 to the power of 3 is 343 ⬅ 4a - If Statements 4 c - Log ical Operators ➡
- 8.4 - Validation & Verification - Eduqas GCSE (2020 Spec) | CSNewbs
Learn about the six main validation checks - range, type, length, format, lookup table and presence. Also, discover three verification checks - double entry, proof-reading and check digits. Based on the 2020 Eduqas (WJEC) GCSE specification. 8.5: Validation & Verification Exam Board: Eduqas / WJEC Specification: 2020 + What are validation and verification checks? Validation is a process to check that data is reasonable or sensible before it is accepted . Verification is the process of checking that data is correct after it has been entered. Validation Checks 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/2001 25th March 01 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 Verification Checks Double Entry Typing in the data twice to make sure there were no spelling errors the first time. Password: fluffythecat123 flufythecat123 Proofreading Checking two copies of data to ensure they are exactly the same . Check Digit Similar to a checksum in a data packet, a check digit is calculated on barcodes to ensure the rest of the numbers are correct . Address: 11 Cherry Lane 11 Cherry Road Confirm Q uesto's Q uestions 8.4 - Validation & Verification: 1. Describe each type of validation check and give an example . a. Range Check [ 3 ] b. Type Check [ 3 ] c. Format Check [ 3 ] d. Presence Check [ 3 ] e. Lookup Table (List) [ 3 ] f. Length Check [ 3 ] 2. For the following data, suggest which validation check would be most suitable and why : a. Password [ 3 ] b. Country of Birth [ 3 ] c. Number of Tickets [ 3 ] d. Weight (in kilograms) [ 3 ] 3. Describe three types of verification check and give an example : a. Double Entry [ 3 ] b. Proofreading [ 3 ] c. Check Digit [ 2 ] 8.4 - Sorting & Searching Theory Topics 9.1 - IDE Tools










