CBSE Coding Class 7 Solution Student Handbook Chapter 4 Understanding Arrays & Collections

CBSE Coding Class 7 Solution – Understanding Arrays & Collections

CBSE Coding Class 7 Solution Student Handbook Chapter 4 Understanding Arrays & Collections all Questions and Answers Solution by Coding Teacher. Net Ex. Here provided all Coding Solution for Class 7.

1.) What is the starting index of an array?

Answer: 0

Reason: The variables in array are always ordered sequentially with index starting from 0.

2.) Which one is an incorrect array?

Answer: Arr[] = [1, ‘a’, ‘b’, 2]

Reason: Arrays do not support different data types in same collection.

3.) An array is

Answer: A group of elements of same data type.

Reason: Arrays are used as containers for elements of the same data type.

4.) Select a correct statement about Arrays

Answer: All of the above

Reason: All the statements are true for array.

Standard Questions

1.) What are collections?

Answer: A collection is nothing but a container that groups multiple items into a single object. Collections are used to store data. We can also retrieve and manipulate data that is stored in the Collections. Examples of collections are a deck of cards which contain a collection of cards, a phone book directory which contain a collection of all the names and phone numbers in an order, a mail folder which contain a collection of cards.

2.) What are different types of collections?

Answer: The Different types of collections are-

 Array

 List

 Sets

 Maps

 Dictionary

 Queue

 Stack

 LinkedList

3.) How can we iterate over collections?

Answer: The iterators are used to provide users a uniform way of accessing collections in a sequential manner. An iteration takes elements from a collection on after another, from one element to the last one. We always need to traverse through the elements of these collections to fetch the data or make any modifications to that data.

We cannot directly add or remove elements while iterating through the collection that includes them.

Ex: Program to iterate a collection

collection = [“apple”, “mango”, “cherry”, “banana” ]

for i in range(len(collection)):

print(collection[i])

4.) What are the different types of modifications that we can perform on collections?

Answer: The modifications that we can do on collections.

 Adding Elements During Iteration

To add elements while iterating a list, set or map, keep the new elements in a temporary list, set, or map and add them to the original after you finish iterating the collection.

 Removing Elements During Iteration

To remove elements from a list, you can create a new list, then insert the elements you wish to keep. Or, add the elements you wish to remove to a different list and remove them after you finish iterating the collection.

5.) What is an Array Index?

Answer: Array index can be defined as the location of an item in an array. The variables that are present in array are always ordered sequentially with index starting from 0. The indexes continue through the natural numbers i.e 1,2,3,4…

6.) Do collections allow backward traversing of data? Support your answer with a proper explanation.

Answer: Yes, collections does allow backward traversing of data just likewe can iterate a collection with from front with the index position being 0. In reverse traversing we start from the last element whose index position is -1 .

For example, if we want to print all the elements from the collections backwards, we have to iterate it from the last index.

7.) Name three real life collections which work like Arrays.

Answer:

Arranging books: Having pile of books and arranging them in your book rack is essentially a real-life example of array.

An Array of chairs: An array of chairs in an auditorium is also an example of real-life array.

An egg tray: An egg tray is a real-life example of array. Having eggs placed in rows.

Higher Order Thinking Skills (HOTS)

1.) Draw a flowchart for the optimized algorithm for finding the square of numbers that we learnt in this chapter

Answer:

2.) Write a program to create an array of prime numbers from 50 to 100.

Answer: Program to Create array of prime numbers from 50 to

100.

low = 50

high = 100

result = []

for i in range ( low, high + 1 ):

for j in range ( 2, i ):

if ( i % j == 0 ):

break

else:

result.append(i)

print(result)

Applied Project

Create an exercise in Minecraft to create and Arrays of even numbers from 1 to 20 and then iterate over each element of this Array.

Answer:

Updated: March 2, 2022 — 12:34 am

Leave a Reply

Your email address will not be published. Required fields are marked *