Week 3 MAK
Week 3 MAK
PYTHON
05.03.2025
Dr. Merve AKBAŞ KAPLAN 1
Basic Data Types in Python
2
Basic Data Types in Python
3
Basic Input/Output (Keyboard/Screen)
4
Basic Input/Output (Keyboard/Screen)
5
Importing Packages in Python
6
Types of Numerical Objects in Python
1. Integers
2. Floats
3. Fractions
4. Decimals
5. Complex numbers
7
1. Integers
8
2. Floats
9
2. Floats
10
2. Floats
11
2. Floats
12
3. Fractions
13
4. Decimals
14
5. Complex Numbers
2
𝑐 = 𝑅2 + 𝐼𝑚
15
Operations in Python
16
Operations in Python
17
Order of Precedence
18
Multiple Assignments
Operation Description
x += y x = x + y
x -= y x = x - y
x *= y x = x * y >>> x=15;y=24
x /= y x = x / y or
x **= y x = x ** y >>> x,y=15,24
x %= y x = x % y >>> x += y
>>> x
39
19
Multiple Assignments
>>> x=15;y=24
or
>>> x,y=15,24
>>> x += y
>>> x
39
20
Mixed-type Operations
21
Data Conversion
Operation Meaning of the Operation Input Command Output
float(x) Converts a string or number to a float. float(16) 16.0
complex(x,y) Create a complex number with real part ‘x’ complex(2,-6) (2-6j)
and imaginary part ‘y’.
bin(integer) Return the binary repr. of an integer. bin(16) '0b10000'
23
Reading Data From The Keyboard
24
Built-in Functions for Numbers
25
Built-in Functions for Numbers
26
eval FUNCTION
▪ eval() evaluates the passed string as a Python expression and returns the result.
29
random Package
30
random Package
31