Python字典入门

时间:2018-11-15 02:23:53

标签: python

城市= {“纽约市”:30,“波士顿”:54,“洛杉矶”:75,“奥兰多”:114,“休斯顿”:389,“迈阿密”:200}

1 个答案:

答案 0 :(得分:0)

这是一个初学者的问题,可以通过在线python课程更好地解决。

但是,我会给你一个答案:

#Define your dictionary
Cities={"New York City":30, "Boston":54, "Los Angeles":75, "Orlando":114, "Houston":389, "Miami":200}

#Print the NY number
print(Cities["New York City"])

#Calculate the difference between the LA and Orlando numbers
difference = Cities["Los Angeles"] - Cities["Orlando"]

#Print the previously calculated difference
print(difference)