Guide to Python: Lesson 03

Let’s write your first code in Python. It’s so satisfying to see yourself coding and your code working and giving output. 

So, let’s get started. Open your VS Code, on the screen you will likely see this interface. 

In this welcome screen or in file menu (Top left) click on new file and press enter to create a new text file in which you will write your code. 
You can also use shortcut “Ctrl+Windows+Alt+N” to create a new file. 
Then press “Ctrl+S” to save your file in your file explorer, You can also use file menu to save it. Please save your file with ‘.py’ extension. Just like other files have their own extension so too are python files with .py extension. 
Your first program can look as simple as like this. 
    print(“Hello, World!”)

This is a simple one line code in python. This code give output “Hello, world” in the terminal window. 

Let’s demystify this simple code bit by bit. 

Here ‘ print() ‘ is a built in functions in python library. ‘Hello, World!’ is text that you want as output. this can be any text like ‘This is my first program in Python’. 

So what is a function? 

A function in simple terms is something that takes input, processes it and gives back output. Kind of just like a machine, which does a specific task by taking input and gives a desired output. You may have learnt in math class about functions. It is a similar concept.  

In the below example the grinder/juicer acts as a function which takes fruits as input, processes them (grinds them), and gives juice as output. 

Fig: Function

In the similar way ‘print()’ function takes input whatever is between the parentheses and gives back output. Usually if the text between the parentheses is enclosed with single, double or triple quotes it is called a String. A string will be printed as it is. 

Great job making it through Lesson 03! Now that you know how ‘ print() ‘ function works. Try it yourself and see how this works. Try to put different things in the parentheses and see the output. Feel free to comment below for feedback, suggestion or doubts. Thanks, and see you in the next lesson. 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top