Break,Continue and Pass Statement

0
Break:-

It is used to terminate the loop statement based on condition.

break statement always will work using a conditional statement.

for i in range(1,10):
  if i==3 or i==5:
     break
  print(i)



for i in range(1,10):
  if i==3 and i==5:
     break
  print(i)

for i in range(1,10,3):
   if i<3 or i==5 and i>=7:
     break
   print(i)


print("Break Example") 


Continue Statement in Java:-

It is only used into a loop only and it is used to skip the data which satisfy the condition and continue loop till last.

for i in range(1,10):
   if i==3:
     continue
   print(i)

..........................................................................................................................................................

for i in range(1,10):

   if i==3 or i==5 and i==7:
     continue


   print(i)
...........................................................................................................................................................

Pass Statement:-

it is specially used to declare block-level statement because python does not use { } bracket to define for loop, while loop,if--else then we can use the pass to define an empty block.
for ():
  pass

if ():
  pass

pass does nothing, it only defines default statement which does nothing and returns nothing.


ASSIGNMENT:-

Q1)WAP to calculate the salary of an employee from empid will be started from 1001 to 1020.
empid 1003,1005 and 1007 salary should not be displayed, if entered salary will be above 20000 then the calculation should be performed till 1017.
empid 1013,1015, 3 days salary will be reduced. Salary is common for all employee.


Q2) WAP to display the prime number in Fibonacci series?


Q3) WAP to count total numeric and decimal digit in any float number?


Q4) WAP to display the approx value in float till 2 digits, if last digit is >5 then it will be considered 6,>6  will be 7 and ...

2.5677
o/p 2.57

o/p 2.5577
o/p 2.55






Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)