top of page

Search CSNewbs

226 items found for ""

  • Computer Science Newbies

    C omputer S cience Newb ie s Popular CSNewbs topics: Programming PYTHON GCSE Computer Science OCR 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: Monday 16th January 2023 Thanks for 284,489 visits to CSNewbs in 2022! About CSNewbs

  • 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

  • Python | 2b - Inputting Numbers | CSNewbs

    Python 2B - Inputting Numbers Inputting Numbers in Python To enter whole numbers then you must use the int command. int stands for integer (a whole number ) and is typed before input – don’t forget the double brackets at the end . = Using float instead of int allows a decimal number to be entered instead. Again, don’t forget the double brackets at the end . = Practice Task 1 1. Type an input line (with int ) to ask the user how many times they’ve been to the zoo. 2. print a reply that uses their response. Example solution: Practice Task 2 1. Type an input line (with float ) to ask the user their height in metres. 2. print a reply that uses their response. Example solution: Embedded Python Editor Powered by trinket.io 2a - Inputting Strings Section 2 Practice Tasks

  • 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. ​ 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

  • Eduqas GCSE Topic List | CSNewbs

    Eduqas / WJEC GCSE Computer Science These pages are based on the Eduqas GCSE Computer Science 2020 specification . The content can also be used by students studying WJEC GCSE Computer Science in Wales . This website is in no way affiliated with Eduqas / WJEC . 1. Hardware 1.1 - The Central Processing Unit (CPU) 1.2 - The FDE Cycle 1.3 - Primary Storage 1.4 - Secondary Storage 1.5 - Performance 1.6 - Additional Hardware 2. Logical Operators & Boolean 2.1 - Logical Operators 2.2 - Boolean Algebra 3. Networks & Security 3.1 - Network Characteristics 3.2 - Data Packets & Switching 3.3 - Network Topology 3.4 - Network Hardware & Routing 3.5 - Protocols 3.6 - 7-Layer OSI Model 3.7 - The Internet 3.8 - Cyber Threats 3.9 - Protection Against Threats 4. Data 4.1 - Number Systems 4.2 - Signed Binary 4.3 - Binary Calculations 4.4 - Arithmetic Shift 4.5 - Character Sets & Data Types 4.6 - Graphical Representation 4.7 - Sound Representation 4.8 - Compression 5. Data Organisation 5.1 - Data Structures & File Design 6. Operating Systems 6.1 - Operating Systems 6.2 - Utility Software 7. Principles of Programming 7.1 - Language Levels 8. Algorithms & Constructs 8.1 - Programming Principles 8.2 - Understanding Algorithms 8.3 - Writing Algorithms 8.4 - Sorting & Searching Algorithms 8.5 - Validation & Verification 9. Software Development 9.1 - IDE Tools 10. Program Construction 10.1 - Translators 10.2 - Stages of Compilation 10.3 - Programming Errors 11. Technological Issues 11.1 - Impacts of Technology 11.2 - Legislation Component 2 (Programming Exam) Python Removed content from the 2016 Specification

  • 1.1 - The CPU - Eduqas GCSE (2020 spec) | CSNewbs

    Exam Board: Eduqas / WJEC 1.1 The Central Processing Unit (CPU) Specification: 2020 + 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 in 1.2 . Cache memory is used to temporarily store data that is frequently accessed . ​ Cache memory is split into different levels . Level 1 and level 2 (L1 & L2) are usually within the CPU and level 3 (L3) is just outside it. See 1.3 and 1.5 for more information about cache. You should know: The control unit is also known as the controller and cache memory is sometimes called internal memory . Computer Architecture The way a computer is designed and laid out is known as its architecture . ​ The most common type of computer architecture is Von Neumann . Von Neumann Architecture The CPU is the most important component in Von Neumann architecture as it is constantly fetching and decoding instructions from RAM and controlling the other parts of the system . ​ Von Neumann architecture also stores both instructions and data in memory . Being able to store programs in memory allows computers to be re-programmed for other tasks - this enables it to multitask and run several applications at the same time. ​ Data input and output is another key feature of this architecture. ​ An alternative architecture is Harvard , which features the control unit as the most essential component. Q uesto's Q uestions 1.1 - 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 four main components of the CPU. [ 4 ] ​ 3. Describe the purpose of: a. The Control Unit [ 2 ] b. The ALU [ 2 ] c. The registers [ 2 ] d. Cache memory [ 2 ] ​ 4a. Describe the key features of Von Neumann architecture . [ 3 ] 4b. Explain why storing data in memory is important. [ 1 ] 4c . State an alternative architecture . [ 1 ] Theory Topics 1.2 - The FDE Cycle

  • Scams & Staying Safe | Key Stage 3 | CSNewbs

    Scams & Staying Safe Part 1: Phishing Scams A phishing scam is when an attacker will send you an email pretending to be someone you trust . They are trying to get your username, password or other sensitive information . What does a phishing email look like? A phishing email might be sent from a long, unrecognisable email address . A phishing email might contain spelling mistakes , so look carefully. An attacker might not know your name , so they will use your email address. Check any links carefully , if it looks suspicious, don't click it. Phishing emails try to rush you into making a silly decision. Don't panic and read the email carefully. Part 2: Secure webpages When you are browsing the web , you should stick to websites that you know and trust. Don't click on any links that you don't recognise , especially from strangers . How do i know a web page is secure? HTTP is a protocol (set of rules) for displaying a web page . ​ If the web address at the top of your web browser starts with HTTP then it is not secure . ​ Do not enter any personal information on an insecure web page. HTTPS is a protocol (set of rules) for displaying a secure web page. If you see a padlock in the address bar of your web browser then you know it is safer to enter information . Part 3: Strong passwords Your passwords must be secure so they cannot be broken easily. How to choose a strong password: ********* Passwords should be more than at least 8 characters long. Passwords should use numbers and punctuation marks . Aa Bb Cc Dd Ee Passwords should use uppercase and lowercase letters . You should use a different password for each account that you have. Passwords should not use words found in the dictionary . KS3 Home

  • Malware | Key Stage 3 | CSNewbs

    Malware Malware is any type of harmful program that seeks to damage or gain unauthorised access to your computer system. Part 1: SiX Types of Malware Virus A virus can replicate itself and spread from system to system by attaching itself to infected files . A virus is only activated when opened by a human . Once activated, a virus can change data or corrupt a system so that it stops working . Trojan A trojan is a harmful program that looks like legitimate software so users are tricked into installing it . A trojan secretly gives the attacker backdoor access to the system . Trojans do not self replicate or infect other files. Ransomware Ransomware locks files on a computer system using encryption so that a user can no longer access them. The attacker demands money from the victim to decrypt (unlock) the data . ? ? Attackers usually use digital currencies like bitcoin which makes it hard to trace them. Spyware Spyware secretly records the activities of a user on a computer. The main aim of spyware is to record usernames, passwords and credit card information . All recorded information is secretly passed back to the attacker to use. Keylogger A keylogger secretly records the key presses of a user on a computer. Data is stored or sent back to the attacker. The main aim of a keylogger is to record usernames, passwords and credit card information . Keyloggers can be downloaded or plugged into the USB port . Worm A worm can replicate itself and spread from system to system by finding weaknesses in software . A worm does not need an infected file or human interaction to spread. A worm can spread very quickly across a network once it has infiltrated it. Part 2: Four ways malware cAN infect your system 1. A ccidentally downloading an infected file from an insecure website . 2. Phishing emails - clicking on attachments or links in spam emails . 3. Installing malware from a physical device, e.g. USB stick . 4. Self-replicating malware , such as worms , spreading across a network . Phishing & Staying Safe

  • Desktop Publishing | CSNewbs

    Desktop Publishing (DTP) What is DTP? Desktop Publishing (DTP) software allows people to create documents with a mixture of graphics and text . Examples of desktop publishing software are Microsoft Publisher and Serif PagePlus . ​ Desktop publishers can be used to produce documents such as business cards, leaflets, brochures, newspapers, magazines and newsletters . DTP software can be cheap and printers at home are more common these days so people can design and print their own documents. Professional-looking documents can be made simply and without an extensive knowledge of graphic design. ​ The biggest advantage of using DTP is that it is frame based . Text and picture frames can be laid out on the page, and rotated, moved or resized as necessary. It is easy to import images from clip art or the web. ​ The view of the page is known as WYSIWYG (W hat Y ou S ee I s W hat Y ou G et) because the view on the computer will be very similar to what you get when it is printed. What to consider when using DTP Orientation Will your document be landscape or portrait ? Some document types are more commonly one orientation than the other. For example, business cards are generally landscape but newsletters are more often portrait. ​ Size The size of a typical piece of paper is A4. But that is too large for most DTP documents. The larger the number, the smaller the piece of paper . A5 is half the size of A4 and A3 is twice the size of A4. Documents can also be measured in millimetres, for example, an appropriate business card size is 85mm wide and 55mm high. House Style A house style is a set of rules to ensure that each document made by a person or company is part of an identity . To be consistent , each document should use the same logo, titles, colours, graphics and layout . For example, the NHS always uses a blue colour, the same logo and similar layout on each of its documents. Some companies have perfected their house style so that they are synonymous with a single colour - e.g. McDonald's use yellow and Coca-Cola use red and white . DTP Documents Business Cards A business card is a small piece of card that must be simple and stylish . The purpose of a business card is to clearly state the contact details of a person or company. Sharing your business card with other people is one way to promote your business or skills to attract new business partners or customers. A business card must be uncluttered and clearly display relevant contact information, such as an email address, phone number or physical address. Today, business cards may also state social media contacts, such as Facebook pages or Twitter accounts. Flyers A flyer is a small handout that advertises an event or new product. ​ The purpose of a flyer is to clearly and quickly promote an event . It must be eye-catching and to-the-point so that people can immediately understand what it is about. Flyers are often handed out in the street or posted through letterboxes so if it is not clear people will just ignore it. ​ A flyer should use a large title to promote the event, as well as appropriate graphics and information about the date, location and time. It should also contain contact details including a telephone number, website and email address. Posters A poster is a large piece of paper that is put up to advertise an event and display more information than a flyer . ​ Posters should promote an event by using large titles and graphics to clearly describe where the event is taking place, when it is and why people should go. Because there is much more space on a poster than a flyer, additional information can be added and some kind of persuasion to entice passers by to attend. Leaflets A leaflet is a small folded handout that provides more information about an event or new product. ​ The purpose of a leaflet is to give additional details about an event . It can be used before an event to describe the different parts, such as the different acts in a circus or different bands at a festival. It can also be used during an event, such as at a school fair to list the different stalls. Because it is folded over it can display a large amount of information, with both text and graphics . ​ The front of the leaflet should clearly display the purpose of it and the text inside must be readable with images to break up the words. There may also be contact information inside the leaflet, such as directions to a website or social media page .

  • Key Stage 3 Python | Turtle | CSNewbs

    Python - #6 - Turtle Import the Turtle The turtle library stores all of the code to create and move an object called a turtle . ​ The turtle library must be imported into your Python program before you can use it to draw lines, shapes and colours . Create a new Python program and save the file as PythonTurtle . ​ Write import turtle as the first line of code. Basic Shapes The turtle can be controlled by writing how many pixels it should travel forward and the angle it should point left or right . Moving Forwards turtle.forward(100) will move the turtle forward by 100 pixels. ​ turtle.forward(200) will move the turtle forward by 200 pixels. ​ ​ ​ ​ When using the left command or the right command, the turtle won't actually move , but it will rotate by the number of degrees that you state. ​ For example, typing turtle.left(90) will point the turtle upwards . Rotating Left & Right Copy the code to the right to make the turtle draw a square. ​ Then try to make: A Rectangle A Triangle A Pentagon A Hexagon Square Rectangle Triangle Pentagon Hexagon Hint: To work out the angles, divide 360 by the number of sides. Using Loops You can use a for loop to repeat code . ​ This is especially helpfully with intricate shapes with many sides. ​ The code below will print a square but in only 3 lines instead of the 8 lines from task 2. This is the number of times the code underneath will be repeated . ​ Change it to a higher number to repeat it more often . Each line after the 'for num in range' line must be indented . ​ Press the tab key once on your keyboard to indent your code. Task 3 - Copy the code above to make the turtle draw a square using a loop. ​ Then try to make: A Heptagon An Octagon A Circle A Pentagram (5-sided Star) Square Heptagon Octagon Circle Pentagram Hint: To work out the angles, divide 360 by the number of sides. Advanced Features Choose a background colour turtle .bgcolor("red") Choose the line size and colour turtle.pensize(6) turtle.color("green") Fill a shape turtle.color("yellow") turtle.begin_fill() (put your turtle's directions in here) turtle.end_fill() ​ Lift the pen turtle.penup() turtle.pendown() Speed up/Slow down the turtle turtle.speed(speed=10) ​ Change the turtle's appearance turtle.shape("turtle") Other options include "circle" and "arrow". Task 4 - Use the code above to make: ​ A blue square on a red background. A yellow triangle on a pink background. Two different coloured circles - not touching each other. Three different shapes of three different colours - not touching each other. Complex Shapes Use everything that you have learned on this page to help you create more complex shapes. ​ You could try: ​ A Flower A Word (like your name - you will need to use the penup() and pendown() commands. A Christmas tree A Landscape (green ground, blue sky, yellow sun) ​ <<< Selection

  • Key Stage 3 Python | Turtle | CSNewbs

    Python - Iteration For Loops Editor Execute A for loop is a count controlled loop. ​ It repeats for a certain number of times as stated in the range brackets. ​ The first number (1) states the number to start on . ​ The second number is an exclusive end . This means it actually finishes on the number before . (11 will end on 10). You need a colon at the end of the loop line . ​ Each line to be repeated must be indented (press the tab key). ​ You can use the loop number within the loop itself. 1. Write a for loop to print your name 8 times . (Count it to double-check it prints eight times.) ​ 2. Use a for loop to print each number between 10 and 50 . ​ 3. Use a for loop from 1 to 10 . Print the 3 times table by multiplying number by 3 underneath the loop. ​ 4. Ask the user to input a whole number (call it num1 ). Write num1 in your range brackets to repeat any message that many times. 5. Ask the user to input a whole number (call it num1 ) and then input a word . Print the word by the number they entered . (Hint: Use num1 in the range.) ​ 6. Delete your code and copy these 3 lines: ​ #Delete the space after the colon for number in range(0,21,2):​ print(number) ​ What happens when you run this code? ​ 7. Use Q6 to help you print 0 to 100 , going up in 5s . Think about the 3 values you need in the range brackets. ​ 8. Use Q6 to help you print 100 down to 0 , backwards by 1 . Think about the 3 values you need in the range brackets. Tasks While Loops Editor Execute A while loop is a condition controlled loop . ​ While loops repeat as long as the condition is true . As soon as the condition becomes false , the loop will end . 1. Change the program in the editor to repeat the loop while a number is not equal to 33 . ​ 2. Make a new while loop that asks the user to enter a whole number . While the number is less than or equal to 1000 , keep repeating. ​ 3. Make a new while loop for while a colour is not equal to purple (or any colour you want). Ask the user to enter a colour inside of the loop . Don't forget to set colour to "" before you start. ​ 4. Edit your colour program to count how many guesses were made. Make a new variable called count and set it to 0 at the start of the program. Increase it by 1 in the loop, using count = count + 1 . 5. While a total is less than 100 , ask the user to input a decimal number . When it is over 100 , print ‘COMPUTER OVERLOAD’ . You need a variable called total . Increase the total each time with total = total + number . Don't forget to start it at 0 . Tasks != means ‘not equal to ’. The loop below will repeat as long as the password is not equal to “abc123” . Any variable you use in your condition must have a value first . You can’t check for your password if it doesn’t exist. That’s why I have written password = “” , to give password a value before we check it .

  • Memory | Key Stage 3 | CSNewbs

    Memory What is memory? Memory, also known as primary storage, is used by a computer to store data and instructions . ​ Memory is quick because the CPU can access it directly . ​ Memory is important because it allows the computer to multi-task . Types of Memory RAM ( R andom A ccess M emory) RAM is volatile (this means that when power is lost, the data is deleted ). Every program that is being run by the computer (such as Google Chrome, Spotify or Microsoft Word) is stored in RAM . RAM is made up of a large number of storage locations , each can be identified by a unique address . ROM ( R ead O nly M emory) ROM is non-volatile (this means that data is saved, even when the power is off ). The start-up instructions (for when a computer is turned on) are stored in ROM . ROM is read-only, which means that it cannot be edited or changed . Cache Memory Cache memory is fast to access because it is very close to the CPU . Cache memory stores data that needs to be accessed very frequently . Cache memory is very expensive , so there is only a small amount in most computers. How can you make a computer faster? If you are trying to run too many programs at the same time , ​there might not be enough space in RAM . ​ Try closing applications and processes that you do not need. Persistently slow computers could be helped by increasing the amount of RAM on the motherboard. KS3 Home

bottom of page