Intro to Coding - Use Data Structures

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Code for the animal list assignment:

# Animal List animals = ["monkey", "dog", "cat", "elephant", "armadillo"] print(animals) print("These are the animals in the list:\n", len(animals)) print("The number of dogs in the list:\n", animals.count("dog")) animals.reverse() print("The list reversed:\n", animals) animals.sort() print("Here's the list sorted alphabetically:\n", animals) animals.append("bear") print("The new list of animals:\n", animals) animals.insert(0, "lion") print("Here's the list with a new animal added at index 0:\n", animals) animals.remove("elephant") print("The list of animals after the elephant is removed:\n", animals) print("The animal being removed:\n", animals.pop()) print("Now the list of animals is:\n", animals) print("The animal being removed:\n", animals.pop(0)) print("The final list of animals:\n", animals)

Select the correct answers from the drop-down menus. A tuple is ? A type code is a ?

1. a coordinate pair (x, y) 2. a single character that defines the type of objects stored in an array

Select the correct answer from the drop-down list. A stack is a type of list in which ?

1. the last element in the sequence is the first to be removed

Why are arrays considered to be immutable? because an array can hold a combination of different object types because the object type of an array cannot be changed after it is created because an array usually has two or more dimensions because an array's object type can be changed over and over

2. because the object type of an array cannot be changed after it is created

How is an array in Python treated differently than arrays in other programming languages? Arrays in other programming languages can have only one dimension. A Python array can have only one dimension. A Python array is constrained in how its elements are defined and positioned. Arrays in other languages have only one object type, while Python arrays can have different types.

3. A Python array is constrained in how its elements are defined and positioned.


संबंधित स्टडी सेट्स

Parts of Speech: Gerunds, Participles, and Infinitives

View Set

N123 Chp 34 Coronary Artery Disease

View Set

CK-12 Biology Chapter 3 Section 3.1

View Set

Chapter 8: Psychosocial Adaptations to Pregnancy

View Set

Diener & Diener Chapter 5: Happiness at Work

View Set