我正在努力为我的化学课列出一个术语表,并且能够打印出我所要求的定义。也就是说,我询问帝国体系的定义,然后我得到了这个术语的定义。我制作了所有变量,并将它们设置为术语的定义,但当我尝试打印某个定义时,它会打印我所有的定义
VolumeUnits = "gal, cup, table spoons, teaspoons, quart, ounces, pints"
MetricSystem = "Based on the meter, really just a stick, Based on powers of 10"
PreFixes = """kilo
hecto
deka
base
deci
centi
mili"""
Mass = "the amount of matter in an object, base unit is kilograms"
Weight = "the pull of gravity on a mass"
Volume = "lenght x width x height"
Random = "1L - dm^3. 1ml - cm^3"
Time = "base is seconds"
Temperature = "Celsius, kelvin"
SigFig = "the last number that can be measured with confidence"
Chemistry = "the study of matter and its properties and reactions"
Matter = "anything that takes up space and has mass"
input("What would you like to know?\n")
if "Imperial":
print(Imperial)
if "VolumeUnits":
print(VolumeUnits)
if "MetricSystem":
print(MetricSystem)
if "PreFixes":
print(PreFixes)
if "Mass":
print(Mass)
if "Weight":
print(Weight)
if "Volume":
print(Volume)
if "Random":
print(Random)
if "Time":
print(Time)
if "Temperature":
print(Temperature)
if "SigFig":
print(SigFig)
if "Chemistry":
print(Chemistry)
if "Matter":
print(Matter)```
试着用这样的字典
当你必须访问某些东西时,只需使用
用于输入使用
或
所以另一个答案当然是你应该做什么。但是为了澄清代码中的错误,您没有将
input()
赋值给任何变量,并且if
-块始终为真,因为它们实际上不检查任何内容也许你想做这样的事
相关问题 更多 >
编程相关推荐