0% found this document useful (0 votes)
8 views10 pages

QnA Algorithms

The document provides a comprehensive overview of algorithms and data concepts suitable for Grade 7 students, including definitions, pseudocode, flowcharts, and practical examples. It covers key topics such as searching algorithms, constants, loops, and decomposition, along with case studies for real-world applications. The document also includes pseudocode and Python code examples for various programming tasks, emphasizing problem-solving and algorithm testing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views10 pages

QnA Algorithms

The document provides a comprehensive overview of algorithms and data concepts suitable for Grade 7 students, including definitions, pseudocode, flowcharts, and practical examples. It covers key topics such as searching algorithms, constants, loops, and decomposition, along with case studies for real-world applications. The document also includes pseudocode and Python code examples for various programming tasks, emphasizing problem-solving and algorithm testing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Grade 7

Algorithms & Data – Questions & Answers

Short Definitions & Facts

Define algorithm.
→ A step-by-step set of instructions to solve a problem.

1. What is pseudocode?
→ A way of writing algorithms in short, clear steps, independent of
any programming language.

2. What does a flowchart represent?


→ A diagram that shows the steps of an algorithm using symbols.

3. Write the symbol used for decision-making in a flowchart.


→ Diamond (♦).

4. Which pseudocode keywords are used for decision-making?


→ IF, THEN, ELSE.

5. Give one advantage of pseudocode.


→ It is easy to understand and language-independent.

6. What is decomposition?
→ Breaking a problem into smaller sub-problems.

7. What is a constant?
→ A fixed value in a program that does not change during execution.

8. Write an example of a constant in real life.


→ Value of π (pi = 3.14).

9. Name one searching algorithm you studied.


→ Linear Search.

10. What does a linear search do?


→ It checks each item in a list one by one until the required item is
found.

11. Which loop repeats a set of instructions while a


condition is true?
→ WHILE loop.

12. What is selection in algorithms?


→ A construct where decisions are made based on conditions.
13. State one benefit of decomposition.
→ Easier to solve smaller problems than one big one.

14. What is the purpose of testing an algorithm?


→ To check whether it works correctly for all inputs.

Conceptual Understanding

1. Differentiate between algorithm and pseudocode.


→ Algorithm is a set of step-by-step instructions to solve a problem.
→ Pseudocode is a structured, human-readable way of representing
algorithms.

2. Write two differences between pseudocode and Python.

o Pseudocode is not a real programming language; Python is.

o Pseudocode has no strict rules; Python has defined syntax.

3. Write any two characteristics of good pseudocode.


→ Clear and precise.
→ Shows start and end clearly.

4. Explain the need for searching algorithms.


→ To find specific data within a dataset, e.g., finding a name in a list.

5. State two uses of constants in algorithms.


→ Prevent accidental changes.
→ Value can be updated in one place instead of everywhere.

6. Write two differences between variable and constant.

o Variable values can change; constant values cannot change.

o Constants reduce risk of errors; variables allow flexibility.

7. Differentiate between FOR loop and WHILE loop.

o FOR loop: repeats a fixed number of times.

o WHILE loop: repeats until a condition is false.

8. Why is decomposition important in programming?


→ Makes problem-solving easier and allows teamwork.

9. What are the three parts of a conditional statement?


→ Condition, code if true, code if false.

10. Give two examples where searching algorithms are


needed.
→ Searching for a student’s roll number in records.
→ Searching for a file on a computer.

Detailed Explanations & Applications

1. Explain with example how pseudocode helps in problem-


solving.
→ Pseudocode allows planning before writing code.
Example:

2. INPUT num1, num2

3. sum ← num1 + num2

4. OUTPUT sum

This helps visualize the program before coding in Python.

5. Draw and explain a flowchart to check if a number is even or


odd.
Steps:

o Input number.

o Check condition (number % 2 == 0).

o If true → Output “Even”, else → Output “Odd”.

6. Explain decomposition with an example from daily life.


→ Making a sandwich can be decomposed into:

1. Take bread.

2. Add filling.

3. Place bread on top.

4. Serve sandwich.
In programming, decomposition makes complex problems
easier.

7. Write pseudocode and Python program to calculate area of a


circle using a constant.
Pseudocode:

CONSTANT PI = 3.14

INPUT radius

area ← PI * radius * radius

OUTPUT area
Python:

PI = 3.14

radius = float(input("Enter radius: "))

area = PI * radius * radius

print("Area:", area)

8. Explain with example how linear search works.


→ Linear search checks each element in a list one by one.
Example list: [5, 9, 12, 20].
Search 12 → check 5 → 9 → 12 (found).
Advantage: Simple to use.
Disadvantage: Slow for large lists.

9. Write pseudocode and Python program for a grading


system.
Pseudocode:

INPUT marks

IF marks >= 90 THEN OUTPUT "A"

ELSE IF marks >= 75 THEN OUTPUT "B"

ELSE IF marks >= 50 THEN OUTPUT "C"

ELSE OUTPUT "Fail"

Python:

marks = int(input("Enter marks: "))

if marks >= 90:

print("Grade A")

elif marks >= 75:

print("Grade B")

elif marks >= 50:

print("Grade C")

else:

