Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menù personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2023-24 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

Programming unit 1, replit exercise

z
zosia (250 points)
1 2 3
in Programming in Python by (250 points)
Hi, does anyone know why I am only getting asked about the triangle sides here? When i input them it returns the type, then "none" and asks about the sides again.

def TriangleType(side1, side2, side3):
  side1 = input("side 1: ")
  side2 = input("side 2: ")
  side3 = input("side 3: ")

  if side1 == side2 == side3:
    print("it is a equilateral triangle")
  if side1 != side2 and side1 != side3 and side2 != side3:
    print("it is a scalene triangle")
  if side1 == side2 or side1 == side3 or side2 == side3:
    print("it is a isosceles triangle")
pass

def IsTriangle(angle1, angle2, angle3):
  angle1 = int(input("angle 1: "))
  angle2 = int(input("angle 2: "))
  angle3 = int(input("angle 3:"))

  if angle1 + angle2 + angle3 == 180:
    return True
  else:
    return False

pass
201 views

2 Answers

Julio Zenelaj (3190 points)
1 8 32
by (3.2k points)
That's because inTriangleType you should return 0, 1 or 3 depending on the case as the task says. You aren't required to print anything.

The reasone why it prints None is because you are using print(TriangleType(...)) in the main function, and since Triangle Type doesn't return, it just shows None.

EDIT: By the way, in IsTriangle you don't have to use input() at all as the angle values are being passed to the function as parameters. That is, if you do IsTriangle(30, 46, 24) , angle1 will be 30, angle 2 will be 46 and angle3 will be 24.
z
zosia (250 points)
1 2 3
by (250 points)
great, thank you!!
J
Jad (2690 points)
6 27 38
by (2.7k points)
In addition to what my colleague has said, when you called input function for side1, side 2, and side 3, you didnt covert the input into integers using int(input())