0% found this document useful (0 votes)
9 views3 pages

Class VII Ch-5

Uploaded by

Anuj dev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Class VII Ch-5

Uploaded by

Anuj dev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

G.D.

Goenka Public Schools

Class- VII

Short answer, type questions:

1. What are collections?


● Collections are data structures that store multiple items together, such as lists, sets, and
maps.

2. What are the different types of collections?


● Common types include List, Set, Queue, and Map.

3. How can we iterate over collections?


● We can iterate using loops (like for or while), iterators, or enhanced loops like
for-each.

4. What are the different types of modifications that we can perform on collections?
● Modifications include adding, removing, updating elements, and clearing the collection.

5. What is an Array Index?


● An array index is the position number of an element in an array, starting from 0.

6. Do collections allow backward or reversing of data? Support your answer with a


proper explanation.
● Yes, collections like lists can be reversed using functions like reverse(), iterators, or
loops. Arrays and lists store elements in a sequential order, allowing easy reversal.

7. Name three real-life collections that work like arrays.


● Book shelves, car parking slots, and seating arrangements in a theater.
8. What are high-level and low-level languages in computers?
● High-level languages (e.g., Python, Java) are closer to human language, easier to write
and understand. Low-level languages (e.g., Assembly, Machine code) are closer to
hardware and are more efficient but harder to understand and program.

Higher order, thinking questions

1. Draw a flowchart for the customized algorithm for finding the square of numbers
that we learnt in this chapter.
● Flowchart:
○ Start
○ Input the number
○ Multiply the number by itself
○ Output the result (square of the number)
○ End

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


python code:

def is_prime(num):

if num < 2:

return False

for i in range(2, int(num ** 0.5) + 1):

if num % i == 0:

return False

return True

prime_numbers = [num for num in range(50, 101) if is_prime(num)]

print(prime_numbers)
3. Draw a flowchart to explain the flow of selection sort techniques in programming.
● Flowchart:
○ Start
○ Input the array
○ Set outer loop from the first to the second-last element
○ Set the minimum element as the current index
○ Inner loop to find the smallest element in the unsorted array
○ Swap the minimum element with the first unsorted element
○ Repeat until the array is sorted
○ End

4. Write an algorithm to sort the below list in descending order using the selection
sort technique: [10, 21, 45, 67, 12].
Algorithm:
1. Start with the first element as the largest.
2. Iterate through the list and find the largest element in the unsorted portion.
3. Swap the largest element with the current element.
4. Move to the next element and repeat until the entire list is sorted.
5. Output the sorted list.

Example using the list [10, 21, 45, 67, 12]:

● First Pass: Largest is 67, swap with 10 → [67, 21, 45, 10, 12]
● Second Pass: Largest is 45, swap with 21 → [67, 45, 21, 10, 12]
● Third Pass: Largest is 21, no swap → [67, 45, 21, 10, 12]
● Fourth Pass: Largest is 12, swap with 10 → [67, 45, 21, 12, 10]

Result: [67, 45, 21, 12, 10] (sorted in descending order).

You might also like