Code Challenges For A Level 21 40 1
Code Challenges For A Level 21 40 1
H446
COMPUTER
SCIENCE
Code Challenges (21 – 40)
September 2015
We will inform centres about any changes to the specification. We will also
publish changes on our website. The latest version of our specification will
always be the one on our website (www.ocr.org.uk) and this may differ from
printed versions.
Copyright
OCR retains the copyright on all its publications, including the specifications.
However, registered centres for OCR are permitted to copy material from this
specification booklet for their own internal use.
CONTENTS
Data Entry Page 4
Simple Life Calculator Page 4
Fibbing Page 4
Hack-proof Page 5
Ordering Page 5
Truth or not! Page 5
Word Subtraction Page 5
Name that Number Page 6
Item Merge Page 6
Year Addition Page 6
Forwards and Backwards Page 6
Code it up Page 6
Mor-se Coding Page 7
What’s the day? Page 7
Game of Chance Page 7
Triangulate Page 7
Fizz Buzz Page 8
Sing Along Page 8
Even more Odd Page 8
Base of Numbers Page 8
3
A LEVEL COMPUTER SCIENCE CODE CHALLENGES (21 – 40)
21 Data Entry
Create a program that retrieves the membership details for a Rock Climbing Club. The program should take a range of details and then repeat them back, with headings, for
confirmation. Once confirmed, the program stores these details; else it clears them and allows a new input.
Extensions:
Extensions:
1. Use a an option menu so that the user can use more than one calculation before the program closes
23 Fibbing
Create a program that will calculate the Fibonacci Sequence to 10 places.
Extensions:
4
A LEVEL COMPUTER SCIENCE CODE CHALLENGES (21 – 40)
24 Hack-proof
Create a program that will only open a text document if the correct password is entered. The user should choose the username and password first and it should also verify the
password before allowing it.
Extensions:
2. Create a random password that contains at least a lowercase, uppercase and special character of at least 8 characters in length
Extension:
1. The user can input a word or string, and it arranges the string into alphabetical order. E.g. My Rabbit would be shown as “abbimty “. (Punctuation placement is not essential)
Extension:
Extension:
1. Also add a function that removes any characters in the second word that occur in the first word. E.g. Fish and Tin, would return “Fsh” and “Tn”
5
A LEVEL COMPUTER SCIENCE CODE CHALLENGES (21 – 40)
Extensions:
1. Can you develop your program so that only words in the dictionary are allowed?
29 Item Merge
Create a program that will compare two shopping lists from “Week A” and “Week B”. It will return any unique items contained on the list.
Extension:
2. Develop this to 4 Weeks of shopping an highlight the top 3 most popular items
30 Year Addition
Create a program that accepts a year in the format ####, e.g. 2015. The program then adds each digit of the year together and outputs the answer. E.g. 2015 becomes the output 8.
Extension:
1. Develop this so that the user can guess an integer value. If the MOD division is “0” they score a point, if it isn’t they can guess again, up to 3 attempts in total
31 Forwards and Backwards
Create a program that is able to detect if an input is the same as the reverse of the same input – i.e. a Palindrome
32 Code it up
Create a program that adds 25 to the value of each character of a string that a user enters. This new string should be saved and output.
Extension:
1. Develop your program to include a conversion from a ‘coded’ string back to a normal string
2. Develop your program to allow the user to enter the number they want the string coded by (e.g. 12)
3. Develop your program to then decode a string, based on the coded value that the end user enters
6
A LEVEL COMPUTER SCIENCE CODE CHALLENGES (21 – 40)
33 Mor-se Coding
Create a program that allows you to enter a string and encode it into Morse code, using ‘ . ‘ and ‘ - ‘ notation. Spaces between words should be replaced with the “|” (pipe) character. Use
a normal space for gaps between each character.
Extension:
1. Develop your program to translate from Morse to alphanumeric, using the standards above
34 What’s the day?
Design a program to take 3 inputs, one for day, one for month and one for year. Get your program to validate if this is an actual day, and, if it is, output the day of the week it is!
Create a program that allows the user to guess a number. A random number is generated. If the guess == the random number then the user wins and gets a pay-out. Combinations of
the win scenarios should be catered for.. e.g. 20 wins 2 x 3 bonus = 6x their money.
Extension:
1. Develop your program to allow a user to enter the amount they want to place for that bet, and work out the resulting pay-out
2. Develop your program to store the user’s current balance and stop them from betting if they have no money left
3. Develop your program to finally incorporate validation so that they cannot enter into a negative about of cash ever, and that a bet should be between 1 and 10 units of currency
Extension:
1. Develop your program to allow 2 sides of a triangle and an angle, to work out the length of the missing side
7
A LEVEL COMPUTER SCIENCE CODE CHALLENGES (21 – 40)
37 Fizz Buzz
Create a program that replicates the famous game Fizz Buzz. The program will take an input, e.g. 20, and then print out the list of Fizz Buzz up to and including that number, where:
• Any multiple of 3 is replaced by the word ‘Fizz’
• Any multiple of 5 is replaced by the word ‘Buzz’
• Any multiple of both 3 and 5 is replaced by the word ‘FizzBuzz’
Extension:
Extension:
1. Develop this program so that you can enter any starting number and it will count down from there
39 Even more Odd
Create a program that accepts and random integer array (at least 10 integers) and orders them firstly by size, (small to large), and then puts all the even numbers AFTER the odd
numbers within the array. It then echos the original array and the modified array to screen. E.g. an array 1,2,3,4,5,6,7,8,9,10 would be output 1,3,5,7,9,2,4,6,8,10.
Extension:
1. Develop your program to allow Character input as well, and these come before the integers, and are listed in reverse alphabetical order
40 Base of Numbers
Create a program that converts a denary number into its hexadecimal equivalent.
Extension:
1. Allow the user to specify the base that they want to convert the number into, using an integer, e.g. 16 for Hexadecimal
8
We’d like to know your view on the resources we produce. By clicking on the ‘Like’ or ‘Dislike’ button you can help us to ensure that our resources work for you. When the email template pops up please add
additional comments if you wish and then just click ‘Send’. Thank you.
If you do not currently offer this OCR qualification but would like to do so, please complete the Expression of Interest Form which can be found here: www.ocr.org.uk/expression-of-interest
Please get in touch if you want to discuss the accessibility of resources we offer to support delivery of our qualifications: [email protected]
OCR customer contact centre
General qualifications
Telephone 01223 553998
Facsimile 01223 552627
Email [email protected]
For staff training purposes and as part of our quality assurance programme your call may be recorded or monitored.
©OCR 2015 Oxford Cambridge and RSA Examinations is a Company Limited by Guarantee. Registered in England.
Registered office 1 Hills Road, Cambridge CB1 2EU. Registered company number 3484466. OCR is an exempt charity.