早教吧作业答案频道 -->其他-->
python2.5与python3.2有什么区别importrandomsecret=random.randint(1,100)guess=0tries=0print("ahoy!I'mthedreadpirate,andihaveasecret!")print("itisanumberfrom1to99.i'11giveyou6tries.")whileguess=secretandtriessecret:p
题目详情
python2.5与python3.2有什么区别
import random
secret = random.randint(1,100)
guess = 0
tries = 0
print ("ahoy!I'm the dread pirate,and i have a secret!")
print ("it is a number from 1to 99.i'11 give you 6 tries.")
while guess =secret and tries secret:
print ("too high,landlubber!")
tries = tries + 1
if guess == secret:
print ("avast!ye got it!gound my secret,ye did!")
else:
print ("no more guesses!butter luck next time,matey!")
print ("the secret numbei wad"),secret
这个在3.2里怎么运行不了
import random
secret = random.randint(1,100)
guess = 0
tries = 0
print ("ahoy!I'm the dread pirate,and i have a secret!")
print ("it is a number from 1to 99.i'11 give you 6 tries.")
while guess =secret and tries secret:
print ("too high,landlubber!")
tries = tries + 1
if guess == secret:
print ("avast!ye got it!gound my secret,ye did!")
else:
print ("no more guesses!butter luck next time,matey!")
print ("the secret numbei wad"),secret
这个在3.2里怎么运行不了
▼优质解答
答案和解析
guess = 20, input("what's yer guess?")
这里是相当于把一个 tuple 赋给 guess
所以执行if guess < secret: 认为两端类型不匹配.
最后一句:
print ("the secret numbei wad"), secret
print 只会打印出括号中的信息,括号外的数据是不会打印的
这里是相当于把一个 tuple 赋给 guess
所以执行if guess < secret: 认为两端类型不匹配.
最后一句:
print ("the secret numbei wad"), secret
print 只会打印出括号中的信息,括号外的数据是不会打印的
看了 python2.5与pyth...的网友还看了以下:
已知全集I=R,集合A={x| x²-3x+2≤0},B={x|x²-2ax+a≤0,a∈R}且B 2020-04-05 …
已知电压一定时,电阻R与电流强度I成反比例,如果电阻R=10欧时,电流强度I=0.3A.求:(1) 2020-04-27 …
输入阻抗等于输出阻抗时候负载获得最大功率是怎么通过公式推导出来的?P=I^2*R=E^2*R/(R 2020-05-13 …
设A为n阶矩阵,证明:R(A+I)+R(A-I)>=n已知R(A)=R(kA),k≠0;R(A+B 2020-05-14 …
设A=(aij)n×n为实矩阵,已知aii>0(i=1,2…n),aij<0(i,j=1,2…n; 2020-05-14 …
1.设集合x={0,1,2,3}中的两个关系,R={|i,j∈x∧(j=i+1∨j=i/2)},S 2020-06-12 …
离散数学,求解答,谢谢设A=(1,2,3),R为A*A上的等价关系,且属于R,当且仅当ab=cd( 2020-07-09 …
(1)I=U/R(2)W=I²RT(3)W=U²T/R(4)W=UIT(5)W=PT(6)P=UI 2020-07-18 …
这题怎么算1.ar^4+ar^6+ar^*+.+ar^100=?当r=1a=32.1+(2^2)r+ 2020-10-30 …
复变函数的积分计算积分I=(闭合c曲线的积分符号)[1/(z-z0)^n+1]dz,其中C是以z0为 2020-11-01 …