BAN5013 WEEK5 QUIZ

  1. A dataframe in R is like which of the following relational database concept?  Table
  2. A DEPARTMENTS table contains DEP_NAME, and DEPT_ID_DEP columns and an EMPLOYEES table contains columns called F_NAME and DEP_ID. We want to retrieve the Department Name for each Employee. Which of the following queries will correctly accomplish this?   SELECT D.F_NAME, E.DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE DEPT_ID_DEP = DEP_ID
  3. A SELECT statement is used to retrieve data from a table.   True
  4. After installing and calling the httr library in R, which command can you use to request information about https://www.google.com? GET(“https://www.google.com/”)
  5. After reading an HTML page from a URL, what must you do to get the <body> node from the root <html> node?  Use the html_node() function to return the <body> as a child node of <html> node.
  6. After you write code in an R script file or the R Console, what component of the R environment parses the code into objects in memory?   R Interpreter
  7. Assume that the function add is defined as follows:
    add <- function(x,y) { (x + y) return (x – y) temp <<- (x * y) return (x / y) }
    What will be the output if you issue the command add(10,5)?   5
  8. Assume that the variable test_result contains the vector c(25, 35, 40, 50, 75). What is the result of the expression test_result[test_result < 50]?   [1] 25 35 40
  9. Assume that the variable test_result contains the vector c(25, 35, 40, 50, 75).What is the result of the expression mean(test_result)?   45
  10. Assume that you have a data frame called employee that contains three variables: name, age, and title. If you want to return all the values in the title variable, what command should you use?  employee$title
  11. Assume the array books_array contains 6 elements. The array has three rows and two columns and appears as follows:   “It” “Misery” “The Shining”
  12. Assume there exists an INSTRUCTOR table with several columns including FIRSTNAME, LASTNAME, etc. Which of the following is the most likely result set for the following query:  LEON
    PAUL
    JOE
  13. Assume you have a variable called word_string that contains the string “The quick red fox jumped over the lazy dog.” Which function can you use to replace the word “dog” with the word “cat” in the word_string variable?  chartr()
  14. Assume you have read a .csv file into a data frame variable called employee. It has 20 rows of data and three variables: name, age, and title. What is the correct statement to use to return the fifth row of data in the name and title columns?   employee[5, c(“name”, “title”)]
  15. Assume you have variable called employee that contains the expression list(name = “Juan”, age = 30). What is the correct command to change the contents of the age item to 35?   employee[“age”] <- 35
  16. Attributes of an entity become ________ in a table.   Columns
  17. Complete the sentence: _________________ is a communication protocol for fetching web resources for clients from servers on the Internet.   HTTP
  18. Complete the sentence: In an HTML page, if the <head> and <body> nodes have the same parent, <html>, they are said to be ___________________ to each other.   Sibling nodes
  19. Complete the statement: A Jupyter Notebook is made up of a series of _______________ that you can use to write, run, and interact with your code.   Cells
  20. Data Definition Language (or DDL) statements are used to define, change, or delete database objects such as tables. Which of the following statements are all DDL statements?   CREATE, ALTER, DROP
  21. Data Manipulation Language statements like INSERT, SELECT, UPDATE, and DELETE are used to read and modify data.   True
  22. Execution order does not matter when executing cells in a Jupyter notebook   False
  23. How can a relational database help R handle memory issues?   Running SQL queries in a relational database reduces memory demands in the R client.
  24. How do you convert a UNIX date/time format to an R Date object?  Pass the UNIX date/time value to the as.POSIXct() function and then pass that value to the as.Date() function.
  25. How do you define a global variable in a function?   Use the <<- assignment operator.
  26. How do you return the number of characters in each paragraph of a text file that has been read into a character vector?   Use the nchar() function.
  27. In a data frame, each column is represented by a _________________ of values of the same data type.   Vector 
  28. In a SELECT statement, which SQL clause controls how the result set is displayed?   ORDER BY clause
  29. In R, assume you have a vector named “age,” and each element in the vector is the age of one person in a group. Which command must you use to reorder the ages from youngest to oldest?  sort(age)
  30. In R, what is the result of the function as.numeric(TRUE)?   1
  31. In R, which command should you use to insert a new row into a data frame?   Rbind
  32. In RStudio, which of the following statements about writing code in the File Editor and the Console are true? Select two answers.   You write code in the Console when you want to try out R commands or to run a few lines of code.
    You write code, usually for multiple lines of code, in the File Editor and execute them in batch mode.
  33. One movie is 150 minutes long, and another is 90 minutes long. Using R, which of the following commands would correctly calculate the difference in length, in seconds, between the two films?   (150 – 90) \* 60
  34. R can perform several forms of statistical computation. What is an example of hypothesis testing?   Testing if the mean values of two groups are statistically different.
  35. The CREATE TABLE statement is a….   DDL statement
  36. The five basic SQL commands are:   CREATE, SELECT, INSERT, UPDATE, DELETE
  37. The INSERT statement can be used to insert multiple rows in a single statement.  True
  38. The primary key of a relational table uniquely identifies each _______ in a table.   Row
  39. The SELECT statement is called a query, and the output we get from executing the query is called a result set.   True
  40. What are the basic categories of the SQL language based on functionality?   Both of the above
  41. What are the three ways to work with multiple tables in the same query?  Sub-queries, Implicit joins, JOIN operators
  42. What are three types of data you can store in an array or matrix? Select three answers.   Numeric valus
    Strings
    Integers
  43. What does the following SQL statement do?
    UPDATE INSTRUCTOR SET LASTNAME = ‘Brewster’ WHERE LASTNAME = ‘Smith’  Changes all rows for the instructor with a last name of Smith to have a last name of Brewster.
  44. What happens if a user-defined function is missing the return statement?   The function returns the last evaluated expression in the function.
  45. What is a nominal factor?   A factor with no implied order.
  46. What is the difference between an error and a warning in you R code?   An error halts code execution, while a warning does not.
  47. What is the difference between the expression c(1, 2, 3, 4, 5) and the expression c(5:1)?   They both produce a vector with five numbers but the first is in ascending order and the second is in descending order.
  48. What is the first step you must take before you can read an Excel spreadsheet in R?  Install the readxl library.
  49. What is the function of a primary key?  The primary key uniquely identifies each row in a table.
  50. What is the function of a WHERE clause in an UPDATE statement?  A WHERE clause enables you to specify which rows will be updated.
  51. What is the main difference between a list and a vector?   A list can contain different types of data, while a vector may only contain one type of data.
  52. What is the main difference between a matrix and an array?   A matrix must be two dimensional, but an array can be single, two dimensional, or more than two dimensional.
  53. What is the purpose of the readLines() function?   Reads each text line (ending with a line break) in a text file and returns a character vector.
  54. What is the result of the conditional statement 25 > 15 | 99 >= 100?   TRUE
  55. What is the result of the R expression 100 * (5 – 3)?   200
  56. What is the result of the R expression 4 + 3 * 25?   79
  57. What type of statement should you add to your code if you know that an error or warning might occur?   A tryCatch statement.
  58. When designing a database and making decisions, which potential issue is not helped by normalization?   Lack of security
  59. When mapping data types between R and a database, you should consider converting which of the following to strings?   Date
  60. When querying a table called Author that contains a list of authors and their country of residence, which of the following queries will return the number of authors from each country?  SELECT Country, count(Country) FROM Author GROUP BY Country
  61. When you convert a date in string format to a Date object, what information do you need to pass to the as.Date() function? Select two answers.  The string containing the date.
    The date format of the string.
  62. Which amongst the following is the simplest way to update individual observations in a dataframe?   Store the data in a relational database instead and make the updates there.
  63. Which command in R would return the following numeric vector?   c(5:1)
  64. Which data structure is more suitable to be exported into a text file rather than a .csv or Excel file?  String or characters
  65. Which features of RStudio help facilitate code writing? Select two answers.   Code auto completion
    Syntax highlighting
  66. Which keyword is used to set a condition for a GROUP BY clause?   HAVING
  67. Which looping statement should you use if you want to continue to perform an operation if the value of an expression is true?  While loop
  68. Which of the following are examples of predictive analysis?   Pandemic trends prediction.
    Understanding human languages.
  69. Which of the following can be used in a SELECT statement to restrict a result set?   All of the above
  70. Which of the following data type conversions may be not allowed in R?   character (like `1`, `A`, or `test`) to numeric
  71. Which of the following is a typical way that developers use the R language?   Predictive analysis
  72. Which of the following queries will change the data type of an existing column (phone) to the varchar data type?   ALTER TABLE author ALTER COLUMN phone SET DATA TYPE VARCHAR(20);
  73. Which of the following queries will return the data for employees who belong to the department with the highest value of department ID.  SELECT * FROM EMPLOYEES WHERE DEP_ID =
    ( SELECT MAX(DEPT_ID_DEP) FROM DEPARTMENTS )
  74. Which of the following queries will return the employees who earn less than the average salary?  SELECT * FROM Employees WHERE Salary < (SELECT AVG(Salary) FROM Employees);
  75. Which of the following queries will return the first name of the employee who earns the highest salary?  SELECT FIRST_NAME FROM EMPLOYEES WHERE SALARY =
    ( SELECT MAX(SALARY) FROM EMPLOYEES )
  76. Which of the following SQL queries would return the day of the week each dog was rescued?  SELECT DAYOFWEEK(RescueDate) From PetRescue WHERE Animal = ‘Dog’;
  77. Which of the following SQL statements will delete the authors with IDs of A10 and A11?  DELETE FROM AUTHOR WHERE AUTHOR_ID IN (‘A10’, ‘A11’)
  78. Which of the following statements about a database is/are correct?   A database is a logically coherent collection of data with some inherent meaning
  79. Which of the following statements about built-in database functions is correct?   Built-in database functions reduce the amount of data that is retrieved.
  80. Which of the following statements about numeric and integer values are true? Select three values.   The converted value of an integer to a numeric is always equal to the original integer value.
    A numeric value can be converted to an integer.
    An integer can be converted to a numeric value.
  81. Which of the following statements about regular expressions are true? Select two answers.   Regular expressions are primarily used for data extraction.
    Regular expressions are used to match patterns in strings and text.
  82. Which of the following statements are correct about databases?   All of the above
  83. Which of the following statements would you use to add a new instructor to the Instructor table.  INSERT INTO Instructor(ins_id, lastname, firstname, city, country)
    VALUES(4, ‘Doe’, ‘John’, ‘Sydney’, ‘AU’);
  84. Which of the following will retrieve the LOWEST value of SALARY in a table called EMPLOYEES?  SELECT MIN(SALARY) FROM EMPLOYEES
  85. Which package do you need to install before reading an Excel file in R?  readxl
  86. Which package do you need to install before writing to an Excel file in R?   xlsx
  87. Which R function loads multiple R data structures from a .Rda file?   load()
  88. Which R function saves a single data structure to a .Rda file?  saveRDS()
  89. Which R function saves a workspace to a .RData file?   save.image()
  90. You are working on a Film database, with a FilmLocations table. You want to retrieve a list of films that were released in 2019.You run the following query but find that all the films in the FilmLocations table are listed.  A WHERE clause to limit the results to films released in 2019.
  91. You are writing a query that will give you the total cost to the Pet Rescue organization of rescuing animals. The cost of each rescue is stored in the Cost column. You want the result column to be called “Total_Cost”. Which of the following SQL queries is correct?  SELECT SUM(Cost) AS Total_Cost FROM PetRescue
  92. You can use the str_sub() function to form a substring by counting back from the last position. This function is part of which package?   Stringr
  93. You want to get a resource by its URL using an HTTP request and assign the HTTP response containing status code, headers, response body to a response variable. Which function should you use?   response <- GET(“https://www.mysite.com”)
  94. You want to retrieve a list of authors from Australia, Canada, and India from the table Authors. Which SQL statement is correct?   SELECT * FROM Author WHERE Country IN (‘Australia’, ‘Canada’, ‘India’);
  95. You want to retrieve a list of books priced above $10 and below $25 from the table Book. What are the two ways you can specify the range?   SELECT Title, Price FROM Book WHERE Price BETWEEN 10 and 25;
    SELECT Title, Price FROM Book WHERE Price >= 10 and Price <= 25;
  96. You want to retrieve a list of books that have between 450 and 600 pages. Which clause would you add to the following SQL statement:  WHERE Pages >= 450 and pages <= 600
  97. You want to retrieve a list of employees in alphabetical order of Lastname from the Employees table. Which SQL statement should you use?   SELECT * FROM Employees ORDER BY Lastname;
  98. You want to retrieve Salary information for an employee called Ed from the Employee table. You write the following statement:   WHERE Firstname = ‘Ed’;
  99. You want to select author’s last name from a table, but you only remember the author’s last name starts with the letter B, which string pattern can you use?  SELECT lastname from author where lastname like ‘B%’

Other Links:

Statistics Quiz

Networking Quiz

See other websites for quiz:

Check on QUIZLET

Check on CHEGG

Leave a Reply

Your email address will not be published. Required fields are marked *