There are other data types other than those mentioned earlier in
Exercise 2 (Data Types). We shall discuss the
boolean data type.
This data type can only be
False. Boolean values are generated when values are compared or when there is a condition.
Eg 1 < 2 is True, 1 > 2 is False .
is_online = True is_swift = True is_human = False
Boolean values are case sensitive. Upper-case
False , in python.
A comment is a piece of text that mostly should tell why or what we are trying to achieve. The
# symbol, placed ( inserted) at the beginning of the line, comments the line ( the line is ignored by the interpreter).
# Hello world program # Display Hello world for the user to see # Using the print function print("Hello world")
The first three lines starting with
# are comments. A comment is ignored during execution. You can also comment out some lines during debugging.
Whatever that comes after the
# would be ignored.
print('hello world') # greetings , greetings would be ignored.
Exercise 2 (Data Types), add comments to your solutions to give the why/what the line is doing or meant to do ( remember that not all lines need a comment if the code is descriptive itself).
- How many comments are there in the code below?
- Which line numbers, would be displayed and why?
- A boolean value is
- These values are generated during the comparison of two or more values.
- A comment is supposed to explain, "the" what or why in the code ( line)
- We can also use it to state how we want to reach our solution
#to create a comment