The Student Room Group

idea gold badge

Scroll to see replies

Original post by armorwarz
I was stuck on this part for the longest time but found the solution if you're still looking.
just copy and paste these questions:

How can I contribute to the
UN's zero waste initiative?

How can I help preserve
food resources for future generations?

How can I reduce my
energy use?

How can I use water better and help to
ensure a clean, steady and safe flow?

How can I reduce the amount of fossil
fuels I use through the way I travel?

How can I help through fashion and
the clothes I wear?

Also make sure to add in another off-topic question but remember to use a question mark
Hope this helped!

thank you!
Original post by dinozaur781
The first error was a logic error, and you needed to change if confidence to if confidence < 70:

The second and third errors were syntax - you needed to change "Wate" to "Waste" (2nd error) and "Water" (3rd error)

The fourth error was a semantic error, and it was that the text was incomplete - instead of it being
print "Carpool with people you work with"
it should've been...
print "Ride a bike for journeys you would normally drive. Live car free. Carpool with people you work with. Use an electric or hybrid powered vehicle.
Use green buses and trams. If you need to purchase a car, make sure it has low emissions."

The fifth and sixth errors were combined, and were a semantic error where the "Fashion" category wasn't mentioned, so you would do elif answerclass == "Fashion": on the first empty line, and
print "Shop less. Have a clothes swap party. Sell old clothes on eBay and Gumtree. Give old clothes to charity. Buy second-hand clothes. Fix tears with stitching or patch over holes."
on the second empty line.

So the final code should look like this.

Def answer_question( ):
question = aw_input(">")
answer = classify(question)
answerclass = answer["class_name"]
confidence = answer["confidence"]
if confidence < 70:
print "Sorry, I don't understand. I am an eco-chatbot, please can you ask me something to do with waste, food, energy, travel or fashion."
elif answerclass == "Waste":
print "Use glass jars. Use a bag for life. Bring your own cup. Compost your food waste. Use metal or bamboo straws. Avoid single-use food and drink containers."
elif answerclass == "Food":
print "Adopt a plant based diet. Buy unpackaged food where possible. Support local shops. Reduce the amount you waste. Buy organic produce. Check labels to make sure they meet credible standards."
elif answerclass == "Energy":
print "Set a goal to reduce consumption. Purchase energy A rated products. Turn technology off at the plug overnight. Use solar powered devices. Wash clothes at a low temperature. Use LED lights."
elif answerclass == "Water":
print "Shower instead of bathing. Drink from tap water instead of bottled water. Fix water leaks promptly. Only use the washing machine or dishwasher with a full load. Use a water can in the garden instead of a hose. Don’t waste water by leaving the tap on when you brush your teeth."
elif answerclass == "Travel":
print "Ride a bike for journeys you would normally drive. Live car free. Carpool with people you work with. Use an electric or hybrid powered vehicle. Use green buses and trams. If you need to purchase a car, make sure it has low emissions."
elif answerclass == "Fashion":
print "Shop less. Have a clothes swap party. Sell old clothes on eBay and Gumtree. Give old clothes to charity. Buy second-hand clothes. Fix tears with stitching or patch over holes."


this part isnt working : does anyone know why? "Ride a bike for journeys you would normally drive. Live car free. Carpool with people you work with. Use an electric or hybrid powered vehicle.

Use green buses and trams. If you need to purchase a car, make sure it has low emissions."
doesnt work
Reply 23
Can someone please help me on the last section of the chat bot code? I have tried using the codes suggested but it still comes up with a semantic error whenever I press run code. Can anyone help??
Here is what i put:
print "Shop less. Have a clothes swap party. Sell old clothes online. Give old clothes to charity. Buy second hand clothes. Fix tears with stitching or patch over holes."
Can someone tell me whats wrong with it?
Reply 24
Original post by armorwarz
I was stuck on this part for the longest time but found the solution if you're still looking.
just copy and paste these questions:

How can I contribute to the
UN's zero waste initiative?

How can I help preserve
food resources for future generations?

How can I reduce my
energy use?

How can I use water better and help to
ensure a clean, steady and safe flow?

How can I reduce the amount of fossil
fuels I use through the way I travel?

How can I help through fashion and
the clothes I wear?

Also make sure to add in another off-topic question but remember to use a question mark
Hope this helped!


Thanks mate was stuck on this for so long. Been a real big help
Original post by goku132
on the first blue line just copy and paste what the chat bot says about travel

what about the other 2 lines underneath?
Reply 26
Original post by bluecat3454
what about the other 2 lines underneath?

you leave that
Reply 27
Original post by mhs8116
you leave that

just ask a random question
Original post by armorwarz
I was stuck on this part for the longest time but found the solution if you're still looking.
just copy and paste these questions:

How can I contribute to the
UN's zero waste initiative?

