This introductory module will guide you through building a Magic 8-Ball app with App Inventor.
#Magic 8 ball responses code
Just wanted to share my 8 ball code, don’t imagine its particularly amazing but I’m proud of it, my first piece of code that actually dose something lol. py it will keep on asking you for input, answers and such a written in dutch but you can easily replace them. This is written in a while loop, so if you run it in. Print(“Antwoord van de Magische 8-Ball:”,answer) Print(“Antwoord van de Magische 8-Ball: Daag sterveling!”) Print(“Antwoord van de Magische 8-Ball: You’ve got to ask me something before I can answer”) Question = input("Stel de Magische 8-Ball een vraag: ") Name = input("Welkom bij de Magische 8-Ball! Voer uw naam in om te beginnen: ")Īnswer = “Het is een gegeven dat het zo is.”Īnswer = “Dat kan ik je nu beter niet vertellen.”Īnswer = “Het ziet er naar uit van niet.” This means they will only be executed when the else condition is true. You have aligned it with answer = “Error”. The last 2 lines of codes should not be indented. Instead of printing out the answer in each of the if-elif statement, you should be assigning to the variable answer. But, this else statement will not happen because we force the random_number to be 1 to 9 and these have been taken care in the if-elif statements. The variable answer is only assigned to “Error” in the else statement. Then, it prints “Reply hazy, try again.” After that, the code gets out of the if-elif-else statement and nothing will be printed! The reason you’re getting this is because the random_number = 4. Jose asks: Will I get another dog named Naruto? Is there anything I could be doing better? Question = "Will I get another dog named Naruto?" Whenever I run my code it rearranges the order of the print statement in a manner that doesn’t make sense. I am on learn python 3 Magic 8-Ball section of the course. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!
#Magic 8 ball responses how to
If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with! Please find the tag relating to the section of the course you are on E.g. You must select a tag to post in this category.