- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to print to the Screen using Python?
The basic way to do output to screen is to use the print statement.
>>> print 'Hello, world' Hello, world
To print multiple things on the same line separated by spaces, use commas between them. For example:
>>> print 'Hello,', 'World' Hello, World
While neither string contained a space, a space was added by the print statement because of the comma between the two objects. Arbitrary data types can also be printed using the same print statement, For example:
>>> import os >>> print 1,0xff,0777,(1+5j),-0.999,map,sys 1 255 511 (1+5j) -0.999 <module 'os' (built-in)>
Objects can be printed on the same line without needing to be on the same line if one puts a comma at the end of a print statement:
>>> for i in range(10): ... print i, 0 1 2 3 4 5 6 7 8 9
To end the printed line with a newline, add a print statement without any objects.
for i in range(10): print i, print for i in range(10,20): print i,
The output will be:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
If the bare print statement were not present, the ouput would be on a single line.
In Python 3, all print statements arguments need to be surrounded by parenthesis. For example,
>>> print("Hello", "world") Hello world
- How to clear screen using python?
- Print screen using VBA in SAP
- How to simulate Print screen button using selenium webdriver in Java?
- How to print the Fibonacci Sequence using Python?
- How to clear screen using C#?
- How to clear screen using Java?
- Printing to the Screen in Python
- How to clear screen in python?
- Print shortest path to print a string on screen in C Program.
- How to center a div on the screen using jQuery?
- How to print the days in a given month using Python?
- How to create a Splash Screen using Tkinter?
- How to create a simple screen using Tkinter?
- How to print % using printf()?
- How to print current date and time using Python?