Skip to content

Instantly share code, notes, and snippets.

@miquelvir
Created March 16, 2025 22:17
Show Gist options
  • Save miquelvir/6c7435bebd5750e9e923848d18dc6bd2 to your computer and use it in GitHub Desktop.
Save miquelvir/6c7435bebd5750e9e923848d18dc6bd2 to your computer and use it in GitHub Desktop.
devQuest - 16/03/2025 23:17

Exercise 1

Teacher solution

side1 = float(input("Side 1: "))
side2 = float(input("Side 2: "))
side3 = float(input("Side 3: "))

if side1 < side2 + side3 and side2 < side1 + side3 and side3 < side1 + side2:  # triangle inequality theorem
# (any side of a triangle must be less than the sum of the other sides)
    print("It is a triangle")
    if side1 == side2 == side3:
        print("Equilateral Triangle")
    elif side1 != side2 and side1 != side3 and side2 != side3:
        print("Scalene Triangle")
    else:
        print("Isosceles Triangle")
else:
    print("It is not a triangle")

Exercise 2

Teacher solution

character = ord(input("Enter a character (will crash if you enter more than one)"))

if ord('a') <= character <= ord('z'):
    print('The letter', chr(character), 'is lowercase')
elif ord('A') <= character <= ord('Z'):
    print('The letter', chr(character), 'is uppercase')
elif ord('0') <= character <= ord('9'):
    print(chr(character), 'is a number')
else:
    print(chr(character), 'is a symbol')

Exercise 3

Teacher solution

age1 = int(input("Enter the age of the first person: "))
age2 = int(input("Enter the age of the second person: "))

if age1 < age2:
  print("The first person is younger.")
elif age2 < age1:
  print("The second person is younger.")
else:
  print("Both people are the same age.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment