Question
The program below creates a list of 5 pet names. Add print() statements as shown in the following steps to print parts of the list.
Print the entire list by passing the variable name into print()
Print the first element in the list by using square brackets and the first element index number
Print the last element in the list by using square brackets and the last element index number
Print the middle three elements in the list by specifying a range in square brackets
The following example demonstrates the expected program output.
('Chewy', 'Yakker', 'RageCat', 'Mr. Barkey', 'Furball')
Chewy
Furball
('Yakker', 'RageCat', 'Mr. Barkey')
petNames = ("Chewy","Yakker","RageCat","Mr. Barkey","Furball")
Print the entire list by passing the variable name into print()
Print the first element in the list by using square brackets and the first element index number
Print the last element in the list by using square brackets and the last element index number
Print the middle three elements in the list by specifying a range in square brackets
The following example demonstrates the expected program output.
('Chewy', 'Yakker', 'RageCat', 'Mr. Barkey', 'Furball')
Chewy
Furball
('Yakker', 'RageCat', 'Mr. Barkey')
petNames = ("Chewy","Yakker","RageCat","Mr. Barkey","Furball")
Answers
Answer
Summary: 5 tests run, 4 tests passed, Original Grade = 80.0
------------------------------------------------------------------------------
PASSED: Source Test 1: Print the entire list (+20.0)
PASSED: Source Test 2: Print the first element (+20.0)
PASSED: Source Test 4: Print the middle 3 elements (+20.0)
PASSED: Output Test 5: Verify program output (+20.0)
FAILED: Source Test 3: Print last element (-20.0)
------------------------------------------------------------------------------
PASSED: Source Test 1: Print the entire list (+20.0)
PASSED: Source Test 2: Print the first element (+20.0)
PASSED: Source Test 4: Print the middle 3 elements (+20.0)
PASSED: Output Test 5: Verify program output (+20.0)
FAILED: Source Test 3: Print last element (-20.0)
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.