Search CSNewbs

281 results found for ""

  • Python | 1c - Creating Variables | CSNewbs

    Python 1c - Creating Variables What is a Variable? A variable represents a value that can change . The two parts of a variable are the variable name (e.g. biscuits) and the variable value (e.g. 20). ​ A variable must start with a letter , can't contain spaces, and you must declare its value before you can use or print it. = Remember to use the print c ommand to display something to the screen. You always need to print the variable name (e.g. biscuits), not the value (20) as the value can change. Important – When writing variable names, we do not need speech marks. (e.g. type biscuits , not “biscuits”) ​ We use variables because the value of something might change as the program is executed. For example, if someone munches a biscuit then the value of our variable changes: = Practice Task 1 1. On line 1 write a variable with the name Age and the value of your current age. 2. On line 2 print the variable name Age. 3. On line 3 write a variable with the name Pets and the value of how many pets you have. 4. On line 4 print the variable name Pets. Example solution: Variables with Strings = In the example above, pokemon is the variable name that represents the variable value "Pikachu" . ​ In programming, a collection of alphanumeric characters (letters, numbers and punctuation) is called a string . "Pikachu" is a string. ​ To create a string, we use "speech marks" . Numbers by themselves and variable names do not use speech marks. A variable can only have one value at a time, but it can change throughout the program. The variable name never changes . = Practice Task 2 1. On line 1 write a variable with the name FirstName and the value as your first name. 2. On line 2 write a variable with the name Surname and the value as your surname. 3. On line 3 print the variable name FirstName. (Use the variable name FirstName, not just your first name in speech marks) 4. On line 4 print the variable name Surname. Example solution: 1b - Commenting 1d - Using Variables

  • Python | Section 8 Practice Tasks | CSNewbs

    Python - Section 8 Practice Tasks Task One Write a program with a blank list. ​ Use the .append() command to add your three favourite ice-cream flavours to this list and then print the list. Example solution: Task Two Write a program with a list of 5 random numbers. ​ Print the list. ​ Delete the first and third numbers. Print the list. Example solution: Task Three Write a program with a list of three random animals. Write an input line that lets the user type an animal. Add what the user has written to the list and print the list. Example solution: Task Four Sort your list from task two into order. Then print the list. Example solution: Task Five Copy the text on the right and create a program that will split the text at each full stop. Count the number of names in the list. ​ Print the longest name. Example solution: annabelle.clara.damien.sarah.chloe.jacques.mohammed.steven.rishi.raymond.freya.timothy.claire.steve.alexandria.alice.matthew.harriet.michael.taylor Task Six Create a dictionary (see 8c ) that asks users questions about yourself, such as first name, favourite colour or birthday. ​ Let the user answer each question and display the answer if they get it correct. Use the 'Using a Dictionary to Make a Game ' section of 8c to help you. Example solution: 8c - Dictionaries 9a - String Handling

  • Python | 1d - Using Variables | CSNewbs

    Python 1d - Using Variables Printing Variables Within Sentences Join sentences and variables together using a plus symbol (+ ). Joining sentences together like this is called concatenation . = Remember to use speech marks for your printed statements but print the variable name to display the variable value. = You need to use the + symbol before and after each variable. Practice Task 1 1. On line 1 write a variable with the name sandwich and the value of a sandwich filling. 2. On line 2 print a sentence that uses the variable name sandwich. 3. On line 3 change the variable sandwich to equal a different filling. 4. On line 4 print the same sentence as line 2. Example solution: Printing Number Variables Within Sentences To join strings and number values then you must use a comma as a plus will not work: = You need to use a comma before and after each variable. Practice Task 2 1. Create a variable called bottles and give it the value 99. 2. print a sentence that uses the variable name. 3. Change the variable value to 98. 4. print the same sentence again. Example solution: Using f-Strings Another method of using variables within a printed sentence is to use f-strings . ​ Type the letter f before your output and place your variable names in curly brackets - { } ​ Variables of any data type can be used with f-strings. Practice Task 3 1. Create three variables: movie_name actor year ​ 2. Use an f-string to print a sentence that uses all three variables. Example solution: 1c - Creating Variables Section 1 - Practice Questions

  • Computer Science Newbies

    C omputer S cience Newb ie s Popular CSNewbs topics: Programming PYTHON GCSE Computer Science EDUQAS OCR Cambridge Technicals Level 3 IT You are viewing the mobile version of CSNewbs. The site may appear better on a desktop or laptop . Programming HTML CSNewbs last updated: Sunday, 19th September 2021 About CSNewbs

  • Python | Setting up Python | CSNewbs

    Setting up Python Downloading Python If you are using Python in Computer Science lessons, then your school should already have it downloaded and installed on the school computers. ​ It is a good idea to download it on a home computer too so you can practice outside of lessons. Python is free and can be downloaded from the official website. You should download the most up-to-date version of Python 3 (currently Python 3.9.7). ​ Save the file and then run it to start installing. Official Download Page Using Python When you run the Python application, it will open the shell. This window will display the outputs of any program you have created. ​ Do not type into the shell . ​ Click on the File tab then New File to open the editor. Python Shell - This displays the outputs of your program. Do not write directly into the shell . Python Editor - All code is written into the editor. When you want to test a program press the F5 key (or click the Run tab then Run Module ). The first time you test a program, it will prompt you to save the file. Make sure you save it somewhere you will remember - it is a good idea to create a folder named 'Python' where you can keep all your practice programs. The next page looks at actually creating a program but above shows how code has been typed into the editor and then displayed in the shell. ​ You never need to save the shell window. Also, the editor saves automatically every time you run the program. Opening a Saved Program When you want to re-open and edit a file you have created previously double-clicking on it won't work . ​ Right-click on the file and select Edit with IDLE : 1a - Printing

  • Python | 9a - String Handling | CSNewbs

    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 . ​ In the real-world, string handling is used to examine passwords and to ensure that they are of an acceptable strength (by checking that they include a mixture of capital letters, lowercase letters and symbols for example). Counting in a String The easiest way to count how many times a certain value appears within a variable 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: Practice Task 1 Create a program that counts how many instances of the letter a have been entered in a sentence. Example solution: 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. We also need to save the calculation into a variable . ​ A common reason for finding the length is as part of validation , for example, checking a password is more than 8 characters we would code: Practice Task 2 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: Checking the Start / End of a String To determine if the first character in a string is a specific value use the .startswith() command. Remember to save the calculation into a variable . For example: ​ start = sentence.startswith(“A” ) ​ If the sentence above does start with the letter A then the Boolean value True will be saved as start, else if the variable begins with any other character, then start will be saved as False instead. If we were creating a program for a library and we wanted to check if a book reference began with “Geo” then we would use the following code: Above we have used an if statement to see if the startswith value is True or False and printed an appropriate comment for either scenario. Careful not to put the True value in speech marks as it won’t work. If we ran the above code, two different outcomes could be: Similarly, you can use .endswith() to check the last characters of a string . Practice Task 3 Ask a user to enter their name. ​ If their name starts with the same letter as your name then print an appropriate message. ​ Else, print a different message. Example solution: 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 4 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 5 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 6 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

  • Python | Section 3 Practice Tasks | CSNewbs

    Python - Section 3 Practice Tasks Task One Create a program that asks the user to input a number and then prints the square of that number. ​ Requirements for a complete program: Use only two lines. Use only one print line. Include the user's number and the squared number in the print line. Remember: Break up variables in a print line by using commas or plus signs between each part of the "sentence" . Example solution: Task Two X Create a program that asks the user to input two numbers. Multiply the two numbers together and print the total. Requirements for a complete program: Only three lines. Use only one print line. Include the user's number and the squared number in the print line. Remember: Break up variables in a print line by using commas or plus signs between each part of the "sentence" . Example solution: Task Three Create a program that asks the user to input their current age and then prints a guess of when they will turn 65. (Note this is more likely to be correct towards the end of the year – think about why). ​ You could do this in just two lines but before trying that work out on paper the steps to calculating your own age you will turn 65. What steps did you take? Try to recreate those steps in Python. You might need to create another variable to make it easier. Example solution: Task Four Let the user enter a number then print the first five multiplications in its times table. Simple example solution: Better example solution: 3c - Modulo 4a - If Statements

  • 3.3a - Network Characteristics | OCR A-Level | CSNewbs

    Exam Board: OCR 3.3a - Network Characteristics Specification: A-Level 2015 What is a network? A network is more than one computer system connected together allowing for communication and sharing of resources . Networks can be split into different types , usually categorised by their geographical distance apart and the area that they serve. Local Area Network 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 . Wide Area Network 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 . Advantages and Disadvantages of using a Network There are many benefits but also some drawbacks to using a network compared to having an unconnected ('standalone' ) computer: Advantages of Networks Easily share files , software and hardware between computers. Disadvantages of Networks There is an initial cost because network devices like routers are required . Larger companies will need to buy and maintain a server . Log in from any connected computer and access your data and files. A network manager / administrator might need to be employed to maintain the network . An administrator can monitor network activity and control security settings. Data from computers on the network can be automatically backed up on central storage. Security breaches are more likely and malware , such as worms, can spread quickly across the network. If the web server fails , all connected computers won't be able to access files or log on . Client-Server and Peer-to-Peer Networks 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. Client-Side & Server-Side Processing Processing data when using a web application can be performed by the client ( client-side ) or by sending/receiving data with the server ( server-side ). ​ Client-Side Server-Side Client-side processing is more secure as no data is being sent along the network to the server, and thus can’t be intercepted . Web pages use JavaScript to quickly validate data and provide interactivity without having to prompt unnecessary interaction with the server . Server-side processing is reserved for more important tasks such as processing user input , interacting with databases and structuring web applications . It is also used to further validate data as client-side processing can be modified or even disabled on the browser so further checks are used to prevent malicious code , such as an SQL injection from being used. 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. 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 . Packet Switching vs Circuit Switching The key difference is that a circuit-switched network sends data along the same route . A packet-switched network sends data packets along different routes . Packet Switching With a packet-switched network the data is split into packets . The data packets are transmitted over a network and may take different routes to its destination. When all the packets have arrived the data is reassembled . The Internet is an example of a packet-switching network. Advantages of Packet Switching: Transmission is more secure as it is harder for a hacker to intercept complete data because it can take different routes . If a network device fails the data packets can take an alternative route . Data packets can be sent efficiently and individually across less busy routes . Disadvantages of Packet Switching: ​ Reassembling the data takes longer because packets may arrive out of order . It is less reliable than circuit switching as some data packets may not reach the destination (this is called packet loss ). Circuit Switching When data is transmitted over a circuit-switched network all of the data takes the same route to the destination address in one continuous stream . The data is quickly reassembled at the destination because it is already in the correct order . The old telephone system is an example of a circuit-switched network. Advantages of Circuit Switching: ​ Reassembling the data is quick because the packets arrive in the order that they were sent. It is more reliable than packet-switching because data is sent in one continuous stream . The transmission is fast and should encounter fewer errors - once the connection has been securely established . Disadvantages of Circuit Switching: Less secure as hackers could intercept the data and more easily access the data as it all takes the same route. Establishing a connection takes time to set up. If any device fails on the route then the whole connection breaks and data transfer will be incomplete. Q uesto's Q uestions 3.3a - Network Characteristics: ​ 1a. Describe two differences between a LAN and WAN . [4 ] 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. 2c. Describe the difference between client-side and server-side processing and give an example of when each would be used. [4 ] ​ 3a. Describe how packet switching works . [3 ] 3b. Describe the advantages of packet switching . [3 ] 3c. Describe the disadvantages of packet switching . [2 ] ​ 4a. Describe how circuit switching works . [3 ] 4b. Describe the advantages of circuit switching . [3 ] 4c. Describe the disadvantages of circuit switching . [3 ] ​ 5a. Draw and label diagrams of client-server and peer-to-peer networks. [4 ] 5b. Draw diagrams of packet switching and circuit switching . [2 ] 3.2b - SQL Theory Topics 3.3b - Protocols & TCP-IP Stack

  • 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

  • CSN+ Preview | CSNewbs

    About CSNewbs Plus (CSN+) CSN+ is a premium collection of resources made for teachers that follows the Computer Science specifications covered on the website . ​ Currently, these resources are in development , with the Eduqas GCSE resource pack arriving first, based on the Eduqas GCSE Computer Science 2020 specification . < Free zip folder download of all resources for Eduqas GCSE topic 1.1 (The CPU) *Updated Jan 2021* ​ Resources included for each topic: Lesson Slides Starter activity (to print) Task resources (e.g. diagrams or worksheets to print) Task answers What is included in the CSNewbs+ GCSE collection? 39 presentation slides 39 starters 39 task answer documents 19 revision activity pages 7 topic tests & answers ​ ​ See below for more details: + Complete presentation slides for each of the 39 theory topics in the Eduqas GCSE 2020 specification . ​ PowerPoint and Google Slides compatible. Activity resources to print . Including diagrams , tables and worksheets for lesson tasks . All answers included for teachers to use. Starter questions that recap the previous topic. For teachers to print before the lesson. All answers included in the lesson slides. 39 starters . Comprehensive answers for all lesson tasks . 39 task answer documents containing answers for over 100 lesson tasks for teachers to use . Revision templates for students to complete, to print on A3 paper . 19 pages and 7 revision lesson slides . Exercise book headings and the driving question (lesson focus) 7 end-of-topic tests with brand new questions . All answers included for teachers. What is included on the presentation slides? The following breakdown shows the presentation slides for 1.1 (The CPU): A title slide The content covered from the Eduqas GCSE specification Exercise book headings and the driving question (lesson focus) Answers to the starter activity questions Lesson objectives An explanation of the topic Clear explanations of the content First task. Students use slides or CSNewbs to complete. All answers on separate teacher document. Task 2. Table provided in teacher resource pack to print. Further explanations of the content Further explanations of the content with diagrams. Further explanations of the content with diagrams. Task 3. Answers in the teacher document. Plenary to check the students' understanding of the lesson topics. < Free zip folder download of all resources for Eduqas GCSE topic 1.1 (The CPU) *Updated Jan 2021*