你分析的很好只要其中三点能否各自给出错误代码例子
- 拼写错误:
错误代码例子:prin("Hello, world!")
正确代码示例:print("Hello, world!")
- 语法错误:
错误代码例子:for i in range(10): print(i)
正确代码示例:for i in range(10): print(i)
- 逻辑错误:
错误代码例子:age = 18 if age > 18: print("You are an adult!") else: print("You are not an adult!")
正确代码示例:age = 18 if age >= 18: print("You are an adult!") else: print("You are not an adult!")
注意:在逻辑上,18岁是成年人,应该使用大于等于符号。
原文地址: https://www.cveoy.top/t/topic/bqgW 著作权归作者所有。请勿转载和采集!