Beispiel #1
0
def subtraction_problem(results_directory, min_value, max_value, videos, show_hints):
  videoprompt.print_video_message(videos, show_hints)
  num1 = random.randint(min_value, max_value)
  num2 = random.randint(min_value, max_value)
  correct = None
  prompt = ' '.join([str(max(num1, num2)), '-', str(min(num1,num2)), '= '])
  while True:
    reply = input(prompt).strip()
    if not reply.isdigit():
      print('Sorry, ' + str(reply) + ' is not a number.' )
      continue
    else:
      reply = int(reply)
      answer = max(num1, num2) - min(num1, num2)
      if reply == answer:
        print('Correct!')
        correct = True
      else:
        print('Incorrect:')
        print('\tThe correct answer is', prompt, answer)
        correct = False
      log_entry = ','.join(['subtraction', prompt, str(reply), str(answer), str(correct)])
      writelog.log_writer(results_directory, log_entry)
      # write_log(args, log_entry)
      print('\n')
      return correct
Beispiel #2
0
def multiplication_problem(results_directory, max_one, max_two, videos,
                           show_hints):
    videoprompt.print_video_message(videos, show_hints)
    num1 = random.randint(0, max_one)
    num2 = random.randint(0, max_two)
    correct = None
    prompt = ' '.join([str(num1), '*', str(num2), '= '])
    while True:
        reply = input(prompt).strip()
        if not reply.isdigit():
            print('Sorry, ' + str(reply) + ' is not a number.')
            continue
        else:
            reply = int(reply)
            answer = num1 * num2
            if reply == answer:
                print('Correct!')
                correct = True
            else:
                print('Incorrect:')
                print('\tThe correct answer is', prompt, answer)
                correct = False
            log_entry = ','.join([
                'multiplication', prompt,
                str(reply),
                str(answer),
                str(correct)
            ])
            writelog.log_writer(results_directory, log_entry)
            print('\n')
            return correct
Beispiel #3
0
def decimal_problem(results_directory, digits, videos, show_hints):
  videoprompt.print_video_message(videos, show_hints)
  greaterThan = float(0)
  lessThan = float(1)
  num1 = round(random.uniform(greaterThan, lessThan), digits)
  num2 = round(random.uniform(greaterThan, lessThan), digits)
  correct = None
  prompt = ' '.join(['Which decimal is bigger (1 or 2)? \n1: ', str(num1), '\n2: ', str(num2), '\n'])
  while True:
    reply = input(prompt).strip()
    if not reply.isdigit() or int(reply) > 2:
      print('Sorry, ' + str(reply) + ' is not an option pick 1 or 2, if they are equal enter 0.' )
      continue
    else:
      print('the reply is : ', reply)
      reply = int(reply)
      answer = comparator(num1, num2)
      if reply == answer:
        print('Correct!')
        correct = True
      else:
        print('Incorrect:')
        text_answer = ''
        if answer == 0:
          text_answer = 'they are equal (enter 0)'
        elif answer == 1:
          text_answer = ' '.join([str(num1), '>', str(num2), '(enter 1)'])
        elif answer == 2:
          text_answer = ' '.join([str(num1), '<', str(num2), '(enter 2)'])
        print('\tThe correct answer is ', text_answer)
        correct = False
      log_entry = ','.join(['decimal', prompt.replace('\n', ' '), str(reply), str(answer), str(correct)])
      writelog.log_writer(results_directory, log_entry)
      print('\n')
      return correct
Beispiel #4
0
def gle_problem(results_directory, min_value, max_value, videos, show_hints):
    videoprompt.print_video_message(videos, show_hints)
    num1 = random.randint(min_value, max_value)
    num2 = random.randint(min_value, max_value)

    correct = None
    equal = ' '.join([str(num1), '=', str(num2)])
    gt = ' '.join([str(num1), '>', str(num2)])
    lt = ' '.join([str(num1), '<', str(num2)])

    prompt = ' '.join([
        'Which answer is correct? \n0: ', equal, '\n1: ', gt, '\n2: ', lt, '\n'
    ])
    while True:
        reply = input(prompt).strip()
        if not reply.isdigit() or int(reply) > 2:
            print('Sorry, ' + str(reply) +
                  ' is not an option pick 1 or 2, if they are equal enter 0.')
            continue
        else:
            print('the reply is : ', reply)
            reply = int(reply)
            answer = comparator(num1, num2)
            if reply == answer:
                print('Correct!')
                correct = True
            else:
                print('Incorrect:')
                text_answer = ''
                if answer == 0:
                    text_answer = 'they are equal (enter 0)'
                elif answer == 1:
                    text_answer = ' '.join([
                        str(num1), '>',
                        str(num2), '(enter 1)', '\n\t',
                        str(num1), 'is bigger than',
                        str(num2)
                    ])
                elif answer == 2:
                    text_answer = ' '.join([
                        str(num1), '<',
                        str(num2), '(enter 2)', '\n\t',
                        str(num1), 'is smaller than',
                        str(num2)
                    ])
                print('\tThe correct answer is ', text_answer)
                correct = False
            log_entry = ','.join([
                'greaterlessequal',
                prompt.replace('\n', ' '),
                str(reply),
                str(answer),
                str(correct)
            ])
            writelog.log_writer(results_directory, log_entry)
            print('\n')
            return correct
