1. Homepage
  2. Programming
  3. [2022] MCD4710 Introduction to Algorithms and Programming Assignment 1

[2022] MCD4710 Introduction to Algorithms and Programming Assignment 1

Engage in a Conversation
MCD4710Introduction to Algorithms and ProgrammingAssignment1Monash

 MCD4710 - Introduction to Algorithms and Programming Assignment 1 (8%) CourseNana.COM

Due: Thursday, July 28, 2022, 11:55 pm - Week 6 CourseNana.COM

Marking Criteria CourseNana.COM

This assignment contributes to 8% of your final mark. Task 1 – Read data: 3 marks
Task 2 – Convert weight to kg: 2 marks
Task 3 – Calculate BMI: 2 marks
CourseNana.COM

Task 4 – Categorise patients: 3 marks
Task 5 – Get BMI: 2 marks
Task 6 – Get blood pressure: 2 marks
Task 7 – Check smoking status: 2 marks Task 8 – Extract high-risk records: 4 marks Programming practice – 2 marks
CourseNana.COM

●  Decomposition (1 mark) CourseNana.COM

●  Variable names and code Documentation (1 mark) Total: 22 marks CourseNana.COM

Background Information CourseNana.COM

A data set containing patient information from a hospital (a modified version of a data set taken from MathWorks sample data sets: hospital.mat) is provided in a CSV file (hospital_data.csv) and contains records of 100 patients with the 8 fields; name, gender, age, weight (lbs), height (cm), smoking status, systolic blood pressure and diastolic blood pressure. CourseNana.COM

You are required to write functions to achieve the following (note that this dataset is just for the purposes of testing, and your module must work for any similar dataset as well). CourseNana.COM

Task 1: Read the data into a table CourseNana.COM

Implement a function named read_data(filename), with the following specification, which reads a given file and returns the contents in a table. Make sure you store the smoking status (in the 6th column) as an integer and the other numerical values as floats. CourseNana.COM

Hint: you can use the isalpha(string) string method (you may assume none of the fields in the data file are alphanumeric). CourseNana.COM

Input: The name of the data file (filename) Output: A table with data in the given file. CourseNana.COM

For example: CourseNana.COM

>>> patient_data = read_data(‘hospital_data.csv’)
>>> patient_data[:3] # The first three rows of the table
[['SMITH', 'M', 38.0, 176.0, 145.0, 1, 124.0, 93.0], ['JOHNSON', 'M', 43.0, 163.0, 146.0, 0, 109.0, 77.0], ['WILLIAMS', 'F', 38.0, 131.0, 147.0, 0, 125.0, 83.0]]
CourseNana.COM

Task 2: Convert the weight to kilograms CourseNana.COM

The weight of each patient is given in pounds (lbs). Write a function named lbs_to_kg(table), which converts the weight to kilograms (kg) and replaces the original weight in the table, for each patient. Make sure the weight in kg is rounded to one decimal place.
Note: 1 lbs = 0.4536 kg
CourseNana.COM

Input: A table containing all the patient data that is available in the given data file. Output: The table with weight converted to kilograms CourseNana.COM

For example: CourseNana.COM

>>> patient_data = read_data('hospital_data.csv')
>>> lbs_to_kg(patient_data)
>>> patient_data[:3] # The first three rows of the modified table
[['SMITH', 'M', 38.0, 79.8, 145.0, 1, 124.0, 93.0], ['JOHNSON', 'M', 43.0, 73.9, 146.0, 0, 109.0, 77.0], ['WILLIAMS', 'F', 38.0, 59.4, 147.0, 0, 125.0, 83.0]]
CourseNana.COM

Task 3: Calculate the body mass index (BMI) CourseNana.COM

The body mass index (BMI) for each patient needs to be calculated. Write a function named calculate_BMI(table), which calculates the BMI for each person, using the formula below. Append the BMI values, rounded to one decimal place, as the last column of the table. CourseNana.COM

mass (kg) height2 (m2 ) CourseNana.COM

Input: A table containing all the patient data that is available in the given data file, with the weight converted to kg.
Output: The table with the BMI values added to the last column of the table.
CourseNana.COM

For example: CourseNana.COM

>>> patient_data = read_data('hospital_data.csv')
>>> lbs_to_kg(patient_data)
>>> calculate_BMI(patient_data)
>>> patient_data[:3] # The first three rows of the modified table
[['SMITH', 'M', 38.0, 79.8, 145.0, 1, 124.0, 93.0, 38.0], ['JOHNSON', 'M', 43.0, 73.9, 146.0, 0, 109.0, 77.0, 34.7], ['WILLIAMS', 'F', 38.0, 59.4, 147.0, 0, 125.0, 83.0, 27.5]]
CourseNana.COM

Task 4: Categorize based on BMI CourseNana.COM

The patients in the data table need to be categorized according to their BMI value. Write a function named categorise(table) that determines the category for each person based on the following classification and store characters U, N or O for underweight, normal and obese, respectively. This information should be stored next to their BMI value in the table. The categorization should be done according to the following classification. CourseNana.COM

BMI <18:Underweight 18 £ BMI < 30 : Normal CourseNana.COM

BMI ³ 30 : Obese CourseNana.COM

Input: A table containing all the patient data that is available in the given data file, with the BMI values appended.
Output: The table with the categories added to the last column of the table.
CourseNana.COM

