Perform a range of programming tests

Assignment Help Other Subject
Reference no: EM133196875

Case Description

Lind, Mayer and Hyatt (LMH) is a company specialising in the provision of IT support, managed services and consulting services to small and medium enterprises in Melbourne. They provide a range of innovative IT services, namely: managed IT services, IT support, consulting and cyber security.

You have applied for a Business Analyst position with the company and one of the requirements of the position is hands-on Python programming knowledge as you will be required to perform advanced data analysis and manipulation. The application process requires that you take a test of your python programming skills more particularly for solving problems in business contexts.

As part of the test, you will are provided with data (in the section below) to perform a range of programming tests.

Furthermore, as the company has strict guidelines for writing quality and maintainable code, they also want to test your knowledge of best practices in the area of python programming using Jupyter notebooks. More details to follow later in the assignment brief.

Data
The data for this assignment is available as a text file (products.json) which can be downloaded from here Download here.
After downloading products.json, save the file to the folder where you will create your Jupyter Notebook.
Instructions for loading the data file in your notebook, will follow in Task A0 in the table below.

Requirements
In this assignment, you are required to perform 2 sets of tasks:
A. Programming
B. Reflective and best practices

A. Programming tasks - Jupyter Notebook
For the programming part of the assignment, you are required to perform 10 tasks. The programming component is worth 80% of the assignment marks and the tasks have equal weights in term of marks.
Please note that although the tasks are expressed as questions in English, your answers to these questions are expected to be python code.
A common issue with novice programmers is working out the solution in their head and writing code just to print the answer. This is called hard-coding and it is not acceptable as a solution. If there are changes in the data, then hard-coding will give erroneous results. The correct solution is expected to programmatically compute the results right from the beginning.

