Help me, how can I let Python calculate equations for me?

Pagina: 1
Acties:
  • 352 views

Onderwerpen

Vraag


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Mijn vraag
How can I let Python calculate equations for me?

Relevante software en hardware die ik gebruik
def Test ():

class Questions:
def __init__(self, question, answer, answer2):
self.question = question
self.answer = answer
self.answer2 = answer2

b = 1
c = 5
a**2 = c-b
a**2 = a*a


questions_list = [
["Solve the equation x**2 + 1 = 5. \n \nRestriction: you can not use spaces in your answer. \nNote your answer in the following form if necessery: x=.. v vx v counter/denominator v x**2.",
"x=2vx=-2", "x=-2vx=2"],
]
questions = []

for item in questions_list:
questions.append(Questions(item[0],item[1],item[2]))

def run_test(questions):
for questions in questions :
print(questions.question)
answer = input("\nAnswer: ")
if answer == "a":
print("\nCorrect!\n")
break
if answer == "x=-2vx=2":
print("\nCorrect!\n")
break
if answer == "x=2":
print ("\nFalse, don’t forget that a negative x-value can also come out.\n\n")
Test()
break
if answer == "x=-2":
print ("\nFalse, don’t forget that a positive x-value can also come out.\n\n")
Test()
break
if answer == ("x=v2") :
print ("\nFalse, you haven taken the root twice of 5 - 1 = 4.\n\n")
Test()
break
if answer == ("x=v2vx=-v2") :
print ("\nFalse, you haven taken the root twice of 5 - 1 = 4.\n\n")
Test()
break
if answer == ("x=-v2vx=v2") :
print ("\nFalse, you haven taken the root twice of 5 - 1 = 4.\n\n")
Test()
break
if answer == ("x=v4vx=-v4") :
print ("\nFalse, you can work out your answer even further.\n\n")
Test()
break
if answer == ("x=-v4vx=v4") :
print ("\nFalse, you can work out your answer even further.\n\n")
Test()
break
if answer == ("x=v4") :
print ("\nFalse, you can work out your answer even further.\n\n")
Test()
break
if answer == ("x=-v4") :
print ("\nFalse, you can work out your answer even further.\n\n")
Test()
break
else :
print ("nFalse, answer not detected. \nTry again! \n\n")
Test()

run_test(questions)


Wat ik al gevonden of geprobeerd heb
I tried to fix it, but it doesn't work

Alle reacties


Acties:
  • +1 Henk 'm!

  • Wish
  • Registratie: Juni 2006
  • Laatst online: 17:20

Wish

ingwell

Afbeeldingslocatie: https://www.thisaigaltv.com/wp-content/uploads/2018/03/a-160.png

He used flowers to try and seduce it to not bite him - maybe the same will work for calculations?

More serious: this is a Dutch forum - and you did not read the prerequisites for posting this it seems?

No drama


Acties:
  • 0 Henk 'm!

  • BM
  • Registratie: September 2001
  • Laatst online: 16:38

BM

Moderator Spielerij
@Verwijderd This is a dutch forum, so we expect out users to post in Dutch. Apart from that this has nothing to do with gaming. Therefore this topic will be closed.

@Wish : volgende keer is een Topic Report een beter idee

Xbox
Even the dark has a silver lining | I'm all you can imagine times infinity, times three


Dit topic is gesloten.