0% found this document useful (0 votes)
50 views2 pages

2nd Term Assessment Revision Compt 8 (2) (Answer Key)

This document is a review pack for the mid-term assessment in Computer for 8th grade, covering programming concepts. It includes a procedure to remove an atom from a list, methods for searching a list, and the advantages of using procedures in programming. Key topics discussed are linear and binary search methods, their speed differences, and reasons for using procedures such as code reusability and modularity.

Uploaded by

Mamoona Batool
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)
50 views2 pages

2nd Term Assessment Revision Compt 8 (2) (Answer Key)

This document is a review pack for the mid-term assessment in Computer for 8th grade, covering programming concepts. It includes a procedure to remove an atom from a list, methods for searching a list, and the advantages of using procedures in programming. Key topics discussed are linear and binary search methods, their speed differences, and reasons for using procedures such as code reusability and modularity.

Uploaded by

Mamoona Batool
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/ 2

TERM 2 AY 2024-25

TERM 2 – AY 2024-25
MID-TERM ASSESSMENT
REVIEW PACK 2
Name: Subject: C o m p u t e r
Date: Grade: 8th
Instructions:
➢ Read the questions carefully and answer them.

Question 1:

This is the code in your program which removes an atom name from the list.

Use the skills you have


learned.

Make a procedure called


remove_atom. Call the
procedure in your main program.

def remove_atom_from_list(name):
if name in atoms:
atoms.remove(name)
print(name, "has been removed from the list.")
else:
print(name, "is not in the list.")

Question 2

1. Name two different ways to search a list.

a. Binary search

b. Linear search

1
TERM 2 AY 2024-25

2. Which of the two methods is usually faster?

A. The linear search method is usually slower compared to the binary search method,
but which one is faster depends on the characteristics of the data.

3. Which type of search algorithm uses a for loop? What commands go inside the for loop?

A. The linear search algorithm typically uses a for loop. This algorithm checks each
element of a list one by one to find the target value. Here’s how it works:

Commands Inside the For Loop:

Comparison: Inside the loop, you compare the current element with the target value.

Action on Match: If the element matches the target, you take some action (e.g., print a
message or return the index).

Exit or Continue: If a match is found, you can exit the loop early, or continue checking
other elements if needed.

4. Describe the reasons why a programmer might choose to use procedures in their program.

A.
Programmers use procedures for several reasons:
1. Code Reusability: Write code once and reuse it, reducing redundancy.
2. Modularity: Breaks down large tasks into smaller, manageable pieces, making the code easier
to understand.
3. Easier Debugging: Isolate and test parts of the program separately, simplifying error
identification.
4. Abstraction: Hide complex details and provide clear interfaces for easier interaction.
5. Improved Collaboration: Allows team members to work on different parts of the code
simultaneously.
6. Efficiency: Reduces duplicated code and optimizes performance.
7. Scalability: Helps manage larger, more complex programs by keeping the structure organized.

You might also like