![]() ![]() In Python we can think of variables as labels that refer to a box( or container) that contains a value such as the score in a game, the result of calculation, an answer to a question or even portion of a program that can perform a calculation. The first usage explored here is to use variables is to refer to numbers. Variables can be used to refer to anything a program needs, to display, change or use. Variables are used by nearly all programs and give programs a great deal of flexibility. ‘ *‘, ‘ /‘, ‘ %‘ (multiplication, division and modulo).For the python operators see here, highest precedence operators are listed first below The result of the expression on line 1 is equal to 13 and on line 2 equal to 10 as the multiplication and division have a higher precedence than addition and subtraction. For example in the following code is the result of the expression on line 1 equal to 16 or 13 and on line 2 equal to 1 or 10 As dollars and euros have cents, meters have centimeters, grams have milligrams a lot of real world measurement units can be divided.Įxpressions are not limited to just one operator and can have many, but need to be careful of operator precedence ( i.e. Floats (float), any number with a decimal point and are used when when more precision is need.Integers (int), whole numbers sometimes called counting numbers i.e.This highlights that Python has two types of numbers, ![]() The result of the the division operation result appears different, it has a decimal point ‘ %‘ performs a modulo operation, returns the remainder after a division.In the Python Console will see the followingĪs can be seen python preforms the following operations resulting a number (for the expressions above): In the Python console type the following: ![]() To use the Python console as a calculator, Open IDLE ![]()
0 Comments
Leave a Reply. |