The Core Python Language I

Christian Hill
{"title":"The Core Python Language I","authors":"Christian Hill","doi":"10.1017/CBO9781139871754.002","DOIUrl":null,"url":null,"abstract":"The Python shell This chapter introduces the syntax, structure and data types of the Python programming language. The first few sections do not involve writing much beyond a few statements of Python code and so can be followed using the Python shell . This is an interactive environment: the user enters Python statements that are executed immediately after the Enter key is pressed. The steps for accessing the “native” Python shell differ by operating system. To start it from the command line, first open a terminal using the instructions from Section 1.4 and type python. To exit the Python shell, type exit() . When you start the Python shell, you will be greeted by a message (which will vary depending on your operating system and precise Python version). On my system, the message reads: Python 3.3.5 |Anaconda 2.0.1 (x86\\_64)| (default, Mar 10 2014, 11:22:25) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type “help”, “copyright”, “credits” or “license” for more information. >>> The three chevrons (>>>) are the prompt , which is where you will enter your Python commands. Note that this book is concerned with Python 3, so you should check that the Python version number reported on the first line is Python 3.X.Y where the precise values of the minor version numbers X and Y should not be important. Many Python distributions come with a slightly more advanced shell called IDLE, which features tab-completion, and syntax highlighting (Python keywords are colored specially when you type them). We will pass over the use of this application in favor of the newer and more advanced IPython environment, discussed in Chapter 5. It is also possible for many installations (especially on Windows) to start a Python shell directly from an application installed when you install the Python interpreter itself. Some installations even add a shortcut icon to your Desktop which will open a Python shell when you click on it. Numbers, variables, comparisons and logic Types of numbers Among the most basic Python objects are the numbers, which come in three types : integers (type: int), floating point numbers (type: float) and complex numbers (type: complex). Integers Integers are whole numbers such as 1, 8, −72 and 3847298893721407. In Python 3, there is no limit to their magnitude (apart from the availability of your computer's memory). Integer arithmetic is exact.","PeriodicalId":146668,"journal":{"name":"Learning Scientific Programming with Python","volume":"1 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2016-02-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"3","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Learning Scientific Programming with Python","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1017/CBO9781139871754.002","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 3

Abstract

The Python shell This chapter introduces the syntax, structure and data types of the Python programming language. The first few sections do not involve writing much beyond a few statements of Python code and so can be followed using the Python shell . This is an interactive environment: the user enters Python statements that are executed immediately after the Enter key is pressed. The steps for accessing the “native” Python shell differ by operating system. To start it from the command line, first open a terminal using the instructions from Section 1.4 and type python. To exit the Python shell, type exit() . When you start the Python shell, you will be greeted by a message (which will vary depending on your operating system and precise Python version). On my system, the message reads: Python 3.3.5 |Anaconda 2.0.1 (x86\_64)| (default, Mar 10 2014, 11:22:25) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type “help”, “copyright”, “credits” or “license” for more information. >>> The three chevrons (>>>) are the prompt , which is where you will enter your Python commands. Note that this book is concerned with Python 3, so you should check that the Python version number reported on the first line is Python 3.X.Y where the precise values of the minor version numbers X and Y should not be important. Many Python distributions come with a slightly more advanced shell called IDLE, which features tab-completion, and syntax highlighting (Python keywords are colored specially when you type them). We will pass over the use of this application in favor of the newer and more advanced IPython environment, discussed in Chapter 5. It is also possible for many installations (especially on Windows) to start a Python shell directly from an application installed when you install the Python interpreter itself. Some installations even add a shortcut icon to your Desktop which will open a Python shell when you click on it. Numbers, variables, comparisons and logic Types of numbers Among the most basic Python objects are the numbers, which come in three types : integers (type: int), floating point numbers (type: float) and complex numbers (type: complex). Integers Integers are whole numbers such as 1, 8, −72 and 3847298893721407. In Python 3, there is no limit to their magnitude (apart from the availability of your computer's memory). Integer arithmetic is exact.
核心Python语言1
Python shell介绍Python编程语言的语法、结构和数据类型。前几节不涉及编写Python代码语句以外的内容,因此可以使用Python shell进行学习。这是一个交互式环境:用户输入Python语句,这些语句在按下Enter键后立即执行。访问“本机”Python shell的步骤因操作系统而异。要从命令行启动它,首先使用第1.4节中的说明打开一个终端,并输入python。要退出Python shell,输入exit()。当您启动Python shell时,您将看到一条消息(这将根据您的操作系统和精确的Python版本而有所不同)。在我的系统上,消息如下:Python 3.3.5 |Anaconda 2.0.1 (x86\_64)|(默认值,2014年3月10日,11:22:25)[GCC 4.0.1 (Apple Inc. build 5493)] On darwin输入“help”,“copyright”,“credits”或“license”获取更多信息。>>>三个符号(>>>)是提示符,您将在这里输入Python命令。请注意,本书涉及Python 3,因此您应该检查第一行报告的Python版本号是否为Python 3. x。其中次要版本号X和Y的精确值不应该很重要。许多Python发行版附带了一个稍微高级一点的shell,称为IDLE,它具有选项卡补全和语法高亮显示(Python关键字在您键入它们时是特殊的颜色)。我们将跳过这个应用程序的使用,转而使用在第5章中讨论的更新和更高级的ippython环境。许多安装(特别是在Windows上)也可以在安装Python解释器本身时直接从安装的应用程序启动Python shell。一些安装甚至会在你的桌面添加一个快捷图标,当你点击它时,它会打开一个Python shell。在最基本的Python对象中,数字有三种类型:整数(类型:int)、浮点数(类型:float)和复数(类型:complex)。整数整数是整数,如1、8、−72、3847298893721407等。在Python 3中,它们的大小没有限制(除了计算机内存的可用性)。整数运算是精确的。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信