Practical Challenges 3

<< Previous: SelectionNext: For loops >>

About the challenges

The challenges below allow you to apply your knowledge of the topics up to this point. Attempt the challenges in a Python IDE of your choice.

Challenge 1: Say hello 2





name = input("Enter your name: ")
if name == "Bob"
    print("Hey that's my name too")
else:
    print(f"Hello {name}")

Challenge 2: Triangle identifier





num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
num3 = int(input("Enter the third number: "))
if num1 == num2 == num3:
     print("Equilateral triangle")
elif num1 == num2 or num1 == num3 or num2 == num3:
    print("Isoceles")
else:
    print("Scalene")

This is just one solution. You may have checked the conditions in a different order. If yours is different and you are uncertain it is right test it with each of the types of triangles.

Challenge 3: Mark to grade





mark = int(input("Enter your mark out of 20: "))
if mark >= 17:
    print("Grade A)
elif mark >= 14
    print("Grade B")
elif mark >= 10
    print("Grade C")
else:
    print("Grade F")
<< Previous: SelectionNext: For loops >>

© All materials created by and copyright S.Goff