求Python高手解答基本Python习题这是第一题, 第二题:图里面的4是指04:00am,15就是下午3点..然后根据这些条件来求出电影票价.不用写太复杂的,就是用基本的if ,elif,while ,for 之类的命令就好.

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/01 13:27:02
求Python高手解答基本Python习题这是第一题,  第二题:图里面的4是指04:00am,15就是下午3点..然后根据这些条件来求出电影票价.不用写太复杂的,就是用基本的if ,elif,while ,for 之类的命令就好.
xT[oD+âdc{Ɨ *HqQԇsY& O(( ))%DT.yK/{7i6J݇>;ߙԓGKyG'nvZ}O6:?vNo>Awn{sPx📕ǽ#ꮭ@4 !ijBVoV}ciwkG6v{O:_k(@b C4};RηmU9T[!ɲԟSty2Z Z57H/7wloolDSaC.fuz@\pra;i3\2l'҂p>bw|4|< wrcjQv3p˄>iz+(s,FAtA>Q:M8 %]g31̶i"v(u|ñјZ]f3ecjRortu L,}@mC̑H% QV_QXNSX(IDD Enʓ%q2{%"y+Jęf \JŸ<#Kq+33H)lgj\

求Python高手解答基本Python习题这是第一题, 第二题:图里面的4是指04:00am,15就是下午3点..然后根据这些条件来求出电影票价.不用写太复杂的,就是用基本的if ,elif,while ,for 之类的命令就好.
求Python高手解答基本Python习题


这是第一题,
 
 
第二题:

图里面的4是指04:00am,15就是下午3点..然后根据这些条件来求出电影票价.
不用写太复杂的,就是用基本的if ,elif,while ,for 之类的命令就好.
 

求Python高手解答基本Python习题这是第一题, 第二题:图里面的4是指04:00am,15就是下午3点..然后根据这些条件来求出电影票价.不用写太复杂的,就是用基本的if ,elif,while ,for 之类的命令就好.
#!/usr/bin/env python
# coding = utf-8
KNOWTREE = dict(
# does it have a backhone?
True = dict(
# does it give birth to live babies
True = "Mammal",
False = dict(
# does it have feathers
True = "Bird",
False = dict(
# does it have gills
True = "Fish",
False = dict(
# does it lay eggs in water
True = "Amphibian",
Flase = "Reptile",
),
),
),
),
False = dict(
# does it have a shell
True = "Mollusc",
False = dict(
# does it have 6 legs
True = "Insect",
False = "Arachind",
),
),
)
def which_animal(ans):
know = KNOWTREE
while isinstance(know,dict):
know = know[repr(ans.pop(0))]
return know
def movie_price(weekday,dayhour):
if weekday == "Tuesday":
return 10.75
elif weekday == "Wednesday":
return 5.75
elif weekday in ("Monday","Thursday","Friday") and dayhour < 17:
return 12.75
else:
return 15.75
print which_animal([True,True,True,True,True,True,True,])
print which_animal([False,False,False,False,False,False,False,])
print movie_price("Tuesday",4)
print movie_price("Saturday",15)
print movie_price("Friday",17)
print movie_price("Friday",16)