0% found this document useful (0 votes)
6 views1 page

Logic for Pet Monster Rescue Code

The document outlines the logic and structure for a Pet Monster Rescue program that helps users find their ideal pet by asking a series of questions. It emphasizes the importance of organizing ideas and creating an algorithm using flowcharts to determine pet characteristics such as horns, body type, eye count, and arm count. The program uses logical statements to match users with pets or indicate when no matches are found.

Uploaded by

biji
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)
6 views1 page

Logic for Pet Monster Rescue Code

The document outlines the logic and structure for a Pet Monster Rescue program that helps users find their ideal pet by asking a series of questions. It emphasizes the importance of organizing ideas and creating an algorithm using flowcharts to determine pet characteristics such as horns, body type, eye count, and arm count. The program uses logical statements to match users with pets or indicate when no matches are found.

Uploaded by

biji
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

Session 2

Be Logical – Organize Your Ideas


Your Pet Monster Rescue program is looking great!
Next, you need to write the part of the code that will help people find their ideal pet. You will do
that by asking questions. If the answer is a match to a monster in the shelter, the person can take
their new pet home. If there is no match, the program will continue to ask questions.
This part of the program will use logic to make decisions:
== equal if A keyword used to trigger an action when a statement is True.
!= different
> else A keyword used to trigger an action only when all other
greater than
statements above are False.
< less than

Before you start to write the code, you must form a plan. Programmers are logical. They often
use a flowchart to make an algorithm. An algorithm is a description of what the program will do.
Complete the algorithm to describe each monster. What is their name? What food do they eat?
What do they like to play?

YES, I want a pet Name:


Do you want a pet with horns.
Food:
with horns?
yes or no if horns == 'yes' Play:

NO. I do not want horns.

I do not want a pet that Name:


What type of body is furry.
Food:
do you like? slimy,
scaly, or furry? if body != 'furry' Play:

I want a furry pet.

I want a pet with less Name:


How many eyes than 2 eyes.
Food:
do you want your
pet to have? if eyes < 2: Play:

I want a pet with more than 1 eye.

I want a pet with Name:


How many arms more than 3 arms.
Food:
do you want your
pet to have? if arms > 3: Play:

else: There are no matches. You will need to adopt a monster at another time.

Copyright © TechnoKids Inc. 30 TechnoPython | Python

You might also like