Question 1

There is a Python list of integers called scores.  Which of the following blocks of code would cause the sum of all those elements to be printed?

print sum(scores)
sum = 0
for num in scores:
sum += scores[num]
print sum
sum = 0
for num in scores:
sum += num
print sum
sum = 0
for index in range(len(scores) – 1):
sum += index
print sum
sum = 0
for index in range(0, len(scores) – 1):
sum += scores[index]
print sum
sum = 0
for index in range(len(scores)):
sum += index
print sum
sum = 0
for position in range(0, len(scores)):
sum += scores[position]
print sum
sum = 0
for position in range(len(scores)):
sum += scores[position]
print sum

Question 2

1.In the Week 6 workshop we used an “airline” database containing tables aircraft, cities, countries and flights.  You can see the contents of the database by consulting the Week 6 workshop instructions or by importing the airline database into the MySQL Workbench from the dump file provided in the workshop.  Now, imagine that you want to produce a list that describes all aircraft types that fly out of Brisbane.  Which of the following database queries will produce the following result set?

AircraftDescription
Airbus A300
Boeing 757
Boeing 747SP

2.(Here’s a copy of the airline database: airlinedump120911.sql )

SELECT DISTINCT AircraftDescription FROM aircraft, flights
WHERE FromCityCode = ‘BNE’
SELECT DISTINCT AircraftDescription FROM aircraft, flights
WHERE FromCityCode = ‘BNE’ AND ToCityCode != ‘BNE’
SELECT * FROM aircraft, flights
WHERE flights.AircraftType = aircraft.AircraftType AND
ToCityCode = ‘BNE’
SELECT AircraftDescription FROM aircraft, flights, cities
WHERE CityName = ‘Brisbane’ AND FromCityCode = ‘BNE’
SELECT AircraftDescription FROM aircraft, flights
WHERE FromCityCode = ‘BNE’
SELECT AircraftDescription FROM aircraft, flights
WHERE flights.AircraftType = aircraft.AircraftType AND
FromCityCode = ‘BNE’

10 points

Question 3

1.Consider the following SQL table, called LDL_Cholesterol, of LDL Cholesterol Levels and their classifications.  (NB: Although the classifications in the table are generally acceptable, a fictitious maximum has been added to the Very High Risk category for the purpose of this exercise.)

Classification Min Max
Desirable 40 99
Optimal 100 129
Borderline High 130 159
High Risk 160 189
Very High Risk 190 250

2.Assume that Min and Max are both numeric and Classification is a character string.  Assume that you want to change the classification ‘Very High Risk’ to ‘Get Help!’.  Complete the following SQL statement so that it changes the table accordingly.

  1. UPDATE Term 1 SET Term 2
    WHERE Term 3

Please use  the bellow options to full the above gaps for term1,term2,term3.

Classification, LDL_/Cholesterol/ */ True/Fales /Classification’Get Help” /**/Min /Max/ Min>=190/ Min<190 AND Max>250/ 190>Min.

 

 

 

 

Question 4

1.Consider the following Python code, where parameter numbers is intended to store a list of numeric values.

def teaser(numbers):

for index in range(len(numbers) – 1):
if numbers[index] > numbers[index + 1]:
return False

return True

 

Which of the following options best describes the purpose or outcome of this code?

 

Returns True if numbers is sorted in descending order, otherwise returns False.
Returns True if the first value in numbers is less than the next value in that list.
Returns True if the first value in numbers is more than the next value in that list.
Returns True if numbers is sorted in ascending order, otherwise returns False.
Returns False if numbers is sorted in ascending order, otherwise returns True.
Returns True if any value in numbers is less than the next value in that list.
Returns False if numbers is sorted in descending order, otherwise returns True.
Returns False if the first value in numbers is more than the next value in that list, then goes on to check each pair of consecutive values

 

 

 

 

Question 5

1.A database has the tables listed below.  The columns in each table are listed in parentheses ().  The primary key for each table is signified by the underlined columns.

UnitDetails (UnitCode, UnitName)
Offerings (UnitCode, Year, Semester, Coordinator)
Results (UnitCode, Year, Semester, StudentNumber, Result)
StudentDetails(StudentNumber, Name, Address)

Consider the following SQL query:

SELECT UnitDetails.UnitCode, UnitDetails.UnitName, Results.Year, Results.Semester, Results.Result
FROM StudentDetails, UnitDetails, Results
WHERE StudentDetails.StudentNumber = Results.StudentNumber
AND UnitDetails.UnitCode = Results.UnitCode
AND StudentDetails.Name = ‘John Brown’
ORDER BY Results.Year, Results.Semester, UnitDetails.UnitCode

Which of the following best describes the purpose of that SQL query:

The query is not valid as it is syntactically incorrect.
The query extracts all unit details and results that John Brown has studied and orders them by year, semester and unit code.  A selection of the columns from the UnitDetails, Results and StudentDetails tables are included in the output.
The query joins all four tables in the database to extract all unit details and results that John Brown has studied and orders them by year, semester and unit code.
The query extracts all unit details and results that John Brown has studied and orders them by year, semester and unit code.  A selection of the columns from the UnitDetails and Results tables are included in the output.
The query extracts all unit details and results that John Brown has studied and orders them by year, semester and unit code.  All of the columns from the UnitDetails, Results and StudentDetails tables are included in the output.
The query extracts all unit details and results that John Brown has studied and orders them by year, semester and unit code.  All of the columns from the UnitDetails and Results tables are included in the output.

 

Use the order calculator below and get ordering with essaygeek.com now! Contact our live support team for any assistance or inquiry.

Free Quote