chatbot about animals only
举报
发布于:2024-08-27
更新于:2024-08-27
2
214
作品介绍:
Mariam is typing ☆**☆: .。. .。.: hi, everyone, this is not a project this is to make a python project, and this sprite from mblock make it and take this code copy and paste it in python in mblock I I I I I I I I \/ from mblock import event @event.greenflag def on_greenflag(): sprite.say('Hello!, my name is Bobert', 2) sprite.say('Iam here to help you , tell me what do you want', 2) answer = sprite.input('Choose a topic') if sprite.answer == "Talk about animals": talk_about_animals() else: sprite.say("Sorry ,i dont know what you need", 2) def talk_about_animals(): animals = ["dog", "cat", "lion", "Tiger", "cheetah", "kangro", "Rabbit", "duck", "koala", "fox", "shark"] animals_info = ["Accompanying man", "so cute", "It is very big", "it's color i love it", "its so fast", "jump so long", "run fast and white", "Duck is the common name for numerous species of waterfowl in the family Anatidae. Ducks are generally smaller and shorter-necked than swans", "A type of mammal belonging to the marsupial bear genus, from the marsupial bear family" ,"Foxes are included in the Canidae family, and they are considered a species of animal that is very close to wolves, and their sizes are slightly larger than cats, with an estimated weight of about 6.8 kg.", "The largest species of fish in the world, reaching a length of about 20 meters and a weight of about 34,019 kg. This type of shark is distinguished by its gray skin."] answer = sprite.input('What is your favourite animal?') animalFound = False for i in range(len(animals)): if sprite.answer == animals[i]: sprite.say(animals_info[i]) animalFound = True break if animalFound == False: sprite.say('sorry i dont know about this animal', 2)
操作说明:
and when you make it run the code the click the green flag in your project if the robot asks you and the robot says (choose a topic) you will write this (Talk about animals) then the robot will ask you and the robot will say (what is your favorite animal) you will choose to write any animal of these only (dog, cat, lion, Tiger, cheetah, kangaroo, Rabbit, duck, koala, fox, shark) you will type any animal of these and one of these animals if you type one the robot will give you information about this animal you type i hope you enjoy by this tutorial i type and bye (*^▽^*)(´▽`ʃ♡ƪ)