--- title: Exam Instructions tags: COMP1010-21T3 slideOptions: transition: slide --- # COMP1010 21T3 Practice Exam ## About The Practice Exam ### Practice Exam Goals 1. To ensure all students know how to submit their COMP1010 exam. 2. To give opportunities to do some practice questions for the exam. (Some similar in style, some similar in content.) ### Practice Exam Timeline 1. Submit before: Thursday 25th November 23:59:00 2. Sim e-mail confirmation before: Saturday 27th November 23:59:00 3. You double check your submission. The confirmation e-mail will include a copy of what was successfully submitted. It is your responsibility to ensure you submitted the correct files. Submissions will not be marked. You may ask for help during your tutorial/lab times as well as by arranging a consultation. You may ask for general feedback along the lines of "inadequate", "adequate", "great". (Beyond this, the amount of detail I will go into with feedback will depend on my availability.) ## Exam Instructions This section is similar, if not identical, to the final exam. ### Important points: (These apply only to the exam. Not the practice one.) * The exam is an <em>individual </em>assessment. Collaboration will be treated as plagiarism and academic misconduct. * You have 3 hours to complete this exam. * The exam (the final one, not this practice one) is a hurdle, meaning you need to get 50% or more on the exam to pass the course, even if your overall course mark is &gt;50. * Partial marks are available for most questions, so include your code even if it doesn't work. * Make sure you save your files often. **More information about plagiarism and academic misconduct:** This exam is to be completed individually. Group submissions will not be allowed. Your program must be entirely your own work. Plagiarism detection software will be used to compare all submissions pairwise and serious penalties will be applied, particularly in the case of repeat offences. Do not copy ideas or code from others. Do not use a publicly accessible repository or allow anyone to see your code. The only exception to this is that you may access, use and adapt any of the lecture, tutorial and lab material from COMP1010 21T3. Please refer to the on-line resources to help you understand what plagiarism is and how it is dealt with at UNSW: * <a href="https://student.unsw.edu.au/plagiarism">Academic Integrity and Plagiarism</a> * <a href="https://www.gs.unsw.edu.au/policy/documents/plagiarismpolicy.pdf">UNSW Plagiarism Policy Statement</a> * <a href="https://www.gs.unsw.edu.au/policy/documents/plagiarismprocedure.pdf">UNSW Plagiarism Management Procedure</a> ### Accessing the Exam: * Practice Exam: From the time this is released, you will be able to download your exam paper here. [Download from here](http://www.cse.unsw.edu.au/~cs1010/21T3/content/exam/practice.zip) The exam paper is in the form of a .zip file. **Steps to take:** * Download the zip file. * Double-click the zip file to produce a folder. **Make sure you delete the old .zip file at this point so you don't accidentally submit it.** The folder contains the following documents: * A copy of this document as a pdf. * Q1.txt -> The document to put your short answer questions in. * Some .py files for the later questions. * A sub-folder called static. Inside that sub-folder is a file called style.css. * Complete the exam by filling in your answers in the relevant files. * Zip up your exam folder (the one that was initially produced when you unzipped). * Upload the .zip file you created with your work in it. * Copy the .zip file you submitted into another folder. Unzip it and check each file contains the correct content that you intended to submit. It is your responsibility to do this before the end of the exam. **What if I have a question during the exam?** If you have a clarification question during the exam, post your question on the [course forum](https://edstem.org/au/courses/7034/discussion/). Please make your question private. **What if there is an announcement during the exam?** It is your responsibility to check the `Exam` section of the forum. I recommend doing this at least once an hour to see any announcements which have been made. (Eg if there's a mistake in the exam paper which we only find during the exam time.) ### Submitting the Exam: What to submit: * A single .zip file. How to submit: * Zip up your folder. * Practice Exam: [Submit it here](https://webcms3.cse.unsw.edu.au/COMP1010/21T3/resources/69192) * Click on `Make Submission`, select your .zip file and click `Submit`. You must submit before the deadline of 23:59:59 on Thursday 25th November in order for your submission to be accepted. When and where: * Anytime before the end of Thursday 25th November. * Online. You can complete the exam from anywhere as long as you have internet access to download the paper after the start of the time period and you have internet access to submit your completed exam paper and accompanying files before the end of the time period. * You can submit as many times as you like. Your latest submission which occurs before the deadline will be the one which is marked. * We recommend submitting after each question you complete to minimise the chances of losing your work. Exam Structure: * Exam is worth ? marks. * Short answer questions (? marks) (approximately 1/4 of the marks). * Programming questions (? marks) (approximately 3/4 of the marks). * You may lose up to 5 marks off your final mark for not following the style guide for the course. (View the style guide <a href="https://hackmd.io/@sim/S13GcqZmY">here</a>.) Exam Content: * Types of questions: * Theory * Programming * Topics: * if statements * loops * functions * methods * all data types we have discussed (strings, int, booleans etc) * dictionaries * lists * Web server. You must use Flask. You may use plain html or pyhtml (whichever you prefer). * External data storage (csv, json). Lab exercises, Kahoots, the revision exercises from thoughout the course, and the practice exam are a good indication of the kinds of questions which will be in the exam. There will **not** be: * PyGame * Databases * Javascript * Object Oriented Programming * Spreadsheets * Manipulating images using PIL Restrictions: * All code must be written in Python * You can import anything from the Python Standard Library but, aside from Flask and PyHTML you can't import from separate packages installed via pip (e.g. Pandas, scipy, etc.) ## Complete List of Files for Practice Exam * `Q1.txt` * `Q2_calculate.py` * `Q2_calculate_web_server.py` * `style.css` (in the `static` folder) * `Q2_calculate_usability.txt` * `Q3_russian_dolls.py` * `Q3_russian_dolls_test.py` (Do not change this file) * `Q4_car_choices.py` * `Q4_car_choices_test.py` (Do not change this file) ## Practice Exam Questions This section is significantly, if not entirely different to the final exam. The structure is the same (short answer questions, some web app development, some other programming questions), but the actual questions are different. ### Q1: Short answer questions (approx 10 marks) 1. What is usability and why is it important? 2. What is the difference between a `if-else` statement and a `for loop`? Give an example of when we might use each one. 3. When writing a web application, what factors would you take into consideration when deciding whether to use cookies to store data or to save the data in a file or database? Be clear which factors would indicate it's more suitable to use a file and which factors indicate it's more suitable to use cookies. 4. If you were setting a COMP1010 exam, what questions would you ask to check if students understood important parts of the course? ### Q2: Calculator (approx 10 marks) Files used in this question: * `Q2_calculate.py` * `Q2_calculate_web_server.py` * `Q2_calculate_style.css` (in the `static` folder) * `Q2_calculate_usability.txt` **Part 1: Write the function** Write a function `calculate` which takes in two numbers and a symbol as parameters, and returns the result of the calculation. Symbols which your function should handle: * `+` means add * `-` means subtract * `*` means multiply * `/` means divide Eg If your function gets passed `3`, `2` and `'*'` it should return `6`. **Part 2: Test the function** Write a function `test_calculate` which tests if your `calculate` function works correctly. This function should contain at least 4 `assert` statements to test your function. For full marks your `assert` statements should test distinctly different features of the function. **Part 3: Write a web server for the function** For this question, write your answer in `calculate_web_server.py`. In that file, write a web server in Python, using Flask, which asks the user for 2 numbers and a symbol, calls the `calculate` function (you may copy and paste the function from `calculate.py`) and displays the result on the screen (in the browser). You may use the code written in lectures as a starting point for this exercise. You may **not** use JavaScript or Django for this exercise. **Part 3: Write a CSS file for your web page** **File:** `calculate_style.css`. In that file write simple CSS and update your web server, `calculate_web_server.py`, to use it. Your CSS file should improve the look and feel of your Calculate webpage/website. This question is designed to assess: * That you can write a CSS file. * That you can connect your CSS file so that it changes the look and feel of your webpage. * That you can use CSS to improve the look and feel of a webpage. Therefore, do not spend too much time on this question. One or two styles (or 5-10 lines of code) is sufficient. **Part 4: Usability** **File:** `calculate_usability.txt` List at least two usability heuristics/features you've followed in implementing your web site (be clear and specific about how your web site follows the heuristic you mention). This feature can be within your website initially, or include your CSS additions. ### Q3: Russian Dolls (approx 10 marks) **Scenario:** Consider what would happen if you took a string and repeatedly inserted it into itself. For example, the string "hello" could be inserted into "hello" to give "helhellolo". Inserting it again and you could end up with "helhhelloellolo". We refer to such strings as nestings. **File:** `Q3_russian_dolls.py` (You may use `Q3_russian_dolls_test.py` to test your code, but do not change that file.) #### Create a nesting Write the function `nest(word, positions)` that creates a nesting. The argument `word` is the initial word and `positions` is a list of positions to do the insertions. For example, inserting "hello" into itself at position 3 gives "helhellolo" then inserting "hello" into that at position 5 gives "helhehellollolo". **NOTE**: You can assume the list of positions is valid; i.e. the position will never be a negative number and will always be less than or equal to the length of the string at that point. ### Dismantle a nesting (harder) Now consider doing this in reverse. Can you start with a nesting like "hhelloellohello" and determine a list of positions that could have built it up from "hello"? Implement a function that does this called `nest_positions(nesting, word)`. It should take in a possible nesting as well as an initial word, and return a list of positions that would create such a nesting. If there is no way to create the nesting with the given word, the function should return `None`. **NOTE**: For some arguments, there are multiple possible results this function could return. Your function is correct if it returns any one of them. ### Q4: Car Choices File: `Q4_car_choices.py` (You may use `Q4_car_choice_test.py` to test your code, but do not change that file.) Part 1: Update the data structure provided in lines 7-27 of `Q4_car_choices.py` (Do not change the lines of code provided. Only add lines of code where it says `# Add your code here`. You may add as many lines of code as you'd like in the place of the `# Add your code here` comment.) Create a dictionary that contains the following cars: * [Nissan Micra](https://www.cse.unsw.edu.au/~cs1010/21T2/exam/examfiles/2015%20Nissan%20Micra%20ST%20K13%20Manual%20MY15.html) * [Ferrari 365 GT4](https://www.cse.unsw.edu.au/~cs1010/21T2/exam/examfiles/1974%20Ferrari%20365%20GT4%20Manual.html) * [Audi SQ7 TDI](https://www.cse.unsw.edu.au/~cs1010/21T2/exam/examfiles/2019%20Audi%20SQ7%20TDI%20Black%20Edition%20Auto%20quattro%20MY19.html) * [Toyota Landcruiser Sahara](https://www.cse.unsw.edu.au/~cs1010/21T2/exam/examfiles/2017%20Toyota%20Landcruiser%20Sahara%20Auto%204x4.html) **Important Notes** * The dictionary fields are up to you but they must be used to complete the `find_cars` function in the next step. * The rules for which cars are permitted for P platers changes from state to state. The allowed or approved states can be found for each car under Overview > Specifications > Probationary Plate Status in the links provided. * The keys `make`, and `model` must be present for marking purposes. Part 2: Replace lines 33-34 of `Q4_car_choices.py` with your code. Complete the function `find_cars` that finds a suitable car. The function will take in the licence level (either a `'P'` for a probationary or `'F'` for a full licence) and the state that the licence is held in (one of: `'QLD'`, `'NT'`, `'NSW'`, `'VIC'`, `'TAS'`, `'SA'`, `'WA'` or `'ACT'`) and return a list of dictionaries of suitable cars. (To be suitable, a car must be either allowed, or approved, for the given licence level, in the given state.)