+ 2

Help please, it's a simple question of Phyton

why this error is happening and how I would fix it? The code is for second grade equations and is working but when I write print("x1= "+x1) an error happens. If I just put print(x1) it works https://code.sololearn.com/ck5etOhJxKVi/?ref=app

5th Sep 2018, 12:00 PM
Artur Spain đŸ‡Ș🇾
6 Respostas
+ 4
a =5 b =15 c =-50 começo=-b b2=b**2 meio=(b2-4*a*c)**(1/2) final=2*a x1=(começo+meio)/final x2=(começo-meio)/final print("x1 es igual a "+str(x1))
5th Sep 2018, 12:14 PM
Louis
Louis - avatar
+ 2
You cant concat numbers with strings. So make the numbers a string by str() method. eg: print("x1="+str(x1))
6th Sep 2018, 12:40 PM
Seniru
Seniru - avatar
+ 1
So, it comes out to be that in python, you cannot concatenate a string with a float. To solve this problem, you first need to convert x1 into a string.
5th Sep 2018, 12:10 PM
Naveen Maurya
Naveen Maurya - avatar
+ 1
how would I write it?
5th Sep 2018, 12:12 PM
Artur Spain đŸ‡Ș🇾
+ 1
thank you bro
5th Sep 2018, 12:26 PM
Artur Spain đŸ‡Ș🇾
0
https://www.sololearn.com/Discuss/1488236/?ref=app could you help me with this also?
5th Sep 2018, 1:05 PM
Artur Spain đŸ‡Ș🇾