In: Computer Science
Python: High school assignment, please keep simple
In python:
Use the following initializer list to create an array:
twainQuotes = ["I have never let my schooling interfere with my education.", "Get your facts first, and then you can distort them as much as you please.", "If you tell the truth, you don't have to remember anything.", "The secret of getting ahead is getting started.", "Age is an issue of mind over matter. If you don't mind, it doesn't matter. "]
Use array functions to sort the quotes. Use functions like extend, insert, pop, remove, sort
Then insert the quote "Courage is resistance to fear, mastery of fear, not absence of fear." at the correct spot alphabetically. Then reprint the quotes.
Sample Run
['I have never let my schooling interfere with my education.', 'Get your facts first, and then you can distort them as much as you please.', "If you tell the truth, you don't have to remember anything.", 'The secret of getting ahead is getting started.', "Age is an issue of mind over matter. If you don't mind, it doesn't matter. "] ["Age is an issue of mind over matter. If you don't mind, it doesn't matter. ", 'Get your facts first, and then you can distort them as much as you please.', 'I have never let my schooling interfere with my education.', "If you tell the truth, you don't have to remember anything.", 'The secret of getting ahead is getting started.'] ["Age is an issue of mind over matter. If you don't mind, it doesn't matter. ", 'Courage is resistance to fear, mastery of fear, not absence of fear.', 'Get your facts first, and then you can distort them as much as you please.', 'I have never let my schooling interfere with my education.', "If you tell the truth, you don't have to remember anything.", 'The secret of getting ahead is getting started.']
twainQuotes = ["I have never let my schooling interfere with my education.", "Get your facts first, and then you can distort them as much as you please.", "If you tell the truth, you don't have to remember anything.", "The secret of getting ahead is getting started.", "Age is an issue of mind over matter. If you don't mind, it doesn't matter. "] print(twainQuotes) twainQuotes.sort() print(twainQuotes) twainQuotes.insert(1,"Courage is resistance to fear, mastery of fear, not absence of fear.") print(twainQuotes)
['I have never let my schooling interfere with my education.', 'Get your facts first, and then you can distort them as much as you please.', "If you tell the truth, you don't have to remember anything.", 'The secret of getting ahead is getting started.', "Age is an issue of mind over matter. If you don't mind, it doesn't matter. "] ["Age is an issue of mind over matter. If you don't mind, it doesn't matter. ", 'Get your facts first, and then you can distort them as much as you please.', 'I have never let my schooling interfere with my education.', "If you tell the truth, you don't have to remember anything.", 'The secret of getting ahead is getting started.'] ["Age is an issue of mind over matter. If you don't mind, it doesn't matter. ", 'Courage is resistance to fear, mastery of fear, not absence of fear.', 'Get your facts first, and then you can distort them as much as you please.', 'I have never let my schooling interfere with my education.', "If you tell the truth, you don't have to remember anything.", 'The secret of getting ahead is getting started.']