Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Please wrte a Python 3 program that does the follwing please also show output

ID: 3836059 • Letter: 1

Question

1. Please wrte a Python 3 program that does the follwing please also show output?

The model will be called an Entry. Here’s what you need to know:

It should be stored in a database table called entries

It should have a primary key field called id

It should have a title field which accepts unicode text up to 255 characters in length

The title should be unique and it should be impossible to save an entry without a title.

It should have a body field which accepts unicode text of any length (including none)

It should have a created field which stores the date and time the object was created.

It should have an edited field which stores the date and time the object was last edited.

Both the created and edited field should default to now if not provided when a new instance is constructed.

The entry class should support a classmethod all that returns all the entries in the database, ordered so that the most recent entry is first.

The entry class should support a classmethod by_id that returns a single entry, given an id.

Remember that in order to have your new model table created, you will have to re-run the initialize_learning_journal_db script after creating your model.

Use the documentation linked in this presentation to assist you. SQLAlchemy has fantastic documentation, but it can be a bit overwhelming. Everything you require for this assignment is on one or more of the pages linked above.

As you define this new model for our application, make frequent commits to your github repository. Remember to write meaningful commit messages.

Errors at the SQL level can sometimes leave your session unusable. To restore it, use the session.rollback() method. You’ll lose uncommitted changes, but you’ll gain a session that can be used again.

Explanation / Answer

## This program runs a test of knowledge # First get the test questions # Later this will be modified to use file io. def get_questions(): # notice how the data is stored as a list of lists return [["What color is the daytime sky on a clear day? ", "blue"], ["What is the answer to life, the universe and everything? ", "42"], ["What is a three letter word for mouse trap? ", "cat"]] # This will test a single question # it takes a single question in # it returns True if the user typed the correct answer, otherwise False def check_question(question_and_answer): # extract the question and the answer from the list # This function takes a list with two elements, a question and an answer. question = question_and_answer[0] answer = question_and_answer[1] # give the question to the user given_answer = input(question) # compare the user's answer to the tester's answer if answer == given_answer: print("Correct") return True else: print("Incorrect, correct was:", answer) return False # This will run through all the questions def run_test(questions): if len(questions) == 0: print("No questions were given.") # the return exits the function return index = 0 right = 0 while index