Python 教学大纲
Power By 赵文瑄
课程简介
这个课程是为了介绍 Python 编程语言,并且通过实践和例子来帮助学生理解 Python 的基础概念。
第一天:Python 基础
Python 简介
- Python 是什么?
- Python 的应用领域
- Python 的优势和特点
安装 Python
- 下载和安装 Python
- 安装和使用 Python 的集成开发环境(IDE),如 PyCharm、VSCode 等
Python 的基本语法
1 2 3 4 5 6 7 8 9 10 11 12
| x = 10
y = 3.14
s = "Hello, Python"
lst = [1, 2, 3, 4, 5]
tup = (1, 2, 3)
dic = {"name": "John", "age": 25}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| print(10 + 5) print(10 - 5) print(10 * 5) print(10 / 5)
print(10 > 5) print(10 < 5) print(10 == 5) print(10 != 5)
print(True and False) print(True or False) print(not True)
|
Python 的控制结构
1 2 3 4 5 6 7
| x = 10 if x > 0: print("x is positive") elif x < 0: print("x is negative") else: print("x is zero")
|
1 2 3 4 5 6 7 8 9
| for i in range(5): print(i)
i = 0 while i < 5: print(i) i += 1
|
实践:Python 的第一个程序
1 2 3 4 5 6 7 8 9
| x = int(input("Enter a number: ")) y = int(input("Enter another number: "))
print("The sum is:", x + y) print("The difference is:", x - y) print("The product is:", x * y) print("The quotient is:", x / y)
|
课后练习
- 编写一个可以接受用户输入的程序,并输出 “Hello, {用户输入}!”
1 2
| name = input("Enter your name: ") print("Hello, " + name + "!")
|
- 编写一个程序,输入两个数字,并输出它们的和、差、积、商
1 2 3 4 5 6 7
| x = int(input("Enter a number: ")) y = int(input("Enter another number: "))
print("The sum is:", x + y) print("The difference is:", x - y) print("The product is:", x * y) print("The quotient is:", x / y)
|
参考资料
下节预告
在下一节课中,我们将深入了解 Python 的函数和模块。