Abstract
This chapter introduces basic Python concepts that will be used throughout the remainder of this text. If you are already familiar with another programming language, such as R, many of the concepts here will be analogous. If you are approaching Python as your first programming language (and it is a good choice for that purpose), you may benefit from working through this material alongside another introductory text such as Shaw (Learn python the hard way, 2013).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
This is true for Python versions 2.7.9 and after. If you do not have pip installed, see https://pip.pypa.io/en/stable/installing/.
- 2.
Also known as a REPL, which stands for “read, evaluate, print loop.” This describes exactly what happens: the interpreter reads your input, evaluates it, and prints the output.
- 3.
Python 2 used integer division by default, so 17 / 3 would return 5.
- 4.
Unlike some other languages, there is no difference in Python between double-quoted and single-quoted strings. The only requirement is that they match, i.e. "hello" is invalid.
- 5.
Note that if you are using Python 2 instead of 3, the last example above should use person_dictionary.iteritems() instead of person_dictionary.items().
References
Shaw, Z. (2013). Learn python the hard way. Retrieved March 24, 2018, from https://learnpythonthehardway.org/book/
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2020 Springer Nature Switzerland AG
About this chapter
Cite this chapter
Cutler, J., Dickenson, M. (2020). Getting Started with Python. In: Computational Frameworks for Political and Social Research with Python. Textbooks on Political Analysis. Springer, Cham. https://doi.org/10.1007/978-3-030-36826-5_1
Download citation
DOI: https://doi.org/10.1007/978-3-030-36826-5_1
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-36825-8
Online ISBN: 978-3-030-36826-5
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)