WEB PRACTICE CHAPTER 01

Your First Python Challenges

Ten additional coding tasks · W001–W010

These extra website exercises are not a substitute for the book's exact numbered questions. Follow your printed book separately using the 100-challenge tracker.
Chapter 1 code

Choose starters to try yourself, or download a separate worked example pack after attempting the tasks.

Chapter 1 starters ↓Chapter 1 worked examples ↓
WEB PRACTICE W001

Welcome message

Create a two-line welcome screen for a Python coding club.

Reveal a hint

Use print() once for each line.

Reveal example code (after trying it yourself)
print("Welcome to the coding club!")
print("Today we are learning Python.")

One possible solution. Try writing your own first.

Extension: Change the sample values and test at least two different cases.

WEB PRACTICE W002

Personal greeting

Store a first name in a variable and display a welcoming message.

Reveal a hint

Join text using a comma in print().

Reveal example code (after trying it yourself)
name = "Sam"
print("Hello", name)
print("Enjoy coding!")

One possible solution. Try writing your own first.

Extension: Change the sample values and test at least two different cases.

WEB PRACTICE W003

Rectangle measurements

Calculate the area and perimeter of a 7 by 4 rectangle.

Reveal a hint

Area multiplies; perimeter adds both pairs of sides.

Reveal example code (after trying it yourself)
width = 7
height = 4
area = width * height
perimeter = 2 * (width + height)
print("Area:", area, "Perimeter:", perimeter)

One possible solution. Try writing your own first.

Extension: Change the sample values and test at least two different cases.

WEB PRACTICE W004

Convert minutes

Convert 135 minutes into hours and remaining minutes.

Reveal a hint

// finds whole hours; % finds the remainder.

Reveal example code (after trying it yourself)
minutes = 135
hours = minutes // 60
remaining = minutes % 60
print(hours, "hours and", remaining, "minutes")

One possible solution. Try writing your own first.

Extension: Change the sample values and test at least two different cases.

WEB PRACTICE W005

Stationery bill

Calculate the total cost of five £1.25 notebooks and three 80p pencils.

Reveal a hint

Use * before adding the two subtotals.

Reveal example code (after trying it yourself)
notebooks = 5 * 1.25
pencils = 3 * 0.80
total = notebooks + pencils
print(f"Total: £{total:.2f}")

One possible solution. Try writing your own first.

Extension: Change the sample values and test at least two different cases.

WEB PRACTICE W006

Temperature conversion

Convert a temperature of 21°C to Fahrenheit.

Reveal a hint

F = C × 9/5 + 32.

Reveal example code (after trying it yourself)
celsius = 21
fahrenheit = celsius * 9 / 5 + 32
print(f"{celsius}C is {fahrenheit:.1f}F")

One possible solution. Try writing your own first.

Extension: Change the sample values and test at least two different cases.

WEB PRACTICE W007

Coins total

Calculate how much six 50p coins and four 20p coins are worth in pounds.

Reveal a hint

Convert the total number of pence to pounds at the end.

Reveal example code (after trying it yourself)
pennies = 6 * 50 + 4 * 20
pounds = pennies / 100
print(f"£{pounds:.2f}")

One possible solution. Try writing your own first.

Extension: Change the sample values and test at least two different cases.

WEB PRACTICE W008

Classroom average

Find the arithmetic mean of three scores: 8, 10 and 12.

Reveal a hint

Sum the three scores, then divide by three.

Reveal example code (after trying it yourself)
scores = [8, 10, 12]
average = sum(scores) / len(scores)
print("Average score:", average)

One possible solution. Try writing your own first.

Extension: Change the sample values and test at least two different cases.

WEB PRACTICE W009

Trip distance

Work out the total distance for a 12.5km cycle and a 3.75km walk.

Reveal a hint

Add the decimal values and format to two decimal places.

Reveal example code (after trying it yourself)
cycle_km = 12.5
walk_km = 3.75
print(f"Total distance: {cycle_km + walk_km:.2f} km")

One possible solution. Try writing your own first.

Extension: Change the sample values and test at least two different cases.

WEB PRACTICE W010

Share a bill

Split a £48 restaurant bill equally between four people.

Reveal a hint

Division with / produces a decimal value.

Reveal example code (after trying it yourself)
bill = 48
people = 4
each = bill / people
print(f"Each person pays £{each:.2f}")

One possible solution. Try writing your own first.

Extension: Change the sample values and test at least two different cases.