How can I help preserve
food resources for future generations?

How can I reduce my
energy use?

How can I use water better and help to
ensure a clean, steady and safe flow?

How can I reduce the amount of fossil
fuels I use through the way I travel?

How can I help through fashion and
the clothes I wear?

Also make sure to add in another off-topic question but remember to use a question mark
Hope this helped!

Legend
Reply 29
Original post by dinozaur781
The first error was a logic error, and you needed to change if confidence to if confidence < 70:

The second and third errors were syntax - you needed to change "Wate" to "Waste" (2nd error) and "Water" (3rd error)

The fourth error was a semantic error, and it was that the text was incomplete - instead of it being
print "Carpool with people you work with"
it should've been...
print "Ride a bike for journeys you would normally drive. Live car free. Carpool with people you work with. Use an electric or hybrid powered vehicle.
Use green buses and trams. If you need to purchase a car, make sure it has low emissions."

The fifth and sixth errors were combined, and were a semantic error where the "Fashion" category wasn't mentioned, so you would do elif answerclass == "Fashion": on the first empty line, and
print "Shop less. Have a clothes swap party. Sell old clothes on eBay and Gumtree. Give old clothes to charity. Buy second-hand clothes. Fix tears with stitching or patch over holes."
on the second empty line.

So the final code should look like this.

Def answer_question( ):
question = aw_input(">")
answer = classify(question)
answerclass = answer["class_name"]
confidence = answer["confidence"]
if confidence < 70:
print "Sorry, I don't understand. I am an eco-chatbot, please can you ask me something to do with waste, food, energy, travel or fashion."
elif answerclass == "Waste":
print "Use glass jars. Use a bag for life. Bring your own cup. Compost your food waste. Use metal or bamboo straws. Avoid single-use food and drink containers."
elif answerclass == "Food":
print "Adopt a plant based diet. Buy unpackaged food where possible. Support local shops. Reduce the amount you waste. Buy organic produce. Check labels to make sure they meet credible standards."
elif answerclass == "Energy":
print "Set a goal to reduce consumption. Purchase energy A rated products. Turn technology off at the plug overnight. Use solar powered devices. Wash clothes at a low temperature. Use LED lights."
elif answerclass == "Water":
print "Shower instead of bathing. Drink from tap water instead of bottled water. Fix water leaks promptly. Only use the washing machine or dishwasher with a full load. Use a water can in the garden instead of a hose. Don’t waste water by leaving the tap on when you brush your teeth."
elif answerclass == "Travel":
print "Ride a bike for journeys you would normally drive. Live car free. Carpool with people you work with. Use an electric or hybrid powered vehicle. Use green buses and trams. If you need to purchase a car, make sure it has low emissions."
elif answerclass == "Fashion":
print "Shop less. Have a clothes swap party. Sell old clothes on eBay and Gumtree. Give old clothes to charity. Buy second-hand clothes. Fix tears with stitching or patch over holes."

Thank you so much! I was stuck with this for almost 2 days because not alot of people has done this badge, it really helps <3
Original post by Alex Tecsan
i'm stuck on idea gold badge chatbots if anyone knows this please help me the question says
There are still some errors to fix. You can check how many errors of each type remain by looking at the numbers next to the headings of “Semantics”, “Syntax” and “Logic”.
Def answer_question( ):
question = aw_input(">")
answer = classify(question)
answerclass = answer["class_name"]
confidence = answer["confidence"]
if confidence = answer["confidence"]
print "Sorry, I don't understand. I am an eco-chatbot, please can you ask me something to do with waste, food, energy, travel or fashion."

elif answerclass == "Waste":
print "Use glass jars. Use a bag for life. Bring your own cup. Compost your food waste. Use metal or bamboo straws. Avoid single-use food and drink containers."

elif answerclass == "Food":
print "Adopt a plant based diet. Buy unpackaged food where possible. Support local shops. Reduce the amount you waste. Buy organic produce. Check labels to make sure they meet credible standards."

elif answerclass == "Energy":
print "Set a goal to reduce consumption. Purchase energy A rated products. Turn technology off at the plug overnight. Use solar powered devices. Wash clothes at a low temperature. Use LED lights."

elif answerclass == "Water":
print "Shower instead of bathing. Drink from tap water instead of bottled water. Fix water leaks promptly. Only use the washing machine or dishwasher with a full load. Use a water can in the garden instead of a hose. Don’t waste water by leaving the tap on when you brush your teeth."

elif answerclass == "Travel":
print "Carpool with people you work with."
do you have any IDEA (c what i did there) what to do after when you test the bot? no matter what i put it just says "Sorry, I don't understand. I am an eco-chatbot. You can ask me anything to do with energy, food, waste, water, travel, or fashion"

Quick Reply

Latest

Trending

Trending