Monday, August 10, 2020

LOOPS.......LET SEE ..VERY SIMPLE

 LOOPS:


1.What is can do by using LOOPS?

                    -> Using  loops we can execute a single statement (or)  Multiple statement  more than one time.


2.When  we will go for loops?

                    ->When ever we want to execute a single statement (or )multiple statement  more than

one time.


TYPE OF LOOPS:

1.FOR LOOP.

2.WHILE LOOP.

3.FOR LOOP with ELSE.


FOR LOOP:

<syntax>

for <variablename>in  range (<starting range>,<ending range+1>):

          logic


PROGRAM:

for i in range(1,6):

     print(i)

output:

1

2

3

4

5

TRACING:


What  range() function will do?

                    -> range() function will initialize given starting value.

                    2) into i, and it will compare i with ending range if condition is true then it will 

execute after execute it will go for auto increment by one.....

PROGRAM 2:

for i in range (1,6):

     print(i,end=" ")

output:

1,2,3,4,5

Trace :

WHILE LOOP:

<Syntax>

while<condition>:

     logic

PROGRAM:

i=1

while i<=5:

     print(i)

     i=i+1

output:

1

2

3

4

5

TASK1:

Write a python program to print 1 to 5 number like below by using while loop.

program:

i=5

while i>=1:

     print(i,end=" ")

     i=i-1

output:

5 4 3 2 1

TRACE:


FOR LOOP WITH ELSE:

         ->Generally else part will there  for only conditional statement ....but in python else part is 

available for loop.


<syntax>

for<variablename>in range(<string range >,<ending range +1>):

     logic


program:

for i in range(1,4):

     pin =int (input("enter ur pin:"))

     if pin ==1122:

          print("valid pin")

          break

else:

     print("you entered invalid pin,you account is blocked")

output:

enter pin:111

enter pin:222                   

enter pin:333

you entered invalid pin,you account is blocked


THANK YOU....😉😋😋😋😋












                    


 




                    

          

          

     




Sunday, July 12, 2020

Branching statement:

BRANCHING STATEMENT:

four type of Branching statement:

# 1. Simple if statement.

# 2. if.......else statement.

# 3. elseif ladder statement.

# 4. Nested if statement.

1.SIMPLE IF STATEMENT:
            1) In this evaluate process the condition must true  then only it will do next process.
            2)If  the condition is false there is nothing to happen automatically came out the process.
2.IF......ELSE STATEMENT:
          1)  If the condition is true it will do only one work.
          2)  If the condition is false it will do another work.
3.ELSE IF LADDER STATEMENT:
          3) It will be Executed  in step by step process and this process will 
                    be hope where the condition is true.
4. NESTED IF STATEMENT:
                In this condition having one if statement  itself  having another if statement on that.


Example:

SIMPLE IF STATEMENT:
        
a=5
if a==5:                              # Evaluate the condition is TRUE.
   print("welcome")

OUTPUT:
           welcome


2.IF......ELSE STATEMENT:

a=5
if a==4:
   print("welcome")
else:
   print("hello")                # Evaluate the condition is FALSE.

OUTPUT:
        hello



3.ELSE IF LADDER STATEMENT:

a=int(input("enter the value"))
if a==4:
   print("four")
elif a==5:
   print("five")                                                 
elif a==6:
   print( "six")                                                            
else:
   print("hello")     


OUTPUT:
  enter the value: 5
      five
enter  the value: 4                                             
      four

enter the value: 7                                  #we assing except this values automatically go to else part
       hello
                                                                                     and print hello

4. NESTED IF STATEMENT:

