zzhou75ubc

module 1

module 1

讲解了python基本量的实践

错题 1

x = 9

sqrt(9) # a built-in math function that returns the square root of its input

What is the value of x after the lines of code above are executed? (Again, remember that we want the value of x, which is not necessarily the value displayed by Jupyter.)
If you want to run this code in Jupyter, you need an "import" so that Jupyter can access the sqrt function. Include a line at the top of your cell saying
from math import *

答案
9

问的是X的value是什么。
错因
求了sqrt的值,没认真审题

错题2

temp = 35.0
result = 'default'

if temp < 10.0:
    result = 'too cold'
elif temp > 25.0:
    result = 'too hot'
elif temp > 30.0:
    result = 'way too hot'
else:
    result = 'just right' 

What is the value stored in result when each of the following code fragments have run?

** 答案**
'too hot'
错解
"way too hot"
错因
没有搞清楚条件语句的运行规则

知识点
当你从A到c时会经过B,b有b1,b2,b3,b4....按顺序,如果b1走不了就去b2以此类推,直到bn可以走了,就从bn走到c了,不再经过b(n+1)。
所以elif temp > 25.0:
满足后 ,直接执行result = 'too hot',不再往下走。

posted on 2023-10-10 17:50  zzhou75  阅读(32)  评论(0编辑  收藏  举报