In a software we need to interact with humans. So to interact with human software need to send some messages in a language which is understandable to human like English. So our first program be to welcome.
To start programming you only need one editor, where you write code means some instruction in English language and second one is special software.
What is editor?
Editor is a software where you can write. Example - Notepad
I recommend you to use Notepad++ or Sublime Text or Visual Studio Code for writing code.
What is special software?
Computer does not know the english language. So this special software is need to tell the computer first that we want to talk in some programming language. For computer to understand that we need this special software.
For python programming language we install python from python.org
To setup python environment in your computer please check official document of python.
Lets code
To show any thing we use print command.
Fist see my code and try this and check the explanation
Explanation:
First we create a file and save it as test.py . Here 'test' is our file name and '.py' is used for python file.
First line of code - print("hello")
Between inverted coma whatever you write it will show in the out put. You have to use () for python3. In python2 it is not mandatory.
Second line - print ("10")
This also show the thing written between " ",10. So output of second line is 10
3rd line - print (10)
Now you think that why I am not using "" here. Because to print any number you can use "" but if you don't use, there is no problem.
4th line - print (10.5)
As same as 3rd line it results 10.5. Here also you can use print ("10.5") also.
Till now, we use only print ("some text to show"), but here one thing in python. When you only use print (" ") , the next print automatically start from the next line. You can see that our 1st line code output in the 1st line and second one is in second line. Now if we use end , we can change the setting.
Like my code, I use end = "next line -". This means after showing whatever write between quote it shows the end option. For that the next line code start after 'next line -'.
By default end = "\n". \n means new line.
If you have any question about printing anything please comment below, I will give you the solution.
Assignment
1. print I got 100% marks
2. print My first priority is "LOVE".
3. print 10,20,30,40,50 #Note : Use end for this. And use 5 print statements
Answer of Assignment
1. print ("I got 100% marks")
2. print ("My first priority is \"LOVE\".")
Note : This is a special case. To print a " you need to write \". Because python has no meaning after " any statement. So we use escape character \.
3. print (10,end=", ")
print (20,end=", ")
print (30,end=", ")
print (40,end=", ")
print (50)
Thank you.