JOBS ESTATE FREE EMAIL ALERTS

i)if:-

                 In Java/C

if(condition){

block 1

}

else if(condition2){

else if block

}

else{

else block

}

 

               In Python

if condition :

    block 1 stmt 1

    block 2 stmt 2

elif condition 2:

    elif block stmt 1

    elif block stmt 2

else :

    else block statement

 

#program to demonstrate if condition

#program to check whether entered integer is 15 or not

x=int(input(“enter an integer value”));

if x==15 :

    print(“value is 15”);

elif (x<15) :

    print(“x value<15”);

else :

    print(“x value>15”);

output:

enter an integer value25

x value>15

 

ii)for loop :for loop in range function

     range(5)–>0-4

     range(5,10)–>5-9

  range(0,10,3)–>0,3,6,9

for i in range(10) :

      block

 

 

#program to demonstrate for loop

for i in range(0,10,3) :

     print(i);

output:

0

3

6

9

 for loop : for loop in List

S = [10,20,30]

for i in S :

    print(i);

output:

10

20

30

 

iii)Break,Continue & Pass:-

break–>terminates from the loop

 

#program to demonstrate break  condition

for i in range(10):

    if(i==3):

break

print(i);

output:-

0

1

2

Continue–>it skips the current iteration’s execution

#program to demonstrate continue  condition

for i in range(10):

    if(i==3):

continue

print(i);

output:-

0

1

2

4….9

Pass–>it do nothing like empty  statement in if condition (Java/C)

In Java/C

 

if(condition){

 

}

if(condition) :

        pass

           In Python                                                                                         

 

 

 

© Copyright 2020 Jobs Estate All Rights Reserved