Mind map
lesson 1 AFEC
Map content
lesson 1 AFEC
smart technology is being integrated into a wide range of computing devices and uses built in sensors. These allow the device to use data gathered by the sensor to change its output
- for example, a light may turn on because it is dark
a conditional statement is defined within the code by starting with an if (if statement)
- if the condition defined after if is true, then the code is run
- there must always be an indent on the next line after an if statement
- where code is selected if the condition is met is called 'selection'
- an indent can be made with a tab
- where code is selected if the condition is met is called 'selection'
- there must always be an indent on the next line after an if statement
- conditional statements must have a colon at the end (including statements with if/else)
- if the condition defined after if is true, then the code is run
user_name = "James" if user_name == "James" print ("Welcome, James!")
- in this code, if the user_name variable is changed to "Charles", nothing will print.
- this code will print the text Welcome, James!
hashtag (#) is used for comments in Python (in HTML, enclose text with * for it to become a comment)
there are four data types; booleans (true or false), strings (always have quotation marks around them), integers (whole numbers), and floats (numbers that have a decimal, eg. 2.5)
to turn a light on, use turn_on("light"), in place of light, you can also use other things, such as aircon
- smart tech allows you to have factors for turning on the light, such as time, like in the code shown below:
- time = 7
- if time == 7:
- turn_on("light")
- if time == 7:
- presence_check("light") is another factor to check whether someone is present or not
- if presence_check("light") == True:
- turn_on("light")
- when using presence check, you must specify the object, eg. light, lock
- with presence check, you do not have to put ==True. You may also write the command like this: if presence_check("light"):. With presence check, if/else can be used. You may say if presence_check("light")==True: (next line) turn_on("light") (next line) else: turn_off("light")
- if presence_check("light") == True:
- time = 7
- smart tech allows you to have factors for turning on the light, such as time, like in the code shown below:
with lights, get_brightness() makes brightness a factor. In the example below, if brightness is below 50, the light will turn on
- for example, if get_brightness() <50: (next line) turn_on("light"), (next line) else: (next line) turn_off("light")
single equals (=) is for assigning a value to a variable. Double equals (==) means exactly equal. So, variable time may equal (=) 7, but if time ==7, then the time is actually 7(o'clock)
get_temp() is used to state that if get_temp() equals a certain number (eg. 30), the air con will turn on
Information
- Description
- Mind Map on lesson 1 AFEC, created by emily ! on 02/05/2020.
- Created by
- emily !
- Views
- 0
- Rating