top of page

Search CSNewbs

304 results found with an empty search

  • Python | 4c - Logical Operators | CSNewbs

    Learn how to use logical operators in Python. Try practice tasks and learn through text and images. Perfect for students learning GCSE Computer Science in UK schools. top Python 4c - Logical Operators AND Operator The AND operator is used to execute certain code if more than one thing is true . AND is commonly used with account logins - both the username AND the password must be correct . The example below requires both a secret word and a secret number to be correct: print ( "To enter you need the secret word and the secret number!" ) word = input ( "What is the secret word? " ) number = int ( input ( "What is the secret number? " )) if word == "solitude" and number == 2011: print ( "Correct! You may enter!" ) else : print ( "Incorrect! Get out of here!" ) If no part or only some of the if statement is true then the indented code will not run : To enter you need the secret word and the secret number! What is the secret word? solitude What is the secret number? 4503 Incorrect! Get out of here! To enter you need the secret word and the secret number! What is the secret word? windhelm What is the secret number? 1021 Incorrect! Get out of here! Only If all parts of the if statement are true will the indented code be executed : To enter you need the secret word and the secret number! What is the secret word? solitude What is the secret number? 2011 Correct! You may enter! Logical Operators Task 1 ( Three Easy Questions) Ask the user three easy questions and print a special response if they get all three correct . Use the and operator to see if their answer for all each of the questions is correct. You must use a unique variable nam e for each of your inputs (it can't be 'answer' for all three, for example). Example solutions: What is the capital of Germany? Berlin What is the chemical formula for water? H20 What year did World War Two end? 1945 You absolute genius! What is the capital of Germany? Vienna What is the chemical formula for water? W20 What year did World War Two end? 1945 Bit awkward, I thought you'd do better... OR Operator The OR operator is used to execute certain code if one of several statements is true . The program below is checking if either a , e , i , o or u were entered. letter = input ( "Enter a letter: " ) if letter == "a" or letter == "e" or letter == "i" or letter == "o" or letter == "u" : print ( "You entered a vowel." ) else : print ( "You entered a consonant." ) Enter a letter: f You entered a consonant. Enter a letter: e You entered a vowel. It is important that you re-write the variable and operator (e.g. letter ==) each time you use 'or' . It will not work if you just write: if letter == “a” or “e” or “i” or “o” or “u”: Logical Operators Task 2 ( Twins?) Ask the user to enter their favourite colour and then ask them their age . If their favourite colour is the same as yours AND their age is the same as yours then print “Snap! Are you my twin?” . If only one of the statements is true (use the OR operator) then print “Spooky! You’re a bit like me.” . Add an else statement to print “We’re not so similar, you and I.” if there's nothing in common. Example solutions: What's your favourite colour? green What's your age? 15 Snap! Are you my twin? What's your favourite colour? blue What's your age? 15 Spooky! You're a bit like me. What's your favourite colour? red What's your age? 16 We're not so similar, you and I. ⬅ 4b - Mathematical Opera tors Sectio n 4 Practice Tasks ➡

  • 6.4 - Protection Measures | Unit 2 | OCR Cambridge Technicals | CSNewbs

    Learn about ways to measure the success of protection. Based on the 2016 OCR Cambridge Technicals Level 3 IT specification for Unit 2 (Global Information). 6.4 - Protection Measures Exam Board: OCR Specification: 2016 - Unit 2 Staff Responsibilities It is the staff of an organisation that will spend the most time handling and amending data so the company must have sufficient and effective protection measures in place so that staff are confident in their role and know their responsibilities of information security. Certain staff members may be responsible for types of data within an organisation, such as personal and confidential data. Clearly assigning specific people to roles ensures that they know what their job is and that they are responsible if data is lost. Organisations also need to carefully consider which members of staff have access rights to certain information. If data is sensitive or confidential then the more people that have access to that data , the higher the risk of it being lost or tampered with (accidentally or on purpose). Sensitive data should only be handled and accessed by those who need to use it as part of their job role to limit the chance of data loss. Staff should be trained so that they know how to adequately handle information including basic data security techniques and how to protect data from unauthorised access and loss. Disaster & Recovery Planning With important data often stored on a computer network, it is absolutely vital that a detailed and effective disaster recovery policy is in place in the event of data being lost due to an unexpected disaster. Disasters include natural disasters (e.g. fire, flood, lightning), hardware failure (e.g. power supply unit failing), software failure (e.g. virus damage) and malicious damage (e.g. hacking). There are three clear parts to a disaster recovery policy: Before the disaster: All of the possible risks should be analysed to spot if there are any weaknesses in preparation. Preventative measures should be taken after the analysis, such as making rooms flood-proof or storing important data at a different location . Staff training should take place to inform employees what should happen in the event of a disaster. During the disaster: The staff response is very important – employees should follow their training and ensure that data is protected and appropriate measures are put in place. Contingency plans should be implemented while the disaster is taking place, such as uploading recent data to cloud storage or securing backups in a safe room and using alternative equipment until the disaster is over. After the disaster: Recovery measures should be followed, such as using backups to repopulate computer systems. Replacement hardware needs to be purchased for equipment that is corrupted or destroyed. Software needs to be reinstalled on the new hardware. Disaster recovery policies should also be updated and improved . Assessment and Effectiveness Organisations should conduct information security risk assessments periodically to ensure that their physical and logical measures are up-to-date and that they provide the most effective methods of protection. There may be training drills of what should happen if a disaster or substantial data loss occurs so that the company is prepared . By testing the security measures in place, they can identify any weak-points and fix those highlighted vulnerabilities to minimise the possibility of external and internal data intrusion. As part of an organisation's security assessment, they may identify specific cost impacts . These are necessary financial expenditures to ensure the security of data and systems, such as: Software - e.g. security software such as firewalls may be purchased to protect networked systems. Hardware - e.g. buying secure storage devices and new computer systems. Training - e.g. hiring industry experts to train staff on how to keep data secure. Security - e.g. hiring staff to protect server rooms. Q uesto's Q uestions 6.4 - Protection Measures: 1. Describe why staff are so important when it comes to data protection . [3 ] 2. Explain the steps an organisation should take as part of a disaster recovery plan . Split your answer into before, during and after the disaster. [12 ] 3. Why is it important to conduct information security risk assessments ? [2 ] 4. Describe two cost impacts to a bank of keeping customer data secure. [4 ] 6.3 - Impacts Topic List 6.5 - Physical Protection

  • 3.2a - Wired & Wireless Networks - OCR GCSE (J277 Spec) | CSNewbs

    Learn about the differences between wired and wireless networks. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 3.2a: Wired & Wireless Networks Exam Board: OCR Specification: J277 Watch on YouTube : Wired Networks Wireless Networks Encryption Wired Connections Wireless Connections Wireless connections, such as WiFi or Bluetooth , use no cables but require a wireless network interface card (WNIC ). Wireless connections generally have a slower speed and can be affected by the computer's distance from the wireless router as well as obstacles like walls or bad weather. Wired connections use physical cables , such as copper or fibre optic wires , and require a network interface card (NIC ) to connect to a network. These wired connections use a wired connection protocol - most commonly Ethernet . Restricted Movement Faster More Secure NIC Required Freedom of Movement Slower Less Secure WNIC Required Encryption Wireless connections are less secure and require encryption . Encryption is the process of scrambling data into an unreadable format so that attackers cannot understand it if intercepted during transmission. The original data (known as plaintext ) is converted to scrambled ciphertext using an encryption key . Only at the correct destination will the encryption key be used to convert the ciphertext back into plaintext to be understood by the receiving computer. Q uesto's Q uestions 3.2a - Wired & Wireless Networks: 1. Briefly compare wired and wireless networks in terms of movement , transmission speed , security and required hardware . You could answer this in the form of a table. [ 8 ] 3.1b - Network Hardware & Internet Theory Topics 3.2b - Protocols & Layers

  • 3.1 - Defensive Design - OCR GCSE (J277 Spec) | CSNewbs

    Learn about defensive design considerations including validation checks, verification, anticipating misuse, maintainable code, authentication and input sanitisation. Based on the J277 OCR GCSE Computer Science specification (first taught from 2020 onwards). 3.1: Defensive Design Exam Board: OCR Specification: J277 Watch on YouTube : Defensive Design Validation Checks Maintainability Defensive Design Considerations There are several things to consider when creating a program that is secure and robust , including: Anticipating Misuse Planning ahead to take steps against potential misuse (e.g the app X prevents the same tweet sent twice in a row as it might be spam ). Input Sanitisation Checking and cleaning up data that has been input , (e.g. removing special characters to prevent a SQL injection ). Validation Checking whether input data follows specific criteria and should be accepted (e.g. a length check on a password). Verification Checking whether data that has been entered is correct (e.g. double entry ). Authentication Ensuring only authorised users can gain access to a system (e.g. usernames and strong passwords ) . Maintainable code Allowing other programmers to easily read and quickly understand code that has been written (e.g. using comments , indentation and appropriate variable names ). Input Validation Validation is a process to check that data is reasonable or sensible before it is accepted . Range Check Checks data is within a certain range . Age: 34 203 Type Check Checks data is a certain data type . Height (in cm): 182 Two metres Format Check Checks data is entered in a certain way . Date of Birth (DD/MM/YYYY) 25/03/2011 25th March 11 Presence Check Checks that data has actually been entered and not left blank . Password: fluffythecat123 Lookup Table A table of acceptable entries , also known as a list . Length Check Checks the length of the input is within a certain amount. Telephone Number 08323877319 07383 Maintainability Programs should be written in a way that makes maintaining and understanding them as straightforward as possible. Examples of making a program maintainable include: Using subprograms to reuse code and make them easier to test . This is called modularisation . Appropriate variable names , using a naming convention , ensure the purpose of a variable is immediately understood. Using indentation to improve readability and clearly show each ‘block’ of code. Comments enable a programmer to understand the purpose of each line of code. Crucial when working in a team . Using constants is another method of improving maintainability. This keeps the program code consistent , which makes it easier to read and debug a program. Q uesto's Q uestions 3.1 - Defensive Design: 1. Describe the different considerations a programmer should make for a defensive design . [ 6 ] 2. Describe the each validation check and give a suitable example . [ 12 ] 3. Explain the different ways a program can be maintained . [ 5 ] 2.3 Additional Programming Theory Topics 3.2 - Testing

  • OCR GCSE Topic List | CSNewbs

    The list of topics in the 2020 OCR GCSE Computer Science specifications. OCR GCSE Computer Science (J277) These pages are based on the J277 OCR GCSE Computer Science specification . This website is in no way affiliated with OCR . Component One: Computer Systems OCR GCSE Key Term Generator Paper 1 Playlist on YouTube 1. Systems Architecture 1.1a - The CPU 1.1b - Registers & FE Cycle 1.2 - CPU Performance 1.3 - Embedded Systems 2. Memory & Storage 2.1 - Primary Storage 2.2 - Secondary Storage 2.3 - Units 2.4a - Number Systems 2.4b - Binary Addition & Shifts 2.4c - Character Storage 2.4d - Image Storage 2.4e - Sound Storage 2.5 - Compression 3. Networks 3.1a - Network Types & Performance 3.1b - Network Hardware & Internet 3.2a - Wired & Wireless networks 3.2b - Protocols & Layers 4. Network Security 4.1 - Network Threats 4.2 - Preventing Vulnerabilities 5. Systems Software 5.1 - Operating Systems 5.2 - Utility Software 6. Impacts 6.1a - Impacts of Technology 6.1b - Legislation Component Two: Computational Thinking, Algorithms and Programming Paper 2 Playlist on YouTube 1. Algorithms 1.1 - Computational Thinking 1.2 - Designing Algorithms 1.3 - Searching & Sorting Algorithms 2. Programming Fundamentals 2.1 - Programming Fundamentals 2.2 - Data Types 2.3 - Additional Programming Techniques 3. Producing Robust Programs 3.1 - Defensive Design 3.2 - Testing 4. Boolean Logic 4.1 - Boolean Logic 5. Languages & IDEs 5.1 - Languages & Translators 5.2 - Integrated Development Environment

  • OCR CTech IT | Unit 1 | 3.2 - Virtualisation | CSNewbs

    Learn about the benefits and drawbacks of virtualization, as well as about cloud storage and virtual clients. Based on the 2016 OCR Cambridge Technicals Level 3 IT specification. 3.2 - Virtualisation Exam Board: OCR Specification: 2016 - Unit 1 What is virtualisation? Virtualisation is the creation of a virtual version of a device , software , operating system or server . These virtual versions can then be run on a different physical computer system , such as a powerful server . There are many different types of virtualisation . Storage virtualisation combines multiple separate storage devices into acting and appearing like a single , central storage system . Using storage virtualisation improves scalability as further devices can join the storage system if more space is required . It also simplifies the management of storage across the network. Server virtualisation allows one physical server to be divided into and host multiple virtual servers , each running separately . Each virtual server operates independently , handling its own operating system and applications . This allows for resources to be used more effectively and improves the scalability and versatility of the physical server . Client Virtualisation (Virtual Clients) Client virtualisation is when several virtual desktops are run on a single server - think back to the hypervisor from 3.1 . A virtual client is a full desktop environment where the processing happens remotely . For example, where an operating system is managed and hosted centrally but displayed locally on a different computer. These are often known as 'dumb clients ' because the server does the processing for it , meaning it can have minimal resources like a slow processor and little memory / storage . General Benefits & Drawbacks of Virtualisation Benefits of virtualisation: Costs are cheaper in the long-term because money is saved by not purchasing multiple physical devices . Money is also saved due to less cabling and lower power consumption . If set up efficiently, it can be used for higher performance at a lower cost - "Do more with less" . Programs can be tested in a secure environment before main-system deployment. Simplified response to recover after a disaster because only the server needs to be fixed. Drawbacks of virtualisation: If not set up efficiently, users could face serious performance issues , as fewer servers do more work. If a single physical system fails , the impact will be greater . Initial set up is complex , requires technical knowledge and can cost a lot. Easier for hackers to take more information at once as the data is stored in the same place. Benefits of client virtualisation: All data is stored in one central location , making backup and disaster planning easier to manage . The whole system can be managed , secured and updated from the server , rather than from each individual system. Hardware costs will be reduced because the virtual clients do not store or process their own data , meaning they can be of a low spec . Users can have multiple virtual machines and log in remotely (from anywhere with internet access ). Drawbacks of client virtualisation: Users will be unable to work if network connectivity is lost . There is a high strain on the server as the virtual clients do not store or process data themselves . An increased load on the server might result in poor performance for each client, especially with multiple connections . As the data is stored in one location , there are security risks of unauthorised access if the server is not adequately protected . Server Virtual Clients Cloud Technology 'The cloud ' is storage that is accessed through a network , primarily the internet. A cloud server is an example of storage virtualisation as data may be stored across multiple physical devices . There are three different types of cloud storage: Private cloud is where a business will have its own data centre that employees can access. This allows for flexible and convenient data storage and gives the business control over data management and security . Users of the private cloud will not usually have to pay individually for access - but the company will need to spend a lot of money on set up and maintenance . Public cloud uses third-party service providers such as Google Drive or DropBox to provide storage over the internet . Public cloud is usually a pay-for-use service , where businesses will pay for specific amounts that they need. Data management and data security is maintained by the cloud provider and the business is dependent on them providing constant access and deploying effective security measures. Hybrid cloud uses a mix of on-site storage (private cloud) and third-party (public cloud) services . Organisations can move workloads between private and public clouds as their specific needs and costs change . A benefit of hybrid cloud is that it gives an organisation greater flexibility and data storage options. As an example, a company could use on-site or private cloud storage to hold sensitive information and third-party, public cloud services to hold less important data . Q uesto's Q uestions 3.2 - Virtualisation: 1. What is the difference between server and storage virtualisation ? [ 2 ] 2a. What is a virtual client ? [ 1 ] 2b. What are the advantages and disadvantages of client virtualisation ? [ 8 ] 3. Explain any further general advantages and disadvantages of using virtualisation , not covered in your answer to 2b. [4 ] 4. Describe the differences between private , public and hybrid cloud storage. [6 ] 3.1 - Server Types Topic List 3.3 - Network Characteristics

  • OCR CTech IT | Unit 1 | 3.1 - Server Types | CSNewbs

    Learn about the role of different server types including file, application, print, email, mail servers and the hypervisor. Based on the 2016 OCR Cambridge Technicals Level 3 IT specification. 3.1 - Server Types Exam Board: OCR Specification: 2016 - Unit 1 What is a server? A server is a powerful dedicated system on a network . It requires increased memory , storage and processing power than traditional computer systems to fulfill its role across the network. Servers need to be scalable - this means they must be adaptable and able to efficiently manage the needs of connected systems if more are added or some are removed . Servers have different roles so a company may use multiple , separate server types within their organisation, each with a specific purpose . Having separate servers is costly but beneficial as if one loses connection , others may still be usable . Also a server will be more efficient if it is only managing one resource (e.g. printers) at a time . File Server A file server centrally stores and manages files so that other systems on the network can access them. The server provides access security , ensuring that only users of the appropriate access level can access files. File servers can be used to automatically backup files , as per the organisation's disaster recovery policy. Using a file server frees up physical storage space within a business and can provide printing services too. Printer Server These servers control any printers on a network and manage printing requests by sending the document to an appropriate printer. Print servers use spooling to queue print jobs so that they are printed when the printer is ready. If a fault occurs with a certain printer, work can be automatically diverted to another available printer. Application Server These servers allow users to access shared applications on a network. All users will be able to access common applications like email software or word processing, but the server will also restrict certain applications to those with invalid access levels (such as hiding financial databases from employees outside of the finance department). Application updates can be simply deployed to the application server only , avoiding individual updates for each system and saving a lot of time . Installers can be hosted on an application server, allowing the software to be easily installed on other connected machines . Database Server These servers manage database software that users on the network can access and use to manipulate data . Data held on the server will be stored in a database accessible from multiple connected computers . The data can be modified using query languages such as SQL. Storing data on a database server, rather than individual computers, is more reliable . A database server for a business also allows for scaling - for example, the database can be increased in size if the customer base grows. Web Server A web server manages HTTP requests from connected devices to display web pages on web browsers . A request (e.g. csnewbs.com) is sent to the web server. The server contains a list of known URLs and their matching IP addresses . The server contacts the server where the web page is held and delivers the web page to the client . Mail Server These servers send and receive emails using email protocols (SMTP & POP) allowing email communication between other mail servers on other networks. The server makes sure emails are delivered to the correct user on the network. Email servers can store company address books making internal communication easier for organisations. The server may have anti-spam functions to reduce junk mail. Hypervisor A hypervisor allows a host machine to operate virtual machines as guest systems. The virtual machines share the resources of the host , including its memory, processing power and storage space. This type of technology is called virtualisation . The guest machines are isolated so if one failed, the other guests and the hosts are not affected - demonstrating good security . The hypervisor optimises the hardware of the host server to allow the virtual machines to run as efficiently as possible. Q uesto's Q uestions 3.1 - Server Types: 1a. What is a server ? Why does it need to be scalable ? [2 ] 1b. Give two reasons why a company may use multiple , separate servers . [2 ] 1c. State the 7 types of server . [1 each ] 2. A medium-sized animation company working on a movie are considering buying a server. Describe each type of server and the different roles they have. a. File Server b. Printer Server c. Application Server d. Database Server e. Web Server f. Mail Server g. Hypervisor [4 each ] 3. What type of technology does a hypervisor use to control multiple virtual machines? [1 ] 2.7 - Protocols Topic List 3.2 - Virtualisation

  • Python | 10b - Read & Search Files | CSNewbs

    Learn how to read and search through files in Python. Try practice tasks and learn through text and images. Perfect for students learning GCSE Computer Science in UK schools. Python 10b - Read & Search Files Reading from a File To read and print from a file you must open it in read mode by typing "r" instead of "a". If you are writing and reading in the same program, make sure you close the file in append mode before you open it in read mode . The program below uses the Customers.txt file from the last section. A simple for loop can be used to print each line of the file. The end = "" code just prevents a space between each line. Practice Task 1 Open one of the files that you used in Section 10a and print each line. Example solution: Reading Specific Lines from a File Sometimes it is necessary only to print certain lines. The following example uses a file where I have written a sentence of advice on each line. The user is asked to enter a number between 1 and 6. If they enter 1, the first line of the file is printed. If they enter 2, the second line of the file is printed etc. Remember Python starts counting everything at 0 so each line is a digit less than you would expect . Square brackets must be used to denote the line to print: [1] not (1). The end = "" code is not necessary but removes space after the line. Practice Task 2 Create a text file (saved in the same folder as your Python file) with a list of video games. Ask the user to enter a number between 1 and 10. Print the line for the number that they input. Example solution: Print a Random Line The randint command can be imported and used to print a random line from a file . The example below prints one of the 12 months . The file is opened in read mode and the readlines() command extracts each line , placing them in a list . A random number is then generated between 0 and one less than the total number of lines . This random number is then used to print a line from the extracted list of lines . Python code from random import randint file = open ( "months.txt" , "r" ) lines = file.readlines() random = randint(0,11) print (lines[random]) months.txt January February March April May June July August September October November December potential outputs March December April July If the length of the file is not fixed (e.g. new lines are being added or lines removed ) then the random number generation line can be adapted to use the len command to calculate the current number of lines . This is required to know the upper limit of the random number . random = randint(0,len(lines)-1) Searching Through Files A for loop is used to search through a file , line by line . First, an input line is used to allow the user to enter their search term . If the term that is being searched for is found, then the whole line is printed. The example below uses a variable named found to state if there is a match when the file is searched. If the search term is found, then the found variable is changed to true . If the search term is not found , the found variable remains as false, so the 'no customers found' statement is printed . Practice Task 3 You should have completed Practice Task 2 from Section 10a (the A Level task). Add extra code to that program so that you can search for specific students. Example solution: ⬅ 10a - Open & Write Files 10c - Remove & Edit Lines ➡

  • 3.6 - Information Systems | Unit 2 | OCR Cambridge Technicals | CSNewbs

    Learn about the differences between open and closed information systems. Based on the 2016 OCR Cambridge Technicals Level 3 IT specification for Unit 2 (Global Information). 3.6 - Information Systems Exam Board: OCR Specification: 2016 - Unit 2 Information systems, such as structured databases , can be defined primarily as either 'open ' or 'closed '. Open Information Systems Closed Information Systems This type of system can interact with other information systems (e.g. another database) to exchange data , even from different platforms (types of computers). Because it is open it is more at risk of data loss and/or hacking. This type of system is private and cannot exchange data with other systems. Access is limited but it is much more secure than an open system. Q uesto's Q uestions 3.6 - Information Systems: 1. Compare and contrast open and closed information systems . [4 ] 3.5 - Data Analysis Tools Topic List 4.1 - UK Legislation

  • 2.1 - Logical Operators - Eduqas GCSE (2020 spec) | CSNewbs

    Learn about the four logical operators - NOT, AND, OR and XOR - and truth tables. Based on the 2020 Eduqas (WJEC) GCSE specification. 2.1: Logical Operators & Truth Tables Exam Board: Eduqas / WJEC Specification: 2020 + What is a logical operator? Inside of each computer system are millions of transistors . These are tiny switches that can either be turned on (represented in binary by the number 1 ) or turned off (represented by 0 ). Logical operators are symbols used to represent circuits of transistors within a computer. The four most common operators are: NOT AND OR XOR What is a truth table? A truth table is a visual way of displaying all possible outcomes of a logical operator. The input and output values in a truth table must be a Boolean value - usually 0 or 1 but occasionally True or False. NOT A NOT logical operator will produce an output which is the opposite of the input . NOT is represented by a horizontal line . Boolean Algebra Notation written as NOT A A Truth Table AND An AND logical operator will output 1 only if both inputs are also 1 . AND is represented by a full stop. Boolean Algebra Notation written as A AND B A.B Truth Table OR An OR logical operator will output 1 if either input is 1 . OR is represented by a plus. Boolean Algebra Notation written as A OR B A+B Truth Table XOR An XOR (exclusive OR) logical operator will output 1 if the inputs are different and output 0 if the inputs are the same . XOR is represented by a circled plus. Boolean Algebra Notation written as A XOR B A B Truth Table Multiple Operations Exam questions will ask you complete truth tables that use more than one logical operator . Work out each column in turn from left to right and look carefully at which column you need to use. Simplification You may be asked to use a truth table to simplify an expression . This is actually really easy. Once you've completed the truth table see if any columns match the final expression . A+B and A+(A+B) both result in the same values , therefore: A+(A+B) can be simplified as just A+B. Q uesto's Q uestions 2.1 - Logical Operators: 1. Copy and complete the following truth tables: 1b. Simplify the expression in the second truth table. 2a. A cinema uses a computer system to monitor how many seats have been allocated for upcoming movies. If both the premium seats and the standard seats are sold out then the system will display a message. State the type of logical operator in this example. 2b. For the more popular movies, the cinema's computer system will also display a message if either the premium seats or the standard seats have exclusively been sold out. However, it will not output a message when both have been sold out. State the type of logical operator in this example. 1.6 - Additional Hardware 2.2 - Boolean Algebra Theory Topics

  • Python | 3b - Simple Calculations | CSNewbs

    Learn how to make simple calculations in Python. Try practice tasks and learn through text and images. Perfect for students learning GCSE Computer Science in UK schools. top Python 3b - Simple Calculations Simple Calculations in Python You can perform calculations on numbers in Python using the four main operators : print ( 89 + 47) print ( 89 - 47) print ( 89 * 47) print ( 89 / 47) = 136 42 4183 1.8936170212765957 For addition , use the plus sign + To subtract numbers, use the dash symbol – (but not an underscore _ ) For multiplication , use an asterisk * which can be made by pressing Shift and 8 on a typical keyboard. To divide numbers, use a forward slash / (but not a backslash \ ) Use a string and the calculation to make the output user friendly . print ( "53 x 7 =" , 53 * 7) = 53 x 7 = 371 Simple Calculations Task 1 ( + - * /) Print four different simple calculations, using a different operator ( + - * / ) for each. Make the output user friendly by also showing the calculation (not just the answer). Copy the divide symbol here using Ctrl and C : ÷ Example solution: 18 + 35 = 53 18 - 35 = -17 18 x 35 = 630 18 ÷ 35 = 0.5142857142857142 Using Variables in Calculations You can also perform calculations on variables . The example below has the values of the variables pre-written. You need to store the result in a variable . The total variable has been used to store the result of the multiplication. num1 = 12 num2 = 20 total = num1 * num2 print ( "The total is" , total) = The total is 240 The example below allows the user to input values . num1 = int ( input ( "Enter number one: " )) num2 = int ( input ( "Enter number two: " )) total = num1 + num2 print ( "The to ta l is" , total) Enter number one: 21 Enter number two: 82 The total is 103 = Don't leave the user in the dark, better user interfaces are clear and explain what outputted values mean: num1 = int ( input ( "Enter number one: " )) num2 = int ( input ( "Enter number two: " )) answer = nu m1 - num2 print (num1 , "-" , n um2 , "=" , answer) Enter number one: 83 Enter number two: 29 83 - 29 = 54 = Simple Calculations Task 2 ( Divide by 3) Use an input line with int to ask the user to enter a number . Divide the number by 3 and output the result . Example solution: Enter a number: 11 11 divided by 3 is 3.6666666666666665 Simple Calculations Task 3 ( Add 3 Numbers ) Make three input lines using int to ask the user to enter three numbers . Add the numbers together and output the total . Example solution: Enter the first number: 45 Enter the second number: 32 Enter the third number: 19 The total is 96 ⬅ 3a - Data Types Section 3 Practice Tasks ➡

  • Python | 9a - String Handling | CSNewbs

    Learn how to handle strings (text) in Python. Try practice tasks and learn through text and images. Perfect for students learning GCSE Computer Science in UK schools. 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 ➡

© CSNewbs 2026

The written, video and visual content of CSNewbs is protected by copyright. © 2026
bottom of page