Writing New Program & Comment

Codynn
2 Min Read

Writing & Running a New Program:

Step 1: Open python IDLE and click on File and new file. Also you can create it with the shortcut key Ctrl+N.

Step 2: write the program and click on run. And, you need to save your file before running it.  

Step 3: After running the program you will get output as below. 

Writing Comment in Program:

Comments are an essential part of coding which is mostly used for describing code. It increases the readability of a code. Also, a code is used to prevent the execution. There are two types of comments i.e. single line comment and multi line comment. 

Types of comments:

i. Single line comment:

Syntax:

a.

#This is a single line comment 
print("Hello, World!")

b.

print("Hello, World!") #This is a single line comment

The single line can be written in two different ways. One way is to write ahead of the code whereas another way is to write at the end of the same line.  

ii. Multiline comment:

Syntax:

a. 

""" This is a
     Multiline 
     Comment """ 
print("Hello, World!")

b. 

# This is a 
# Multiline 
# comment
print("Hello, World!")

The multiline comment can be written in two different ways. One way is to write inside the triple quotes whereas another way is to write a hash-tag ahead of every statement. The multi-line comment inside of quotes is more preferable because it is more effective in large programs. Python will read and ignore statements inside of comments.  

Share This Article
Leave a comment

Leave a Reply

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