print("Fail")

10. How do you test an algorithm? Give an example.


→ By running it with different inputs and checking if outputs are
correct.
Example:
For an algorithm to check even/odd:

o Input 4 → Output Even

o Input 9 → Output Odd

o Input 0 → Output Even

11. Explain with example the difference between


prediction and testing.

o Prediction: Guessing what the output will be.

o Testing: Running the algorithm to verify.


Example: For input 3 in “Even/Odd” algorithm → Prediction:
Odd → Testing confirms output: Odd.

Case Study Based Questions

Case Study 1: School Library System

A school library needs a simple program that allows students to:

1. Enter the name of a book.

2. Check if the book is available in the library list.

3. If available, output "Book Available", otherwise "Not Available".

Questions:

1. (1 mark) Which searching algorithm is most suitable here?


→ Linear Search, as the program checks each book one by one.

2. (2 marks) Write the pseudocode for this program.

INPUT bookName

libraryList ← ["Maths", "Science", "English", "Computing"]

FOR each book IN libraryList

IF book == bookName THEN

OUTPUT "Book Available"

STOP

OUTPUT "Not Available"

3. (3 marks) Write the equivalent Python code.


libraryList = ["Maths", "Science", "English", "Computing"]

bookName = input("Enter book name: ")

found = False

for book in libraryList:

if book == bookName:

found = True

break

if found:

print("Book Available")

else:

print("Not Available")

Case Study 2: Student Grading System

A teacher wants to design an algorithm to calculate student grades based


on marks.

 Marks ≥ 90 → Grade A

 Marks ≥ 75 → Grade B

 Marks ≥ 50 → Grade C

 Marks < 50 → Fail

Questions:

1. (1 mark) Which algorithm construct is mainly used here?


→ Selection (IF, ELSEIF, ELSE).

2. (2 marks) Write pseudocode for this grading algorithm.

INPUT marks

IF marks >= 90 THEN

OUTPUT "A"

ELSE IF marks >= 75 THEN

OUTPUT "B"
ELSE IF marks >= 50 THEN

OUTPUT "C"

ELSE

OUTPUT "Fail"

(3 marks) Write Python code and test it with 3 different inputs


(prediction + testing).

marks = int(input("Enter marks: "))

if marks >= 90:

print("Grade A")

elif marks >= 75:

print("Grade B")

elif marks >= 50:

print("Grade C")

else:

print("Fail")

1. Prediction: Input 92 → Output A

2. Prediction: Input 77 → Output B

3. Prediction: Input 40 → Output Fail

Case Study 3: Currency Converter

A program converts US dollars to Indian rupees.

 Use constant exchange rate: 1 USD = 83 INR.

Questions:

1. (1 mark) What programming concept is used for storing the


exchange rate?
→ Constant.

2. (3 marks) Write pseudocode for the program.

CONSTANT rate = 83

INPUT dollars
rupees ← dollars * rate

OUTPUT rupees

(3 marks) Write the Python program.

RATE = 83

dollars = float(input("Enter amount in USD: "))

rupees = dollars * RATE

print("Amount in INR:", rupees)

Case Study 4: Fitness Tracker – Step Counter

A fitness tracker records steps daily.

 If steps ≥ 10,000 → Output “Goal Achieved”.

 Else → Output “Keep Going!”.

 Repeat for 7 days (use loop).

Questions:

1. (1 mark) Which type of loop is best here?


→ Count-controlled FOR loop (since 7 days are fixed).

2. (5 marks) Write pseudocode.

FOR day = 1 TO 7

INPUT steps

IF steps >= 10000 THEN

OUTPUT "Goal Achieved"

ELSE

OUTPUT "Keep Going!"

NEXT day

(5 marks) Write Python program.

for day in range(1, 8):

steps = int(input(f"Enter steps for day {day}: "))

if steps >= 10000:

print("Goal Achieved")
else:

print("Keep Going!")

Case Study 5: Pizza Order Billing (Decomposition Example)

A pizza shop wants to automate billing:

1. Input customer name.

2. Input size of pizza (Small = 200, Medium = 350, Large = 500).

3. Add fixed delivery charge = 50.

4. Output final bill.

Questions:

1. (1 mark) Which computational thinking skill is used to break this


problem into parts?
→ Decomposition.

2. (5 marks) Write pseudocode using functions.

FUNCTION get_order

INPUT name

INPUT size

RETURN size

END FUNCTION

FUNCTION calculate_bill(size)

CONSTANT delivery = 50

IF size == "Small" THEN price = 200

ELSE IF size == "Medium" THEN price = 350

ELSE price = 500

RETURN price + delivery

END FUNCTION

FUNCTION display(bill)

OUTPUT "Final Bill: ", bill


END FUNCTION

(10 marks) Write Python program.

def get_order():

name = input("Enter your name: ")

size = input("Enter pizza size (Small/Medium/Large): ")

return size

def calculate_bill(size):

DELIVERY = 50

if size == "Small":

price = 200

elif size == "Medium":

price = 350

else:

price = 500

return price + DELIVERY

def display(bill):

print("Final Bill:", bill)

# Main Program

size = get_order()

bill = calculate_bill(size)

display(bill)

You might also like