Search CSNewbs
304 results found with an empty search
- HTML Guide 3 - Text Tags | CSNewbs
Learn how to use tags to format text in HTML, including how to underline, italicise and embolden text. Also, learn about heading size and paragraphs. 3. Tags for Text HTML Guide Watch on YouTube: Remember to write the tags for everything you want the user to see between the and tags. Headings Time to add text to your web page such as headings and paragraphs. To write a large heading , use and To write headings in a smaller size, use numbers between 1 and 6. Add a large heading and a sub-heading to your webpage. paragraph Paragraphs Typing text between the and tags will create a paragraph . Add at least three different paragraphs to your webpage. bold underline italics Bold, Underline & Italics You can format your text by changing it to be bold , underlined or italicised (slanted). Now you have text on your web page, you can add hyperlinks to take viewers to different websites. In the paragraphs you have already written, add at least 1 bold tag, 1 underline tag and 1 italics tag. 2. Essential Tags HTML Guide 4. Hyperlinks
- Python | 1c - Creating Variables | CSNewbs
Learn how to create variables in Python. Try practice tasks and learn through text and images. Perfect for students learning GCSE Computer Science in UK schools. top Python 1c - Creating Variables What is a Variable? A variable represents a value that can change as a program is running . The two parts of a variable are the name (e.g. sweets) and the value (e.g. 8). sweets = 8 print (sweets) = 8 amount of sweets = 8 8sweets = 8 sweets A variable can't contain spaces , it must start with a letter , and you must declare its value before you can use or print it. 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 eats a sweet then the value of our variable changes: sweets = 8 print (sweets) sweets = 7 print (sweets) = 8 7 sweets = 8 print ( Sweets) You must be consistent with capital letters when writing variable names. sweets and Sweets are treated as two different variables. Creating Variables Task 1 ( Age & Pets) Make a variable named age and set it to your current age. On the next line print age . Make another variable named pets and set it to how many pets you have. On the next line print pets . Example solution: 14 2 Variables with Strings (Text) In programming, a collection of alphanumeric characters (letters, numbers and punctuation) is called a string . "Pikachu" is a string. In the example below, pokemon is the variable name that represents the variable value "Pikachu" . pokemon = "Pikachu" print (pokemon) = Pikachu To create a string, we use "speech marks" . Numbers by themselves and variable names do not use speech marks. Each variable can only have one value at a time, but it can change throughout the program. pokemon = "Pikachu" print (pokemon) pokemon = "Squirtle" print (pokemon) = Pikachu Squirtle Creating Variables Task 2 ( Superhero & Colour ) Make a variable named superhero and set it to any of your choice, such as "Spider-Man" . Print the superhero variable on the next line. Make another variable named colour and set it to the colour related to your chosen superhero. Print the colour variable on the next line. Example solutions: Spider-Man Red The Hulk Green ⬅ 1b - Co mmenting 1d - Using Variables ➡
- Motherboard | Key Stage 3 | CSNewbs
Learn about the motherboard and the components that are connected to this important piece of computer hardware. The Motherboard What is a motherboard? The motherboard is the main circuit board of a computer that links all other components together. Components can communicate by sending signals and data across pathways called buses . Some components, like the CPU and RAM , are directly installed in special sockets on the motherboard . There are expansion slots for further components like a graphics card . What is connected to the motherboard? Central Processing Unit Random Access Memory Graphics Processing Unit Read Only Memory Cache Memory Sound Card Hard Disk Drive Power Supply Unit What is a motherboard's form factor? Form factor relates to the motherboard's size , shape and how many components it can fit . The three most common form factors are compared below: ATX Micro ATX Mini ITX Standard Small Very Small 32 GB 64 GB 128 GB 7 4 1 Size Max RAM Expansion Card Slots GB stands for gigabytes What ports does a motherboard have? The motherboard contains several ports on the back panel , allowing cables to be connected to input or output data . Below are some of the common ports : USB (Type-A) Connects input devices like keyboards and mice or storage devices like a USB memory stick. USB (Type-C) A newer type of USB that is faster and commonly used to charge devices or transfer data. Ethernet Allows a device to connect to a wired network, most commonly to a router, for internet access. HDMI Connects to a monitor or TV to show the computer's audio and visual output. KS3 Home
- 3.1 - Planning Projects | F160 | Cambridge Advanced National in Computing AAQ
Learn about the importance of planning application development projects, including the advantages and disadvantages of planning and the consequences of not planning. Also covers planning considerations such as budget, time, resources, success criteria and legislation. Based on Unit F160 (Fundamentals of Application Development) for the OCR Cambridge Advanced National in Computing (H029 / H129) (AAQ - Alternative Academic Qualification). Qualification: Cambridge Advanced National in Computing (AAQ) Unit: F160: Fundamentals of Application Development Certificate: Computing: Application Development (H029 / H129) 3.1 - Planning Projects Watch on YouTube : Purpose of Planning Planning Considerations Planning Projects You need to know why it is important to plan an application development project , as well as the advantages and disadvantages of taking the time to plan . You must also consider the potential consequences if a development team decide not to plan their project. There are several considerations (e.g. budget , time and legislation ) that must be looked at in the planning stage and you need to know how these may impact application development . You need to be aware of copyright , data protection and electronic communication legislation , but for this unit , you do not need to know the details of any specific laws . Importance of Planning Projects Planning application development projects is important as it sets clear goals and direction for the project and identifies required resources (e.g. time , money , people and tools ). Other advantages include better organisation , as team members should know their roles and tasks . Also, planning improves time management as deadlines and milestones keep the project on track . However, there are disadvantages to planning as it takes time and can delay the start of development . Also, plans may become outdated if requirements unexpectedly change mid-project . Avoiding planning entirely will have consequences , such as a higher potential for missed deadlines and overrunning costs due to poor time / budget estimates . Goals may be unclear , leading to confusion , delays or an unusable product . Planning Considerations There are several considerations team members must carefully evaluate in the planning phase of application software development : The three types of legislation cover copyright , data protection and electronic communication . Q uesto's Q uestions 3.1 - Planning Projects: 1. A company developing smartphones is considering whether to skip the planning stage and move straight to design. Give two advantages and two disadvantages of planning and two consequences of not planning an application development project . [6 ] 2. Summarise the impact of the three identified types of legislation on application development . [6 ] 3. Justify which planning consideration you think has the biggest potential impact on the success of a software application development project and why . [ 3 ] 4. Describe the impact of three planning considerations (other than legislation and the one you chose in Q3 ) on application development . [6 ] If a company seriously breaches the Data Protection Act , it can be fined up to £17.5 million or 4% of its global turnover , whichever is higher . D id Y ou K now? 2.2 - Phases of Development Models Topic List 3.2 - Project Planning Tools
- Python | Extended Task 4 | CSNewbs
Test your ability to create a more complex program in Python based on a given scenario. Perfect for students learning GCSE Computer Science in UK schools. Extended Task 4 Hi, Jacob Mortimer here from Cats & Dogs Veterinary Surgery . There was a flood last week, and our computer systems were totally destroyed . I need you to create a program , using a file , that allows my receptionist to: Add new animals to the file . Search through the file and print the details of a specific animal . Allow a specific animal to be removed from the file . Vet Surgery For this task, you will need to create a document and include the following sections (with screenshots where appropriate): An introduction to explain the Purpose of your program . A List of Requirements for a successful program. Screenshots of your code (with comments in your code to show understanding). Testing – Create a plan to show how you will test your program and then explanations of any errors that you found and how they were fixed . An Evaluation of what worked, what didn’t, and how you met each of your requirements from your original list. Also, discuss further improvements that you could have made to improve your program. Reminders for this task: You will need to create a selection of options for the user to choose from. Subroutines and a while true loop may help. Section 10 will help you to open, write and read from files . Section 10c shows how to edit data in a file. You will need to adapt this code and not write the line that has been selected, instead of writing a modified version of it. There are multiple ways to approach this program, and your solution might look different from the example. Break the problem down and focus on one part at a time. Example solution: Entering 1 allows the user to enter the details of a new animal which is saved into the file . Entering 4 will stop the loop and ends the program. Entering 2 allows the user to enter the details of an animal to search for . If the animal is in the file, their details are printed clearly on a new line. Entering 3 allows the user to enter the details of an animal to remove from the file . If the animal is in the file, all lines are transferred into a temporary file except for the line to be removed . ⬅ Extended Task 3 (Blackjack) Extended Task 5 (Colour Collection) ➡
- HTML List of Tags | CSNewbs
A complete list of tags required for students to know how to use in the 2016 Eduqas GCSE specification. Follow the links on each tag to see how to use them. Here you can find a list of tags. Click a tag to see how to use it. Tags for Eduqas GCSE:
- Download Greenfoot | CSNewbs
A tutorial to understand how to create a game in Greenfoot. A simple step-by-step guide and walkthrough featuring all code needed for the Eduqas GCSE 2016 specification. Installing Greenfoot Greenfoot Home According to the Eduqas 2016 specification exam students will use version 2.4.2 of Greenfoot in the Component 2 exam . Eduqas GCSE students should practice using version 2.4.2 - despite the most up-to-date version currently being 3.6.1. If you are not learning Greenfoot for the Eduqas GCSE then you may wish to download and use the most current version. Eduqas 2016 Specification Students Other Students The version used in the Component 2 exam is 'Greenfoot version 2.4.2 '. Scroll down to 2.4.2 on the old download page and select the correct version for your computer. Windows systems should use the 'For Windows ' option. If you are not following the Eduqas 2016 specification then you should download the most up-to-date version of Greenfoot. Select the correct version for your computer at the top of the download page .
- App Inventor 2 | Munchin' Pizza | CSNewbs
Learn how to use App Inventor 2 to create simple programs. Try to complete task 3 on this page. Perfect for Key Stage 3 students to experiment with block coding, objects and properties. App Inventor Task 3 - Munchin' Pizza This page will teach you how to make a simple app that changes pictures when a button is pressed . You can make the app more complex by adding sounds or additional buttons. Step 1: Set up App Inventor 2 Open App Inventor 2 (use the button on the right) and create a new project. You will need to log in with a Google account. Download the picture images from the zipped folder on the App Inventor 2 Basics page here . Once you have downloaded the pizza pictures you will need to upload them. Find the Media tab on the right side of App Inventor and click 'Upload File...' You will need to upload each picture individually. In the Palette tab on the left side, drag two buttons into the middle screen so they look like this: In the Components tab on the right, click on Button1 and click the Rename button at the bottom to change it to Pizza . Then Rename Button2 to Munch . This will help us when we code later as it will be less confusing. Click on the second button (Munch) that you just dragged into the centre then look in the Properties tab on the right and scroll down to Text . Change 'Text for Munch' to something like 'Munch Pizza' . Now click on the first button in the centre (Pizza) and in the Properties tab, click on Image and select the first image. It should be the full slice of pizza. When you have set the image, you might notice it goes a bit crazy. Still in the Properties tab, change the Height and Width to 'Fill parent...' for both. This will make the image fit within the boundaries of the screen. Finally, change the Text for the Pizza button to be blank. Otherwise it will appear on top of the pizza and look odd. So far you should have a button disguised as a pizza and another button that tells you to munch that lovely cheesy deliciousness. If your program does not look like this, read the instructions above again carefully. Step 2: Code Click on the Blocks button in the top right to start adding code. In the Blocks tab on the left side click on Munch and drag the when Munch Click block into the centre. This block will execute any code inside of it whenever the munch button is clicked. In the Blocks tab on the left side click on Logic and drag an if then block and snap it inside the block you just dragged over. Click on the blue cog button and drag four else if blocks inside the if block at the bottom. The blocks at the top will automatically update when you drag the blocks under the if block underneath. Because we are using different images, we need to check which image is currently being displayed, so we know which picture to change to. Firstly we want to check if the first image is being displayed. Connect an = block from the Logic section. Then add a Pizza Image block from the Pizza section. Lastly grab a " " block from the Text section and write the name of your first image inside (e.g. pizza1.jpg) Don't forget the extension (.jpg). But what does this code actually mean? It is checking to see what the current pizza image is. And if it is pizza1.jpg then it is going to... ...change the picture to pizza2.jpg, as if someone has munched the pizza! Grab a set Pizza Image to block from Pizza and then snap another " " block from Text and add the pizza2.jpg text inside. Now that we have written the code to check the current picture and move it to the next one when pressed, we just need to copy this for the other four pizza pictures. Rather than select all the blocks again, right-clicking on the blocks and selecting 'Duplicate' will copy them. Copy each block and then change the values so that if pizza2.jpg is the current image, then it sets it to pizza3.jpg and so on. Make sure that pizza5.jpg sets the image to pizza1.jpg so that it goes round in a loop. Program 3 Complete! Step 3: Run The easiest way to run an app that you have created at home using App Inventor 2 is to download the free MIT AI2 Companion App on your smartphone from the Google Play Store . At the top of the App inventor program on your computer , click on Connect and AI Companion . This will generate a six-digit code you can type into your phone. If your school has the emulator installed, you can also use this to test your app. Extra Step: Challenges 1. Create your own images and upload them . You can easily create your own set of pictures and link them together. Why not try: Eating a different type of food (e.g. cookie or doughnut). A simple scene that changes from night to day. A simple character that changes appearance (like Pikachu powering up a thunder strike with each button press). 2. Add a sound effect whenever a button is pressed . In the video at the top of the page, you'll see I have a 'munch' sound whenever the button is pressed. You could record this sound yourself or use a sound effect site. Once you have got your sound file (it should be short and .mp3) you need to upload it, just like you uploaded your images. In the Designer layout click 'Upload file...' in the Media tab on the right. Then look in the Palette tab on the left side, open the Media section and drag a Sound block into the centre. It will appear underneath the phone screen in a section called 'non-visible components' which is fine. Now click on Properties on the right side and choose the sound file you just uploaded in the Source box. Click on the Blocks button in the top right to start adding the code! In the Blocks tab on the left side, click on Sound1 and drag the call Sound1 Play block directly underneath when Munch click . This will play the sound everytime the button is pressed. 3. Add more buttons . You could add a second clickable button which reverses the pattern and a third button that resets the order back to the first image. Adding new buttons is easy - drag them from the Palette tab in the Designer layout. Change the button text in the Properties tab and the name of the button in the Components tab. To add code, click on Blocks in the top right then you can duplicate the code for Munch by right-clicking and choosing Duplicate. Now just change the values to what you want. If you are making a reset button, you don't need an if then statement, just set the image to your first image when the button is clicked. Keep messing around with the program and have fun! KS3 Home Tasks 4, 5 & 6
- Python | 8a - Using Lists | CSNewbs
Learn how to create and use lists in Python. Try practice tasks and learn through text and images. Perfect for students learning GCSE Computer Science in UK schools. top Python 8a - Using Lists Lists A list is a temporary data structure . Any changes made to the list while the program is running will not be saved the next time it is run . Data can be added to and removed from lists so they can change in size (unlike an array which is fixed and not used in Python). It is important to note that each data element in a list has an index so that it can be specifically referenced (to delete it for example) and that indexes start at 0 . A list of the rainbow colours in order would start at 0 like this: Creating & Printing Lists Lists use square brackets in Python. Separate list items with commas . Strings must use speech marks and integers do not use speech marks. people = [ "Alan" , "Jesse" , "Max" , "Jack" ] years = [ 2010, 2019, 2001, 2016 ] There are many different ways to print items from a list depending on how you want it to look . Print all items on one line Type the list name into a print command to output the complete list . Typing an asterisk * before the list name removes punctuation . cities = [ "Shanghai" , "Sao Paolo" , "Bishkek" , "Asmara" ] print (cities) cities = [ "Shanghai" , "Sao Paolo" , "Bishkek" , "Asmara" ] print (*cities) ['Shanghai', 'Sao Paolo', 'Bishkek', 'Asmara'] Shanghai Sao Paolo Bishkek Asmara Print each item on a separate line To print a list line-by-line use a for loop to cycle through each item. 'city ' is just a variable name and can be replaced with the traditional 'i ' or anything relevant to the context, such as 'colour ' in a list of colours or 'name ' in a list of people. cities = [ "Shanghai" , "Sao Paolo" , "Bishkek" , "Asmara" ] for city in cities: print (city) Shanghai Sao Paolo Bishkek Asmara Print separated items on one line To print separated data elements on the same line then you can use the end command which defines what should go after each item . The example below uses slashes but end = " , " would add comma and space between each element. cities = [ "Shanghai" , "Sao Paolo" , "Bishkek" , "Asmara" ] for city in cities: print (city, end = " / " ) Shanghai / Sao Paolo / Bishkek / Asmara / Print specific list items To print an element with a certain index , put the index in square brackets . But remember that the index starts at 0 not 1. cities = [ "Shanghai" , "Sao Paolo" , "Bishkek" , "Asmara" ] print ( "The first city is" , cities[0]) print (cities[2], "is the third city" ) The first city is Shanghai Bishkek is the third city Create a list of five different of foods . Print all list items on one line . Then print each item on a different line . Finally print just the first and fifth items . Example solution: lettuce yoghurt tomato artichoke tuna lettuce yoghurt tomato artichoke tuna The first item is lettuce The fifth item is tuna Lists Task 1 (Five Foods ) Lists Task 2 (Four Numbers ) Create a list of four integer values . Print all list items on one line separated by colons . Example solutions: 345:123:932:758: 812:153:783:603: Add (Append / Insert) to a List Append items to the end of a list To add a new item to the end of a list use the .append() command. Write .append() after the name of your list, with the new data in brackets . pets = [ "dog" , "cat" , "hamster" ] pets.append( "rabbit" ) print (*pets) fillings = [ "ham" , "cheese" , "onion" ] extra = input ( "Enter another filling: " ) fillings.append(extra) print ( "Your sandwich:" , *fillings) dog cat hamster rabbit Enter another filling: lettuce Your sandwich: ham cheese onion lettuce Insert items to a specific index Use the insert command to place an item in a specific position within the list. Remember that Python counts from 0 so the medals example below puts "silver" as index 2 , which is actually the 3rd item . medals = [ "platinum" , "gold" , "bronze" ] medals.insert(2, "silver" ) print (*medals) names = [ "Stacy" , "Charli" , "Jasper" , "Tom" ] name = input ( "Enter a name: " ) position = int ( input ( "Enter an index: " )) names.insert(position,name) print (*names) platinum gold silver bronze Enter a name: Lena Enter an index: 0 Lena Stacy Charli Jasper Tom Enter a name: Pat Enter an index: 3 Stacy Charli Jasper Pat Tom Use a loop to add items to a list A for loop can be used to add a certain number of items to a list. A while loop can be used to keep adding values until a certain value (e.g. ' stop ' or ' end ') is input. animals = [ ] for i in range (4): animal = input ( "Enter an animal: " ) animals.append(animal) print ( "\nAnimals:" , *animals) animals = [ ] while True : animal = input ( "Enter an animal: " ) if animal == "stop" : break else : animals.append(animal) print ( "\nAnimals:" , *animals) Enter an animal: lion Enter an animal: horse Enter an animal: hyena Enter an animal: squirrel Animals: lion horse hyena squirrel Enter an animal: rhino Enter an animal: gazelle Enter an animal: deer Enter an animal: stop Animals: rhino gazelle deer Example solution: Lists Task 3 (Favourite Musicicans ) Create a list of three musicians or bands you like . Print the list . Then append two new bands using two inputs . Print the list again. Use the sandwich filling example for help. Musicians I like: Lana Del Rey Devon Cole Elly Duhé Enter another musician: Charli XCX Enter another musician: Kenya Grace Musicians I like: Lana Del Rey Devon Cole Elly Duhé Charli XCX Kenya Grace Lists Task 4 (Missing 7 ) Create a list of numbers in order from 1 to 10 but miss out 7 . Use the insert command to add 7 in the correct place . Print the list before and after you insert 7. Example solution: 1 2 3 4 5 6 8 9 10 1 2 3 4 5 6 7 8 9 10 Lists Task 5 ('Land' Countries ) Use a while True loop to input countries that end in 'land' until the word 'finish ' is input . Print the list at the end. Note: You do not need to check if the countries entered are correct. There are also more than four. Example solution: Enter a country ending in 'land': Iceland Enter a country ending in 'land': Poland Enter a country ending in 'land': Switzerland Enter a country ending in 'land': Thailand Enter a country ending in 'land': finish Country list: Iceland Poland Switzerland Thailand Delete (Remove/Pop) from a List Delete items with a specific value To delete data with a certain value use the .remove() command, with the value in brackets . trees = [ "fir" , "elm" , "oak" , "yew" ] trees.remove( "elm" ) print (*trees) fir oak yew trees = [ "fir" , "elm" , "oak" , "yew" ] tree = input ( "Select a tree to remove: " ) trees.remove(tree) print (*trees) Select a tree to remove: oak fir elm yew Delete items with a specific index To delete data in a specific position in your list use the .pop() command, with the position in the brackets . Remember that indexes start at 0 so .pop(0) removes the first item . Negative values start from the end of the list , so -1 is the final item and -2 is the second last item and so on. kitchen = [ "plate" , "cup" , "spoon" , "jug" ] kitchen.pop(0) print (*kitchen) kitchen = [ "plate" , "cup" , "spoon" , "jug" ] kitchen.pop(-2) print (*kitchen) kitchen = [ "plate" , "cup" , "spoon" , "jug" ] index = int ( input ( "Select an index: " )) kitchen.pop(index) print (*kitchen) cup spoon jug plate cup jug Select an index: 1 plate spoon jug Delete all items in a list To delete data in a list use the .clear() command. insects = [ "ant" , "bee" , "wasp" ] insects.clear() insects.append( "hornet" ) print (*insects) hornet Lists Task 6 (Day Off ) Example solution: Create a list with the five week days . Ask the user to input a weekday and remove that day from the list. Print the list. Which day do you want off? Tuesday Your new days of work: Monday Wednesday Thursday Friday Lists Task 7 (May and October ) Create a list with the twelve months in order . Delete May and then October using the pop command by referring to their indexes in the list. Print the list. Note: Be aware the index of each month after May will change when May is popped from the list. Example solution: January February March April June July August September November December Finding the Length of a List To find the length of a list use the len function. You can create a separate variable for the length (shown in the first example below) or use the len command directly (second example). states = [ "Maine" , "Utah" , "Ohio" , "Iowa" ] length = len (states) print ( "There are" , length , "states in the list." ) states = [ "Maine" , "Utah" , "Ohio" , "Iowa" ] print ( "There are" , len (states), "states in the list." ) There are 4 states in the list. Lists Task 8 (Q Words ) Use a while True loop to input words beginning with q until the word ' stop ' is entered. Then use len to find the length of the list and print this value. Note: You do not need to check if the entered words actually start with q. Example solution: Input a Q word: question Input a Q word: quick Input a Q word: quiet Input a Q word: quandry Input a Q word: stop You wrote 4 Q words! Cycle Through List Items A for loop can be used to cycle through each item in a list. The following examples present some ways that this may be used. This program uses a for loop to add a word (David) before each list item. davids = [ "Beckham" , "Attenborough" , "Schwimmer" , "Tennant" , "Lynch" ] for i in range (5): print ( "David" , davids[i]) David Beckham David Attenborough David Schwimmer David Tennant David Lynch An if statement can be used within a for loop to check the value of each item . The example below checks how many items are 'medium'. sizes = [ "small" , "medium" , "small" , "large" , "medium" , "small" ] count = 0 for i in range (6): if sizes[i] == "medium" : count = count + 1 print ( "There were" ,count, "medium choices." ) There were 2 medium choices. The program below uses a while loop to allow entries until 'stop ' is input then a for loop to check the value of each item . Because the final length of the list is not known when the program starts, the len command is used in the range of the for loop . sports = [] fcount = 0 rcount = 0 while True : option = input ( "Choose football or rugby: " ) sports.append(option) if option == "stop" : break for i in range ( len (sports)): if sports[i] == "football" : fcount = fcount + 1 elif sports[i] == "rugby" : rcount = rcount + 1 print ( "\nResults:" ,fcount, "people chose football and" ,rcount, "chose rugby." ) Choose football or rugby: rugby Choose football or rugby: rugby Choose football or rugby: football Choose football or rugby: rugby Choose football or rugby: football Choose football or rugby: stop Results: 2 people chose football and 3 chose rugby. Lists Task 9 (Over 25 ) Create a list with the following eight numbers: 13, 90, 23, 43, 55, 21, 78, 33 Use a for loop to cycle through the list and check if each item is over 25 . Use a count variable to increase by 1 if the number is over 25. At the end print how many numbers are over 25 - there are five . Example solution: 5 numbers are over 25. Lists Task 10 (Favourite Lesson ) Use a while True loop to keep inputting school subjects until ' done ' is entered. Keep a count of how many times ' Maths ' is entered. Print the total number of people who entered maths. Example solution: Enter a subject: English Enter a subject: Maths Enter a subject: Art Enter a subject: Maths Enter a subject: History Enter a subject: done There were 2 people who chose maths. Sorting Lists The .sort() command will sort elements in a list into alphabetical order (if a string ) or numerical order (if a number ). names = [ "Robb" , "Jon" , "Sansa" , "Arya" , "Bran" , "Rickon" ] print ( "Original:" , *names) names.sort() print ( "Sorted:" , *names) Original: Robb Jon Sansa Arya Bran Rickon Sorted: Arya Bran Jon Rickon Robb Sansa numbers = [56,98,23,12,45] numbers.sort() print (*numbers) 12 23 45 56 98 The .sort() command can be used to sort values in descending order by including reverse = True in the brackets. names = [ "Robb" , "Jon" , "Sansa" , "Arya" , "Bran" , "Rickon" ] print ( "Original:" , *names) names.sort(reverse = True ) print ( "Sorted:" , *names) Original: Robb Jon Sansa Arya Bran Rickon Sorted: Sansa Robb Rickon Jon Bran Arya numbers = [56,98,23,12,45] numbers.sort(reverse = True ) print (*numbers) 98 56 45 23 12 Lists Task 11 (Sorted Fruit ) Example solution: Use a for loop to append six fruits to an empty list. Sort the list into alphabetical order and print it. Enter a fruit: strawberry Enter a fruit: kiwi Enter a fruit: lemon Enter a fruit: pear Enter a fruit: orange Enter a fruit: mango Sorted fruit: kiwi lemon mango orange pear strawberry Searching Through Lists A simple if statement can be used to see if a certain value appears within a list. names = [ "Alex" , "Bill" , "Charlie" , "Darla" ] name = input ( "Enter a name: " ) if name in names: print ( "Yes," , name , "is in the list." ) else : print ( "Sorry," , name , "is not in the list." ) Enter a name: Bill Yes, Bill is in the list. Enter a name: Sadie Sorry, Sadie is not in the list. Lists Task 12 (Packed Suitcase ) Example solutions: Create a list with five items to take on holiday. Ask the user to input an item and use an if statement to check if it is or isn't in the list. What should I pack? sun cream I've already packed sun cream What should I pack? toothpaste Whoops! I forgot to pack toothpaste Calculating the Sum of a List To calculate the sum of a list of numbers there are two methods. Using Python's built-in sum function : numbers = [1,4,2,3,4,5] print ( sum (numbers)) Both methods will result in the same output : 19 Using a for loop to cycle through each number in the list and add it to a total . numbers = [1,4,2,3,4,5] total = 0 for number in numbers: total = total + number print (total) Lists Task 13 (Sum and Average ) Example solution: Use a for loop to ask the user to input 5 numbers and append each to a list. Use the sum command to output the total and use it calculate the average . Enter a number: 6 Enter a number : 7 Enter a number : 6 Enter a number : 9 Enter a number : 4 The total is 32 The average is 6.4 Extending a List .extend() can be used in a similar way to .append() that adds iterable items to the end of a list . This commands works well with the choice command (imported from the random library ) to create a list of characters that can be randomly selected. The code below adds a lowercase alphabet to an empty list and then, depending on the choice of the user, adds an uppercase alphabet too. The choice command is used in a loop to randomly select 5 characters. Using .extend() to make a random 5-character code from random import choice list = [] list. extend ( "abcdefghijklmnopqrstuvwxyz" ) upper = input ( "Include uppercase letters? " ) if upper == "yes" : list. extend ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) code = "" for number in range (5): letter = choice (list) code = code + letter print ( "Your five character code is" , code) Possible outputs: Include uppercase letters? yes Your five character code is yPfRe Include uppercase letters? yes Your five character code is GJuQw = Include uppercase letters? no Your five character code is gberv Extend treats each character as an indidual item whereas append adds the whole string as a single entity . Most of time append would be used, but extend is suitable for a password program as additional individual characters can be added to a list depending on the parameters (e.g. lowercase letters, uppercase letters, numbers and special characters). list = [] list. extend ( "ABCD" ) list. extend ("EFGH" ) print (list) list = [] list. append ( "ABCD" ) list. append ("EFGH" ) print (list) ['A','B','C','D','E','F','G','H'] ['ABCD' , 'EFGH'] = = Practice Task 14 Use the code above (for a 5-character code ) to help you make a password generator . Ask the user if they want uppercase letters , numbers and special characters and use the extend command to add them to a list of characters if they type yes (you should extend lowercase characters into an empty list regardless, like in the code above). Use a for loop and the choice command (imported from the random library) to randomly generate a 10-character password . Example solutions: Include uppercase letters? yes Include numbers? yes Include special characters? yes Your new password is RjWSbT&gW5 Include uppercase letters? no Include numbers? yes Include special characters? no Your new password is hdf8se9y2w ⬅ Section 7 Practice Tasks 8b - 2D Lists ➡
- App Inventor 2 | Pop-up Blob | CSNewbs
Learn how to use App Inventor 2 to create simple programs. Try to complete the final task (7) on this page. Perfect for Key Stage 3 students to experiment with block coding, objects and properties. App Inventor Task 7 - Pop-up Blob The previous apps have been preparing you to make a longer and more complicated app. Now we will put together all of the skills you have learned to create a fun game. Check the video: Open App Inventor 2 (use the button below) and create a new project. You will need to log in with a Google account. App Inventor 2 Ready for a challenge? This is what the program looks like in Designer layout. To the left are the components with all their Properties correct. To the right are the Components names. Put the three labels and button inside a HorizontalArrangement from the Layout section of Palette . The Text for ScoreLabel is 'Score: 0'. The Text for TimeRemainingLabel is 'Time Remaining:'. The Text for SecondsLabel is '20'. Place an ImageSprite inside a Canvas (both from the Drawing and Animation section of Palette ). Download the blob image from the Basics page here and upload it as the Picture for the ImageSprite . Change to Blocks layout and drag a initialize global to block from Variables . Type 'Score' in the empty space to create a variable that we will use to track how many times the blob has been touched. Attach a 0 block from Math to start the score at 0. This big block of code uses some of the concepts which you have used before. Whenever the Blob is touched the variable Score is increased by 1. The X and Y coordinates of the Blob are changed by random numbers so it will appear in a random location on the screen. The bottom blocks change the ScoreLabel to show the current score. Every second that the timer ticks we want to check if the score is more than 1 (to check it hasn't reached 0). If it is more than 1 second then the time will count down by 1. In the else part you need to add the following: Set Blob Enabled to false . Set Blob Visible both to false . Set TimeRemainingLabel Visible to false . Set SecondsLabel Visible to false . When the Reset Button is clicked the score variable is changed to 0 and the Seconds label is rewritten to 0. Make sure you use the " " block from Text and not a block from Math. Inside the when ResetButton Click block you need to reverse the code you have added for the else block when the timer ticks: Set Blob Enabled to true . Set Blob Visible both to true . Set TimeRemainingLabel Visible to true . Set SecondsLabel Visible to true . Extra Step: Challenges 1. Large score display . If you watch the video at the top of the page again, you will see that when the time runs out (is less than 1) some of the labels turn invisible and the TextColour and FontSize of the ScoreLabel changes. Try to do the same in your app. Remember to reverse what you have done in the code for the reset button; otherwise, the labels will still be invisible! 2. Customise your game . Change the background of the Canvas to an image, change the blob to a different image and add a sound when the character is 'popped'. 3. *HARDER Challenge* Add a High Score Label . Follow these hints carefully and use the colours to help you. You need to initialize a new Variable called HighScore and set it to 0 . You also need to add a new HighScoreLabel and put it in your Horizontal Arrangement in Designer layout. Add an if then block in the else part of the When Timer Timer block you already have. If Score > HighScore then HighScore = Score . This will change the value of HighScore to the current Score if it is higher than the current high score. Remember to make the HighScoreLabel display the new HighScore . KS3 Home
- GCSE Key Terms | CSNewbs
A key term generator to display randomised or sequential terms from the OCR GCSE Computer Science (J277) course. Filter terms by topics and 'favourite' tricky terms to focus on later. Perfect for students learning GCSE Computer Science in UK schools. GCSE Key Terms Generator If you see this message, your school may be using a strict network filter which has blocked it. The tool uses basic JavaScript and should work fine on a home network. Use this tool to check your understanding of the OCR GCSE J277 specification's key terms . OCR GCSE Homepage
- Python | 3a - Data Types | CSNewbs
Learn about the different data types used in Python. Try practice tasks and learn through text and images. Perfect for students learning GCSE Computer Science in UK schools. top Python 3a - Data Types Data Types in Python If you are a Computer Science student you need to know about the different data types that are used in programming. String – A sequence of alphanumeric characters (e.g. “Hello!” or “Toy Story 4” or “Boeing 747” ) Integer – A whole number (e.g. 1470 or 0 or -34) Float (also called Real ) – A decimal number (e.g. -32.12 or 3.14) Boolean – A logical operation (True or False) Character – A single alphanumeric character (e.g. “a” or “6” or “?”) [ Not used in Python as it would just be a string with a length of 1] Converting to Another Data Type Converting a variable from one data type to another is called casting . Casting Commands str (variable_name) converts a variable to a string . int (variable_name) converts a variable to a integer . float (variable_name) converts a variable to a float (decimal number). An integer (or float ) value may be cast into a string so that it can be used with + as part of a sentence to avoid spaces . total = 45 print ( "You owe £" , total , "in total." ) print ( "You owe £" + str (total) , "in total." ) = You owe £ 45 in total. You owe £45 in total. When dividing an integer the answer is automatically given as a decimal number (float ), even if it is .0 (e.g. 10 / 2 would give 5.0). Casting a float (also known as real) number into an integer using int() will remove the decimal . total = 100/10 print ( "The answer is" , total ) print ( "The answer is" , int(total) ) The answer is 10.0 The answer is 10 = Data Types Task 1 ( Time) Write an input line with int to ask the current hour . Write another input line with int to ask the current minute . Write a print line with str() that outputs this as a clock time. Example solution: What is the hour? 12 What is the minute? 44 The time is 12:44 Data Types Task 2 ( Decimal ) Write an input line with int to ask for any number . Use float() in a print line to output number as a decimal. Example solution: Enter any number: 456 456.0 ⬅ Section 2 Practice Tasks 3b - Simple Calculations ➡










