How to print two variables in the same line in Python

7 Answers

0 votes
a = 1.34

b = a * 1.8

print('a = {0} b = {1}'.format(round(a, 2), round(b, 2)))

'''
run:

a = 1.34 b = 2.41

'''

 



answered Feb 20, 2016 by avibootz
0 votes
a = 1.34

b = a * 1.8

print("a = ", a, "b = ", b)

'''
run:

a =  1.34 b =  2.4120000000000004

'''

 



answered Feb 20, 2016 by avibootz
0 votes
a = 1.34

b = a * 1.8

print("a = ", a, "b = ", round(b, 2))

'''
run:

a =  1.34 b =  2.41

'''

 



answered Feb 20, 2016 by avibootz
0 votes
a = 100

b = a * 30000

print("a = ", a, "b = ", b)

'''
run:

a =  100 b =  3000000

'''

 



answered Feb 20, 2016 by avibootz
0 votes
a = 100

b = a * 30000

print('a = {0} b = {1}'.format(a, b))

'''
run:

a =  100 b =  3000000

'''

 



answered Feb 20, 2016 by avibootz
0 votes
s1 = "abc"
s2 = "xyz"

print('s1 = {0} s2 = {1}'.format(s1, s2))

'''
run:

s1 = abc s2 = xyz

'''

 



answered Feb 20, 2016 by avibootz
0 votes
s1 = "abc"
s2 = "xyz"

print("s1 = ", s1, "s2 = ", s2)

'''
run:

s1 =  abc s2 =  xyz

'''

 



answered Feb 20, 2016 by avibootz
...