Lean Python: Learn Just Enough Python to Build Useful Tools by Paul Gerrard
Author:Paul Gerrard [Paul Gerrard]
Language: eng
Format: epub
Publisher: Apress
Published: 2016-11-10T22:00:00+00:00
Getting input from and writing output to disk files.
Displaying Output
You’ve seen the print() function1 quite a few times already. The most common way of getting output from a program is to use the print() statement. Print is a function that takes as its arguments the items to be displayed. Optionally, you can also define a separator that is placed between the displayed items and a line terminator value that can replace a newline. The function call looks like this:
print(arg1,arg2,arg3...,sep=' ',end='\n')
Here are some examples of the print() function in use.
>>> boy="Jack"
>>> girl="Jill"
>>> print("Hello World!")
Hello World!
>>> print(boy,'and',girl,'went up the hill')
Jack and Jill went up the hill
It is common to use the string formatting feature.
>>> print('%d plus %d makes %d' % (3, 7, 10))
3 plus 7 makes 10
You can suppress the trailing newline by setting the end argument to an empty string (or something else).
>>> #
>>> # the end= argument defaults to '\n'
>>> # if you change it, there won't be a newline
>>> #
>>> print('one...','two...','three',end='')
one... two... three>>> # note the >>> prompt
The string separator defaults to a single space but can be changed or suppressed by setting it to an empty string.
>>> #
>>> # the sep= argument defaults to a space ' '
>>> # but you can change it, for example...
>>> #
>>> print('one...','two...','three',sep='***')
one...***two...***three
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12555)
Hello! Python by Anthony Briggs(9904)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9785)
The Mikado Method by Ola Ellnestam Daniel Brolund(9769)
Dependency Injection in .NET by Mark Seemann(9329)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8282)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7756)
Grails in Action by Glen Smith Peter Ledbrook(7685)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7550)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7003)
Microservices with Go by Alexander Shuiskov(6769)
Practical Design Patterns for Java Developers by Miroslav Wengner(6678)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6626)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6398)
Angular Projects - Third Edition by Aristeidis Bampakos(6030)
The Art of Crafting User Stories by The Art of Crafting User Stories(5560)
NetSuite for Consultants - Second Edition by Peter Ries(5492)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5296)
Kotlin in Action by Dmitry Jemerov(5048)
