🪸Different ways to use print() in Python🐍

When I was new to coding, late in 2022's, I use only 2 or 3 types of print()...But now, I got to know so many new ways to use print()...

Do you want to know these methods ???

✌🏻Let's have a glimpse on these methods :

  1. Simple Print:

     print("Hello, World!")
    
  2. Print with Variables:

     name = "John"
     age = 25
     print("Name:", name, "Age:", age)
    
  3. Formatted String Literal (f-string):

     name = "Alice"
     age = 30
     print(f"Name: {name}, Age: {age}")
    
  4. String Concatenation:

     name = "Bob"
     age = 22
     print("Name: " + name + ", Age: " + str(age))
    
  5. Multiple Arguments in print:

     name = "Charlie"
     age = 28
     print("Name:", name, end=", ")
     print("Age:", age)
    
  6. Using format method: name = "Eve" age = 35 print("Name: {}, Age: {}".format(name, age))

  7. Using join with a Separator:

     codefruits = ["apple", "banana", "orange"]
     print(", ".join(fruits))
    
  8. Printing on the Same Line:

     print("Hello", end=" ")
     print("World!")
    
0
Subscribe to my newsletter

Read articles from Hitendra Kumar Dewangan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Hitendra Kumar Dewangan
Hitendra Kumar Dewangan

👋 Hi, I’m @HitenDewangan 👀 I enjoy coding, music, graphic designing and martial arts. 🧩 Intermediate coder in Python. 🪸 Learnt Fundamentals of C and Data Analysis with MS Excel. 🌱 I’m currently learning Web Development, and Data Science with Python(Panda). 💞️ I’m looking to collaborate on projects. 📫 How to reach me : Email: hitendewangan100j@gmail.com