Spaces:
Runtime error
Runtime error
| import random | |
| import datetime | |
| greetings = ["Hello there!"] | |
| goodbyes = ["Bye!", "Goodbye!", "See you later!", "See you soon!"] | |
| responses = {"hello": "How is your day going today?" , | |
| "hi": "How is your day going today?" , | |
| "bad": "bad to know :)", | |
| "great": ":)", | |
| "how about you": "I am very fine, thank you.", | |
| "and you": "I am very fine, thank you.", | |
| "what do you want to talk about": "we can talk about the art and jokes if you would like.", | |
| "Great": ":)", | |
| "not too well": "So sorry to hear that.", | |
| "Fantastic": "Good for you!", | |
| "good": "good to know :)", | |
| "well": "good to know :)", | |
| "So far so good!": "Glad to hear!", | |
| "I'm fine": "Nice to know that you are fine", | |
| "music": "Music is so relaxing!", | |
| "pet": "Animals are such agreeable friends—they ask no questions; they pass no criticisms.", | |
| "book": "I know about a lot of books.", | |
| "game": "I like to play video games.", | |
| "what can": "I can: talk about the weather, discuss art, tell you jokes, and inspire you.", | |
| "weather": "The weather in Ohio is 66.66℉", | |
| "joke": "What is the best thing about Swizterland? I don't know, but the flag is a big plus.", | |
| "inspire": "Keep your face always toward the sunshine and shadows will fall behind you.", "movies": "I love to watch movies", | |
| "sports" :"I follow the English Premier League very closely, my favorite team is Manchester United.", | |
| "animal": "Did you know the only mammal capable of flight is the bat.", | |
| "food": "Who doesn't love food? I love trying new cuisines and recipes.", | |
| "hobbies": "In my free time, I enjoy playing sports, reading, and exploring the outdoors.", | |
| "art": "Art is a powerful form of self-expression and has the ability to evoke deep emotions and spark conversation.", | |
| "travel": "Travel is one of life's greatest joys. It broadens the mind and enriches the soul.", | |
| "work": "Work provides purpose and meaning, and helps us to grow and develop new skills.", | |
| "health": "Taking care of your health is one of the most important things you can do for yourself. Exercise, eat well, and get enough sleep.", | |
| "technology": "Technology has revolutionized the way we live, work, and communicate. It's amazing what we can do with it.", | |
| "fashion": "Fashion is a form of self-expression and can be a lot of fun. What's your favorite fashion trend?", | |
| "nature": "Nature has a beauty and peace all its own. Take a walk outside and enjoy the fresh air and sunshine.", | |
| "education": "Education is key to personal growth and success. Learning never ends and there is always more to discover."} | |
| conversation_log = [] | |
| print(random.choice(greetings)) | |
| user = input("Say something (or type bye to quit): ") | |
| user = user.lower() | |
| while (user != "bye"): | |
| conversation_log.append((datetime.datetime.now(), user)) | |
| keyword_found = False | |
| for keyword in responses: | |
| if keyword in user: | |
| print("Bot: " + responses[keyword]) | |
| keyword_found = True | |
| if keyword == "weather": | |
| follow_up = input("Would you like to know the temperature of any other city? ") | |
| if follow_up.lower() == "yes": | |
| city = input("Which city would you like to know the temperature of? ") | |
| print("Bot: The current temperature in " + city + " is 81℉") | |
| if keyword == "music": | |
| follow_up = input("Which genre of music you like to listen? ") | |
| if follow_up.lower() == "pop": | |
| print("Bot: I love pop music too! Some of my favorite pop artists are Taylor Swift and Ed Sheeran.") | |
| elif follow_up.lower() == "rock": | |
| print("Bot: Rock music is terrfic! Some of my favorite rock artists are AC/DC and Led Zeppelin.") | |
| elif follow_up.lower() == "jazz": | |
| print("Bot: Jazz is fantastic! Some of my favorite jazz artists are Duke Ellington and Louis Armstrong.") | |
| elif follow_up.lower() == "classical": | |
| print("Bot: Classical music is amazing! Some of my favorite classical compossers are Antonio Vivaldi and Ludwig van Beethoven.") | |
| if keyword == "pet": | |
| follow_up = input("Do you like dogs or cats? ") | |
| if follow_up.lower() == "dog": | |
| print("Bot: I love dogs too! Dogs are better than human beings because they know but do not tell. —Emily Dickinson") | |
| elif follow_up.lower() == "cat": | |
| print("Bot: I love cats too! They are independent and low maintenance. Do you wawnt to hear a joke about them?") | |
| follow_up_joke = input() | |
| if follow_up_joke.lower() == "yes": | |
| print("What do you call a cat who loves to bowl? An alley cat!") | |
| elif follow_up_joke.lower() == "no": | |
| follow_up = print("OK") | |
| if keyword == "book": | |
| follow_up = input("Which genre of book you like to read? ") | |
| if follow_up == "fantasy": | |
| print("Bot: Fantasy books are great! Some of my favorite fantasy books are Harry Potter and Lord of the Rings.") | |
| elif follow_up == "thriller": | |
| print("Bot: Thriller books are interesting! Some of my favorite thriller books are The Girl on the Train and The Da Vinci Code.") | |
| elif follow_up == "non-fiction": | |
| print("Bot: Non-fiction books are works of art! Some of my favorite non-fiction books are Atomic Habits and Thinking, Fast and Slow.") | |
| elif follow_up == "comics": | |
| print("Bot: Comic books are fun to read! Some of my favorite comic books are Superman, Batman, Spider-Man, X-Men, Wonder Woman, The Avengers.") | |
| if keyword == "art": | |
| follow_up = input("""Select one of these a well known works of art to get an image to text description of the art piece. | |
| - Starry night(1) | |
| - The Persistence of Memory(2) | |
| - Campbell's Soup Cans(3) | |
| """) | |
| if follow_up == "1": | |
| print("""Bot: The Starry Night is a painting made in 1889 by Vincent Van Gogh: | |
| The work, which is oil paint on canvas, is about 74 cm high and 92 cm wide. | |
| It depicts a night sky with a crescent moon and starry night sky, as well as a quiet villageand a | |
| large cypress tree in the foreground.The sky is the most dynamic part of the painting and is filled | |
| with hundreds of short,thickly applied brushstrokes that give the appearance of roiling movement. | |
| The tree is the nearest and darkest feature in the painting.The painting is considered remarkable | |
| for its depiction of the sky and its ability to touch one's emotions.""") | |
| elif follow_up == "2": | |
| print("""Bot: "The Persistence of Memory" by Salvador Dali: | |
| The Persistence of Memory is a painting made by Salvador Dali in 1931 using oil paint on canvas. | |
| The work measures 24 inches by 33 inches, or 60 cm by 84 cm.It depicts a barren landscape with | |
| several melting pocket watches draped over various objects.The watches symbolize the fluidity of | |
| time and its effects on physical objects.""") | |
| elif follow_up == "3": | |
| print("""Campbell's Soup Cans by Andy Warhol: Made in 1962, this piece is a series of 32 | |
| canvases, each depicting a different flavor of Campbell's soup. Each canvas measures 20 inches tall and 16 | |
| inches wide, and is made using the silkscreen printing technique. The canvases are displayed in a grid formation, | |
| creating a colorful and vibrant display. | |
| The soup cans are rendered in bright, flat colors, with bold outlines and minimal shading. The labels on the cans | |
| are clearly legible and include the flavor of the soup, the company name, and the familiar Campbell's logo. | |
| The repetition of the images creates a mass-produced, commercial feel, reflecting Warhol's fascination with | |
| popular culture and the rise of consumerism | |
| in post-war America.""") | |
| if keyword == "joke": | |
| follow_up = input("Would you like to hear another one? y/n") | |
| if follow_up == "y": | |
| print("I invented a new word!...Plagiarism!") | |
| input("Would you like to hear another one? y/n") | |
| if follow_up == "y": | |
| print("""Knock! Knock! | |
| Who’s there? | |
| Control Freak. | |
| Con… | |
| OK, now you say, “Control Freak who?” """) | |
| input("Would you like to hear another one? y/n") | |
| if follow_up == "y": | |
| print("""Hear about the new restaurant called Karma? | |
| There’s no menu: You get what you deserve.""") | |
| input("Would you like to hear another one? y/n") | |
| if follow_up == "y": | |
| print("""Knock, knock. | |
| Who's there? | |
| Noble. | |
| Noble who? | |
| No bell, so I just knocked.""") | |
| elif follow_up == "n": | |
| print("Got it.") | |
| break | |
| if keyword_found == False: | |
| new_keyword = input("I'm not sure how to respond. What keyword should I respond to? ") | |
| new_response = input("How should I respond to " + new_keyword + "? ") | |
| responses[new_keyword] = new_response | |
| user = input("Say something (or type bye to quit): ") | |
| user = user.lower() | |
| if user == "bye": | |
| break | |
| conversation_log.append((datetime.datetime.now(), user)) | |
| print("Bot: Here is a summary of our conversation:") | |
| for entry in conversation_log: | |
| print(entry[0], entry[1]) | |
| print(random.choice(goodbyes)) | |