Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Western Sydney University Sample Exam - Autumn Session 2021 Unit Name: Programming for Data Science Unit Number: 301113 Number of �estions: 4 Total Number of Pages: 2 Unit Coordinator: Laurence...

1 answer below »
Western Sydney University
Sample Exam - Autumn Session 2021
Unit Name: Programming for Data Science Unit Number: 301113
Number of �estions: 4 Total Number of Pages: 2
Unit Coordinator: Laurence Park Time Allowed: 1.5 hours (includes reading time)
Value of �estions: Exam questions are worth 10 marks, giving a total of 40 marks. Each question shows
the
eakdown of marks.
Answering �estions: Answer all questions in the provided script books.
Resources Allowed: This is an open book computer lab exam. This computer test requires the use of
Rstudio and vUWS. A computer is to be used to answer questions. No communication software is allowed.
No other devices are allowed.
This paper must be returned to the person running the test.
Before the test is started
• Start vUWS and download the exam scripts and data using the links in the vUWS exam page.
• Write your name, student number and unit details at the top of your script �le following the example
elow (make sure to replace Laurence’s details with yours):
# Student Surname: Park
# Student Firstname: Laurence
# Student ID: XXXXXXXXXX
# Unit Name: Programming for Data Science
# Unit Number: 301113
All code is R code.
Do not start the exam until told to do so.
Task 1: Algorithms XXXXXXXXXX = 10 marks)
1. Write the code to print “Start exam!” if the variable countdown equals 0.
2. Write a while loop that prints the statement “Time remaining: X” at each iteration, where X is 10 at the
�rst iteration, 9 in the second, and counts down to 0.
3. Write a for loop that loops from 0 to 1000, with intervals of size 100 (i.e. 0, 100, 200) and prints “Time
elapsed: X” at each iteration, where X is the loop variable.
4. Give an example of an in�nite loop and explain why it is an in�nite loop.
Task 2: Functions XXXXXXXXXX = 10 marks)
1. Write a function with one argument, a numeric variable x, that returns double that number as output.
2. Write a function with two arguments that returns the product of the two.
3. Write a function with two arguments, that returns the product of the two. But if the second argument is
not provided, it uses the default value of 2 for that missing argument.
4. R is a functional language. Explain what it means for a language to be functional.
1
Task 3: Data Structures and Analysis XXXXXXXXXX = 10 marks)
The CSV �le task3data.csv contains details of the size of a set of electrical components.
1. Write the code to load the �le task3data.csv, then print the number of rows and the column names of
the data frame.
2. Write the code to provide the rows where the variable “back” is greater than 100.
3. Write the code to �nd the value(s) of “front” in the rows where the value of “back” is the maximum.
4. A record of who has purchased each component is required, where each component could be purchased
any number of times. Brie�y describe a data structure to record the purchase information.
Task 4: Visualisation XXXXXXXXXX = 10 marks)
Run the below code to create the data frame d with columns degree, inCount and outCount, then use the
data frame to perform the following tasks.
x <- 1:100
d <- data.frame(degree = x, inCount = ceiling(10000*xˆ{-2.2}),
outCount = ceiling(10000*xˆ{-2.4}))
1. Provide the code to produce a plot of degree and inCount (degree is the x axis) with the axis labelled
and the plot titled.
2. Provide the code to produce a log-log plot (both x and y axis have log scales) of degree and inCount
(degree is the x axis) with the axis labelled and the plot titled.
3. Provide the code to produce a log-log plot (both x and y axis have log scales) of degree and inCount
(degree is the x axis) with the axis labelled and the plot titled. Also include a line estimating the mean in
count for each degree.
4. Describe a plot that allows us to compare the inCount and outCount variables.
2
    Before the test is started
    Task 1: Algorithms XXXXXXXXXX = 10 marks)
    Task 2: Functions XXXXXXXXXX = 10 marks)
    Task 3: Data Structures and Analysis XXXXXXXXXX = 10 marks)
    Task 4: Visualisation XXXXXXXXXX = 10 marks)
Answered 1 days After Mar 20, 2023

Solution

Mukesh answered on Mar 22 2023
40 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here