Back to gallery
Courseware
Intro to Python, Lesson 1 — College
A neon geek-style coding class: variables, types, I/O, conditionals and loops — code kept verbatim, with a guess-the-number project.

1 / 10
Source inputExpand
This is the complete input used to generate this example — nothing was edited by hand.
Python 编程入门 · 第 1 课:从 Hello World 到第一个小游戏
课程目标
1. 了解 Python 是什么、能做什么(数据分析、AI、自动化、Web)。
2. 学会安装 Python 与 VS Code,运行第一行代码 print("Hello, World!")。
3. 掌握变量、数据类型(int、float、str、bool)、input() 与 if 判断。
4. 独立完成“猜数字”小游戏。
知识点
1. 变量:name = "小明";age = 18。
2. 数据类型与转换:int("18")、str(3.14)。
3. 输入输出:guess = int(input("请输入一个数字:"))。
4. 条件判断:if guess > target: print("大了") elif guess < target: print("小了") else: print("猜对了!")
5. 循环:while True 与 break。
6. 随机数:import random; target = random.randint(1, 100)。
课堂实战:猜数字游戏,最多猜 7 次,给出“大了/小了”提示。
课堂练习:写程序判断一个数是奇数还是偶数;计算 1 到 100 的和。
课后作业:把猜数字改成两人对战版,并统计每人猜了几次。