题目一
Exercise 3.9
Test if the t value read in the program from Exercise 3.7 lies between 0 and 2*v0/g. if not, print a massage and abort execution.Name of program file:ball_cml_errorcheck.py
3.7的题目如下
Modify the program listed in exercise such that v0 and t are read from the command line. (v0=3,t=0.6)
然后3.7的题目解答如下
import sys
v0=float(sys.argv[1])
t=float(sys.argv[2])
g=9.81
y=v0*t-0.5*g*t**2
print y
= =想问下3.9这道题怎么做……咱还是新手刚学~想请教下
知道开头是这样
import sys
try:什么什么什么
except:什么什么什么
还有一道额……
Exercise 3.10
Instead of printing an error message and aborting the program explicitly,raise a valueerror exception in the if test on legal t values in the program from Exercise 3.9.The exception message should contain the legal interval for t.
谁能解答下~谢了哈
答案满意者+悬赏