0% found this document useful (0 votes)
54 views2 pages

Variables and Mathematical Operators

The document explains the concept of variables and mathematical operators, detailing how variables are assigned values and providing a list of common mathematical operators such as addition, subtraction, and multiplication. It includes examples of operations performed with these operators and demonstrates variable assignment and type conversion in Python. Additionally, it highlights an error encountered when trying to access an undefined variable.

Uploaded by

medrek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views2 pages

Variables and Mathematical Operators

The document explains the concept of variables and mathematical operators, detailing how variables are assigned values and providing a list of common mathematical operators such as addition, subtraction, and multiplication. It includes examples of operations performed with these operators and demonstrates variable assignment and type conversion in Python. Additionally, it highlights an error encountered when trying to access an undefined variable.

Uploaded by

medrek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

VARIABLES AND MATHEMATICAL OPERATORS

VARIABLES
Variables are assigned values.
A box filled with an object is a similar process.

MATHEMATICAL OPERATORS
Addition +
Subtraction -
Multiplication *
Power **
Division /
Floor Division //
Modulus %
Integer int(number)
Float float(number)

In [19]:

100 + 5
100 - 5
100 * 5
100 / 5

Out[19]:
20.0

In [89]:
print(4*4*4)
print(4**3)

64
64

In [3]:

box1 = 12
box2 = 100
box3

---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-7e7408937c3a> in <module>()
1 box1 = 12
2 box2 = 100
----> 3 box3

NameError: name 'box3' is not defined


NameError: name 'box3' is not defined

In [91]:
box3 = 300
box3
a, b, c = 20, 30, 40
a
b
c

num = a + b * c / 2
num
Out[91]:
620.0

In [82]:
x = 22 ; y = 32; z = 42.123456
x
y
z
type(z)
int(z)
type(int(z))

Out[82]:
int

In [77]:
var = 5
print(40/var)
print(40 //var)
print(40 % var)
print(40- (8*var))

8.0
8
0
0

You might also like