Skip to the content.

FRQ Questions and Answers

def restore(data):
        with app.app_context():
            db.session.query(CoolFacts).delete()
            db.session.commit()

            restored_facts = {}
            for fact_data in data:
                fact = CoolFacts(
                    coolfacts=fact_data['coolfacts'],
                    age=fact_data['age']
                )
                fact.create()
                restored_facts[fact_data['id']] = fact

            return restored_facts
  1. Defines the procedures name as restore with the return type defined as a dictionary. The parameter, data, acts as the input for the function. Sequences through data and finds the data that correspond to coolfact and age.
def restore_data(data):
    with app.app_context():
        users = User.restore(data['users'])
        _ = CoolFacts.restore(data['coolfacts'])
        _ = Section.restore(data['sections'])
        _ = Group.restore(data['groups'], users)
        _ = Channel.restore(data['channels'])
#        _ = Post.restore(data['posts'])
        _ = Hobby.restore(data['hobbies'])
        _ = Steps.restore(data['steps'])
        _ = Quote.restore(data['quotes'])
        _ = BucketList.restore(data['bucketlists'])
        _ = StriverGoals.restore(data['strivergoals'])
  1. The restore function is being called in this other function where data from different tables are being called in as the data part of the restore function.
def initCoolFacts():
    """
    Initializes the QuizCreation table and inserts test data for development purposes.
    """
    with app.app_context():
        db.create_all()  # Create the database and tables
        # Sample test data
        quizzes = [
            CoolFacts(coolfacts="Elon Musk saved Tesla from bankruptcy", age="37"),
            CoolFacts(coolfacts="Messi moved to Barcelona, Spain to play soccer and recieve proper medical treatment", age="13"),
            CoolFacts(coolfacts="Lebron James was scouted by the Cleveland Cavaliers and played his first NBA game there", age="18")
        ]
        for quiz in quizzes:
            try:
                quiz.create()
                print(f"Created quiz: {repr(quiz)}")
            except IntegrityError as e:
                db.session.rollback()
                print(f"Record already exists or error occurred: {str(e)}")
  1. Within the CoolFacts data table, I am storing actual facts in the coolfact category and an age in the age category.
def generate_data():
    initGoals()
    initCoolFacts()

Retrieves data from initCoolFacts and processes the list data by printing each coolfact and age.

  1. Explain how I could have used feedback, testing, or reflection in the development of my program.

I could have used User feedback from N@TM to add more purpose to my feature and have a more unique frontend. More feedback such as literally connecting my feature to my group-mates features and getting rid of alert’s as the method for informing the user of their actions, could have been implemented into my code. I tested my CRUD operations using Postman to isolate the problem to either the fronted or backend code. I also used Postman to see what error message my code gives and what the problem is. I tested my feature locally first before deploying so if any errors occurred I could isolate the problem to a select few files or lines of code. I asked other group-mates what they thought of my feature and how to make it better and incorporated the input age based on their feedback.

  1. Describe the problem that your program was created to address or the creative expression it pursues.

The Coolfacts feature was developed in order for those lacking in motivation or needing that extra push could set unrealistic expectations with time constraints on themselves so that they could push themselves to be the best version of themselves they could be.

Final MCQ Blog

I have spent sufficient time on each problem as per these images

Image Image Image Image Image Image Image Image

Top 5 things I need to learn

Topic 1.4 Identifying and Correcting Errors

I got Question 39, Question 58, Question 66, and Question 67 wrong.

These questions are all based on topic 1.4

  • Error in calculating sum

    Question 39: Assume that the list of numbers nums has more than 10 elements. The program below is intended to compute and display the sum of the first 10 elements of nums. Which change, if any, is needed for the program to work as intended?

    Response: Line 3 should be changed to REPEAT UNTIL (i ≥ 10). / Making this change to the loop will cause the loop to terminate when i is 10, which does not fix the problem with the program.

    Answer: Lines 5 and 6 should be interchanged. / As is, the program does not include the first element of the list in the sum because i is incremented before nums[i] is added to sum. By interchanging these two lines of code, the program will include all of the first ten elements of the list when computing the sum.

  • Error in AnyPairs procedure

    Question 58: The following procedure is intended to return true if at least two of the three parameters are equal in value and is intended to return false otherwise. For which of the following procedure calls does the procedure NOT return the intended value?

    Response: AnyPairs("bat", "cat", "rat"), For this set of inputs, the IF condition x = y evaluates to false, so the body of the ELSE statement is executed. The expression y = z evaluates to false, so false is returned as intended.

    Answer: AnyPairs("bat", "cat", "bat"), For this set of inputs, false is returned even though two of the inputs are equal in value. The IF condition x = y evaluates to false, so the body of the ELSE statement is executed. The expression y = z evaluates to false, so false is returned.

  • Error in counting perfect numbers

    Question 66: In mathematics, a perfect number is a type of integer. The procedure IsPerfect(num) returns true if num is a perfect number and returns false otherwise.

    The following program is intended to count and display the number of perfect numbers between the integers start and end, inclusive. Assume that start is less than end. The program does not work as intended.

    Which two lines of code should be removed so that the program will work as intended?

    Response:

    Line 5: This line should be removed. The variable count should increase by 1 when currentNum is a perfect number, so it should only be incremented in the body of the IF statement.

    Line 11: This line should not be removed. Every integer from start to end should be checked, so currentNum should be incremented inside the loop but outside the body of the IF statement.

    Answer: Line 5, Line 8: This line should not be removed. The variable count should increase by 1 when currentNum is a perfect number, so it should be incremented in the body of the IF statement.

