You are on page 1of 2

#Indentaions

#Python uses indentations to represent a block of code

if 5 > 2:

print("five is greater than two!")

#^ needs atleast only 1 space but 4 is recommended. if you skip it, it will cause-

# a syntax error

if 5> 2:

print("five is greater than two!")

print("five is greater than two!")

#^ dont separate code spaces when attempting to execute the same code.

Out - five is greater than two!

five is greater than two!

five is greater than two!

#Variables are created when you assign something a value

#x = value

a = 5 #int

b = "ELmer" #str

print(type(a)) # < to get the data type of a variable, do this func

print(type(b))

Out - <class 'int'>

<class 'str'>

#Casting - to specify the data type of a variable

#The conversion of one data type into the other data type is known as type casting

#in python or type conversion in python.

#Python supports a wide variety of functions or methods like:

#int(), float(), str(), ord(), hex(), oct(), tuple(), set(), list(), dict(), etc. for the type casting in python.

x = str(3)

y = int(3)

z = float(3)

print(x)
print(y)

print(z)

Out - 3

3.0

#String variables can be declared either by using single or double quotes

#variables are also case sensitive

You might also like