+ 1
String and algebra
How to print a thing ,which contains strings and numbers that have been defined?
5 odpowiedzi
+ 1
You have to transform integers to string with "str()" and concatenate strings with the plus symbol: +
If I rewrite your print, it would be:
print("While" + str(c) + " degree Celsius,\nit is" + str( ((9 / 5) * c + 32) ) + " degree Farenheit!!!")
Note that str(c) just returns the value of c like a string but it doesn't change the type of c.
+ 2
Maybe I didn't understand well your question but, if you want to print the result of the string "5 + 4" , you can call the "eval" function.
>>> print(eval("5 + 4"))
9
+ 1
string = "Nathan"
int = 15
print(string + str(int)) //output: Nathan15
print(string , str(int)) //output: Nathan 15
I mean, you should convert it to string using str() function
0
I understood now :) jajajaj
0
I have a problem with this thing,and I don't know how to fix the "c" word that I had defined before:
c=0
while True:
print("while" 'c' "degree Celsius,\nit is" '((9/5)*c+32)' "degree Fahrenheit!!!")
c=c+1
if c>=100:
print("out of calculation")
break
print("finished")