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 :
Output(show on Terminal):
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):
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):
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
Post a Comment