Practical Challenges 2

<< Previous: Python mathsNext: Selection >>

About the challenges

The challenges below allow you to apply your knowledge of the topics up to this point. Click remix to be able to add your code and use the run button to display its output.

Challenge 1: Username





forename = input("Enter your forename: ").upper()
surname = input("Enter your surname: ").upper()
username = surname[-3:] + forename[:3]
print(f"Your username is {username}")

Challenge 2: Average calculator





num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
average = (num1 + num2)/2
print(f"The average of {num1} and {num2} is {average}.")

Challenge 3: Remainder calculator





num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
whole = num1 // num2
part = num1 % num2
print(f"{num1} / {num2} is {whole} remainder {part}.")

Challenge 4: Taxi fare





num_passengers = int(input("Enter the number of passengers: "))
num_miles = int(input("Enter the number of miles travelled: "))
cost = num_passengers * 2 + num_miles * 1.50
print(f"The cost of a journey with {num_passengers} travelling {num_miles} is £{cost}.")
<< Previous: Python mathsNext: Selection >>

© All materials created by and copyright S.Goff