Your first task for this assignment is to create a Jupyter Notebook (as explained in a previous learning activity in week 1).
Please ensure that you have markdown cells for the following at the beginning of the notebook:
• Course details (course code and name)
• Assignment details ( assignment number and name)
• Student details (student full name and student number.
After having added the above details to markdown cells at the beginning of the notebook, insert a code cell and copy and paste the code shown below to the cell.

Read the Python comments in the code cell to understand what the code does.
Press Shift+Enter to execute the code cell (while your cursor is positioned in that cell). The contents of the JSON file should be displayed below the code cell.
You are now done with Task A0. For each of the tasks described below (A1-A10), you need to insert two cells:
• A markdown cell for the name of the task
• A code cell for the response (Python code) to the questions being asked. All your answers to the questions for a particular task should be in a single code cell (with blank lines and comments between the answers

Task A1 - Process a single dictionary In this task, you are required to demonstrate your knowledge of dictionaries.
Before you can answer the questions of this task, you will need to select a dictionary from the provided data. Copy and paste the code below to your code cell (and make sure that you read the comments in the code):
# Make a copy of the first product
# So that any changes made to the copy do not affect the item in the list
# This code is used only once in your notebook
# Do not use this code in other tasks
prod = products[0].copy()
This code assigns the first product from list products to a variable named prod. Furthermore, it makes a copy of the contents of products[0] rather than just just pointing to the memory location where products[0] is stored. In this way, any modifications made to prod is not reflected at products[0].
Next, write Python code (in the same code cell that you made a copy of the product) to answer the following questions:
1. Print the category of the product (the copy you've made). Of course, since your python programming skills are being tested, you cannot figure this from the data and write down the answer or even use python code to just print the answer that you've figured out as this would amount to what is known as hard-coding in programming (as previously explained). Instead, you will need to write python code to do everything.
2. Add attribute "recall_product" to the product and set its value to 1. How would you check that the attribute has been added? (again all the steps should be done programmatically).
3. Remove attribute "lead_time_days" from the product. How would you check that the attribute has been deleted? At this stage, I will stop repeating that everything has to be done programmatically.
4. Change the name of the product to "Genre: Country & Western". How would you check that the change has been made?
Every time you are asked to do something as part of any task, you need to provide evidence that the operation worked.
Write the code for this task (and for the other programming tasks) in a single code cell i.e. do not answer the parts of this task in separate code cells.
Hints:
• Week 2 Pre-workshop Learning Activities 2.1.0
• Week 2 Workshop Learning Activity 2.2.1 - Collections

Task A2- Process a list of dictionaries Write Python code to do the following:
1.
1. Find the length of the products list (as loaded from the JSON file)
2. Change the *unit_price* of the second product from *549.99* to *509.99*.
3. Add a new product to the list with the following details (be careful with the dictionary syntax i.e. don't get confused between : and = ):
discontinued = 1
lead_time_days = 2
product_category = Wireless Phone
product_description = Display: 5.5-inches Camera
product_id = 166
product_name = Samsung Galaxy Note II, White 16GB (AT&T)
reorder_level = 44
unit_price = 749.99
4. Remove the first product from the list
Hints:
• Week 2 Pre-workshop Learning Activities 2.1.0 (lists, dictionaries),
• Week 3 Pre-workshop Learning Activities 3.1.0 (loops and conditional statements)
• Week 3 Workshop Learning Activity 3.2.1 - Programming constructs - Programming Constructs (loops and conditional statements)

Task A3 - User-defined functions Write a function to do the following:
• Take a list as input parameter
• Iterate through the items in the list to find the maximum value in the list. Please note that you are not allowed to use the Python built-in max(). Instead you must use a loop to determine the maximum value. If you do not comply with the instructions, you will be marked down.
• Return the maximum value
Next, instantiate a list with the following values: 20, 230, 5.2, 3555, 22.
Then, make a function call to the previously defined function, pass the list as argument to the function and save the value returned by the function to an appropriately-named variable.
So, what is the computed value?
Notes:
• Although the course materials might not contain an exact example of how to write a function that computes the maximum value of the items in a list, and you should be able to figure this out from the text book and other parts of the course materials.
Hints:
• Week 3 Pre-workshop Learning Activities 3.1.0 (loops and conditional statements
• Week 3 Workshop Learning Activities 3.2.1 Programming Constructs (loops and conditional statements).
• Week 3 Workshop Learning Activities 3.2.2 UDF (user-defined functions).
• Severance book - Section 5.6.2 Maximum and minimum loops

Task A4 - Iteration Given the provided list of products, write python code to:
1. Process the list of dictionaries to create a list called product_names to store the product names.
2. Join the product names from the product_names list with two semi-colons followed by space to form a single string e.g. Samsung Galaxy S III, Blue 16GB (Sprint);; LG Optimus F7 (Boost Mobile);; ZTE Boost Max - Prepaid Phone (Boost Mobile);; Samsung Galaxy Note II, White 16GB (AT&T)
3. Print the joined string.
Hints:
• Week 2 Pre-workshop Learning Activities 2.1.0 (lists, dictionaries)
• Week 3 Pre-workshop Learning Activities 3.1.0 (loops and conditional statements)
• Week 3 Workshop Learning Activities 3.2.1 Programming Constructs (loops and conditional statements).
• Week 3 Workshop Learning Activities 3.2.4 - Advanced Techniques for Collections (joining items in a list as a single string)

Task A5 - Create a dictionary Write python code to:
1. Create a dictionary named employee_201 with the following key/value pairs:
o email = [email protected]
o employee_id = 201
o firstname = Christine
o lastname = Howard
o title = Mrs
o work_phone: (03) 7465 4973
2. Print the dictionary
Hints:
• Week 2 Pre-workshop Learning Activities 2.1.0
• Week 2 Workshop Learning Activity 2.2.1 - Collections

Task A6 - Filter items from a list Given the provided list of products, write python code to:
1. Process the list of dictionaries to create a new list of dictionaries.
2. Only include products that are from either the "Wireless Phone" or "Wireless Phone Accessory" categories in the new list.
3. Print the length of the new list
4. Print the contents of the new list
Notes:
• This problem must be solved in ONE LINE using filter() with a SINGLE lambda function
Hints:
• Week 3 Workshop Learning Activities 3.2.4 - Advanced Techniques for Collections .
• You can solve this problem using the "or" operator i.e.
o x['key_name'] == ??? or x['key_name'] == ???

Task A7 - Process items from a list Given the provided list of products, write python code to:
1. Process the list of dictionaries to create a list of products formatted as
o product_id - product_category - product_name
• e.g. 163 - Wireless Phone Samsung Galaxy S III, Blue 16GB (Sprint), etc
o Please pay careful attention about using spaces for proper punctuation
2. Print the newly created list
Notes:
• This problem must be solved in ONE LINE using map() with a SINGLE lambda function
• The output can be obtained using string concatenation
• Numbers should be cast to strings for concatenation to work
Hints:
• Week 3 Workshop Learning Activities 3.2.4 - Advanced Techniques for Collections

Task A8 - Date processing and formatting Write Python code to:
1. Convert the Australian date string 18/07/2022 to a python date object
2. Print the date object without any formatting. Double-check that the day and month are in the correct order.
3. Create a date object by passing the following parameters: 2022, 10, 14 to the date() object from the datetime library.
4. Print the date object in Australian format i.e. dd/mm/yyyy.
Hint:
• Week 2 Workshop Learning Activities 2.2.3 - Date and datetime

Task A9 - Regex We have some email addresses in the username\@companyname.com format. Both user names and company names are composed of letters only.
Write Python code to print the user name of a given email address.
• Example: If the email address is: [email protected], then, the result should be: roberto.
Notes:
• You must use a regex and group() to solve this problem
Hints:
• Week 3 Workshop Learning Activities 3.2.5 - Regex
• Use \w to match letters

Task A10 - Object-Oriented Programming Write Python code to define a class named Product as per following specifications.
1. Class name: Product (note uppercase "P").
2. Define instance attributes as specified by the items in the dictionary objects from the provided products list i.e. discontinued, lead_time_days, etc.
3. Define an _init_() method (note: 2 underscores before and after the init method) which initialises the instance attributes to the value of the parameters passed to the method. The init() method should accept a single dictionary containing all the key:value pairs for a product as parameter. The task of the init() method is to store the key:value pairs as individual instance attributes. Although there's no example of passing a dictionary as a parameter to a method, this is not different than passing any other variable to a method. You should be able to figure out how to do this from the course materials as your ability to integrate concepts is being tested here.
4. Define a set_unit_price() method which sets (saves) the unit_price in the instance variable to the value of the parameter passed.
5. Define a get_unit_price() method which returns the unit_price stored in the instance variable. Again, there might not be an exact example in the course materials and you should be able to figure how to return something to the caller as this has been taught in other parts of the course.

After having defined the class, in the same code cell, instantiate an object of the class Product and call its methods as follows:
1. Instantiate an object of the class (name it prod) and pass products[1] to the initialiser (pass the whole products[1] object, not individual attributes) as parameter.
2. Set ( or store) the unit_price to 199.99 by calling set_unit_price() and passing this value as argument.
3. Call the get_unit_price() method to get (or retrieve) the new value stored in the unit price and print the returned value.

Notes:
• You must used the techniques taught in the course to solve this problem.
• If you different techniques (e.g. getattr(), ** to pass the key:value pairs of a dictionary as named arguments), you will be marked down as the purpose of this course is to learn the basics of the Python programming language.

Hints:
• Week 4 Pre-workshop Learning activities 4.1.0
• Week 4 Workshop Learning activities 4.2.1 Implement a class

Attachment:- Python programming.rar

Reference no: EM133196875

Questions Cloud

Do the vaccine mandate violate any subsection of the article : In your opinion, do these vaccine mandates violate any subsection of the article? Everyone, without any discrimination, has right to equal pay for equal work.
Write a paper on the Internet of Things : Conduct research and write a paper on either collaborative technologies or the Internet of Things. Briefly define the technologies you chose
Devise a completion plan for all milestones : Devise a completion plan for all milestones, including revisions of previous work as suggested by the instructor. Review the deadlines for completing assignment
Create a crosstabulation between lettergrade and newlocation : Create a crosstabulation between LetterGrade (DV) and NewLocation (IV). Provide an interpretation of the output.
Perform a range of programming tests : Provide a range of innovative IT services, namely: managed IT services, IT support, consulting and cyber security - perform a range of programming tests
Research on compliance and codes of ethics : Pick one of the following terms for your research: Compliance, codes of ethics, ethics officers, formal controls, or ethics audit
Which of dynamic growth-market-oriented reforms in russia : Which of the following periods is characterized by dynamic growth and market-oriented reforms in Russia? Boston University.
What is the equivalent rate with annual compounding : An interest rate is quoted as 5%5% per annum with semiannual compounding. What is the equivalent rate with (a) annual compounding
Manufacturing budget case study : Post Me assembles timber mailboxes which he sells to homeowners and builders for $48.00 each. Each mailbox requires the following:

Reviews

Write a Review

Other Subject Questions & Answers

  Eye witness testimony and the misinformation effect

Eye Witness Testimony and the Misinformation Effect

  Socio-economic considerations of federal procurement process

Assess the socio-economic considerations of the federal procurement process. Distinguish between contract financing via loan guarantees vs. private financing, and determine the impact each will have on a minority vendor.

  Research non-business areas where data mining be applied

Please send a 150-word response to the following - You are to research and cite at least three non-business areas where data mining might be fruitfully applied

  How the exercise would be appropriate for the topic

Write an explanation of the exercise to discuss the ways in which it illustrates behaviorism, and discuss which behavioral principles or characteristics.

  Create presentation on Competition in Craft Beer Industry

Need to create a 6 slide presentation as per the format requirement. Case - Competition in the Craft Beer Industry in 2016

  Evaluate client satisfaction with various clinical services

You have been selected by your nonprofit agency to evaluate client satisfaction with various clinical services. The agency serves approximately 2,000 clients.

  What benefit would be gained by utilizing the linear

answer the following questionsquestion 1 what benefit would be gained by utilizing linear programming lp for marketing

  Public relations-public affairs and media paper

Explain the public's right to know versus personal privacy. What ethical questions emerge when considering organizational truth and public communication?

  Personal awareness of complex organizational systems

Develop a personal awareness of complex organizational systems, and integrate values and beliefs with organizational mission

  Deals with juvenile justice issue

Find a recent case in any jurisdiction that deals with a juvenile justice issue.

  Direction from the supreme court

Explain that significance, and explain the direction from the Supreme Court to the Congress in those two cases?

  Define presentation about the pathophysiology of a topic

For this project, you will complete a clinical case study analysis, research review, and PowerPoint video presentation about the pathophysiology of a topic.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd