What is Python? - Write Your First Hello, World Program!

in hello-world •  6 years ago 

Python is an object-oriented, high-level programming language just like C, C++, Perl, and Java. It’s also a general purpose language, means you can build anything with the help of right tools and libraries. When I decided to learn a programming language, many of my friends who have a computer science background advised me to start with C or C++. If you search online, you will find dozens of blogs, articles, and forums where people have suggested to start your programming career with C or C++ to get a solid foundation but that’s not true. Many people start with C or C++ and quit after learning some basic concepts. The reason is that once you get to the advanced topics, it becomes difficult for you to absorb all of the advanced concepts, hence making it almost impossible to continue learning a programming language. Adding to this, we have to write far fewer lines of code in Python than in Java or C++ to build an equivalent application.

This is a simple program in C++ that will print out “Hello, World!” on the screen.

#include 
using namespace std;

int main() 
{
    cout << "Hello, World!";
    return 0;
}

And the same program in Python looks like this:

print(“Hello, World!”)

Did you check the difference? I had to write 5 – 6 lines of code just to print out “Hello, World!” on the screen but on the other hand, you are just using a print() function in Python that outputs the same result on the screen. This is one of the benefits of using Python that is human readability. Python is a great human readable and versatile programming language allowing us to quickly comprehend and understand the code, the easiest to learn and nicest to use programming language. Python is also a cross-platform language means the same Python program can be run on Windows and UNIX like systems (Linux & Mac). One of the great features of Python is that it comes with a complete and comprehensive Standard Library (Collection of script modules that can be accessed in a Python program to simplify the programming progress.) and you don’t have to rewrite your commonly used commands, just call/import them at the beginning of your program and that's it!. In addition to the standard library, Python supports thousands of third-party libraries as well like numpy, scipy,simpy etc. You can do almost anything you want with Python, whether it’s a website or a web application you want to build, carry out data analysis, scientific computing, machine learning & artificial intelligence or build productive tools, games, and desktop applications, the list never ends :)

Writing Your First Hello, World! Program

Usually, whenever you start learning a new language, the first program you write is “Hello World”. Though we have already seen how to display “Hello World” on your screen but let’s take a deeper look on our first program.

print(“Hello, World!”)

This is an example of how to print statements in Python, it doesn’t mean that it will print anything on paper. Let’s break down the different components of our first program.

print() is a function that instructs our computer to print or display something on the screen. How do we know that it’s a function? We know it because it has parentheses with the word print and whatever you write inside these parentheses (Also called an argument), it will be displayed on your screen. In our case, the output will be:

Hello, World!

print() is a default Python function means that it comes with the Python Standard Library but we can define our own functions that we can use multiple times in a program. Did you notice the quotation marks before Hello and after World? Whenever you write something inside the quotation marks, Python treats it as a String and doesn’t display the quotation marks. You can use either single or double quotation marks. You can also pass an integer as an argument but remember not to put it inside the quotation marks.

Print(300)
And the output will be:

300

However, if you put this number inside the quotation marks, this will still print 300 but this time, the type of this number would be a string, not an integer. We will learn more about data types later.

Congratulations! You have written your first Hello, World! program along with displaying an integer with the help of print() function.



Posted from Data Science With Python SteemPress : http://datasciencewithpython.info/what-is-python-write-your-first-hello-world-program/
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!