0% found this document useful (0 votes)
10 views5 pages

Creating Simple Selection Algorithm

The document outlines a simple selection algorithm in Python for a school heating system that activates when the temperature drops below 18 degrees. It provides pseudocode and a Python code snippet that checks the temperature input and determines whether to turn the heating on or off. The algorithm uses a conditional statement to compare the input temperature to 18 and responds accordingly.

Uploaded by

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

Creating Simple Selection Algorithm

The document outlines a simple selection algorithm in Python for a school heating system that activates when the temperature drops below 18 degrees. It provides pseudocode and a Python code snippet that checks the temperature input and determines whether to turn the heating on or off. The algorithm uses a conditional statement to compare the input temperature to 18 and responds accordingly.

Uploaded by

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

USE OF SELECTION IN AN ALGORITHM

Creating a simple selection algorithm in python


 Consider the following simple brief:
The new school heating system needs to be programmed. If the
temperature in school drops below 18 degrees, the heating system should
come on and stay on until the temperature reaches 18 degrees.
 This could be broken down into pseudocode:
IF temperature<18,THEN turn heating on
ELSE turn heating off.
 #Selection algorithm
temp=int(input(“What temperature is it in school?”))
if temp<18:
print(“Thank you, heating is being turned on”)
else:
print(“Thank you, heating not required”)
 The value of temperature is compared to 18,if it is lower the first
statement is displayed. Otherwise the second statement is
displayed

 The input command asks for the temperature and this is stored as
an integer as the variable temp.

You might also like