跳至主要內容
04-str

1. 字符串的定义

字符串是由字母、数字和特殊字符来组成的序列。

有序性

2. 创建字符串

如何创建字符串?

——使用 单引号、双引号或者三引号

name = 'bornforthis'
number = "18"
paragraph = '''Hello,Bornforthis!
Hello,World!'''
paragraph_two = """Hello,Bornforthis!
Hello,World!"""

AI悦创原创...大约 20 分钟1v1Python notebookPython 1v11v1Python notebookPython 1v1
01-Variable

1. 理解变量——生活中的例子

1.1 从字面意思去理解

  • 变:变化
  • 量:大小

1.2 举个例子🌰

假如,你是班级当中的课代表,每个月需要统计班级中每个学生的月考成绩。月考成绩会每个月一张纸,每张纸上都会依次记录每个学生的成绩越到成绩,例如:

  1. 李雷 98分
  2. 马冬梅 89分
  3. 刘奕彤 96分
  4. ......

某一天,老师要看刘奕彤 1月、2月、3月的成绩,这个时候作为课代表的你需要怎么办。——总不能直接把每个月的月考成绩单直接给老师,显然是不合适的。


AI悦创原创...大约 7 分钟1v1Python notebookPython 1v11v1Python notebookPython 1v1
03-Numeric type

1. 数字型的特点

In [2]: 1 + 1
Out[2]: 2

In [3]: 1 + 1.0
Out[3]: 2.0

In [4]: 2 - 1
Out[4]: 1

In [5]: 2 - 1.0
Out[5]: 1.0

In [6]: 2 * 1
Out[6]: 2

In [7]: 2 * 1.0
Out[7]: 2.0

In [8]: 2 * 1
Out[8]: 2

In [9]: 9 / 3
Out[9]: 3.0

AI悦创原创...大约 7 分钟Python 1v1Python notebook
02-Introduction to Data Types

1. 数字型「int、float」

1.1 代码示例

  1. 整型
int_num = 1
t = type(int_num)
print(int_num)
print("int num type is:>>>", t)
print("直接检测数据类型,并输出:>>>", type(int_num))

# output
1
int num type is:>>> <class 'int'>
直接检测数据类型,并输出:>>> <class 'int'>

AI悦创原创...大约 7 分钟Python 1v1Python notebook