Skip to main content

Print Statments and Comments in Python

1) Print Statement Function in Python

A print statement Function is used to show output on the screen. In Python, we write print() with a small letter p, not a capital letter.

Roman : Print statement Function screen par output dikhane ke liye use hota hai. Python me print() small letter p se likhte hain, kyunki Python case-sensitive hota hai.

Example of Print Statement Function in Python :

print("Hello World")

        

Output(show on Terminal):

Hello World
        

Another Example of Print Statement Function in Python :

print(10)
print(2.0)
print(True)
print(10+5)
print(2*5)
print(0-0)


        

Output(show on Terminal):

10
2.0
True
15
10
0
        

2) Comments in Python (Single and Multiples):

Single Line Comments using Hash(#) in Python

A comment is used to explain a line of code. In Python, a comment is written using #(hash) at the start of the line, and the shortcut key Ctrl + / can be used to add or remove comments,but comment doesn't show in output

Roman : Comment line ko explain karne ke liye use hota hai. Python me comment # se line ke start me likha jata hai, aur shortcut key Ctrl + / se bhi comment add ya remove kiya ja sakta hai, lekin output mein comment nhi show hota hai.

Example of single Line Comments in Python :

# It is a print Statement -- using Comments is Single Line Comments
print("My Name is Hamid Hasnain")
        

Output(show on Terminal):

My Name is Hamid Hasnain
        

Multiple Line Comments using (''' ''') or (""" """) in Python

A multiple line comment is used when we need to write long explanations or comments in multiple lines. In Python, it is commonly written using triple quotes (''' ''' or """ """). Using # is mainly for single line comments.

Roman: Multiple line comment tab use hota hai jab hume long explanation ya multiple lines me comment likhna hota hai. Python me isko commonly triple quotes se likhte hai (''' ''' ya """ """). ka use mainly single line comment ke liye hota hai.

Example of Multiple Line Comments in Python :

# print a Two Line Code for Jokes of Code! --- it is a Single line Comments using Hash # 
'''Programmer: Why is my code not working?
Also Programmer: I didn’t even run the code   ---- It is a Multiple Line Comments using triple quotes (""" or ''')''' 
 
print('''Programmer: Why is my code not working?
Also Programmer: I didn’t even run the code''')
        

Output(show on Terminal):


Programmer: Why is my code not working?
Also Programmer: I didn’t even run the code
        

Comments

Popular posts from this blog

" Welcome to NiceinPython."

Information of Python Programming Language. ✨ Welcome to NiceinPython Learn You can learn Python here in an easy and simple way. This website provides Python notes, practice programs, real projects, and a Python setup guide. Everything is explained step by step for beginners. Content is available in Hindi + English and Urdu + English style for easy understanding. NiceinPython is made for learners who want to learn Python by practice and projects, not just by watching or reading. (Roman English: Yaha par aap Python ko easy aur simple tareeke se seekh sakte ho. Is website par aapko Python Notes, Programming Practice, Real World Projects aur Python Setup Guide milega. Har topic step by step aur simplified learning style me explain kiya gaya hai taaki beginners easily samajh saken. Is website ka content Urdu + English aur Hindi + English language = Roman English style me available hai, taaki learners apni comfortable language me concepts samajh saken. NiceinPython ek...

Full Python and Vs code Setup Completed

Information of Python Programming Language. ✨ Welcome to NiceinPython Learn Full Python and Vs code Setup Completed.. Python Download and Install – Download Python from the official website, install it, and make sure to tick the PATH option. VS Code Download and Install – Download VS Code and install it on your system. Install Python Extension in VS Code – Open VS Code and install the Python extension from the Extensions section. Check Python Installation – Type python --version in CMD or Terminal to check. Run First Python Program Test – Create a simple Python file, run it, and check the output. For detailed setup, click this button or open the Python Setup Guide page from the menu bar. Python Setup Guide