There are many components in Python which to develop a program. Let's see some of the very common and frequently used building block o...
There are many components in Python which to develop a program. Let's see some of the very common and frequently used building block of the program.
Expressions:-
These are the legal combination of symbols or operators which represents a value.
eg
1) a=15
2) x=y+z
3) if b>5:
Statements:-
These are programing instructions
eg
1) a=15
2) print("Hello World")
3) a=b+x
Comments:-
Comments are the lines that are ignored during program execution. Comments are mostly used to clarify the source code.# a symbol is used to make the statement comment.
eg
Single line comment
# This line of code is for variable declaration
Inline comment
a=10 # variable a has value 10
Multiline comments
#This is the first-line comment
#The is second line comment
Functions:-
Functions are a set of statements that are defined under a named code section and we can reuse these functions by specifying the function name( function call). The function's definition is started with "def" keyword
eg
To Define a function SayHello
def SayHello():
print("Hello India")
To Call the function
SayHell() # this is function call
Blocks or suites:
These are a group of statements that are part of another statement or a function. All the statements inside the block or suite are intended at the same level.
eg
To write a block statements for if condition will be
if a> 1000:
print(" value is too large")
print("This is a if statement block"
COMMENTS