BIT 2008 Exam Review PDF

Document Details

Uploaded by Deleted User

2008

BIT

James Brunet

Tags

django web development programming computer science

Summary

This document is an exam review for BIT 2008, covering topics such as Django concepts, web development concepts, HTTP, persistence, authentication, Python/Django programming knowledge, templates and views, querying models, Django models and relationships, and multimedia concepts.

Full Transcript

Exam Review BIT 2008 James Brunet Table of contents 01 Exam Format 02 Topics Covered Practice 03 Exam/Sample Questions 01 Exam Format Exam Format No cheat sheet But, the final exam is easier than the midterm Class average will be higher Exam...

Exam Review BIT 2008 James Brunet Table of contents 01 Exam Format 02 Topics Covered Practice 03 Exam/Sample Questions 01 Exam Format Exam Format No cheat sheet But, the final exam is easier than the midterm Class average will be higher Exam Format 50 multiple-choice questions Scantron Choose 1 of 4 options or 1 of 5 options (varies by question) Material covered is almost entirely content after reading week (exception: there will be very simple SQL) 02 Topics covered Exam Format Django Concepts - 12 questions Web Development Concepts HTTP - 9 questions Persistence, Authentication - 5 questions Python/Django Programming Knowledge Templates and Views - 4 questions Querying Models - 7 questions Django Models and Relationships - 4 questions Multimedia Concepts - 9 questions 03 Sample Questions Knowledge Questions What does views.py in Django do? a) It serves static files like images, CSS, and JavaScript files b) It matches a requested URL to the correct view based on the URL patterns defined in the file c) It contains functions to handle requests, return responses, and store and retrieve data from the database d) It creates HTML for forms based off of Django models What does views.py in Django do? a) It serves static files like images, CSS, and JavaScript files b) It matches a requested URL to the correct view based on the URL patterns defined in the file c) It contains functions to handle requests, return responses, and store and retrieve data from the database d) It creates HTML for forms based off of Django models 11. What is the purpose of the media directory in a Django project? a) To store files like CSS, JavaScript, and static images b) To store the Python scripts for the application logic c) To store user-uploaded images and video d) To manage session and authentication data 11. What is the purpose of the media directory in a Django project? a) To store files like CSS, JavaScript, and static images b) To store the Python scripts for the application logic c) To store user-uploaded images and video d) To manage session and authentication data What is the primary purpose of the POST method in HTTP? a) To delete data from the server b) To update existing data on the server c) To submit new data to the server d) To retrieve data from the server What is the primary purpose of the POST method in HTTP? a) To delete data from the server b) To update existing data on the server c) To submit new data to the server d) To retrieve data from the server James' template code has an error in it: it contains a link which has a typo in the URL: https://localhost:8000/addd_task instead of https://localhost:8000/add_task. What HTTP status code would a user most likely receive when clicking this link? a) 1XX b) 2XX c) 3XX d) 4XX e) 5XX James' template code has an error in it: it contains a link which has a typo in the URL: https://localhost:8000/addd_task instead of https://localhost:8000/add_task. What HTTP status code would a user most likely receive when clicking this link? a) 1XX b) 2XX c) 3XX d) 4XX e) 5XX Which of the following is a component of the GET request? a) Query Parameters b) WGET c) Message Body d) Footers e) Status Code Which of the following is a component of the GET request? a) Query Parameters b) WGET c) Message Body d) Footers e) Status Code What is the primary use of SessionStorage in web development? a) To store large amounts of user data on the client side b) To store small pieces of persistent information like user preferences c) To encrypt sensitive data transmitted over the internet d) To enhance the visual appeal of the website through dynamic styling What is the primary use of SessionStorage in web development? a) To store large amounts of user data on the client side b) To store small pieces of persistent information like user preferences c) To encrypt sensitive data transmitted over the internet d) To enhance the visual appeal of the website through dynamic styling James is compressing a video file by looking for similarities between different frames of video. What type of compression is this? a) Spectral b) Watermark c) Temporal d) Logical e) Framorial James is compressing a video file by looking for similarities between different frames of video. What type of compression is this? a) Spectral b) Temporal c) Logical d) Watermark James is trying to send a secret message to another person by encoding information in an image. He doesn't care if the message is still readable after the image is compressed or resized. This is: a) Steganography b) Watermarking c) Digital Rights Management (DRM) d) Spectral Compression James is trying to send a secret message to another person by encoding information in an image. He doesn't care if the message is still readable after the image is compressed or resized. This is: a) Steganography b) Watermarking c) Digital Rights Management (DRM) d) Spectral Compression Programming Questions Which of the below is the correct syntax to write in a Django template to check if a user is authenticated? a) {% if user.is_authenticated %} You are authenticated! b) {% if user.is_authenticated %} You are authenticated! {% endif %} c) {{ if user.is_authenticated }} You are authenticated! {{ endif }} d) {{ if user.is_authenticated }} You are authenticated! e) You are authenticated! Which of the below is the correct syntax to write in a Django template to check if a user is authenticated? a) {% if user.is_authenticated %} You are authenticated! b) {% if user.is_authenticated %} You are authenticated! {% endif %} c) {{ if user.is_authenticated }} You are authenticated! {{ endif }} d) {{ if user.is_authenticated }} You are authenticated! e) You are authenticated! Easier Among the following Python code snippets using Django, which one is most similar to the SQL query below? SELECT * FROM order WHERE customer_id = 123 a) Order.objects.all('customer_id=123') b) Order.objects.all('customer_id=123').get(*) c) Order.select('*').where('customer_id = 123') d) Order.objects.get(customer_id=123) Easier Among the following Python code snippets using Django, which one is most similar to the SQL query below? SELECT * FROM order WHERE customer_id = 123 a) Order.objects.all('customer_id=123') b) Order.objects.all('customer_id=123').get(*) c) Order.select('*').where('customer_id = 123') d) Order.objects.get(customer_id=123) What is the difference between get() and filter()? Easier # Assume a Task model exists and there is a record with ID 1 # in the database my_task = Task.objects.get(pk=1) my_task.completed = True my_task.save() Which statement best describes Django's behaviour when the following code is run? a) An error will occur b) No changes will occur in the database after running this code c) One row in the Task table will have the value in its completed column set to True d) All rows in the Task table will have the value in its completed column set to True Easier # Assume a Task model exists and there is a record with ID 1 # in the database my_task = Task.objects.get(pk=1) my_task.completed = True my_task.save() Which statement best describes Django's behaviour when the following code is run? a) An error will occur b) No changes will occur in the database after running this code c) One row in the Task table will have the value in its completed column set to True d) All rows in the Task table will have the value in its completed column set to True from django.db import models Easier class Musician(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) instrument = models.CharField(max_length=100) class Fan(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) favorite_musicians = models.ManyToManyField(Musician, related_name="fans") Based off of the above code, which of the following statements about these models are true? a) Musician and Fan have a one-to-many relationship b) Musician and Fan have a many-to-one relationship c) Musician and Fan have a many-to-many relationship d) Musician and Fan have a one-to-one relationship e) Musician and Fan have a flexible relationship from django.db import models Easier class Musician(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) instrument = models.CharField(max_length=100) class Fan(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) favorite_musicians = models.ManyToManyField(Musician, related_name="fans") Based off of the above code, which of the following statements about these models are true? a) Musician and Fan have a one-to-many relationship b) Musician and Fan have a many-to-one relationship c) Musician and Fan have a many-to-many relationship d) Musician and Fan have a one-to-one relationship e) Musician and Fan have a flexible relationship from django.db import models Medium class Musician(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) instrument = models.CharField(max_length=100) class Fan(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) favorite_musicians = models.ManyToManyField(Musician, related_name="fans") Let's assume that your database contains some Musician and Fan records. Based on the above Django model code, what would occur when a Musician is deleted? a) The associated Fan(s) are deleted b) The associated Fan(s) are assigned to a default Musician named 'Musician' c) The associated Fan(s) would automatically create a new Musician for association d) The associated Fan(s) is not directly affected by the Musician being deleted e) The associated Fan(s) inherits the attributes from the Musician class from django.db import models Medium class Musician(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) instrument = models.CharField(max_length=100) class Fan(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) favorite_musicians = models.ManyToManyField(Musician, related_name="fans") Let's assume that your database contains some Musician and Fan records. Based on the above Django model code, what would occur when a Musician is deleted? a) The associated Fan(s) are deleted b) The associated Fan(s) are assigned to a default Musician named 'Musician' c) The associated Fan(s) would automatically create a new Musician for association d) The associated Fan(s) is not directly affected by the Musician being deleted e) The associated Fan(s) inherits the attributes from the Musician class from django.db import models class Musician(models.Model): first_name = models.CharField(max_length=50) Hard last_name = models.CharField(max_length=50) instrument = models.CharField(max_length=100) class Fan(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) favorite_musicians = models.ManyToManyField(Musician, related_name="fans" ) What would occur when the following code is run? # Assume my_musician is an instance of the Musician model for fan in my_musician.fans.all(): print(fan.first_name) #my_musician.fans.get(pk=1) a) An error will occur due to incorrect syntax b) An error could occur because it's possible there are no fans associated with the Musician c) The code will print a list of all fan names associated with the musician - if there are no fan associated with the musician, nothing will be printed d) The name of one associated fan to the Musician will be printed, and there will guaranteed not be an error from django.db import models Hard class Musician(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) instrument = models.CharField(max_length=100) class Fan(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) favorite_musicians = models.ManyToManyField(Musician, related_name="fans" ) What would occur when the following code is run? # Assume my_musician is an instance of the Musician model for fan in my_musician.fans.all(): print(fan.first_name) a) An error will occur due to incorrect syntax b) An error could occur because it's possible there are no fans associated with the Musician c) The code will print a list of all fan names associated with the musician - if there are no fan associated with the musician, nothing will be printed d) The name of one associated fan to the Musician will be printed, and there will guaranteed not be an error That's all! Do you have any questions? You can ask now, or post to the Brightspace forums! For personal questions, email: [email protected] CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon and infographics & images by Freepik

Use Quizgecko on...
Browser
Browser