how do you print for example the answer of 7*8 and the string hello on the same line? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

how do you print for example the answer of 7*8 and the string hello on the same line?

thank you

22nd Sep 2016, 6:58 PM
poo
8 Antworten
+ 3
Cuneyt's solution works. You can also use str() to turn stuff into strings. print("Hello World " + str(7*8))
22nd Sep 2016, 8:08 PM
Zen
Zen - avatar
+ 2
You can also print("Hello World! 7*8=", 7*8)
22nd Sep 2016, 9:27 PM
Harris Tran
Harris Tran - avatar
+ 1
You can use below code Print("Hello World", 7*8)
22nd Sep 2016, 7:03 PM
Cuneyt Celebican
Cuneyt Celebican - avatar
+ 1
print("hello world" + str(7*8))
24th Sep 2016, 7:38 PM
nitesh pandey
nitesh pandey - avatar
0
You can use format function as: print("Hello World! {0}".format(7*8)) I think you are looking for this solution as I had the same doubt when I started to engage with python at beginner's level. You can try out more with "format()" function.
23rd Sep 2016, 7:17 AM
Ajay Singh Parmar
Ajay Singh Parmar - avatar
0
my prefered is print("Hello world!" %d) % (7*8)
30th Sep 2016, 3:52 AM
William Touzalin
William Touzalin - avatar
0
Input: print(7*8 + 'hello') Output: 56hello
19th Nov 2016, 2:31 PM
fighter_Ethan
- 1
use the code result= 7*8 print("Hello world" +result)
22nd Sep 2016, 7:40 PM
Rajab
Rajab - avatar