Posted December 16, 2022 by RaeesMalik
This lesson we looked at integers, floating point numbers and decision making with python.
In Python, integers are whole numbers that can be positive, negative, or zero. For example:
2
, -4
, and 0
are all integers. On the other hand, floating point numbers (also called "floats") are numbers with decimal points. For example: 3.14
, -2.718
, and 0.0
are all floats.
Here is a code about decision making.This code defines a variable num
and sets it equal to 5
. Then, it uses an if
statement to check if num
is less than or equal to 3
. If it is, it prints "duck"
. If num
is not less than or equal to 3
, the elif
statement is checked to see if num
is greater than 3
. If it is, it prints "swan"
.
So, when this code is run, it will print "swan"
because num
is equal to 5
, which is greater than 3
.