{
	"cells": [
		{
			"cell_type": "markdown",
			"metadata": {
				"collapsed": true
			},
			"source": [
				"### 任务描述\n",
				"了解Python简单数据类型（数字）以及变量的定义，完成相关习题。\n",
				"\n",
				"### 相关知识\n",
				"\n",
				"#### Numbers数字"
			]
		},
		{
			"cell_type": "markdown",
			"metadata": {},
			"source": []
		},
		{
			"cell_type": "markdown",
			"metadata": {},
			"source": [
				"Python 数字数据类型用于存储数值。Numbers数字分为四种类型：\n",
				"\n",
				"- 整型(Int) - 通常被称为是整型或整数，是正或负整数，不带小数点；\n",
				"- 长整型(long) - 无限大小的整数，整数最后是一个大写或小写的L，如51924361L；\n",
				"- 浮点型(float) - 浮点型由整数部分与小数部分组成，如15.20；\n",
				"- 复数(complex) - 复数由实数部分和虚数部分构成，如a + bj，复数的虚部以字母J或j结尾。如3e+26J。"
			]
		},
		{
			"cell_type": "markdown",
			"metadata": {},
			"source": [
				"我们已经知道数字类型可分为四种类型，那么10和10.0分别属于什么类型呢？我们可以使用type()函数查看数据类型。"
			]
		},
		{
			"cell_type": "code",
			"execution_count": 35,
			"metadata": {},
			"outputs": [
				{
					"name": "stdout",
					"output_type": "stream",
					"text": [
						"<class 'int'> <class 'float'>\n"
					]
				}
			],
			"source": [
				"# 使用print()函数输出/打印内容\n",
				"x1 = 10\n",
				"x2 = 10.0\n",
				"print(type(x1),type(x2))"
			]
		},
		{
			"cell_type": "markdown",
			"metadata": {},
			"source": [
				"### 认识变量\n",
				"\n",
				"\n",
				"\n",
				"什么是变量？在上一个案例中，x1、x2这种等号左边的就是属于变量。 变量可以指定不同的数据类型，比如整数，小数等。\n",
				"\n",
				"#### 1、定义变量\n",
				"\n",
				"变量名=变量值\n",
				"\n",
				"其中等号=用来给变量赋值。\n",
				"\n",
				"#### 2、变量命名规则：\n",
				"① 变量名第一个字符必须是字母（大小写均可）或者下划线（“_”），不能数字开头；\n",
				"\n",
				"② 变量名不能和常用功能性名字重合，例如print，if，for；\n",
				"\n",
				"③ 不要有空格。"
			]
		},
		{
			"cell_type": "markdown",
			"metadata": {},
			"source": [
				"#### 变量赋值\n",
				"以下代码展示了怎么给单个变量赋值。"
			]
		},
		{
			"cell_type": "code",
			"execution_count": 38,
			"metadata": {},
			"outputs": [
				{
					"name": "stdout",
					"output_type": "stream",
					"text": [
						"100\n",
						"1000.0\n",
						"John\n"
					]
				}
			],
			"source": [
				"counter = 100 # 赋值整型变量\n",
				"miles = 1000.0 # 浮点型\n",
				"name = \"John\" # 字符串\n",
				" \n",
				"print(counter)\n",
				"print(miles)\n",
				"print(name)"
			]
		},
		{
			"cell_type": "markdown",
			"metadata": {},
			"source": [
				"#### 多变量赋值\n",
				"以下代码展示了怎么给多个变量同时赋值。"
			]
		},
		{
			"cell_type": "code",
			"execution_count": 31,
			"metadata": {},
			"outputs": [
				{
					"name": "stdout",
					"output_type": "stream",
					"text": [
						"1 1 1 1 2 hello\n"
					]
				}
			],
			"source": [
				"a = b = c = 1\n",
				"d , e , f = 1 , 2 , 'hello'\n",
				"print(a,b,c,d,e,f)"
			]
		},
		{
			"cell_type": "markdown",
			"metadata": {},
			"source": [
				"#### 动态变量\n",
				"动态变量的意思是变量的值是可更改的，或者说，变量可以随时指向任意值。"
			]
		},
		{
			"cell_type": "code",
			"execution_count": 32,
			"metadata": {},
			"outputs": [
				{
					"name": "stdout",
					"output_type": "stream",
					"text": [
						"10\n",
						"20\n"
					]
				}
			],
			"source": [
				"var1 = 10\n",
				"print(var1)\n",
				"var1 = 20\n",
				"print(var1)"
			]
		},
		{
			"cell_type": "markdown",
			"metadata": {},
			"source": [
				"### 编程要求\n",
				"\n",
				"同时定义4个变量，并给这四个变量分别赋值为整型，长整型，浮点型和复数。并输出这四个变量的值以及他们的数据类型。"
			]
		},
		{
			"cell_type": "code",
			"execution_count": 47,
			"metadata": {},
			"outputs": [
				{
					"name": "stdout",
					"output_type": "stream",
					"text": [
						"232\n",
						"1000.0\n",
						"232\n"
					]
				}
			],
			"source": [
				"# 本程序进行华氏温度和摄氏温度之间的转换\n",
				"# 请通过换算公式来计算相应的摄氏温度值，需给出Python表达式\n",
				"# 最终输出格式为：华氏**度=摄氏**度\n",
				"\n",
				"F = float(input())   # 华氏温度\n",
				"\n",
				"#   请在此添加实现代码   #\n",
				"# ********** Begin *********#\n",
				"C = ( F - 32 ) * 5 / 9    # 根据换算公式计算相应的摄氏温度值\n",
				"print(\"华氏%.2f度=摄氏%.2f度\" %(F, C))  #格式化字符串\n",
				"\n",
				"# ********** End **********#"
			]
		}
	],
	"metadata": {
		"anaconda-cloud": {},
		"kernelspec": {
			"display_name": "Python 3",
			"language": "python",
			"name": "python3"
		},
		"language_info": {
			"codemirror_mode": {
				"name": "ipython",
				"version": 3
			},
			"file_extension": ".py",
			"mimetype": "text/x-python",
			"name": "python",
			"nbconvert_exporter": "python",
			"pygments_lexer": "ipython3",
			"version": "3.8.2"
		}
	},
	"nbformat": 4,
	"nbformat_minor": 1
}
