Search CSNewbs
286 items found for ""
- 4.3b - Flip Flops, Adders, Laws & Maps | OCR A-Level | CSNewbs
Exam Board: OCR 4.3b - Flip Flops, Adders, Laws & Maps Specification: A-Level 2015 An instruction set is a list of all the instructions that a CPU can process as part of the FDE cycle . CPUs can have different sets of instructions that they can perform based on their function. The two most common instruction sets are the simpler RISC (Reduced Instruction Set Computer ) and more complicated CISC (Complex Instruction Set Computer ). Instruction Sets This page is still being updated. Graphical Processing Unit What is cache memory? Cache memory is temporary storage for frequently accessed data . Cache memory is very quick to access because it is closer to the CPU than other types of memory like RAM . Multicore & Parallel Systems What is cache memory? Cache memory is temporary storage for frequently accessed data . Cache memory is very quick to access because it is closer to the CPU than other types of memory like RAM . Multicore & Parallel Systems What is cache memory? Cache memory is temporary storage for frequently accessed data . Cache memory is very quick to access because it is closer to the CPU than other types of memory like RAM . Q uesto's Q uestions 4.3b - Flip Flops, Adders, Laws & Maps: 1. What is cache memory ? [ 2 ] 4.3a - Logical Operators & Truth Tables Theory Topics 5.1 - Computer Legislation
- 2.4b - Character Storage - OCR GCSE (2020 Spec) | CSNewbs
2.4b: Character Storage Exam Board: OCR Specification: 2020 What is a Character Set? A character set is a table that matches together a character and a binary value . Each character in a character set has a unique binary number matched with it . Character sets are necessary as they allow computers to exchange data and humans to input characters . Two common character sets are ASCII and Unicode : H = 01001000 ASCII Unicode ASCII (American Standard Code for Information Interchange ) is a common character set which does not take up much memory space . It is important to understand that the number of characters that can be stored is limited by the bits available - ASCII uses 1 byte (8 bits ) which only gives 256 possible characters . This is enough for the English language but it can’t be used for other languages or all punctuation symbols. Unicode is a more popular character set because it uses 2 bytes (16 bits ) that allow for 65,536 possible characters . The extra byte allows many different languages to be represented , as well as thousands of symbols and emojis . However Unicode requires more memory to store each character than ASCII as it uses an extra byte . Character sets are logically ordered . For example, the binary code for A is 01000001 , B is 01000010 and C is 01000011 as the code increases by 1 with each character. The file size of a text file is calculated as shown below: bits per character x number of characters Example: A small text file uses the ASCII character set (which uses 8 bits per character ). There are 300 characters in the file . 300 x 8 = 2,400 bits This could be simplified as 300 bytes or 0.3 kilobytes . Q uesto's Q uestions 2.4b - Character Storage: 1. What is a character set and why are they needed ? [ 2 ] 2. Describe 3 differences between ASCII and Unicode . [6 ] 3. The binary code for the character P in ASCII is 01010000 . State what the binary code for the character S would be. [1 ] 4a. A text file uses the ASCII character set and contains 400 characters . What would the file size be in kilobytes ? [ 2 ] 4b. A text file uses the Unicode character set and contains 150 characters . What would the file size be in kilobytes ? [ 2 ] File Size of Text Files 01101010 = 256 possible characters 8 bits (1 byte) 1000101101001111 = 65,536 possible characters 16 bits (2 bytes) 2.4a - Number Storage Theory Topics 2.4c - Image Storage
- 11 Graphical User Interface | CSNewbs
Python 11 - GUI Graphical User Interface In Python, you don’t have just to use a text display; you can create a GUI (Graphical User Interface ) to make programs that look professional. This page demonstrates the basic features of Python’s built-in GUI named tkinter . You can add images, labels, buttons and data entry boxes to develop interactive programs . Sections covered in this post: Creating the Window Window Background, Size and Title Labels Data Entry Boxes Buttons Message Boxes Placing Objects Adding Images Creating The Window Creating the Window Firstly, import the tkinter command. Then you must create a variable that stores this tkinter command. In this example, I have named the variable window but it can be given any alternative name. Running the code opposite will create a blank window like this: Practice Task 1 Import tkinter and create a new window. Example solution above Window Featues Window Background, Title and Size Three essential things that you will want to set straight away are the size of the window , the title that appears at the top and background colour . Using the variable that you set up earlier, you can easily configure these features: The .geometry(“400x400”) command sets the size of the window in pixels. The first number is the width, and the second number is the height . The .configure(background = “lightblue") command sets the window background. For a full list of the different colours you can use with tkinter, check here . Here is another code example of a blank window: Practice Task 2 Make the title of your window "Multiplication Program". Set the window size to 450 by 250. Change the background colour to your choice - use the list to see all options. Example solution: Labels Labels The code above seems long, but I have broken it down into what each component does. The label must be saved into a variable , I have called mine label1 . Make sure that you choose appropriate label names , especially if you will be having lots of labels in your program. Any object that you create will need to be packed into the program: The final line of your program going forward must be window.mainloop() The default label background will be a grey colour, so if you have changed your window’s background earlier then you might want to set your label’s background as the same colour (or not, up to you). All colours available in tkinter can be found here . Practice Task 3 Create a label that reads "Enter two numbers to multiply together:". Change the background colour of the label to match your window background colour. Example solution: Data Entry Labels Data Entry Labels The code above creates a data entry box (to type data in) and saves it into a variable that I have named textbox1 . Remember that to pack each object in the order you want it displayed (and keep window.mainloop() last): If you want to use data that has been entered in the entry box then you use .get() : In this example, I have used int() to turn the entry into an integer value because I want to perform a calculation on it later. The entered data should be saved into a variable . HOWEVER, If you put this code into your program as it is, then it would only get the data from the text box at the start of the program (when it is empty ). Check the next section to see how to use this code when a button is clicked. Practice Task 4 Create two data entry boxes. Pack them on top of each other (we will move them later). Example solution: Buttons Buttons The above code creates a button and saves it into a variable named button1. The command part is very important as it creates a subroutine name for the action of when the button is clicked. You must create the subroutine separately for what you want to happen when the button is clicked . I have named mine 'WhenPressed '. This subroutine must be created above the button code in the program. In this example, when the button is clicked, I take the contents of textbox1 using the .get() command and save it into a variable called usernum. I then display a message box (check the next section for that) that has the title ‘Squared Numbers’ and show a message of the square number of the number the user entered. Here it is in action: Practice Task 5 Create a button with the text "Multiply". Create a subroutine called When Pressed for when the button is clicked. Inside the subroutine, get the value for the first text box and then get the value for the second text box. Remember to use the int command when you are getting the values. Create a variable called total and add the two values together. Example solution: Error Messages Message Boxes To use a message box you must add a new import line at the start of your program . The three main types of message box can be seen below: The first string in the brackets is the title of the message box and, after the comma , the second string is the message itself. Use an if statement directly after a multiple choice text box to determine what happens: Practice Task 6 Import messagebox at the start of the program. In the WhenPressed subroutine from the previous task display a message with the total variable. Use the image from the Buttons section to help you. Use the showinfo message box to display the message. Example solution: Placing Objects Placing Objects Use the .place() command to choose the exact co-ordinates where an object should be. For example: In my example I have packed the first three labels then placed the two buttons: Practice Task 7 Instead of .pack(), use the .place() command to choose exactly where to place your two text boxes and button so that the program looks better. This will take trial and error to get perfect. Example solution: Using Images Adding Images To use an image in Python, it must be saved as a .gif file and displayed within a label . An easy way to save a picture as a .gif file is to convert it using Microsoft Paint (click File then Save as GIF Picture). The image must also be saved in the same folder as the Python file you are using . The full name you have saved the file as must be the string in the first line, such as “apple.gif”. You must include .gif in the file name. You can call the label and photo whatever you like, I have named them ImageLabel and photo1 for ease. Practice Task 8 Add an image of a calculator to your program. It must be a .gif Use the .place() command instead of .pack() It should be a copyright free image. You might need to resize the image using Paint first. Example solution: ⬅ Section 10 Practice Tasks 12 - Error Handling ➡
- 1.1a- The CPU & FDE Cycle | OCR A-Level | CSNewbs
Exam Board: OCR 1.1a: The CPU & The FDE Cycle Specification: A-Level 2015 The Central Processing Unit ( CPU ) is the most important component in any computer system. The purpose of the CPU is to process data and instructions by constantly repeating the fetch - decode - execute cycle . CPU Components The control unit directs the flow of data and information into the CPU. It also controls the other parts of the CPU . ALU stands for ‘ Arithmetic and Logic Unit ’. It performs simple calculations and logical operations . The registers are temporary storage spaces for data and instructions inside the CPU . The registers are used during the FDE cycle . Five essential registers are explained below. Important Registers A register is a small storage space for temporary data in the CPU . Each register has a specific role . There are five essential registers used in the FDE cycle : Program Counter (PC) A register that tracks the RAM address of the next instruction to be fetched . Memory Address Register (MAR) A register that tracks the RAM address of data that is currently being accessed . Memory Data Register (MDR) The MDR stores the data that is transferred from RAM to the CPU . Current Instruction Register (CIR) A register that stores the instruction that has been fetched from RAM , and is about to be decoded or executed . Accumulator (ACC) The ACC stores the result of executions performed in the FDE cycle . The FDE Cycle The essential idea of the FDE cycle is that instructions are fetched from RAM , to be decoded (understood) and executed (processed) by the CPU . The Fetch - Decode - Execute (FDE) cycle is performed by the CPU millions of times every second. This cycle is how the CPU processes data and instructions for each program or service that requires its attention. 1. 2. 3. The Program Counter (PC ) register displays the address in RAM of the next instruction to be processed . This value is copied into the Memory Address Register (MAR ). 0054 The PC register is increased by 1 . This prepares the CPU for the next instruction to be fetched. 0055 The CPU checks the address in RAM which matches the address held in the MAR . 0054 4. The instruction in RAM is transferred to the Memory Data Register (MDR ). MDR 5. The instruction in the MDR is copied into the Current Instruction Register (CIR ). MDR CIR 6. The instruction in the CIR is decoded (understood) and executed (processed). Any result of an execution is stored in the Accumulator (ACC ) register. CIR ACC 7. The cycle repeats by returning to the first step and checking the program counter for the address of the next instruction . Buses Data is transferred within a computer system along pathways called buses . There are three types of bus: Address Bus Sends a memory address of where data is stored. The address is sent from the CPU to RAM in the FDE cycle. Data Bus Transfers data between components. Data is sent both ways . Control Bus Sends control signals from the control unit to other components of the system. Status signals are sent back to the CPU. Think about which buses would be used during the FDE cycle and when. For example, look back at stages 3 and 4 of the FDE cycle above. The address bus is used to send the address in RAM of the next instruction . The control bus is used to send the fetch signal . The data bus is used to transfer the instruction from RAM to the MDR . Computer Architecture The way a computer is designed and internally organised is known as its architecture . The most common type of computer architecture is Von Neumann architecture . Von Neumann Architecture The key features of Von Neumann architecture include: The CPU , which constantly performs the FDE cycle , and contains: One control unit One ALU Special registers D ata and instructions are stored in the same format in the same area in memory . Instructions are commands and data are the specific values used when processing. Data and instructions are transferred across buses (pathways) between the CPU, memory and input or output devices. Harvard Architecture The key features of Harvard architecture include: The CPU , which constantly performs the FDE cycle , and contains: One control unit One ALU D ata and instructions are stored in separate areas in memory . Instructions are commands and data are the specific values used when processing. Data and instructions are transferred across buses (pathways) between the CPU, data memory, instruction memory and input or output devices. Q uesto's Q uestions 1.1a - The Central Processing Unit (CPU): 1a. What does 'CPU ' stand for ? [1 ] 1b. What is the purpose of the CPU ? [ 2 ] 2a. Draw a diagram of the CPU , use the same symbols as shown on this page. [ 4 ] 2b. Label the three main components of the CPU. [ 4 ] 3. Describe the purpose of: a. The Control Unit [ 2 ] b. The ALU [ 2 ] c. The registers [ 2 ] 4a. Describe the key features of Von Neumann architecture . [ 3 ] 4b. Describe the differences between the two main types of architecture. [ 2 ] Theory Topics 1.1b - Performance
- 1.3b - Memory & Storage | OCR A-Level | CSNewbs
Exam Board: OCR 1.3b: Memory & Storage Specification: A-Level 2015 An instruction set is a list of all the instructions that a CPU can process as part of the FDE cycle . CPUs can have different sets of instructions that they can perform based on their function. The two most common instruction sets are the simpler RISC (Reduced Instruction Set Computer ) and more complicated CISC (Complex Instruction Set Computer ). Instruction Sets This page is still being updated. Graphical Processing Unit What is cache memory? Cache memory is temporary storage for frequently accessed data . Cache memory is very quick to access because it is closer to the CPU than other types of memory like RAM . Multicore & Parallel Systems What is cache memory? Cache memory is temporary storage for frequently accessed data . Cache memory is very quick to access because it is closer to the CPU than other types of memory like RAM . Multicore & Parallel Systems What is cache memory? Cache memory is temporary storage for frequently accessed data . Cache memory is very quick to access because it is closer to the CPU than other types of memory like RAM . Q uesto's Q uestions 1.3b - Memory & Storage: 1. What is cache memory ? [ 2 ] 1.3a - Input & Output Theory Topics 2.1 - Operating Systems
- OCR CTech IT | Unit 1 | 1.4 - Connectivity | CSNewbs
1.4 - Connectivity Exam Board: OCR Specification: 2016 - Unit 1 For computers to communicate with other devices and share data a form of connection is required. Wired Connections Copper Cables Copper cables are a cheaper type of wired internet connection that may be poorly insulated and therefore susceptible to electromagnetic interference . Copper cables are more likely to suffer from attenuation (network distortion ). However, they are malleable (easier to bend) and less likely to break than other cables such as fibre optic. They have a lower bandwidth - cannot transmit as much data at once - than fibre optic cables. Fibre Optic Cables Fibre optic cables are a very fast but expensive type of wired internet connection. Signals are transmitted as waves of light through a glass tube. Because of this fibre optic cables are not affected by electromagnetic interference and suffer less from attenuation . Fibre optic cables have a higher bandwidth - can transfer more data at one time - than copper cables but they are more fragile . Wireless Connections Bluetooth Bluetooth is a temporary short-range communication between devices within a limit of about 10 metres . For example, Bluetooth can be used to transfer audio files from one smartphone to another. The close proximity is a disadvantage but no other hardware is required for a connection. Infrared Infrared networks have been replaced by Bluetooth or WiFi connections because infrared requires devices to be in direct line of sight . Infrared is still used by some devices such as remote controls to transmit signals to a TV but it only works across a short distance . Microwave Microwave connections use radio waves to send signals across a large area via microwave towers . It can transmit a large amount of data but antennas must be in the line of sight of each other with no obstructions . Microwave connections are affected by bad weather , leading to higher chances of attenuation (network distortion ). Laser Satellite GSM / 5G Although not common, laser connections can send data between devices that are in the line of sight of each other as long as there are no barriers . Laser connections can transmit data up to 2km but bad weather severely affects the transmission rate. Laser connections can be used in space as there are fewer barriers between the satellites. Satellite networks use point-to-multipoint communication by using satellites above the Earth's atmosphere that receive a transmission and rebroadcast them back to Earth. Because of the distance between the communication device and the satellite (roughly 45,000 miles), there is a delay between data transmission and it being received. See 3.4 for more information on satellite networks . GSM (Global System for Mobile communications ) is a technology for allowing mobile phones to connect to a network for calls and text messages. Advances in mobile technology are classified by generations such as 4G and 5G (the current generation). Each generation is generally faster, more secure and allows for new opportunities. See 3.4 for more information on cellular networks . Q uesto's Q uestions 1.4 - Connection Methods: 1. Compare the differences between copper and fibre optic cables (possibly in a table) by the following features: a. Price b. Bandwidth c. Inteference d. Attenuation e. Malleability / Fragility [2 each ] 2. Describe each of the different types of wireless connection . Try to list 1 advantage and 1 disadvantage of using each type. a. Bluetooth b. Infrared c. Microwave d. Laser e. Satellite f. GSM / 5G [5 each ] 1.3 - Computer System Types Topic List 1.5 - Communication Hardware
- 3.1a - Network Types & Performance - OCR GCSE (2020 Spec) | CSNewbs
3.1a: Network Types & Performance Exam Board: OCR Specification: 2020 What is a network? A network is more than one computer system connected together allowing for communication and sharing of resources . Network Types Networks can be split into different types , usually categorised by their geographical distance apart and the area that they serve. Local Area Network Wide Area Network Client-Server Network Clients make requests to a server , the server manages that request and responds. For example, if the user (client) makes a request to access www.bbc.co.uk to a web server. Large services like Amazon and Google will need very powerful servers to handle millions of requests a second. The client is completely dependent on the server to provide and manage the information. The server controls network security , backups and can be upgraded to manage higher demand. Advantages: The network can be controlled centrally from the server to easily backup data and update software . Hardware, software and resources can be shared across the network, such as printers, applications and data files . The network allows for improved scalability , meaning more clients can be easily added to the central server . Disadvantages: Large amounts of traffic congestion will cause the network to slow down . If a fault occurs with the server then the whole network will fail . IT technicians may be required to manage and maintain the network . Malware , such as viruses, can spread quickly across the network. Peer-to-Peer Network For peer-to-peer networks , data is shared directly between systems without requiring a central server . Each computer is equally responsible for providing data. Peer to peer is optimal for sharing files that can then be downloaded. Disadvantages: Without a dedicated server there is no central device to manage security or backups . Backups must be performed on each individual system. Computer performance will decrease with more devices connected to the network, especially if other machines are slow. Advantages: This is a simpler network than client-server to set up as no server is required . Clients are not dependent on a server . Perfect for quickly sharing files between systems , such as downloading media files. A local area network (LAN ) has computer systems situated geographically close together , usually within the same building or small site , like a school or office . The network infrastructure of a LAN (such as servers and routers) is usually owned and managed by the network owner . A wide area network (WAN ) has computer systems situated geographically distant to each other, possibly across a country or even across the world . WANs often use third party communication channels , such as connections by internet services providers like BT or Virgin Media. Other network types do exist, such as a Metropolitan Area Network (MAN ) for computer systems connected across a town or city or a Personal Area Network (PAN ) for devices connected and used by an individual . Data Packets When sending data across a network, files are broken down into smaller parts called data packets . Whole files are too large to transfer as one unit so data packets allow data to be transferred across a network quickly . Each packet of data is redirected by routers across networks until it arrives at its destination. Data packets may split up and use alternative routes to reach the destination address. When all the packets have arrived at the destination address the data is reassembled back into the original file. Contents of a Data Packet: Header Payload Trailer Source address Destination address Packet number Protocol The data itself A checksum - this is a calculation on the data to see if any errors or corruption have occurred during transmission . What is a network topology? Network topology refers to layout of computer systems on a local network . Devices in a network topology diagram are often called 'nodes' . Two types of typology are star and mesh . Star Topology Each computer system is connected to a central device , usually a hub or switch . How it works: Each computer system is connected to the central hub or switch and transfers its data packets there. The hub or switch looks at the destination address and transfers the packets directly to the intended computer. Advantages: A star topology has improved security because data packets are sent directly to and from the hub / switch in the centre and not necessarily all devices like in a bus or ring topology. New systems can be attached directly to the central system so the network doesn't need to be shut down . System failures of attached computers won't usually cause complete network failure. Transfer speeds are generally fast in a star topology as there are minimal network collisions . Disadvantages: Extra hardware (the hub or switch) is required to be purchased, installed and maintained. If the central system (the hub or switch) fails then the whole network will be unusable until the error is fixed. Mesh Topology In a full mesh network, each computer system is connected to every other computer system . There is also a partial mesh network where only some nodes (e.g. a printer) are connected to every other node. How it works: Data packets are transferred to the destination address along the quickest path , travelling from node to node. If a pathway is broken , there are many alternative paths that the packets can take. Advantages: If one cable or system fails then data packets can take an alternative route and still reach the destination address. Because of the large possible number of systems and connections, a mesh topology can usually withstand large amounts of data traffic . New systems can be added to the network without disrupting the entire topology . Disadvantages: Because of the possibly large amount of cables required (especially in a full mesh topology) this network layout can be expensive to install and maintain . Redundant cabling should be avoided - this is when cables are connected between systems that won't ever need to communicate . Performance There are several different factors that can affect the performance ( speed ) of a network, such as: The bandwidth available * Interference (e.g. thick walls) Applications being used Number of users at the same time Distance to travel / signal strength Server / CPU Performance Number of data collisions Amount of data to transfer * Bandwidth is the maximum amount of data that can be sent across a network at once . Q uesto's Q uestions 3.1a - Network Types & Performance: 1a. Describe the difference between a LAN and WAN . [2 ] 1b. Give an example of how a LAN and a WAN could each be used . [ 2 ] 2 a. Describe how peer-to-peer networks and client-server networks function. 2b. Give one use for both types of network. 3. Draw and label diagrams of client-server , peer-to-peer , star and mesh networks. [8 ] 4. An office currently uses a star topology but is considering changing to a mesh topology . Describe two advantages and two disadvantages of both topologies. [ 8 ] 5. State five factors that could affect the performance of a network . [5 ] 2.5 - Compression 3.1b - Network Hardware & Internet Theory Topics
- 8.2 - Understanding Algorithms - Eduqas GCSE (2020 Spec) | CSNewbs
8.2: Understanding Algorithms Exam Board: Eduqas / WJEC Specification: 2020 + 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 : Defining Algorithms - Pseudocode & Flowcharts Pseudocode Pseudocode is not a specific programming language but a more general method of describing instructions . It should be unambiguous, and it should not resemble any particular kind of programming language (e.g. Python or Java), so it can theoretically be turned into working code in any language. Generally, pseudocode can be written in any way that is readable and clearly shows its purpose. However, the Eduqas exam board advises that pseudocode for the programming exam should follow the conventions below : Annotation { Write your comment in curly brackets} Define data type price is integer firstname is string Declare a variable's value set price = 100 set firstname = "Marcella" Input / output output "Please enter your first name" input firstname Selection (must have indentation) if firstname = "Steven" then output "Hello" + firstname elif firstname = "Steve" then output "Please use full name" else output "Who are you?" end if Iteration (while loop) while firstname ! = "Steven" output "Guess my name." input firstname repeat Iteration (for loop) for i in range 10 input item next i Define a subroutine Declare Sub1 [Subroutine content indented] End Sub1 Call a subroutine call Sub1 Flowcharts A flowchart can be used to visually represent an algorithm. The flowchart symbols are: 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 Flowchart {This is a program to see how many items you can buy in a supermarket before you spend over £100} total is integer, itemsentered is integer, itemprice is integer set total = 0 set itemsentered = 0 while total < 100 output "enter the price of the next item" input itemprice total = total + itemprice itemsentered = itemsentered + 1 repeat if itemsentered >= 20 then output "You are on your way to saving money." elif itemsentered => 30 then output "You're a real money saver." else output "Look for better deals next time." end if 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: Start NewProgram i is integer maxvalue is integer input maxvalue for i = 1 to maxvalue output (i * i) ??????? output 'program finished' End NewProgram 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 Q uesto's Q uestions 8.2 - Understanding Algorithms: 1a. Read the algorithm shown on the left and list all outputs in the correct order if the inputs are 2 for height and 72 for weight . 1b. Give the code that is missing from line 25 . 8.1 - Programming Principles Theory Topics 8.3 - Writing Algorithms
- Assembly Language | CSNewbs
Assembly Language Assembly language is a low-level programming language - it is closer to machine code (binary) than high-level programming languages like Python. Assembly language uses mnemonics (abbreviations of commands) to signify instructions; for example, input is written as INP and output is written as OUT . Little Man Computer is a representation of assembly language . This simulator will help you understand assembly language and allow you to check if your instructions are correct. Assembly Language Mnemonics INP (Input) INP is used to input a number . The number is temporarily stored in the accumulator . OUT (Output) OUT is used to output the number currently stored in the accumulator . STA (Store) STA stores the value that is currently in the accumulator . It can be used to assign a value to a variable. ADD (Addition) ADD is used to add a number to the value currently stored in the accumulator. SUB (Subtraction) SUB takes away a number from the value currently stored in the accumulator. LDA (Load) LDA is used to load the value of a stored variable back into the accumulator . BRZ (Branch if Zero) BRZ is used to loop only if the value in the accumulator is currently 0 . BRP (Branch if Positive) BRP is used to loop only if the value in the accumulator is currently positive (including 0). BRA (Branch Always) BRA is used to loop continuously . HLT (Halt) HLT will stop running the program . Every program MUST have a HLT command. DAT (Data Definition) DAT must be used to define a variable name (and / or set it with a starting value). Data definitions must be written at the end of the instructions . Peter Higginson's Little Man Computer simulation Examples of Simple Assembly Language Programs #1 - Input & Output Program Purpose: Input a number, store the number as a variable called Number1 and output the number. 1. Lets the user input a number 3. Outputs the value in the accumulator - which will be the number that was just inputted. 5. Defines a variable called 'Number1'. This has to be at the end of the program and you must write the variable name first, not the command first. INP STA Number1 OUT HLT Number1 DAT 2. Stores the number in a variable named 'Number1' - there must be no spaces in a variable name. 4. Halts (stops) the program. Type these instructions line by line into the Little Man Computer simulator to see how it works. #2 - Addition Program Purpose: Input and store two numbers. Add them together. Output the total. 1. Lets the user input a number 3. Lets the user input another number 5. Adds number1 to the value in the accumulator (which is currently number2 as you just inputted it). 7. Halts the program. Type these instructions line by line into the Little Man Computer simulator to see how it works. Then change the program to subtract the number instead. INP STA Number1 INP STA Number2 ADD Number1 OUT HLT Number1 DAT Number2 DAT 2. Stores the inputted number in a variable named 'Number1'. 4. Stores the inputted number in a variable named 'Number2'. 6. Outputs the value in the accumulator (which is now number1 added to number2. 8. & 9. The two variables Number1 and Number2 are defined on separate lines. #3 - Load in Order Program Purpose: Input and store three numbers. Load and output them in the order that they were entered. 1. - 6. Lets the user input three numbers and immediately stores each one as they are entered. 8. Now that Number1 has been loaded into the accumulator, this value is outputted. 13. Halts the program. Type these instructions line by line into the Little Man Computer simulator to see how it works. Let the user input a fourth number and output this fourth number last . INP STA Number1 INP STA Number2 INP STA Number3 LDA Number1 OUT LDA Number2 OUT LDA Number3 OUT HLT Number1 DAT Number2 DAT Number3 DAT 14. - 16. The three variables Number1, Number2 & Number3 are defined on separate lines. 9. - 12. Number2 is loaded and output then Number3 is loaded and output 7. Once all three numbers have been inputted and stored, the first number is loaded back into the accumulator. #4 - Branching Program Purpose: Input and store two numbers. Output the largest number. (Branching required). 1. - 4. Lets the user input two numbers and immediately stores each one as they are entered. 7. BRP is 'Branch is Positive'. If the result of Number1 - Number2 is positive then the program will jump to line 11. You can write any value instead of 'loop', such as 'jump' or 'break'. If the result is not positive it will continue to the next line. 11. - 13. The program will jump to line 11 if the result of Number1 - Number2 is positive. This means that Number1 is larger than Number2 so Number1 is loaded and output then the program is halted. INP STA Number1 INP STA Number2 LDA Number1 SUB Number2 BRP loop LDA Number2 OUT HLT loop LDA Number1 OUT HLT Number1 DAT Number2 DAT 5. & 6. Loads Number1 and subtracts Number2 from it. 8. - 10. The program will continue to line 8 if the result of Number1 - Number2 is not positive. Because the result is a negative number, this tells us that Number2 is larger than Number1. So we load Number2, output it because it is bigger, then halt the program. 14. - 15. The variables Number1 & Number2 are defined on separate lines. Type these instructions line by line into the Little Man Computer simulator to see how it works. Change the program so that the smallest number is output .
- OCR CTech IT | Unit 1 | 2.2 - Applications Software | CSNewbs
2.2: Applications Software Exam Board: OCR Specification: 2016 - Unit 1 What is applications software? Don't confuse applications software and apps . Apps generally have a single use, such as Angry Birds or the flashlight tool on a phone. Applications Software can be used for a number of different functions depending on the user's needs and their purpose. Productivity Software This is general use software for completing tasks accurately and efficiently . Key examples include word processors (e.g. Microsoft Word or Google Docs), presentation software (e.g. Microsoft PowerPoint or Google Slides) and web browsers (e.g. Microsoft Edge or Google Chrome). Email applications (e.g. Microsoft Outlook or Gmail) are beneficial to organisations because staff can send information to many customers at once which is a simpler and less costly method of communication than something like sending letters or leaflets in the mail. Emails can also include attachments of important documents and include multimedia elements like images and videos to make communication more interesting . Databases and Spreadsheets Database tables and spreadsheets can store both numerical and textual data ready for analysis. Examples include simple database tables and financial spreadsheets of a company's profits this year. Microsoft Access is an example of database software that uses tables and Microsoft Excel is an example of spreadsheet software. Data can be sorted numerically or alphabetically for both software types but graphs can be created from spreadsheets to visualise data . When using spreadsheets (or databases) records can be locked ('record locking' ) so that only one person can make edits at any one time. Edits will be saved before unlocking the file. This will stop data being incorrectly overwritten and will ensure that the data in the spreadsheet is up-to-date, accurate and fit for purpose. An advantage of databases over spreadsheets is that data can be atomised - stored in separate tables but linked through relationships. Development Tools These are tools for programmers who are creating or modifying software . An integrated development environment ( IDE ) is software used to create and edit programs. An IDE features a number of tools including: A translator is a program that converts one type of language into another. A compiler is a type of translator that converts instructions into machine code (binary). A debugger is used to test code and display errors . Other development tools aid programmers with developing and maintaining websites and apps for phones / tablets. Wix.com has been used to create and update this website. Business Software This is specialist software for businesses , often made bespoke for an organisation. One example of business software is design packages such as CAD / CAM (C omputer-A ided D esign / C omputer-A ided M anufacturing). This is the use of software to design and construct products . Workers such as manufacturers and dentists use this type of software. Another type of business software is project management software that allows teams of workers to collaborate and divide projects into manageable tasks. Expert systems use large databases for automatic decision making , such as medical diagnosis programs . Further examples of business software, such as Management Information Systems (MIS), can be found in 3.5 . Q uesto's Q uestions 2.2 - Applications Software: 1. State four different kinds of productivity software and briefly describe how each could be used . For example: "Word processors can be used to type up a letter in an office or write an essay for school." [8 ] 2. Describe two differences between database and spreadsheet software. [2 ] 3a. What is an Integrated Development Environment ? [1 ] 3b. Describe three tools used in an IDE. [6 ] 4. Giving brief examples of how they can be used, state four different types of business software . [8 ] 5. Suggest how a website design company could use each of the three types of applications software (Productivity Software , Development Tools and Business Software ). [ 6 ] 2.1 - Types of Software Topic List 2.3 - Utility Software
- Python | 3a - Data Types | CSNewbs
top Python 3a - Data Types Data Types in Python If you are a Computer Science student you need to know about the different data types that are used in programming. String – A sequence of alphanumeric characters (e.g. “Hello!” or “Toy Story 4” or “Boeing 747” ) Integer – A whole number (e.g. 1470 or 0 or -34) Float (also called Real ) – A decimal number (e.g. -32.12 or 3.14) Boolean – A logical operation (True or False) Character – A single alphanumeric character (e.g. “a” or “6” or “?”) [ Not used in Python as it would just be a string with a length of 1] Converting to Another Data Type Converting a variable from one data type to another is called casting . Casting Commands str (variable_name) converts a variable to a string . int (variable_name) converts a variable to a integer . float (variable_name) converts a variable to a float (decimal number). An integer (or float ) value may be cast into a string so that it can be used with + as part of a sentence to avoid spaces . total = 45 print ( "You owe £" , total , "in total." ) print ( "You owe £" + str (total) , "in total." ) = You owe £ 45 in total. You owe £45 in total. When dividing an integer the answer is automatically given as a decimal number (float ), even if it is .0 (e.g. 10 / 2 would give 5.0). Casting a float (also known as real) number into an integer using int() will remove the decimal . total = 100/10 print ( "The answer is" , total ) print ( "The answer is" , int(total) ) The answer is 10.0 The answer is 10 = Data Types Task 1 ( Time) Write an input line with int to ask the current hour . Write another input line with int to ask the current minute . Write a print line with str() that outputs this as a clock time. Example solution: What is the hour? 12 What is the minute? 44 The time is 12:44 Data Types Task 2 ( Decimal ) Write an input line with int to ask for any number . Use float() in a print line to output number as a decimal. Example solution: Enter any number: 456 456.0 ⬅ Section 2 Practice Tasks 3b - Simple Calculations ➡
- Python | 9a - String Handling | CSNewbs
top Python 9a - String Handling What is String Handling? String handling refers to the manipulation of a string variable , typical uses include: Checking the length of a variable. Searching a variable for a certain phrase. Checking the number of times a specific character or word is used . String handling is used to examine passwords and to ensure that they are of an acceptable strength (e.g. by checking that they are at least 8 characters in length and include a mixture of capital letters , lowercase letters and symbols ). Password: arsenal Password: $tr0nG_pA$$w0rd Lowercase & Uppercase .lower() and .upper() are functions that convert a string into a fully lowercase or uppercase version. dogbreed = "Chihuahua" print (dogbreed.upper()) CHIHUAHUA character = "sPoNgeBoB" print (character.lower()) spongebob You may have realised that Python is very specific . 'yes ', 'Yes ' and 'YES ' are all treated as different values . Converting user input into one case , such as lowercase, and then comparing that input is a better way of checking an input than having an if statement with multiple or comparisons. The program below converts the user input into lowercase to compare. 'yes', 'Yes' and 'YES' are all converted to 'yes'. answer = input ( "Would you like water? " ) answer = answer.lower() if answer == "yes" : print ( "I'll fetch you a glass." ) else : print ( "Don't dehydrate!" ) Would you like water? yes I'll fetch you a glass. Would you like water? Yes I'll fetch you a glass. Would you like water? YES I'll fetch you a glass. Practice Task 1 Ask the user to enter their first name and surname. Print their surname in uppercase followed by their first name in lowercase. Example solution: Enter First Name: Jayden Enter Surname: Hargrove Welcome HARGROVE, jayden Count Characters The easiest way to count how many times a certain value appears within a string is to use the .count() command. It is important to note that, just like when using an input statement or calculation line, you must save the calculation into a variable . An example, for counting the number of e’s in a sentence, is below: sentence = input ( "Enter your sentence: " ) e_count = sentence.count( "e" ) print ( "There were" , e_count, "e's in your sentence!" ) Enter your sentence: even ellie eats elderberries There were 9 e's in your sentence! Practice Task 2 Create a program that counts how many instances of the letter a have been entered in a sentence. Bonus: Use the .lower() function in your code to include capital letters. Example solution: Enter a sentence: An angry aardvark named Aaron. That sentence had 8 a's. Finding the Length of a String Just like when we wanted to find the length of a list, we use the len command to see how many characters are in a string . It is sensible to save the result of the function into a variable so it can be used later . fruit = input ( "Enter a fruit: " ) length = len (fruit) print ( "That fruit was" , length, "characters." ) Enter a fruit: pineapple That fruit was 9 characters. A common reason for finding the length is as part of validation , for example, checking a password is more than 8 characters : password = input ( "Enter a new password: " ) length = len (password) if length >= 8: print ( "Password accepted!" ) else : print ( "Password is too short, must be at least 8 characters." ) Enter a password: snake54 Password is too short, must be at least 8 characters. Enter a password: pebblesthedog76 Password accepted! Practice Task 3 Create a program that asks for a name. Check that the name is between 4 and 10 characters. Print appropriate messages if it is within this range and if it isn't. Example solution: Enter a name: Tom That name is too short, it must be between 4 and 10 characters. Checking the Start / End of a String To determine if the first character in a string is a specific value use the .startswith() command. .startswith() is a function that will return True or False . Below is an example program to check if a name begins with the letter L . name = input ( "Enter a name: " ) if name.startswith( "L" ) == True : print ( "I like that name." ) else : print ( "I don't like that name." ) Enter a name: Lionel I like that name. Enter a name: Katjaa I don't like that name. Similarly, you can use .endswith() to check the last characters of a string . Practice Task 4 Ask the user to enter a country. Print a message if it ends with 'land', 'stan' or any other ending. Use .endswith() Example solution: Enter a country: Finland You have entered a 'land' country. There are 9 in the world. Enter a country: Kyrgyzstan You have entered a 'stan' country. There are 7 in the world. Enter a country: Peru Thanks for your entry. Note: You don't need to check if it's a valid country. Reversing a String To reverse a string, you write the variable name and then use square brackets to move one character at a time backwards. The first two colons are left empty as they denote where to start and end from (which don’t need to be changed). Therefore the -1 states that it will reverse from the end to the start : Ask the user to enter a random sentence. Print the sentence in reverse. Example solution: Practice Task 5 Printing Parts of a String You may want to print just part of a string or variable using square brackets. You can also use len to work out the length and work back, if you want to display the last characters: Practice Task 6 Ask the user to input a long word. Output the middle character of the word. Example solution: Split Strings Use the .split command to split a string into separate words . An empty split command such as words.split() will split at each space . You can enter a value in the brackets to split at certain characters , such as words.split(",") Use the len function to count the number of words once they have been split. You can use a for loop to cycle through each word. The program below checks the length of each word . Practice Task 7 Ask the user to input a sentence. Calculate and print the amount of words in the sentence. Calculate and print the amount of words that begin with s. Example solution: ⬅ Section 8 Practice Tasks 9b - Number Handling ➡