@burakboduroglu/penote 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,132 @@
1
+ ## Python Basics - 1 🚀👩‍🚀
2
+
3
+ #### - Data Structures 📄
4
+
5
+ ```python
6
+ number_1 = 5 # integer
7
+ number_2 = 5.2 # float
8
+ string_1 = "Hello World" # string
9
+ boolean_1 = True # boolean
10
+ list_1 = [1, 2, 3, 4, 5] # list
11
+ tuple_1 = (1, 2, 3, 4, 5) # tuple
12
+ dictionary_1 = {"key_1": "value_1"} # dictionary
13
+ set_1 = {1, 2, 3, 4, 5} # set
14
+ ```
15
+
16
+ #### - Operators
17
+
18
+ ```python
19
+ # Arithmetic Operators
20
+ 5 + 5 # 10
21
+ 5 - 5 # 0
22
+ 5 * 5 # 25
23
+ 5 / 5 # 1.0
24
+ 5 % 5 # 0
25
+ 5 ** 5 # 125
26
+ 5 // 5 # 1
27
+
28
+ # Comparison Operators
29
+ 5 == 5 # True
30
+ 5 != 5 # False
31
+ 5 > 5 # False
32
+ 5 < 5 # False
33
+ 5 >= 5 # True
34
+ 5 <= 5 # True
35
+
36
+ # Logical Operators
37
+ True and True # True
38
+ True and False # False
39
+ True or True # True
40
+ True or False # True
41
+ not True # False
42
+ not False # True
43
+ ```
44
+
45
+ - ### About Lists
46
+ It is a collection which is ordered and changeable. Allows duplicate members.
47
+
48
+ ```python
49
+ list_1 = [1, 2, 3, 4, 5]
50
+ list_1.append(6) # add an element to the end of the list
51
+ list_1.insert(3, 12) # insert an element at a given position (index, element)
52
+ list_1.remove(12) # remove an element from the list
53
+ list_1.pop() # remove the last element from the list
54
+ list_1.pop(3) # remove the element at the specified position
55
+ list_1.clear() # remove all elements from the list
56
+ list_1.index(3) # return the index of the first element with the specified value
57
+ list_1.count(3) # return the number of elements with the specified value
58
+ list_1.sort() # sort the list
59
+ list_1.reverse() # reverse the list
60
+ list_1.copy() # copy the list
61
+ ```
62
+
63
+ - ### About Tuples
64
+ It is a collection which is ordered and unchangeable. Allows duplicate members.
65
+
66
+ ```python
67
+ tuple_1 = (1, 2, 3, 4, 5)
68
+ tuple_1.count(3) # return the number of elements with the specified value
69
+ tuple_1.index(3) # return the index of the first element with the specified value
70
+ ```
71
+
72
+ - ### About Sets
73
+ It is a collection which is unordered and unindexed. No duplicate members.
74
+
75
+ ```python
76
+ set_1 = {1, 2, 3, 4, 5}
77
+ set_1.add(6) # add an element to the set
78
+ set_1.update([7, 8, 9]) # add multiple elements to the set
79
+ set_1.remove(9) # remove an element from the set
80
+ set_1.discard(9) # remove an element from the set if it is a member
81
+ set_1.pop() # remove an element from the set
82
+ set_1.clear() # remove all elements from the set
83
+ set_1.copy() # copy the set
84
+ ```
85
+
86
+ - ### About Dictionaries 🔑📔
87
+ It is a collection which is unordered, changeable and indexed. No duplicate members.
88
+
89
+ ```python
90
+ dictionary_1 = {"key_1": "value_1"}
91
+ dictionary_1["key_2"] = "value_2" # add an element to the dictionary
92
+ dictionary_1.pop("key_2") # remove an element from the dictionary
93
+ dictionary_1.popitem() # remove the last inserted element from the dictionary
94
+ dictionary_1.clear() # remove all elements from the dictionary
95
+ dictionary_1.copy() # copy the dictionary
96
+ dictionary_1.keys() # return a list of all the keys in the dictionary
97
+ dictionary_1.values() # return a list of all the values in the dictionary
98
+ dictionary_1.items() # return a list of tuples containing the key-value pairs
99
+ dictionary_1.get("key_1") # return the value of the specified key
100
+ dictionary_1.update({"key_3": "value_3"}) # update the dictionary with the specified key-value pairs
101
+ dictionary_1.setdefault("key_4", "value_4") # return the value of the specified key. If the key does not exist: insert the key, with the specified value
102
+ ```
103
+
104
+ - ### About Strings
105
+ It is a collection of characters.
106
+
107
+ ```python
108
+ string_1 = "Hello World"
109
+ string_1.capitalize() # capitalize the first letter of the string
110
+ string_1.lower() # convert the string to lower case
111
+ string_1.upper() # convert the string to upper case
112
+ string_1.isdigit() # check if the string is a digit
113
+ string_1.isalpha() # check if the string is an alphabet
114
+ string_1.isalnum() # check if the string is an alphanumeric
115
+ string_1.islower() # check if the string is in lower case
116
+ string_1.isupper() # check if the string is in upper case
117
+ string_1.strip() # remove whitespaces from the beginning and the end of the string
118
+ string_1.strip('*') # remove the specified characters from the beginning and the end of the string
119
+ string_1.replace("Hello", "Hi") # replace a string with another string
120
+ string_1.split() # split the string into substrings if it finds instances of the separator
121
+ string_1.split(',') # split the string into substrings if it finds instances of the separator
122
+ string_1.join(["Hello", "World"]) # join the elements of an iterable to the end of the string
123
+ string_1.find("World") # search the string for a specified value and returns the position of where it was found
124
+ string_1.index("World") # search the string for a specified value and returns the position of where it was found
125
+ string_1.startswith("Hello") # check if the string starts with a specified value
126
+ string_1.endswith("World") # check if the string ends with a specified value
127
+ string_1.count("l") # return the number of times a specified value occurs in a string
128
+ string_1.format() # format specified values in a string
129
+ ```
130
+
131
+ - Thanks for reading. If you have any questions, please feel free to ask me. I will be happy to help you. See you in the Python Basics - 2. 👋
132
+ - If you want more exercises, you can check out my Kaggle account [-Kaggle-](https://www.kaggle.com/burakbodurolu) and Python Projects account [-Python Projects-](https://github.com/burakboduroglu/Python-Projects).
@@ -0,0 +1,137 @@
1
+ ## Python Basics - 2 🚀👩‍🚀
2
+
3
+ ### - for loop 🔄
4
+
5
+ ```python
6
+
7
+ # example 1
8
+ for i in range(10): # range(10) = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
9
+ print(i)
10
+
11
+ # example 2
12
+ for i in range(1, 10): # range(1, 10) = [1, 2, 3, 4, 5, 6, 7, 8, 9]
13
+ print(i)
14
+
15
+ # example 3
16
+ for i in range(1, 10, 2): # range(1, 10, 2) = [1, 3, 5, 7, 9]
17
+ print(i)
18
+
19
+ # example 4
20
+ for i in range(10, 0, -1): # range(10, 0, -1) = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
21
+ print(i)
22
+
23
+ # example 5
24
+ my_dict = {"key_1": "value_1", "key_2": "value_2", "key_3": "value_3"} # dictionary
25
+ for key, value in my_dict.items():
26
+ print(key, value)
27
+
28
+ ```
29
+
30
+ ### - while loop 🔁
31
+
32
+ ```python
33
+ while True:
34
+ print("Hello World")
35
+ ```
36
+
37
+ ### - if statement 📝
38
+
39
+ ```python
40
+ i = 4
41
+ if i>5:
42
+ print("i is greater than 5")
43
+ elif i<5:
44
+ print("i is less than 5")
45
+ else:
46
+ print("i is equal to 5")
47
+ ```
48
+
49
+ ### - Functions 📝
50
+
51
+ ```python
52
+ def my_function():
53
+ print("Hello World")
54
+ my_function()
55
+
56
+ def my_function_2(name):
57
+ print("Hello " + name)
58
+ my_function_2("John")
59
+
60
+ def my_function_3(name="John"):
61
+ print("Hello " + name)
62
+ my_function_3()
63
+
64
+ def my_function_4(name="John"):
65
+ return "Hello " + name
66
+ print(my_function_4())
67
+ ```
68
+
69
+ ### - random module 🎲
70
+
71
+ ```python
72
+ import random
73
+ random.randint(1, 10) # return a random integer between 1 and 10
74
+ random.choice([1, 2, 3, 4, 5]) # return a random element from a list
75
+ random.shuffle([1, 2, 3, 4, 5]) # shuffle a list
76
+ random.sample([1, 2, 3, 4, 5], 3) # return a list of 3 random elements from a list
77
+ random.random() # return a random float between 0 and 1
78
+ random.uniform(1, 10) # return a random float between 1 and 10
79
+ ```
80
+
81
+ ### - datetime module 📅
82
+
83
+ ```python
84
+ import datetime
85
+ datetime.datetime.now() # return the current date and time
86
+ datetime.datetime.now().year # return the current year
87
+ datetime.datetime.now().month # return the current month
88
+ datetime.datetime.now().day # return the current day
89
+ datetime.datetime.now().hour # return the current hour
90
+ datetime.datetime.now().minute # return the current minute
91
+ datetime.datetime.now().second # return the current second
92
+ datetime.datetime.now().microsecond # return the current microsecond
93
+ datetime.datetime.now().strftime("%Y") # return the current year in string format
94
+ datetime.datetime.now().strftime("%m") # return the current month in string format
95
+ datetime.datetime.now().strftime("%d") # return the current day in string format
96
+ datetime.datetime.now().strftime("%H") # return the current hour in string format
97
+ datetime.datetime.now().strftime("%M") # return the current minute in string format
98
+ datetime.datetime.now().strftime("%S") # return the current second in string format
99
+ datetime.datetime.now().strftime("%f") # return the current microsecond in string format
100
+ datetime.datetime.now().strftime("%Y-%m-%d") # return the current date in string format
101
+ datetime.datetime.now().strftime("%H:%M:%S") # return the current time in string format
102
+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # return the current date and time in string format
103
+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f") # return the current date and time with microsecond in string format
104
+ datetime.datetime.now().timestamp() # return the current date and time in seconds
105
+ datetime.datetime.now().timedelta(days = 1)
106
+ datetime.datetime.now().timedelta(days = -1)
107
+ datetime.datetime.now().timedelta(hours = 1)
108
+ datetime.datetime.now().timedelta(days = 10, hours = 1, minutes = 1, seconds = 1, microseconds = 1)
109
+ ```
110
+
111
+ ### - import local module 🌍
112
+
113
+ ```python
114
+ import locale
115
+ locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') # set the locale
116
+ ```
117
+
118
+ ### - import time module ⏰
119
+
120
+ ```python
121
+ import time
122
+ time.time() # return the current time in seconds
123
+ time.localtime() # return the current time in a struct_time format
124
+ time.localtime().tm_year # return the current year
125
+ time.localtime().tm_mon # return the current month
126
+ time.localtime().tm_mday # return the current day
127
+ time.localtime().tm_hour # return the current hour
128
+ time.localtime().tm_min # return the current minute
129
+ time.localtime().tm_sec # return the current second
130
+ time.localtime().tm_wday # return the current weekday
131
+ time.localtime().tm_yday # return the current day of the year
132
+ time.localtime().tm_isdst # return the current daylight saving time flag
133
+ time.sleep(1) # sleep for 1 second
134
+ ```
135
+
136
+ - Thanks for reading. If you have any questions, please feel free to ask me. I will be happy to help you. See you in the Python Basics - 2. 👋
137
+ - If you want more exercises, you can check out my Kaggle account [-Kaggle-](https://www.kaggle.com/burakbodurolu) and Python Projects account [-Python Projects-](https://github.com/burakboduroglu/Python-Projects).
@@ -0,0 +1,139 @@
1
+ ## Python Basics - 3 🚀👩‍🚀
2
+
3
+ ### - subprocessing 📄
4
+
5
+ ```python
6
+ import subprocess
7
+
8
+ subprocess.call("calc.exe") # it will open the calculator
9
+ ```
10
+
11
+ ### - try except finally
12
+
13
+ ```python
14
+ try: # try to execute this block of code
15
+ print("Hello World")
16
+ except: # if there is an error, execute this block of code
17
+ print("Something went wrong")
18
+ else: # if there is no error, execute this block of code
19
+ print("Nothing went wrong")
20
+ finally: # this block of code will be executed no matter if there is an error or not
21
+ print("The 'try except' is finished")
22
+ ```
23
+
24
+ ### - raise
25
+
26
+ ```python
27
+ x = -1
28
+ if x < 0:
29
+ raise Exception("Sorry, no numbers below zero") # it will raise an error
30
+ ```
31
+
32
+ ### - assert
33
+
34
+ - assert is used to test if a condition in your code returns True, if not, the program will raise an AssertionError.
35
+
36
+ ```python
37
+ x = "hello"
38
+ assert x == "hello" # it will return nothing
39
+ assert x == "goodbye" # it will raise an AssertionError
40
+ ```
41
+
42
+ ### - error types
43
+
44
+ - SyntaxError
45
+ - NameError
46
+ - TypeError
47
+ - IndexError
48
+ - ValueError
49
+ - KeyError
50
+ - ModuleNotFoundError
51
+ - ImportError
52
+ - AttributeError
53
+
54
+ ### - file processing
55
+
56
+ ```python
57
+ # open a file
58
+ file = open("file.txt", "r") # "r" means read only
59
+
60
+ # read a file
61
+ print(file.read()) # read the whole file
62
+
63
+ # read a file line by line
64
+ print(file.readline()) # read the first line
65
+
66
+ # read all lines
67
+ print(file.readlines()) # read all lines
68
+
69
+ # write to a file
70
+ file = open("file.txt", "w") # "w" means write only
71
+ file.write("Hello World")
72
+
73
+ # append to a file
74
+ file = open("file.txt", "a") # "a" means append only
75
+ file.write("Hello World")
76
+
77
+ # close a file
78
+ file.close()
79
+ ```
80
+
81
+ ### - codecs
82
+
83
+ ```python
84
+ import codecs
85
+
86
+ # open a file
87
+ file = codecs.open("file.txt", "r", "utf-8") # "utf-8" means unicode
88
+
89
+ # read a file
90
+ print(file.read()) # read the whole file
91
+
92
+
93
+ # with statement (it will close the file automatically)
94
+ with codecs.open("file.txt", "r", "utf-8") as file:
95
+ print(file.read()) # read the whole file
96
+ ```
97
+
98
+ ### - seek
99
+
100
+ ```python
101
+ # open a file
102
+ file = open("file.txt", "r")
103
+
104
+ # seek to a position
105
+ file.seek(0) # seek to the beginning of the file
106
+
107
+ ```
108
+
109
+ ### - insert file
110
+
111
+ ```python
112
+ # open a file
113
+ file = open("file.txt", "r")
114
+ file.insert(0, "Hello World") # it will insert "Hello World" to the beginning of the file
115
+ ```
116
+
117
+ ### - writelines
118
+
119
+ ```python
120
+ # open a file
121
+ file = open("file.txt", "r")
122
+
123
+ # writelines
124
+ file = open("file.txt", "r")
125
+ file2 = open("file2.txt", "w")
126
+ file2.writelines(file.readlines()) # it will write all lines to the file
127
+ ```
128
+
129
+ ### - delete file
130
+
131
+ ```python
132
+ import os
133
+
134
+ # delete a file
135
+ os.remove("file.txt")
136
+ ```
137
+
138
+ - Thanks for reading. If you have any questions, please feel free to ask me. I will be happy to help you. See you in the Python Basics - 2. 👋
139
+ - If you want more exercises, you can check out my Kaggle account [-Kaggle-](https://www.kaggle.com/burakbodurolu) and Python Projects account [-Python Projects-](https://github.com/burakboduroglu/Python-Projects).
@@ -0,0 +1,126 @@
1
+ ## Database process with SQLite3
2
+
3
+ ### 1. Create a database
4
+
5
+ ```python
6
+ import sqlite3
7
+
8
+ # create a database
9
+ conn = sqlite3.connect("database.db")
10
+ ```
11
+
12
+ ### 2. Create a table
13
+
14
+ ```python
15
+ import sqlite3
16
+
17
+ # create a database
18
+ conn = sqlite3.connect("database.db")
19
+
20
+ # create a table
21
+ conn.execute("CREATE TABLE IF NOT EXISTS table_name (column1, column2, column3, ...)")
22
+ ```
23
+
24
+ ### 3. Insert data
25
+
26
+ ```python
27
+ import sqlite3
28
+
29
+ # create a database
30
+ conn = sqlite3.connect("database.db")
31
+
32
+ # insert data
33
+ conn.execute("INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...)")
34
+ conn.commit()
35
+ ```
36
+
37
+ ### 4. Select data
38
+
39
+ ```python
40
+ import sqlite3
41
+
42
+ # create a database
43
+ conn = sqlite3.connect("database.db")
44
+
45
+ # select data
46
+ cursor = conn.execute("SELECT column1, column2, column3, ... FROM table_name")
47
+ for row in cursor:
48
+ print("column1 = ", row[0])
49
+ print("column2 = ", row[1])
50
+ print("column3 = ", row[2], "\n")
51
+ ```
52
+
53
+ ### 5. Update data
54
+
55
+ ```python
56
+ import sqlite3
57
+
58
+ # create a database
59
+ conn = sqlite3.connect("database.db")
60
+
61
+ # update data
62
+ conn.execute("UPDATE table_name SET column1 = value1, column2 = value2, column3 = value3, ... WHERE condition")
63
+ conn.commit()
64
+ ```
65
+
66
+ ### 6. Delete data
67
+
68
+ ```python
69
+ import sqlite3
70
+
71
+ # create a database
72
+ conn = sqlite3.connect("database.db")
73
+
74
+ # delete data
75
+ conn.execute("DELETE FROM table_name WHERE condition")
76
+ conn.commit()
77
+ ```
78
+
79
+ ### 7. Delete table
80
+
81
+ ```python
82
+ import sqlite3
83
+
84
+ #create a database
85
+ conn = sqlite3.connect("database.db")
86
+
87
+ # delete table
88
+ conn.execute("DROP TABLE table_name")
89
+ conn.commit()
90
+ ```
91
+
92
+ ### 8. Show data
93
+
94
+ ```python
95
+ import sqlite3
96
+
97
+ # create a database
98
+ conn = sqlite3.connect("database.db")
99
+
100
+ # show data
101
+ cursor = conn.execute("SELECT * FROM table_name")
102
+ for row in cursor:
103
+ print(row)
104
+ ```
105
+
106
+ ### 9. Close database
107
+
108
+ ```python
109
+ import sqlite3
110
+
111
+ # create a database
112
+ conn = sqlite3.connect("database.db")
113
+
114
+ # close database
115
+ conn.close()
116
+ ```
117
+
118
+ ### - fetchall
119
+
120
+ ```python
121
+ # fetchall
122
+ cursor = conn.execute("SELECT * FROM table_name")print(cursor.fetchall())
123
+ ```
124
+
125
+ - Thanks for reading. If you have any questions, please feel free to ask me. I will be happy to help you. See you in the Python Basics - 2. 👋
126
+ - If you want more exercises, you can check out my Kaggle account [-Kaggle-](https://www.kaggle.com/burakbodurolu) and Python Projects account [-Python Projects-](https://github.com/burakboduroglu/Python-Projects).
@@ -0,0 +1,18 @@
1
+ ### About Python-Notes 🚀
2
+
3
+ Kişisel Python notları — Markdown formatında düzenlenmiştir.
4
+
5
+ ### Table of Contents 📚
6
+
7
+ | File Name | Topics |
8
+ | --------- | ------ |
9
+ | [python_basic_1.md](python_basic_1.md) | Data structures |
10
+ | [python_basic_2.md](python_basic_2.md) | Functions, loops, conditions |
11
+ | [python_basic_3.md](python_basic_3.md) | Error handling, files |
12
+ | [python_db_process.md](python_db_process.md) | Database usage |
13
+ | [advanced_python_1.md](advanced_python_1.md) | Comprehensions |
14
+ | [advanced_python_2.md](advanced_python_2.md) | map, filter, reduce |
15
+
16
+ ---
17
+
18
+ [← README](../README.md)