Python QGIS
1- Open Python console:
QGIS provides Python console for scripting. You can open it from the: Plugins ► Python Console menu.

2- Typing in Python console:
In the Python console use print() function to write.
Print("Hello My Dear Learner!")
Then click "Enter"

3- Writing script on "Script editor":
For long scripts, you can use Script editor. To open it click on 'Show Editor"

https://smartrs.hashnode.dev/series/learning-python-qgis