Jupyter notebook 如何根据条件在Jypyter笔记本中显示gif图像?

Jupyter notebook 如何根据条件在Jypyter笔记本中显示gif图像?,jupyter-notebook,gif,Jupyter Notebook,Gif,问题是:我试图创建一个简单的测验,并根据分数显示一个gif图像。 请参见下面的分数类别: 满分:5分 真棒:5 不错:3-4 差:0-2 我可以使用以下命令显示单个gif 从IPython.display导入图像 图像(url=)https://images.gr-assets.com/hostedimages/1555943935ra/27397694.gif,宽度=375,高度=200) 但是,我能够根据以下逻辑显示gif。希望有人能帮我解决这个问题。谢谢大家! if score==5:

问题是:我试图创建一个简单的测验,并根据分数显示一个gif图像。 请参见下面的分数类别:

  • 满分:5分
  • 真棒:5
  • 不错:3-4
  • 差:0-2
我可以使用以下命令显示单个gif
从IPython.display导入图像
图像(url=)https://images.gr-assets.com/hostedimages/1555943935ra/27397694.gif,宽度=375,高度=200)

但是,我能够根据以下逻辑显示gif。希望有人能帮我解决这个问题。谢谢大家!

if score==5:
   Image(url='https://images.gr-assets.com/hostedimages/1555943935ra/27397694.gif', width=375, height=200) 
   print("Awesome!")

elif score>2 and score<=4:
    Image(url='https://media3.giphy.com/media/l0HepmE7eqiK86GSQ/giphy.gif?cid=ecf05e473mzzo1br8w9didsqr5j34nruzuks3wlvxmxf2zse&rid=giphy.gif', width=375, height=200)
    print("Not bad!")

if score<=2:
    Image(url='https://media1.tenor.com/images/ea96c313bbb74cc69abc861e21ee3098/tenor.gif', width=375, height=200) 
    print("Bad!")
如果分数==5:
图像(url=)https://images.gr-assets.com/hostedimages/1555943935ra/27397694.gif'宽度为375,高度为200)
打印(“太棒了!”)

elif评分>2和评分使用
显示
绘制图像

if score==5:
   img = Image(url='https://images.gr-assets.com/hostedimages/1555943935ra/27397694.gif', width=375, height=200) 
   display(img)
   print("Awesome!")

elif score>2 and score<=4:
    img = Image(url='https://media3.giphy.com/media/l0HepmE7eqiK86GSQ/giphy.gif?cid=ecf05e473mzzo1br8w9didsqr5j34nruzuks3wlvxmxf2zse&rid=giphy.gif', width=375, height=200)
    display(img)
    print("Not bad!")

elif score<=2:
    img = Image(url='https://media1.tenor.com/images/ea96c313bbb74cc69abc861e21ee3098/tenor.gif', width=375, height=200) 
    display(img)
    print("Bad!")
如果分数==5:
img=图像(url=)https://images.gr-assets.com/hostedimages/1555943935ra/27397694.gif'宽度为375,高度为200)
显示器(img)
打印(“太棒了!”)
elif得分>2,得分为