Python
Python
What is python?
Indentation:-
For ex:-
if 5 > 2:
print("Five is greater than two!")
You have to use same no of space in same block of code to avoid error.
if 5 > 2:
print("Five is greater than two!")
print("Five is greater than two!")
Comments:-
Comments are of two types single line comment and multi line
comments.
Ex:-
#This is a comment
print("Hello, World!")
And
#This is a comment
#written in
#more than just one line
print("Hello, World!")
We can also use triple quotes in a multiline string which is not assigned
to a variable.
"""
This is a comment
written in
more than just one line
"""
print("Hello, World!")
Variables:-
Ex:-
x = 5
y = "John"
print(x)
print(y)
Ex:-
x = str(3) # x will be '3'
y = int(3) # y will be 3
z = float(3) # z will be 3.0
Conditions to create a variable:-
For Ex:-
myvar = "John"
my_var = "John"
_my_var = "John"
myVar = "John"
MYVAR = "John"
myvar2 = "John"
Data type:-