Math understanding


#1

Hey I am stuck at the exercise 10 of the Python, i.e. the MATH excercise it has the start as follows:
"MATH
Great! Now let's do some math. You can add, subtract, multiply, divide numbers like this"
Addition=
Subtraction=
Multiplication=
Division=

Set the variable count_to equal to the sum of two big numbers.

I did not understand the meaning of the instructions actually,
The following is the code I wrote:

variable_name1=first variable
variable_name2=second variable
count_to=addition=variable_name1+variable_name2
print count_to

Please indicate what the instructions meant and what have I done wrong here..
`


#2

Eg.

set the variable `c` equal to the sum of `743 + 1089`

c = 743 + 1089

print c       # 1832

#3

So the instructions do not say to define the inputs, like inputting the numbers 743 and 1089 as above..
Understood. Just addition of the numbers is defined by the signs "+", subtraction by "-" and so on..
Thank you!!


#4

The math operators are similar to those on your calculator.

+  plus
-  minus
*  times
/  divide
=  assign

We'll often see x ^ 2 in pseudo code. This is exponent syntax. In Python we use,

** exponent

Other forms of division are modulo and floor. Modulo concerns itself with the remainder, only. Floor converts any division to integer and rounds down.

%  remainder
// floor divide

For logic and inequality we have comparators:

==  identity
>=  greater or equal
<=  less or equal
>   greater
<   less
!=  not identical

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.