Beispiel #5
0
def place_value_problem(results_directory, min_value, max_value, videos,
                        show_hints):
    videoprompt.print_video_message(videos, show_hints)
    correct = None
    number = random.randint(100, 999)
    place = random.choice(['ones', 'tens', 'hundreds'])
    answer = 0
    if place == 'hundreds':
        answer = int(str(number)[0])
    elif place == 'tens':
        answer = int(str(number)[1])
    elif place == 'ones':
        answer = int(str(number)[2])
    prompt = ' '.join(
        ['What is the value of the', place, 'place in',
         str(number), '? '])
    while True:
        reply = input(prompt).strip()
        if not reply.isdigit():
            print('Sorry, ' + str(reply) + ' is not a number.')
            continue
        else:
            reply = int(reply)
            if reply == int(answer):
                print('Correct!')
                correct = True
            else:
                print('Incorrect:')
                print('\tThe correct answer is', answer)
                correct = False
            log_entry = ','.join(
                ['place_value', prompt,
                 str(reply),
                 str(answer),
                 str(correct)])
            writelog.log_writer(results_directory, log_entry)
            print('\n')
            return correct
Beispiel #6
0
def division_problem(results_directory, numerator_max_value,
                     denominator_max_value, videos, show_hints):
    videoprompt.print_video_message(videos, show_hints)
    # num1 = random.randint(max(1, min_value), max(1, max_value))
    # num2 = random.randint(max(1, min_value), max(1, max_value))
    num1 = random.randint(1, numerator_max_value)
    num2 = random.randint(numerator_max_value, denominator_max_value)
    correct = None
    print('First give the answer, then the remainder')
    prompt = ' '.join([str(max(num1, num2)), '/', str(min(num1, num2)), '= '])
    while True:
        reply = input(prompt).strip()
        if not reply.isdigit():
            print('Sorry, ' + str(reply) + ' is not a number.')
            continue
        else:
            reply = int(reply)
            reply_remainder = int(input('remainder = '))
            answer = int(max(num1, num2) / min(num1, num2))
            answer_remainder = max(num1, num2) % min(num1, num2)
            if reply == answer and reply_remainder == answer_remainder:
                print('Correct!')
                correct = True
            else:
                print('Incorrect:')
                print('\tThe correct answer is', prompt, answer,
                      ' remainder = ', answer_remainder)
                correct = False
            log_entry = ','.join(
                ['division', prompt,
                 str(reply),
                 str(answer),
                 str(correct)])
            writelog.log_writer(results_directory, log_entry)
            print('\n')
            return correct
Beispiel #7
0
def skip_count_problem(results_directory, by_values, videos, show_hints):
    videoprompt.print_video_message(videos, show_hints)
    correct = None
    by = int(random.choice(by_values))
    number_of_times = random.randint(3, 10)
    print('Example Input for Skip Counting: 2 4 6')
    prompt = ''.join([
        'Skip count by ',
        str(by), 's.  Your first number will be ',
        str(by), ' and your last number will be ',
        str(by * number_of_times), ': '
    ])
    reply = input(prompt).strip().split(' ')
    answer = np.arange(by, by * number_of_times + by, by)

    while True:
        if len(reply) != len(answer):
            print('Please enter ', str(number_of_times),
                  ' numbers. You entered ', len(reply), ' numbers.')
            reply = input(prompt).split(' ')
        else:
            reply = [r for r in reply if r.isdigit()]
            if len(reply) == len(answer):
                check = pd.DataFrame({'reply': reply, 'answer': answer})
                check['reply'] = check['reply'].astype(int)
                check['answer'] = check['answer'].astype(int)
                check['difference'] = check['reply'] - check['answer']
                if check['difference'].max() == 0 and check['difference'].min(
                ) == 0:
                    correct = True
                    print('Correct!')
                else:
                    correct = False
                    print('Incorrect.')
            else:
                correct = False
                print('Incorrect. Seems some values were not numbers')

            print(''.join([
                '\tSkip counting by ',
                str(by), ' from ',
                str(by), ' to ',
                str(by * number_of_times), ' is the same as:'
            ]))
            addition_string = ''
            for n in np.arange(by, by * number_of_times + by, by):
                if n != by * number_of_times:
                    addition_string = addition_string + str(by) + ' + '
                else:
                    addition_string = addition_string + str(by) + ' = ' + str(
                        by * number_of_times)
            print('\t', addition_string)
            multiplication_string = ''
            multiplication_string = ''.join([
                str(by), ' * ',
                str(number_of_times), ' = ',
                str(by * number_of_times)
            ])
            print('\t', multiplication_string)
            log_entry = ','.join(
                ['skip_count', prompt,
                 str(reply),
                 str(answer),
                 str(correct)])
            writelog.log_writer(results_directory, log_entry)
            print('\n')
            return correct