#PYTHON
#INTRODUCTION IN PYTHON
#aRithmetic operators
#data types #conversion of types
#built-in functions #variables
Arithmetic operators
· Addition: +
· Subtraction: -
· Multiplication: *
· Division: /
· Floor division: //
· Modulus: %
· Exponent: **
Data types
· Integer numbers – int: …, -5, -4, -3, -2, -1, 0, 1, …
· Floating-point numbers – float: …, -1.1, 5.16, 3e-10, …
· String – str: …, «S», «LINUX», «3ABoP», «Hello, World!», …
· Boolean type – bool: False, True
· Nothing – NoneType: None
Conversion of types
· int to float
in [1]: float(1)
out [1]: 1.0
· float to int
in [2]: int(5.7)
out [2]: 5
· float to str
in [3]: str(54.4)
out [3]: 54.4
· str to float
in [4]: float(54.4)
out [4]: 54.4
· str to float
in [5]: float(NO)
out [5]: ValueError
Built-in functions
· help()
- if you need some help - use help() !
· input()
- built-in function input() – basic input for simple data.
· print()
- built-in function print() – basic output for data.
Variables
name_of_variable = value_of_variable
· First advice: register is important!
· Second advice: use more informative names of variables.
a = 8
b = 15.0
B = 7
abba = False
letter = C
path = C:\Users\my_folder\second_folder\
list_of_temperature = [37.8, 38.3, 38.5, 37.0]