1. This program produces this output. True or False? books o points book input(W
ID: 3731654 • Letter: 1
Question
1. This program produces this output. True or False? books o points book input(What book are you returning? )while book !". books.append(book) book - input(What book are you returning? ')books.sortOprint(books) What book are you returning? Dickens What book are you returning? Austen What book are you returning? Bronte What book are you returning? [Austen, 'Bronte', 'Dickens] * True O False O option 1 2. Every problem that can be solved using a while loop can 0 points also be solved using a for loop (and vice versa). So how do you know which one to use?* Your answer 3. When do you want to use a while loop? * 0 points Your answerExplanation / Answer
Answer 1: True
Because we are reading list of books ( strings ) , sorting them in ascending order and then printing them.
So in alphabetical order A comes before B and B comes before D.
------------------------------------------------------------------------------------------
Answer 2:
Yes, every problem that can be solved by using while loop also can be solved by for loop ( vice - versa ) . When we do not know exact number of iterations then we use while loop, but if we know number of iterations to be performed then we use for loop.
----------------------------------------------------------------------------------------------------------
Answer 3:
When we do not know exact number of iterations then we use while loop.
--------------------------------------------------------------------------------------------------------
Answer 4: False
We can convert string into list using list built in function.
----------------------------------------------------------------------------------------------------
answer 5:
---------------------------------------------------------------------------------------------------
Answer 6:
Yes, slicing works on list for any kind of data. Yes, given code demostrate that.
-------------------------------------------------------------------------------------------------
Answer 7:
join() , is a string method which joins list of strings with any substring as separator.
Example:
listWord = ["Welcome", "to","Chegg"]
# suppose we want to separate each string with '-'
print ('-'.join(listWord))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.