To print anything in python we use print() method. There exists many ways to print hello world (any string) in python, mentioned below.
Using Command Prompt
Go to search panel and type ‘cmd’ or ‘command prompt’ and select the first option that appears like a blackboard. Now as we have already have python installed in our system just type the command ‘py’. You can now see the version of python and these >>> ,yes that where we have to write print() method. Mention the string hello world within the round brackets of print() method in single or double quotes.
In above mentioned examples semicolon(;) is optional, the string hello world can get printed with or without semicolon. Below mentioned syntax is invalid.
Using a .py file
Its simple, open notepad and just place the below mentioned code, save that file with .py extension. Then open command prompt type this command – python filename.py
print("hello world") print("hello world"); print('hello world') print('hello world');
Here cd desktop command was used because the file 3.py was in desktop.