top of page
top

Python - Section 9 Practice Tasks

noun-text-4214022-FFFFFF.png

Task One

It is the national hockey championships and 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.

  • Bonus: Display the teams in uppercase.

Example solution:

Welcome to the National Hockey Championships!!!

Enter the first country: Montenegro

Enter the second country: Kazakhstan

​

Scoreboard: MO vs KA

G

Task Two

In some places, 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.

Example solution:

Enter your sentence: good day! great golly gosh, got a good feeling!

There were 7 instances of that awful letter!

Task Three

A pet shop has just ordered in a batch of new dog collars with name tags.

 

However, there was a mistake with the order and the tags are too small to display 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.

Example solutions:

Welcome to 'Dogs and Cats' Pet Shop!

What is the name of your dog? Miles

Excellent, we will make this dog tag for you!

Welcome to 'Dogs and Cats' Pet Shop!

What is the name of your dog? Sebastian

Sorry, our dog tags are too small!

Task Four

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 the OR operator between each statement to separate them.

  • After the for loop you need to print the number of vowels they have used.

Example solution:

Enter your sentence: Put that thing back where it came from, or so help me!

You used 14 vowels in your sentence.

Task Five

Remember the national hockey championships? Well, the company that hired you just fired you…

 

Never mind 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.

Example solution:

Welcome back to the National Hockey Championships!!!

Enter the first country: Montenegro

Enter the second country: Kazakhstan

​

Scoreboard: GRO vs TAN

Task Six

Too many people are using inappropriate names on Instagram so they have decided to scrap the username 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 Instagram name!

Example solution:

Welcome to Instagram

What is your name? Matthew

What is your favourite colour? red

Which year were you born in? 1987

Your new profile name is: ATRED98

Task Seven

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:

The list contains 20 names

The longest name is alexandria

annabelle.clara.damien.sarah.chloe.jacques.mohammed.steven.rishi.raymond.freya.timothy.claire.steve.alexandria.alice.matthew.harriet.michael.taylor

bottom of page