a=int(input("enter the value"))
b=int(input("enter the value"))
if a==4:
   if a>4:
      print('yes")
   else:
      print("no")
else:
   print("terminate")

OUTPUT:

      


            





Saturday, July 11, 2020

OPERATOR PRECEDENCE

OPERATOR PRECEDENCE:

()                                                -> Parentheses.

+x, -X, ~X                  -> Unary Plus, Unary minus,  Bitwise No.

**                                            -> Exponentiation (raise to the power).

* / % //                               -> Multiply, divide, Modulo, and Floor 
                                                                                                Division.

+ , -                                  -> Addition and Subtraction.

>>  <<                                 -> Right and Left bitwise .

&&                                         -> Bitwise  "AND"td.

^|                                               -> Bitwise exclusive "OR" and  regular "or".



Example:
        
e=(a+b)* c/d
                                                              #try this using in above the operator 
 e=a+(b*c)/d 
                                                                                precedence.
e=((a+b)*c)/d



       a,b,c,d=2,4,3,5

1.  e=(a+b)* c/d                           e=(2+4)*3/5     
        print(e)                                        e=(6)*3/5 
                                                                    e=18/5  
                                                                    Print(e)  
 OUTPUT:                             3.6                      
3.6

                                              
    2. e=a+(b*c)/d                                  e=2+(4*3)/5
         print(e)                                            e=2+(12)/5
                                                                         e=2+2.4
                                                                         print(e)
                                                                        4.4                                                                                                OUTPUT:          
     4.4
    
 3  e=((a+b)*c)/d
        print(e)
                                                  # YOU  TRY   ðŸ˜œðŸ˜œ                         
OUTPUT:
3.6


Monday, March 2, 2020

INTRODUCTION for....PYTHON

Basic for PYTHON.....
-March 2.3.2020

CONCEPT:
Introduction for Python.....and basic method.
today class for..
#LIST  []
#SORTING
#TUPLES ()
#SET  {}


                              #LIST []

Example 1:

fruits=['apple', 'orange', 'cherry']
print(fruits)
output:
('apple', 'orange', 'cherry')

Example 2:

fruits=['apple','orange','cherry']
print(fruits[1])
output:
orange

Example 3:

fruits=['apple','orange','cherry']
print(fruits[1:3])
output:
orange, cherry

Example 4:
fruits=['apple','orange','cherry']
print(fruits[-1])
output:
cherry

Example 5:

fruits=['apple','orange','cherry']           
fruits[1]='banana'
print(fruits)
output:
['apple','banana','cherry']

Example 6:

 
fruits.append('banana')                       #Append used for  JOIN ONE STRING.
print(fruits)
output:
['apple','orange','cherry', 'banana']

                                                     #SORTING

number=[11, 2, 20, 0]
number.sort()
print(number)                                       #SORTING IS USED FOR ARRANGING THE  NUMBER 
 output:                                                     FROM ASCENDING  TO DESCENDING
[0, 2, 11, 20]

Example 2:

number=[11, 2, 20, 0]
number.sort(reverse=true)
print(number) 
output:
[ 20, 11, 2, 0]   

                                                   #TUPLES ()


fruits=['apple','orange','cherry']
number=[11, 2, 20, 0]
print(fruits+number)                     #A Tuples is a collection  which is order and  UNCHANGEABLE.
output:
['apple','orange','cherry', 11, 2, 20, 0]

                                                   #SET{}

fruits={'apple','orange','cherry'}
print(fruits)
number=(11, 2, 20, 0)                           #Set  is Use for Changing the order
print(number)
output:
{'apple','orange','cherry'}
(11, 2, 20, 0)


                                                







 




Sunday, March 1, 2020

PYTHON INTRODUCTION.........simple to learn.

Basic for PYTHON.....
-March 1.3.2020

CONCEPT:
Introduction  for Python.......and basic method.

PYTHON FACTS:
-This Developed  by GUIDO VAN ROSSUM and released on February 20,  IN 1991.

IMPORTANT  3 THINKS.

Indentation----> TO Avoid Unnecessary Space.
Colon        ----> This must for Python.
Function:

CONTENTS:-

Primitives--> Number, strings, Boolean . 

#INTEGERS --1, 2, 3, 4..........Numbers.
#FLOAT-- 1.2 , 5.6, 9.5,
#COMPLEX-- 5+2j


                                               #VARIABLES
Example 1:

  Watch=500
  print(Watch)

output:
     500

Example 2:
  Watch=500
   print(Watch+20)

output:

520
    
                                             #STRING METHOD.

Example 1:

word1="hi dude"
word2="my age is 24!"
print(word2)
out put:
my age is 24!

IN PYTHON STRING CONVERTED  IN ARRAY.

Array start in ZERO.


INDICES:

word1="HELLO"
print(word1[3])

output:
L

SLICING:

word3="HELLO"
print(word3[1:3])                       

output:
EL                                         #Before array value in 3.

LENGTH:
word3="hello,  world"
print(len(word3))            #keyword------len
output:
12

STRIP()

word2="    my age  is 19"
print(word2)                           #Strip is used in removed in unnecessary space.
output:                                     
Error                  #because  word2    using unnecessary   space.


word2="my age is 19"
print(word2)
output:
my age is 19

BOOLEAN:

Example 1:
   word3="hello"
   print("hell" in word3)                 #Boolean
                                                    #out put is --------> TRUE , FALSE
output:
TRUE

Example 2:
   word3="latha"
   print("hell"in word3)
output:
FALSE







Sunday, January 5, 2020

pyramid pattern

PYRAMID PATTERN USING FOR LOOP IN PYTHON LANGUAGE

-5 JANUARY 2020

CONCEPT:

The below program prints the pyramid pattern using * by for loop.

INPUT:

Enter the no of rows:4

PROGRAM:

num=int(input("Enter the no rows:"))
for i in range (0,num):
      for j in range(0, num-i-1):
           print (end=" ")
for j in range(0,i+1):
           print("*",end=" ")
print()

OUTPUT:

       

Friday, January 3, 2020

REGULAR EXPRESSION

REGULAR EXPRESSION using PYTHON
-january 4.1.2020

CONCEPT:
     To get the year from the e-mail id using \d+.
SYMBOL:
\d  - digit(match digit)
\w - specific alphanumeric
\s - space(count the no of space
\.   - each single characters
 - 1..............infinity
 - 0.............infinity
?   - (+91)(Eg: 91  is optional number may be)

INPUT:
     Given Email Id (2000lathaammu2020@gmail.com)
OUTPUT:
     if your input email id is 2000lathaammu2020@gmail.com then your output is ['2000','2020']

PROGRAM:

     for PYTHON..........

import re
s="2000lathaammu2020@gmail.com"
re.findall('\d+',s)


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