| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- line width
- matplotlib.pyplot
- self parameter
- line color
- variables
- __init__
- error
- Else
- Default X points
- AS
- iterates
- pie charts
- PROJECT
- machine learning
- polynomial regression
- train/test
- For loops
- start exercise
- Python
- multiple lines
- PANDAS
- matplotlib
- MySQL
- Text mining
- Text Analytics
- data distribution
- break
- SQL
- continue
- Github
- Today
- Total
목록Python (42)
Data Science Explorer
The following exercise was the one that I struggled and I have provided the solution as well. # 3. Write a function called print_pattern that takes integer number as an argument and prints following pattern if input number is 3, # * # ** # *** # if input is 4 then it should print # * # ** # *** # **** # Basically number of lines it prints is equal to that number. (Hint: you need to use two for l..
Built-In Math Functions The min() and max() functions can be used to find the lowest or highest value. Example x = min (3,10, 1) y = max (3,10, 1) print(x) print(y) The abs() function returns the absolute (positive value) of the specified number. Example x = abs(-8.25) print(x) The pow(x,y) function returns the value of x to the power of y. Example Return the value of 4 to the power of 2. x = po..
Python Dates A date in Python is not a data type of its own, but we can import a module named datetime to work with dates as date objects. Example Import the datetime module and display the current date. import dateime x = datetime.datetime.now() print(x) Date Output When we execute the code from the example above the result will be 2023-11-23 12:42:21.743477 which contained year, month, day, ho..
Think a module to be the same as a code library. A file containing a set of functions you want to include in your application. Create a module To create a module, you can save the code you want in a file with the file extension .py. Use a module When using a function from a module, use the syntax: module_name.function_name. Example import mymodule mymodule.greeting("Grace") Variables in module T..
Python Inheritance Inheritance allows us to define a class that inherits all the methods and properties from another class. Parent class (base class) is the class being inherited. Child class(derived class) is the class that inherits from another class. Example Create a class named Christmas with month, date properties. class Christmas: def__init__(self, month, date)" self.month = month self.dat..
A class is like an object constructor, blueprint for creating objects. Example Create a class named MyClass, with a proprty named x: class MyClass: x = 10 Create Object Example Create an object named p1, and print the value of x: p1 = MyClass () print (p1.x) The __init__() Function All classes have a function called __init__(), which is always executed when the class is being initiated. Example ..
Creating Pie Charts You can use the pie() function to draw pie charts Example import matplotlib.pyplot as plt import numpy as np y = np.array ([3, 6, 7, 1]) plt.pie(y) plt.show() Result Labels The label parameter must be an array with one label for each wedge. import matplotlib.pyplot as plt import numpy as np y = np.array([35, 25, 25, 15]) mylabels = ["Apples", "Bananas", "Cherries", "Dates"] p..
A histogram is a graph showing frequency districutions. We use the hist() function to create histogram. It will use an array of numbers to create historgram. Example import matplotlib.pyplot as plt import numpy as np x = np.random.normal(50, 10, 250) plt.hist(x) plt.show() Result
Creating bars Use bar() function to draw the bar graph. Example import matplotlib.pyplot as plt import numpy as np x = np.array(["Grace", "Momo", "Anas", "David"]) y = np.array([3, 8, 1, 10]) plt.bar(x,y) plt.show() Result Horizontal bars Use barh() to have your graph displayed horizontally. Example import matplotlib.pyplot as plt import numpy as np x = np.array(["A", "B", "C", "D"]) y = np.arra..
Creating Scatter Plots You can use the scatter() function to draw a scatter plot. Example import matplotlib.pyplot as plt import numpy as np x = np.array([1, 4, 6, 2]) y = np.array([4, 5, 2, 1]) plt.scatter(x, y) plt.show() Result Compare plots Example import matplotlib.pyplot as plt import numpy as np #day one, the age and speed of 13 cars: x = np.array([5,7,8,7,2,17,2,9,4,11,12,9,6]) y = np.ar..