programming-with-python-GOC-gang-of-crypto

Programming with Python

Example Program in Python

Hello, world!

Now that you have got an idea of what python code looks like. Let’s check out one of the basic examples and dive deeper into what’s going on. Get ready. We are going to use the Python interpreter to make our computer say hello to the world.

When we run this code either locally on our machine or on a web interpreter, the words hello world appear on the screen, just like magic. Actually it’s not magic. It’s because print is a Python function that writes what we tell it to on the screen. 

In Python, the hello world example is just one line, in C, it’s three lines, in other languages it can be even more. While learning to write,  hello world won’t teach you the whole language, it gives you a first impression of how functions are used, and how a program written in that language looks.

//Example program of Python
friends=["Mike","Alexa","Cara","Mon-el"]
for a friend in friends:
    print("Hi"+friend) 
OUTPUT:

Hi Mike
Hi Alex
Hi Cara
Hi Mon-el