First Python Program

we will learn to make simple codes in the pycharm IDE editor window and the code will be compiled and run. You will also get familiarized with the output window and execution of the python program. Note that all the python files have a “.py”  file type extension.

In the last post, we had opened pycham and had located the editor window. The default code can be cleared for writing a new program or click the project window on the left and select a new python file.



The first program executed in almost every language is a program to print hello world on the screen. Keeping the tradition going, we will make our first program in python to print “Hello world” on the screen. This is a simple one-line program as shown under:

print(“Hello world”)

You can delete the entire default code in the main.py file and type the above one-line code and press the run button to execute the code. The result of the program appears in the console window that will get automatically opened just below the code window, as shown in the next image. In case of any error, the same is also displayed in this window.

Congratulation! You have created your first code in python. Now we will try to understand the code!

All working in python is done through functions. The functions are ready-made codes to do a certain type of work. Functions can be assumed as a black box, you only need to provide input and it provides results. You need not bother about any calculations or methods that it deploys. Python has various built-in functions to reduce your work.

We will study them one by one in upcoming lessons. For now, we assume them as a black-box that takes inputs and provide result. In the above program, print() is a function. Anything written inside it will be printed on the screen. The work of converting the text into machine language, interaction with hardware, and providing results to the screen is handled automatically by this function.

The inputs to the function are written inside the brackets and are separated by commas ( these values separated by commas are also known as parameters). In the above case, “print” is a function, it can take input. The input is written inside a bracket after the print keyword i.e.”hello world”.


At this point you don’t worry about that quote (“), marks put around “Hello World”, you will understand the reason behind it in upcoming lessons. 

Index to "Basic Python for Traders"

Resources

Highest Rated Udemy Course on PineScript - Grab your Seat Now 

Udemy Discount Coupon Code : UDEMY-JAN23 (Valid upto 30th Nov 2023)

Learn more about coding on tradingview in PineScript through Books on pinescript available on amazon and kindle.


200+ pages book100 pages book200+ pages book


Point and Figure Charts : A Time-Tested Tool for Technical Analysis

In the dynamic world of financial markets, investors and traders constantly seek tools that can provide valuable insights into market trends...