BMI= CourseNana.COM

For example: CourseNana.COM

>>> patient_data = read_data('hospital_data.csv') >>> lbs_to_kg(patient_data)
>>> calculate_BMI(patient_data)
>>> categorise(patient_data)
CourseNana.COM

>>> patient_data[:3] # The first three rows of the modified table
[['SMITH', 'M', 38.0, 79.8, 145.0, 1, 124.0, 93.0, 38.0, ‘O’], ['JOHNSON', 'M', 43.0, 73.9, 146.0, 0, 109.0, 77.0, 34.7, ‘O’], ['WILLIAMS', 'F', 38.0, 59.4, 147.0, 0, 125.0, 83.0, 27.5, ‘N’]]
CourseNana.COM

Task 5: Look up BMI value of a given patient CourseNana.COM

Write a function named get_BMI(table,name) that returns the BMI value of a given patient by looking up the name in the table. If the given name is not available in the table, the function should return None. You may assume that the names are unique. CourseNana.COM

Input: A table containing all the patient data that is available in the given data file, with the BMI values appended and the name of a patient.
Output: The BMI value of the given patient.
CourseNana.COM

For example: CourseNana.COM

>>> patient_data = read_data('hospital_data.csv') >>> lbs_to_kg(patient_data)
>>> calculate_BMI(patient_data)
>>> get_BMI(patient_data,’Johnson’)
CourseNana.COM

34.7 CourseNana.COM

Task 6: Look up blood pressure value of a given patient CourseNana.COM

Write a function named get_BP(table,name) that returns the blood pressure readings as a tuple, (systolic, diastolic), of a given patient by looking it up in the table. Make sure the blood pressure readings are returned as integer values. If the given name is not available in the table, the function should return None. You may assume that the names are unique. CourseNana.COM

Input: A table containing all the patient data that is available in the given data file and the name of a patient.
Output: The blood pressure readings of the given patient as a tuple.
CourseNana.COM

For example: CourseNana.COM

>>> patient_data = read_data('hospital_data.csv') >>> get_BP(patient_data,’Johnson’)
(109, 77)
CourseNana.COM

Task 7: Determine whether a given patient is a smoker or not CourseNana.COM

Write a function named is_smoker(table,name) that returns True if the given patient is a smoker and False if not. The function should return None if the patient record is not available in the table. CourseNana.COM

Input: A table containing all the patient data that is available in the given data file and the name of a patient.
Output: True if the patient is a smoker and False otherwise.
CourseNana.COM

For example: CourseNana.COM

>>> patient_data = read_data('hospital_data.csv') >>> is_smoker(patient_data,’Johnson’)
False
>>> is_smoker(patient_data,’White’)
CourseNana.COM

True CourseNana.COM

Task 8: Extract the records of high-risk patients and write to a separate csv file CourseNana.COM

Now we need to extract the records of high-risk patients from the table and save their details (all column values of the patient in the table) into a new csv file. Write a function named extract_high_risk(table,filename) that extracts the records of patients who satisfy all of the following conditions and write their data into the given file, output_filename. Add the column headings to the file as well. CourseNana.COM

A patient is deemed at high-risk if they CourseNana.COM

  • ●  are obese
  • ●  has either systolic blood pressure greater than 125 or diastolic blood pressure greater than 85.
  • ●  are a smoker

Note: You have to use the functions written in the previous tasks. Do not rewrite the code written in the previous tasks here. CourseNana.COM

Input: A table containing all the patient data and a filename Output: The given file updated with the high-risk patient details CourseNana.COM

For example: CourseNana.COM

>>> patient_data = read_data('hospital_data.csv') >>> lbs_to_kg(patient_data)
>>> calculate_BMI(patient_data)
>>> categorise(patient_data)
CourseNana.COM

>>> extract_high_risk(patient_data,'high_risk_patients.csv')
>>> high_risk_table = read_data('high_risk_patients.csv') # read high-risk values (for testing)
CourseNana.COM

  CourseNana.COM

high-risk records [['SMITH', 'M', 38.0, 79.8, 145.0, 1, 124.0, 93.0, 38.0, 'O'], ['WHITE', 'M', 39.0, 91.6, 152.0, 1, 130.0, 95.0, 39.6, 'O']] CourseNana.COM

---------------------------------- END OF ASSIGNMENT --------------------------------------- CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
MCD4710代写,Introduction to Algorithms and Programming代写,Assignment1代写,Monash代写,MCD4710代编,Introduction to Algorithms and Programming代编,Assignment1代编,Monash代编,MCD4710代考,Introduction to Algorithms and Programming代考,Assignment1代考,Monash代考,MCD4710help,Introduction to Algorithms and Programminghelp,Assignment1help,Monashhelp,MCD4710作业代写,Introduction to Algorithms and Programming作业代写,Assignment1作业代写,Monash作业代写,MCD4710编程代写,Introduction to Algorithms and Programming编程代写,Assignment1编程代写,Monash编程代写,MCD4710programming help,Introduction to Algorithms and Programmingprogramming help,Assignment1programming help,Monashprogramming help,MCD4710assignment help,Introduction to Algorithms and Programmingassignment help,Assignment1assignment help,Monashassignment help,MCD4710solution,Introduction to Algorithms and Programmingsolution,Assignment1solution,Monashsolution,