CMPSC101-Midterm 1&2 questions & answers.docx - Midterm 1...

This preview shows page 1 - 3 out of 10 pages.

Midterm 1 Question 1 0 / 6 pts What would this program display? y = 7 y = x print(x) a. It would print 7, because y is 7 b. There would be an error saying 'x' is undefined c. It would print the letter x d. It would print a 0, assuming all variables are 0 at first Question 2 6 / 6 pts One of these is NOT defined by the Python language to analyze a list. Which is NOT defined? a. sum -- for sum of valuesb. average -- for average of valuesc. len -- for number of valuesd. max -- for maximum value Question 36 / 6 ptsWhich of these would be the appropriate statement to get auser's name into a program? Question 46 / 6 ptsA 75-minute class starting at 2:10 ends at 3:25. Which of these calculations is a reasonable way to represent the arithmetic for this problem? Question 56 / 6 ptsGiven this short dictionary:capitals = {"France":"Paris", "Egypt":"Cairo", "Peru":"Lima"}what would be displayed by the following statement?print(capitals[1]) a. "France":"Paris"b. "Paris"c. "France"d. "Cairo"e. "Egypt"f. "Egypt":"Cairo"g. A KeyError because 1 is not a search key Incorrect Question 6 0 / 6 pts Which of these possible input values would most likely be converted using int()? a. the user's year of birth b. the user's height, as measured in meters c. the user's current Grade Point Average d. the user's student ID number Question 7 12 / 12 pts [ Select ] ["17 % 5", "21 % 5", "13 % 5", "9 % 5"] = 1[ Select ] ["22 // 5", "13 // 5", "9 // 5", "17 // 5"] = 2[ Select ] ["6 - 3 * 3 - 2", "6 - 3 * 2 - 3", "6 - 2 * 2 + 1"] = 3[Select ] ["4 - 6 + 2", "6 - 4 + 2", "5 - 2 + 2", "8 - 2 + 2"] = 4Answer 1:21 % 5Answer 2:13 // 5Answer 3:6 - 2 * 2 + 1Answer 4: 6 - 4 + 2 Question 820 / 20 ptsChoose the appropriate statements to produce a complete Python program to solve the described problem:# Given an input distance in units of feet, display that distance in units of kilometers.
print("Distance in kilometers: ", kilometers) Question 912 / 12 ptsIdentify the results of the following list operations (they might not necessarily be different): 5 numbers[-1]4

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture