| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
- pie charts
- Text mining
- train/test
- Python
- MySQL
- Github
- SQL
- self parameter
- start exercise
- line width
- break
- matplotlib
- machine learning
- PROJECT
- continue
- line color
- Text Analytics
- PANDAS
- error
- Default X points
- matplotlib.pyplot
- variables
- iterates
- Else
- For loops
- polynomial regression
- AS
- data distribution
- multiple lines
- __init__
- Today
- Total
목록Python (42)
Data Science Explorer
A lambda function is small anonymous function. Syntax lambda arguments : expression Example Add 10 to argument a, and return the result. x = lambda a : a + 10 print (x(8)) Multiply argument a with argument b and return the result. x = lambda a,b : a * b print (x(8, 1)) Example def myfunc(n): return lambda a : a * n mydoubler = myfunc(2) mytripler = myfunc(3) print(mydoubler(11)) print(mytripler(..
Creating a Function We can use def keyword to define a function. Example def my_function(): print("Hello World") ** Do not forget ":" when you define a function! ** Calling a Function Example def my_function(): print ("Hello World") my_function() Parameters vs Arguments Let's differentiate parameters and agruments with the following code. def my_function(fname): print(fname + " Refsnes") my_func..
A For Loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). In other words, it repeats the same function. Example Print each color in a color list. colors = ["blue", "white", "black"] for x in colors: print (x) ** When you use for loops, dont' forget ":" and be careful with the indentation! ** Looping Through a String Example Loop through ..
Python loops Python has two primitive loop commands: while loops for loops The While Loop We can execute a set of statements as long as a condition is true. ** Do not forget ":" when you use the while loop.** Example Print i as long as i is less than 10: i = 2 while i < 10: print (i) i += 1 ** i += 1 is equivalent to writing i = i + 1. ** The break statement We can stop the loop with the break s..
Python Conditions and If statements Equals: a == b Not Equals: a != b Less than: a = b Those are usually used in IF statement and loops. For IF statement, we use if keywords. Example a = 33 b = 95 if b > a: print("b is greater than a") ** In IF statement, indentation is very important, so you should keep the correct indentation for the ..
Type Conversion You can convert from one type to another with th int(), float(), and complex. Example Convert from one type to another. x = 1 # int y = 2.8 # float z = 1j # complex #convert from int to float: a = float(x) #convert from float to int: b = int(y) #convert from int to complex: c = complex(x) print(a) print(b) print(c) print(type(a)) print(type(b)) print(type(c)) Specify a variable t..
There are three numeric types in Python which are int(), float(), complex(). Int() It is a whole number, positive or negative (without decimals). Example x = 2 y = -2 print (x) print (y) Float() It is a number, positive or negtiave, containing one or more decimals. Example x = 1.89 print(type(x)) Example = 35e3 y = -67.7e100 print(type(x)) print(type(y)) Complex() They are numbers that are writt..
Variables can store data of different types. Let's check out the data types that Python has. Text Type str Numeric Types: int, float, complex Sequence Types: list, tuple, range Mapping Type: dict Set Types: set, frozenset Boolean Type: bool Binary Types: bytes, bytearray, memoryview None Type: NoneType When you want to know the data type of the variable, you can use type() function. Example x = ..
Output Variables The print() function is used to output variables. Example x = "Hello World" print(x) Output Multiple Variables It can be separated by a comma. Example x = "Hello" y = "World" print(x, y) You can also use the + operator to output multiple variables. Example x = "Python " y = "is " z = "awesome" print(x + y + z) ** When you try to combine a string and a number with the + operator,..
Many Values to Multiple Variables We can assign values to multiple variables in one line. Example x, y, z = "Nike", "Adidas", "Puma" print(x) print(y) print(z) One value to Multiple Variables Assigning the same value to multiple variables in one line Example x = y = z = "Honeydew" print(x) print(y) print(z) Unpack a Collection When you want to extract the values from the collection of values in ..