Skip to main content

Command Palette

Search for a command to run...

print function in python

Updated
2 min read
print function in python
A

I'm an aspiring Software Engineer specializing in web development. I have built various web apps and utilities using Javascript, ReactJS and NodeJS technologies.

I'm currently working on a full-stack project named JU Query, an online platform for University students to connect with peers, juniors and seniors, ask and answer doubts, help each other out as a growing community.

I'm a polyglot programmer in diverse languages such as C, C++, Java, Python, JavaScript and TypeScript.

I'm also a blogger where I have published various posts on programming, python language and course works to share my knowledge and spread awareness. I have received more than 10,000+ reads from platforms like Medium, Dev and Hackernoon.

I love to contribute to the world through community work. I'm a community leader where I spread awareness, promote and educate students on how to code. I have personally taught Internet basics and front end web development for over 400+ students. I have additionally participated in several initiatives as an NSS volunteer.

I'm a passionate learner who has gained knowledge from numerous events and workshops. I have learnt about Aeromodelling, Rover sensor project, Smart devices using the internet of things. And I have also won the runners up position in the open day competition conducted by IIAEM for building a cost-efficient Hydraulic Arm.

My hobbies include sketching, graphic design, reading books, and watching selective movies.

print() function and input() function makes the program more interactive with the user.

Although, there are some extra things we can do with print(), making the output formattable.

Functionalities of print() function

  • Let’s start with the syntax:
    print(object(s), sep=separator, end=end, file=file, flush=flush)

  • Fact: In python, all data types are implemented as an object.

  • object(s): Will accept any number of objects, which will be converted into a string before printing. We can pass it in two ways:

  • Concatenated:

  • Comma separated:

  • Output:
Enter any number: 2021  
year:2021
  • sep=’separator’: This is Optional. Used to specify how to separate the objects, if there is more than one. The default is ‘ ‘ (space).

  • Output:
Enter any number: 2021  
year:   2021
  • end=’end’: This is Optional. It is used to specify what to print at the end. The default is ‘\n’ (new line).

  • Output:
Enter any number: 2021  
year: 2021  month: Jan
  • file: This is Optional. The default is sys.stdout. Used to specify the name of the file to write the output. If the file doesn’t exist, it will create a new file.

  • Output (in ‘Greetings.txt’ file):
!!! Wish you a happy new year   !!!  
Enjoy the year--->2021---> and the month --->January

Who Am I?

I’m Aswin Barath, a Software Engineering Nerd who loves building Web Applications, now sharing my knowledge through Blogging during the busy time of my freelancing work life. Here’s the link to all of my craziness categorized by platforms under one place: https://linktr.ee/AswinBarath

Join me to learn Python!

Checkout my Python Programming Series where my mission is to share my knowledge on Python: https://aswinbarath.hashnode.dev/series/python-programming

Learn what I know about Python from any of my favourite knowledge sources:

Keep Learning

Now, I guess this is where I say GoodBye👋.
But, hey it’s time for you to start learning with your newfound Knowledge(Power)👨‍💻👩‍💻 .
Good Job that you made it this far 👏👏
Thank you so much for reading my Blog🙂.

More from this blog

Aswin Barath Hashnode Blog

21 posts