Saturday, 16 March 2019

fundamental of python class 11 cbse part 3

PART 3

FLOWCHART

Flowchart is a graphical representation of an algorithm, workflow or process. The flowchart shows the steps as boxes of various kinds, and their order by connecting the boxes with arrow.

Conditional (if) statement.

In python, if statement is used to select statement is to be done on the basis of a condition, if statement.
if <condition>:
                statement.

if-else statement.

if<condition>:
                   statement when condition is true.
else:
      statement when condition is false.

if-elif statement.

a=int(input("Enter a number"))

if a==10:

           print("a is equal to 10")

elif a==20:

           print("a is equal to 20" )

else:

           print("a is not equal to 10 and 20")

NESTED if-else.

a=int(input("enter a no.")) 
b=int(input("enter a no."))
c=int(input("enter a no."))
if a>b:
        if a>c:
                  print("a is greater")
    else:
           print("c is greater")

in and not operator.

  • in operator 
           3 in [1,2,3,4] will return true.
           5 in [1,2,3,4] will return false.
  • not operator
           5 not in [1,2,3,4] will return true.

While loop

n=int(input("enter a no."))
c=1
while c<11:
           print(n,"x",c,"=",c*n)

JUMP STATEMENT(break)

n=int(input("enter a number"))
  c=1 
while c<11:
         is c==5:
              break
           print

CONTINUE STATEMENT

n=int("input a no."))
c=0
while c<11:
c=c+1
if c==5:
       continue
print (n,"x",c,"=",c*n)
           


No comments:

Post a Comment