Start
by assigning to variable answers a list containing an arbitrary
sequence of strings ‘Y’ and ‘N’. For example:
answers=
[‘Y’,’N’,’N’,’Y’,’N’,’Y’,’Y’,’Y’,’N’,’N’,’N’]
Write Python statements
corresponding to the following:
(a) assign to variable numYes
the number of occurrences of ‘Y’ in list answers.
(b) assign to
variable numNo the number of occurrences of ‘N’ in list answers.
(c)
assign to variable percentYest the percentage of strings in answers
that are ‘Y’.
(d) sort the list answers.
(e) Assign to
variable f the index of the first occurrence of ‘Y’ in sorted list
answers.
thank
you in advance
The post an arbitrary sequence of strings appeared first on My Assignment Online.