Using the tuple, birds = ('peacock', 'parrot', 'owl', 'sparrow'), determine the position of 'owl'., print(birds.index('owl')), print(birds.count('owl')), Write the code to access the third bird in the tuple., print(birds[2]), print(birds[3]), Write the code to display the second and third birds in the tuple., print(birds[2:3]), print(birds[1:3]), Write the code to display the last two birds in reverse order using negative indexing., print(birds[-1:-3:-1]), print(birds[-1:-3]), Write the code to reverse the entire tuple., print(birds[-1::-1]), print(birds[-1:-1]), Assume the tuple is ('peacock', 'parrot', 'owl', 'parrot', 'sparrow'). Write the code to count the occurrences of 'parrot'., print(birds.index('parrot')), print(birds.count('parrot')), Write the code to check whether 'parrot' is present in the tuple., print('parrot' with birds), print('parrot' in birds), The wildlife department wants to know the total number of birds., print(len(birds)), print(count(birds)), The wildlife department wants to know whether eagle is present in the list of birds., print('eagle' in birds), print(birds['eagle']), Find the position of 'sparrow' in the tuple., print(birds.index('sparrow')), print(birds.count('sparrow'))

Classifica

Stile di visualizzazione

Opzioni

Cambia modello

Ripristinare il titolo salvato automaticamente: ?