Everyday Python — Day 1 “Hello World”
The inauguration step for starting coding, is always been writing a “Hello World!” program, so we will be begin with writing a basic printing statement and then proceed further to know the real extent of using both printing and input statements.
Now before we move further I want you to use the CodeStock IDE . It is easy and available online, so no need of laptop and complex applications.
In case you have a laptop and want to use a local IDE, stay tuned for my article about how to install python on your laptops.
Printing Statement — print()
Python is very easy so many of its instructions are basic grammar commands, we use in our daily life. Such an instruction is print() , it is basic function that takes argument which will be printed in the output. For instance, when you go to a photo-copy shop, you told the shopkeeper to print a copy of your documents, or print your science projects, or print a basic balance sheet onto a piece of blank paper.
This print() instruction is similar to it, here python is shopkeeper, IDE is xerox machine, documents are the values passed between the parenthesis of print and output is the piece of paper which will be having the data printed on it.
print("Hello Coder! I am a python program")
In above statement we are passing a message to the IDE and it will be getting printed in the output. Notice that the message is passed between the set of round brackets as well as the pair of double quotes. For passing a message, it is mandatory for you to put your message between these parenthesis.
Input Statement — input()
As I mentioned earlier python is human readable even in terms of syntax. So is its input() instruction. It is basic function that reads user input and returns the value to the variable. For instance, when your teacher asks you to read a paragraph, so that she can start explaining the paragraph and everyone can hear her to understand, what you are reading.
Similarly here , variable is the teacher who stores the value returned from input statement and the instruction given to the python is you and the IDE or input console is the book from which you are reading, the program code is the other students those who are understanding the input with the help of variable.
variable = input()
From the above statement, you can understand that whatever the user will input, it will be stored in variable.
Now let’s use both of these statements to write our first Python code:
name = input() print("Hello ",name," I am a python program")
Try the above code in the CodeStock IDE and tell me what happens, don’t forget when you run the code the input console will expect something from you to print the desired output in the output console.
Paste the output in the comments, Waiting to see your imaginations. Stay tuned for the next topic.
Until then complete the above mentioned task.