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,888 questions

51,815 answers

573 users

How to use string interpolation (inserting values of variables in place of placeholders) in Python

1 Answer

0 votes
a = 300
b = True
c = "c++"
d = 3.14
e = "python"

print("%d" % a)
print("%d + 88 = %d" % (a, a + 88))
print("%s and %s" % (c, e))
print("[%d, %s, %s, %s, %f]" % (a, b, c, e, d))
print("PI: %f" % d)




'''
run:

300
300 + 88 = 388
c++ and python
[300, True, c++, python, 3.140000]
PI: 3.140000

'''

 



answered Jan 31, 2022 by avibootz

Related questions

4 answers 266 views
4 answers 219 views
1 answer 110 views
3 answers 291 views
1 answer 158 views
1 answer 150 views
...