PDF Download
FREE AND STUDY GAMES ABOUT PYTHON FINAL EXAM
EXAM QUESTIONS
Actual Qs and Ans Expert-Verified Explanation
This Exam contains:
-Guarantee passing score -55 Questions and Answers -format set of multiple-choice -Expert-Verified Explanation Question 1: The index of the first element in a list is 1, the index of the second element is 2, and so forth.
Answer:
False Question 2: When accessing each character in a string, such as for copying purposes, you would typically use a while loop.
Answer:
False Question 3: Which method would you use to determine whether a certain substring is the suffix of a string?
Answer:
endswith(substring) Question 4: The strip() method returns a copy of the string with all the leading whitespace characters removed but does not remove trailing whitespace characters.
Answer:
False
Question 5: What will be assigned to the variable s_string after the following code executes?special = '1357 Country Ln.'
s_string = special[ :4]
Answer:
'1357'
Question 6: In order to create a graph in Python, you need to include
Answer:
import matplotlib.pyplot
Question 7: Indexing works with both strings and lists.
Answer:
True
Question 8: What will be displayed after the following code executes?
mystr = 'yes' yourstr = 'no' mystr += yourstr * 2 print(mystr)
Answer:
yesnono
Question 9: The index -1 identifies the last element in a list.
Answer:
True
Question 10: What are the data items in a list called?
Answer:
elements Question 11: What will be the value of the variable string after the following code executes?string = 'abcd' string.upper()
Answer:
'ABCD'
Question 12: What values will list2 contain after the following code executes?
list1 = [1, 10, 3, 6] list2 = [item * 2 for item in list1 if item > 5]
Answer:
20, 12]
Question 13: Which list will be referenced by the variable number after the following code is executed?number = range(0, 9, 2)
Answer:
[0, 2, 4, 6, 8]
Question 14: Which method can be used to place an item at a specific index in a list?
Answer:
insert
Question 15: The following code will display 'yes + no': mystr = 'yes' yourstr = 'no' mystr += yourstr print(mystr)
Answer:
False Question 16: What will be the value of the variable list after the following code executes?list = [1, 2] list = list * 3
Answer:
[1, 2, 1, 2, 1, 2]
Question 17: The sort method rearranges the elements of a list so they are in ascending or descending order.
Answer:
False Question 18: You cannot use a for loop to iterate over the characters in a string.
Answer:
False Question 19: Indexing of a string starts at 1 so the index of the first character is 1, the index of the second character is 2, and so forth.
Answer:
False