- 3

Please tell me what's wrong in this code.

when I run this code the analyser says, syntax error in line9 side1 = int(input()) side2 = int(input()) side3 = int(input()) side3>side1 side3>side2 side1**2=x side2**2=y side3**2=z if x+y=z: print("Right-angled") else: print("Not right-angled")

20th Aug 2020, 3:05 PM
Samudra Saikia
Samudra Saikia - avatar
17 odpowiedzi
+ 5
Samudra Saikia , yes sure - your code is for practice, but what is the purpose of this code? I assume it is to check if a triangle with 3 given sides is a right-angled triangle. So this information should be given when posting the question. if so the code for it could be done like: # input 3 values separated by space # input of the 3 values will be splitted, converted to int and stored in a list inp inp = [int(i) for i in input('values for a, b, c: ').split()] if inp[0]**2 + inp[1]**2 == inp[2]**2: print(True) else: print(False) #or in a more compact form use this: inp = [int(i) for i in input('values for a, b, c: ').split()] print(True) if inp[0]**2 + inp[1]**2 == inp[2]**2 else False
20th Aug 2020, 4:38 PM
Lothar
Lothar - avatar
+ 4
Samudra Saikia , can you please tell us, what you try to achieve with this code. Thanks!
20th Aug 2020, 3:59 PM
Lothar
Lothar - avatar
+ 3
Oh try if x+y==z: As far as i know = is the assignment operator and == is for comparison:) If this still doesn't work you could try to store x+y in another variable and compare that with z :)
20th Aug 2020, 3:15 PM
Christian Hauck
Christian Hauck - avatar
+ 2
Single '=' is an assignment operator, it cannot be used to compare two operator, Hence you should use '==' operator.
20th Aug 2020, 4:29 PM
Jeevan Manjunath Naik
Jeevan Manjunath Naik - avatar
0
Maybe you're missing a space or tab?
20th Aug 2020, 3:08 PM
Christian Hauck
Christian Hauck - avatar
0
I don't think so, what should I try to fix it
20th Aug 2020, 3:09 PM
Samudra Saikia
Samudra Saikia - avatar
0
I can tell that there's no problem in those things, I tried it all. Its a problem with the if statement
20th Aug 2020, 3:18 PM
Samudra Saikia
Samudra Saikia - avatar
0
its the same fixing problem here too color = input() if color=red: print('1') elif color=green: print('2') elif color=black: print('3') else: print() when I run it the analyser says invalid syntax line2
20th Aug 2020, 3:20 PM
Samudra Saikia
Samudra Saikia - avatar
0
and in this one too number = input() if number%2=0: print(number**2) elif number%3=0 print(number**3) else number=0 print("0") invalid syntax line2 can anyone tell me what's wrong here
20th Aug 2020, 3:21 PM
Samudra Saikia
Samudra Saikia - avatar
0
anyone please
20th Aug 2020, 3:24 PM
Samudra Saikia
Samudra Saikia - avatar
20th Aug 2020, 3:31 PM
Christian Hauck
Christian Hauck - avatar
0
Christian Hauck is right, same problem in the other two codes as same single '=' in them too.
20th Aug 2020, 3:38 PM
Arnesh
Arnesh - avatar
0
that code was to practice
20th Aug 2020, 4:15 PM
Samudra Saikia
Samudra Saikia - avatar
0
Christian Hauck thanks
20th Aug 2020, 4:16 PM
Samudra Saikia
Samudra Saikia - avatar
0
If x+y=z has no items since they don't exist as variables.
22nd Aug 2020, 1:57 AM
Jason Kennedy
0
color = input() if color=='red': print('1') elif color=='green': print('2') elif color=='black': print('3') else: print('4')
22nd Aug 2020, 3:31 PM
</€N!GM@>🏴‍☠️
</€N!GM@>🏴‍☠️ - avatar
- 2
Hello
22nd Aug 2020, 10:53 AM
Dostonbek Karoll
Dostonbek Karoll - avatar