Section 9 Practice Tasks

1. It is the national hockey championships! You need to write the program for the TV channel showing the live games.

  • Let the user enter the name of the first country that is playing.
  • Then let the user enter the name of the second country.
  • Shorten country 1 to the first two letters.
  • Shorten country 2 to the first two letters. 

    Your final output could look like this:screenshot-2016-10-22-at-8-52-12-pm

    2. In Dajikistan, the letter G is seen as an offensive letter. The government want you to create a program to count how many times the letter G appears in a sentence.

    • Let the user input any sentence that they like.
    • You need to count how many g’s there are. 
    • Then print the number of g’s there are.


3. A pet shop has just ordered in a batch of new dog collars with name tags. But the tags are too small to display any names longer than 6 characters! You need to create a program that checks the user’s dog name can fit!

  • Let the user enter their dog’s name.
  • Calculate the length of their name.
  • Use an if statement to see if it is greater than 6 characters.
  • If it is then print – Sorry but our dog tags are too small to fit that!
  • Otherwise print – Excellent, we will make this dog tag for you!
    pnewbs3 pnewbs2

4. It’s literacy week and the Head of English would like you to create a vowel checker program to ensure that year 7s are using plenty of vowels in their work.

  • Let the user enter any sentence they like.
  • For each letter in the sentence that they have just entered you need to use if statements to check if it is a vowel.
  • You will need to use five if statements on the same line. Use the or operator between each statement to separate them.
  • After the for loop you need to print the number of vowels they have used.

5. Remember the national hockey championships? Well, the company that hired you just fired you… Nevermind though, a rival scoreboard company want to hire you right away!

  • You need to let the user enter two countries like last time.

But this time you don’t want to calculate the first two letters, you want to print the last three letters!

6. Too many people are using inappropriate names on Facebook so they have decided to scrap your profile name and will give you a code instead. The code is the 2nd and 3rd letters of your first name, your favourite colour and then the middle two numbers of the year you were born.

  • Let the user input their name, then their favourite colour and then the year they were born.
  • Using their data, calculate their new Facebook name!


< Back to Section Nine