Docsity

Python List and String Fundamentals, Exams of Nursing

Toggle sidebar
bg1
Python Exam 3 questions with verified
answers/passed (4)
This term refers to an individual item in a list - correct answer ✔✔Element
This is a number that identifies an item in a list - correct answer ✔✔index
This is the first index in a list - correct answer ✔✔0
This is the last index in a list - correct answer ✔✔The size of the list minus one
This will happen if you try to use an index that is out of range for a list - correct answer ✔✔an IndexError
will occur
This function returns the length of a list - correct answer ✔✔len
When the * operator's left operand is a list and its right oberand is an integer, the operator becoms this -
correct answer ✔✔the repetition operator
This list method adds an item to the end of an existing list - correct answer ✔✔append
This removes an item at a specific index in a list. - correct answer ✔✔the del method
Assume the following statement appears in a program:
mylist = []
pf3
pf4

Partial preview of the text

Download Python List and String Fundamentals and more Exams Nursing in PDF only on Docsity!

Python Exam 3 questions with verified

answers/passed (4)

This term refers to an individual item in a list - correct answer ✔✔Element This is a number that identifies an item in a list - correct answer ✔✔index This is the first index in a list - correct answer ✔✔ 0 This is the last index in a list - correct answer ✔✔The size of the list minus one This will happen if you try to use an index that is out of range for a list - correct answer ✔✔an IndexError will occur This function returns the length of a list - correct answer ✔✔len When the * operator's left operand is a list and its right oberand is an integer, the operator becoms this - correct answer ✔✔the repetition operator This list method adds an item to the end of an existing list - correct answer ✔✔append This removes an item at a specific index in a list. - correct answer ✔✔the del method Assume the following statement appears in a program: mylist = []

What statement would you use to add the string 'Labrador' to the list at index 0? - correct answer ✔✔mylist.insert(0, 'Labrador') If you call the index method to locate an item in a list and the item is not found, this happens. - correct answer ✔✔A ValueError exception is raised This built-in function returns the highest value in a list - correct answer ✔✔max This file object method returns a list containing the file's contents - correct answer ✔✔readlines Which of the following statements creates a tuple? a) values = [1, 2, 3, 4] b) values = {1, 2, 3, 4} c) values = (1) d) values = (1,) - correct answer ✔✔values = (1,) This is the first index in a string. - correct answer ✔✔ 0 This is the last index in a string - correct answer ✔✔The size of the string minus one This will happen if you try to use an index that is out of range for a string - correct answer ✔✔an IndexError will occur This function returns the length of a string. - correct answer ✔✔len This string method returns a copy of the string with all leading whitespace characters removed - correct answer ✔✔lstrip

A set of standard diagrams for graphically depicting object-oriented systems is provided by ______________. - correct answer ✔✔the Unified Modeling Language In one approach to identifying the classes in a problem, the programmer identifies the _____ in a description of the problem domain. - correct answer ✔✔nouns In one approach to identifying a class' data attributes and methods, the programmer identifies the class'

  • correct answer ✔✔responsibilities