2023. 1. 15. 00:42ㆍData science/Python
1. History of Python
: Appeared in 1991, Guido Van Rossum
: interpreted, object-oriented, high-level programming language with dynamic semantics
2. Why Python?
: Attractive for Agile software development
: use as a scripting language, powerful, applicable for GUI, games and more
: Open-source, simple and easy, shortcodes, No compilation step(fast edit-test-debug cycle, increased productivity)
: Debugging is easy (Error raises an exception)
: Huge user community
3. Using python as a calculator
: Last printed expression assigned to the variable "_(underbar)."
: //(floor division-반올림결과), %(remainder), **(Powers), import math, math.sqrt(36)...etc
: int , float, complex(use indicate the imaginary part -> 3+5j)
: Division always turns the integer to float -> 4//2 -> 2.0
: divide with zero -> Zerodivisionerror
: Operators with mixed-type operands convert the integer operand to a floating point.
: String is not a numeric data type(But a sequence type)
: Adding up a string and integer variables will through an Error.
: Float + Int -> Float
: the actual stored value is the nearest representable binary fraction. (>>>0.1 means 0.10000.....5551115...)
>>>print(10+0.1-10)
>>>0.09999999999999964
4. String
: Single quotes(') - all sequences will be recognised as a string
: Double quotes(") - \ shall be used along with. Some of the combinations have different functions.
: print() function produces a more readable output (omitting enclosing quotes)
: input() function prompts the user for input and returns the result as a string(with contents automatically escaped)
: concatenation is the process of adding up strings
"ABC" + "de" -> ABCde / "2"+"3" -> '23' / Hi*3 -? HiHiHi / 2 * "3" ->'33' /"4" * "9" -> error/ "Hi" * 3.0 -> error
: inside of print() function, concatenation can be achieved via + or comma
5. Type conversion
: int(str) -> int, float(int) -> float , str(int)-> str
6. Variables
: variable names can consist only of letters, numbers, and underscores(_), cannot start with a number or space
: Python is case sensitive
: del statement to remove a variable (rarely used)
7. In-place operators
: allow writing arithmetic operations, such as "x=x+4 -> x+=4"
'Data science > Python' 카테고리의 다른 글
How to print python file (0) | 2023.02.20 |
---|---|
Python - np.empty vs. np.zeros (0) | 2023.02.15 |
[IBM] Data Analysis with Python - Model Development (0) | 2021.05.17 |
[IBM]Data Analysis with Python - Exploratory Data Analysis(EDA) (0) | 2021.05.15 |
[IBM] Data Analysis with Python - Pre-Processing Data in Python (0) | 2021.05.14 |