Abstract
This chapter introduces expressions, literals, operators, identifiers, binding and module importing, by illustrating how Python can be used as a calculator. Three mathematical modules, including math, cmath and random, are introduced, which enable more mathematical calculations than built-in operators.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
The content after the # symbols are comments and can be ignored when typing the examples. Details about comments are given in Chap. 3 or the rest of the book \(>>>\) indicates an IDLE command.
- 2.
The memory addresses in the examples below are unlikely to be reproduced when the examples are tried again, since the allocation of memory addresses is dynamic and runtime dependent.
- 3.
Exactly which small values are represented as frequently accessed objects depends on the Python distribution.
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Copyright information
© 2015 Springer Science+Business Media Singapore
About this chapter
Cite this chapter
Zhang, Y. (2015). Using Python as a Calculator. In: An Introduction to Python and Computer Programming. Lecture Notes in Electrical Engineering, vol 353. Springer, Singapore. https://doi.org/10.1007/978-981-287-609-6_2
Download citation
DOI: https://doi.org/10.1007/978-981-287-609-6_2
Published:
Publisher Name: Springer, Singapore
Print ISBN: 978-981-287-608-9
Online ISBN: 978-981-287-609-6
eBook Packages: EngineeringEngineering (R0)