tfalcon57 / CTS285

0 stars 0 forks source link

User Story: (Answer Checker) #2

Open tfalcon57 opened 1 year ago

tfalcon57 commented 1 year ago

As a teacher, I want student answers to be graded automatically, so I can get work done faster.

tfalcon57 commented 1 year ago

** WORK IN PROGRESS**

class Question: def init(self, num1, sym, num2, answer): self.num1 = num1 self.sym = sym self.num2 = num2 self.answer = answer def dipslay(self): print(self.num1, self.sym , self.num2, '=', self.answer)

def check(self):
    if self.sym == '+':
        self.answer = self.num1 + self.num2
        return self.answer
    if self.sym == '*':
        return self.num1 * self.num2
    if self.sym == '/':
        return self.num1 / self.num2

question1 = Question(2, '*', 2, 4) question1.dipslay()

tfalcon57 commented 1 year ago

class Question: def init(self) -> None: pass

def input(self):
    self.num1, self.sym , self.num2,self.equal, self.answer = input('Enter Problem With Spaces Like so: (# + # = #) ' ).split()

def dipslay(self):
    print(self.num1, self.sym , self.num2, self.equal, self.answer,)

def add(self):
    num1 = int(self.num1)
    num2 = int(self.num2)
    answer = int(self.answer)
    total = num1 + num2
    if total == answer:
        print('Correct')
    elif total != answer:
        print('Inorrect')

def sub(self):
    num1 = int(self.num1)
    num2 = int(self.num2)
    answer = int(self.answer)
    total = num1 - num2
    if total == answer:
        print('Correct')
    elif total != answer:
        print('Inorrect')

def multi(self):
    num1 = int(self.num1)
    num2 = int(self.num2)
    answer = int(self.answer)
    total = num1 * num2
    if total == answer:
        print('Correct')
    elif total != answer:
        print('Inorrect')

def div(self):
    num1 = int(self.num1)
    num2 = int(self.num2)
    answer = int(self.answer)
    total = num1 / num2
    if total == answer:
        print('Correct')
    elif total != answer:
        print('Inorrect')

# def savedQuestions(self):
#     saved = self.num1, self.sym , self.num2, self.equal, self.answer
#     print(saved, 'Was saved.')

def menu(): print('1) Start Answer Checker ') print('2) Display Saved Questions ') print('3) Exit ')

menu() userChoice = input('Please make a choice: ') while userChoice != '3': if userChoice == '1': userQuestion = Question() userQuestion.input() if userQuestion.sym == '+': userQuestion.add()

userMem = input('Would you like to store this question? (y/n): ')

        # while userMem != 'n':
        #     if userMem == 'y':
        #         saved = [userQuestion.savedQuestions()]
        #         print('Question saved')
        #         break
        #     else:
        #         print('That is not an option. Please try again: ')
        menu()
        userChoice = input('Please make a choice: ')
    elif userQuestion.sym == '-':
        userQuestion.sub()
        menu()
        userChoice = input('Please make a choice: ')
    elif userQuestion.sym == '*':
        userQuestion.multi()
        menu()
        userChoice = input('Please make a choice: ')
    elif userQuestion.sym == '/':
        userQuestion.div()
        menu()
        userChoice = input('Please make a choice: ')
# elif userChoice == '2':
#     print(userQuestion.savedQuestions())
#     menu()
#     userChoice = input('Please make a choice: ')

else:
    print('That is not an option. Please try again: ')
    menu()
    userChoice = input('Please make a choice: ')

print('Have a great day!')