Error in numOccurrences procedure

Question 67:
The procedure NumOccurrences is intended to count and return the number of times targetWord appears in the list wordList. The procedure does not work as intended.

For which of the following code segments will the call to NumOccurrences NOT return the intended value?

Response:

  • A. For this code segment, count is increased to 1 the first time “birch” is encountered in the list. However, count is reset to 0 when the code segment moves to the next list element. The last time “birch” is encountered in the list, count is again increased to 1, causing the procedure to return 1 instead of the intended result 2.

  • D. For this code segment, count is initialized to 0. Since “spruce” does not appear in the list, the procedure returns the intended result 0.

Answer: A and B

  • B. For this code segment, count is increased to 1 the first time “maple” is encountered in the list. However, count is reset to 0 when the code segment moves to the next list element. This causes the procedure to return 0 instead of the intended result 1.

Topic 3.11 Calling Procedures

3.11: Binary Search

  • Question 47:
    The procedure BinarySearch (numList, target) correctly implements a binary search algorithm on the list of numbers numList. The procedure returns an index where target occurs in numList, or -1 if target does not occur in numList.

    Which of the following conditions must be met in order for the procedure to work as intended?

Response:
I chose The list numList must not contain any duplicate values because I thought binary search should not contain any duplicate values, but in order for a binary search on a list to work as intended, the list must be sorted.

Topic 3.17 Algorthimic Efficiency

  • Q56: Compare execution times of two versions (Learn how to read them)

    I chose Version II requires approximately 1 more minute to execute than version I, but the answer was:

    • Version I calls the GetPrediction procedure once for each element of idList, or four times total. Since each call requires 1 minute of execution time, version I requires approximately 4 minutes to execute.

    • Version II calls the GetPrediction procedure twice for each element of idList, and then again in the final display statement. This results in the procedure being called nine times, requiring approximately 9 minutes of execution time.


  • Q50: Reasonable time algorithms

    Question:
    Consider the following algorithms. Each algorithm operates on a list containing n elements, where n is a very large integer.

    • I: An algorithm that accesses each element in the list twice.
    • II: An algorithm that accesses each element in the list n times.
    • III: An algorithm that accesses only the first 10 elements in the list, regardless of the size of the list.

    Which of the algorithms run in reasonable time?

    Responses:
    I chose III only because the first 10 elements seemed to run faster than accessing all elements.

    The answer was all because:

    • Algorithm I accesses elements twice (twice for each of n elements), which is considered reasonable time.
    • Algorithm II accesses elements n times (n times for each of n elements), which is considered reasonable time.

Topic 4.2 Fault Tolerence

I got Question 44 wrong

This question relates to this topic

Remove connections in network configuration

Question 44:
The figure below shows two possible network configurations for devices P through V. A line between two devices indicates a connection. Devices can communicate only through the connections shown. In configuration I, what is the minimum number of connections that must be broken or removed before device T can no longer communicate with device U?

Response:
Four / Incorrect. While it is possible to disconnect computers U and T by removing four connections, it can be done by removing only two connections.

Answer:
Two / Correct. If the connections between U and V and between U and P were removed, then computer T and computer U can no longer communicate.

Topic 3.9 Developing

I got Question 15 wrong

This question relates to this topic

Compare output of program A and program B

Question 15 Consider the 2 programs below. Which of the following best compares the values displayed by programs A and B?

Response: D / Incorrect. Both programs print 10 values

Answer A / Correct. Program A initializes i to 1. Inside the loop, it prints i and then increments i. The loop terminates when i is greater than 10, which occurs after 10 is printed. Program A prints 1 2 3 4 5 6 7 8 9 10. Program B initializes i to 0. Inside the loop, it increments i and then prints i. The loop terminates when i equals 10, which occurs after 10 is printed. Program B prints 1 2 3 4 5 6 7 8 9 10.