In the last article, we have completed the Python installation and setup. Now we will start with our first program. Print “Hello India!” is a basic program to start with for any coding language.
Unlike Java, C++ or any other coding language we don’t have to write many lines of code to do this task.
First Programme in Python
Creating the first programme: Print “Hello India!”
Step 1: Open Python Editor. Select create new project.
Step 2: Provide the location to save your project. The default project name will be “untitled”. Change the project name to something more meaningful.
Step 3: Click on create.
Step 4: From File menu, select New and from sub-menu select Python File.
Step 5: Provide a file name. And click ok.
Step 6: Type simple code, as shown below.
print “ Hello India! “
Step 7: Now from the menu bar, go to Run and select Run from sub-menu to run the code.
Step 8: The programme will give output in case of no error. If error is present, the error details will be seen at the bottom of the Python Editor.
Step 9: If you do not have Python Editor installed in your device. You can still run your Python programme from the command prompt.
Step 10: Open Command Prompt and provide the path of your python file. Press enter to produce the output.
Example: C: \ PythonProject > HelloIndia.py
Congratulations you have created your first code in Python. Now you can start building more.
Start to create basic python programmes to get command over python language. Some of them are listed below:
- Addition/subtraction of numbers
- Check if the number is prime or not
- Factorial of a number
- Calculate simple interest
- nth Fibonacci series
- Searching and sorting of numbers
- Basic user input
- Check whether the input character is alphabet or number
- Add two matrices