forked from DailysDailyNews/DailyInvestorProjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDailys_Python_Course
More file actions
184 lines (160 loc) · 4.91 KB
/
Copy pathDailys_Python_Course
File metadata and controls
184 lines (160 loc) · 4.91 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
[Installs/Programs]
1.pip install requests
install itertools
pip install flask
pip install Django
pip install numpy
pip install pandas
pip install sqlalchemy
pip install beautifulsoup4
pip install pytest
pip install notebook
pip install –upgrade notebook
pip install glob
pip install signal
pip install multiprocessing
pip install moch
pip install xgboosy
pip install shutil
pip install yara
pip install virtualenv
pip install ruby gems
pip install scapy
pip install impacket
pip install shodan
pip install python-nmap
pip install sublist3r
pip install mechanize
pip install sqlmap
pip install subprocess
pip install threading
pip install passlib
pip install wordlist
pip install pycryptodome
pip install spiderfoot
pip install pymetasploit3
pip install pyinstaller
pip install colorama
pip install termcolor
pip install rich
pip install hashcat
pip install auditwheel
pip install pwntools
pip install flake8
pip install safety
pip install bandit
pip install pip-audit
2. [Apt: (Example)]
import apt
cache = apt.Cache()
cache.update()
cache.open()
pkg = cache["nmap"]
if pkg.is_installed:
print("Nmap is already installed")
else:
pkg.mark_install()
print("Installing Nmap...")
3.1. Core Concepts
* Variables:
* name = "value"
* number = 42
* boolean = True
* Data Types:
* int: Integers (e.g., 10, -5)
* float: Floating-point numbers (e.g., 3.14, -2.5)
* str: Strings (e.g., "Hello", 'world')
* bool: Boolean (True or False)
* list: Ordered collection (e.g., [1, 2, 3], ["apple", "banana"])
* tuple: Immutable ordered collection (e.g., (1, 2, 3))
* dict: Key-value pairs (e.g., {"name": "Alice", "age": 30})
* set: Unordered collection of unique elements (e.g., {1, 2, 3})
2. Operators
* Arithmetic: +, -, *, /, // (floor division), % (modulo), ** (exponentiation)
* Comparison: ==, !=, >, <, >=, <=
* Logical: and, or, not
* Assignment: =, +=, -=, *=, /=
3. Control Flow
* if statements:
if condition:
# code to execute if condition is True
elif another_condition:
# code to execute if another_condition is True
else:
# code to execute if no conditions are True
* for loops:
for item in iterable:
# code to execute for each item
* while loops:
while condition:
# code to execute as long as condition is True
* break: Exits the current loop
* continue: Skips the current iteration and moves to the next
4. Functions
* Defining a function:
def function_name(parameter1, parameter2):
# code to be executed
return result
* Calling a function:
result = function_name(argument1, argument2)
5. Data Structures
* Lists:
* list_name = [] (create an empty list)
* list_name.append(item) (add an item to the end)
* list_name.insert(index, item) (insert an item at a specific index)
* list_name.remove(item) (remove the first occurrence of an item)
* list_name.pop(index) (remove and return the item at the given index)
* list_name[index] (access an element by index)
* list_name[start:end] (slice a portion of the list)
* Dictionaries:
* dict_name = {} (create an empty dictionary)
* dict_name["key"] = "value" (add or update a key-value pair)
* value = dict_name["key"] (access the value associated with the key)
* keys(), values(), items() (methods to get keys, values, or key-value pairs)
6. Modules and Packages
* Importing modules:
import math
from math import pi, sin
import my_module as mm
* Creating your own modules:
* Save Python code in a file (e.g., my_module.py)
* Import the module in other Python files
7. Object-Oriented Programming (OOP)
* Classes:
class MyClass:
def __init__(self, attribute1, attribute2):
self.attribute1 = attribute1
self.attribute2 = attribute2
def my_method(self):
# code to be executed
* Objects: Instances of a class
* Attributes: Characteristics of an object
* Methods: Functions that belong to an object
8. File Handling
* Opening a file:
file = open("filename.txt", "r") # 'r' for reading, 'w' for writing, 'a' for appending
* Reading from a file:
content = file.read()
line = file.readline()
lines = file.readlines()
* Writing to a file:
file.write("some text")
* Closing a file:
file.close()
9. Exception Handling
* try...except blocks:
try:
# code that might raise an exception
except ExceptionType:
# code to handle the exception
10. Common Libraries
* math: Mathematical functions (e.g., sqrt, sin, cos)
* random: Generate random numbers
* os: Interact with the operating system
* sys: System-specific parameters and functions
* datetime: Work with dates and times
* requests: Make HTTP requests
* pandas: Data manipulation and analysis
* NumPy: Numerical computing
* Matplotlib: Data visualization
This is a basic overview. For a deeper understanding, I recommend exploring official Python documentation and online resources.