Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,855 questions

51,776 answers

573 users

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
...