Search This Blog

Sunday, 23 August 2020

Python all basics first this then other ...

#printing string using variable

student = "Dnyaneshwar mauli"       #string savr in variable student

#print(student)

Student = "DNYANESHWAR MAULI"      #string savr in variable Student

#print(Student)

a1 = 10           #intger values

#print(a1)

#print(type(a1))

a2 = 3.14              #float values

#print(type(a2))

b1 = True         #boolean values True , False

b2 = False

#print(b1)

#print(b2)

#print(type(b1))

#print(type(student))        #type of string 

c1 = 3+4j                #complex number in this 'i' is replace with 'j'----j is stand for imaginary    

#print(c1)

#print(type(c1)) 



#Arithematic Operator

a=10

b=20

#print(a+b)

#print(b-a)

#print(a*b)

#print(type(a/b))

#print(a/b)

#print(type(a%b))



#Relatioal Operator

#print(a,b)

# print(a>b)           # ans is false

#print(a<b)            # a=10 , b = 20  ans is False

#print(a==b)           # ans is false 

#print(a!=b)            #ans is true


#logical operator

b1 = True         

b2 = False

#print(b1&b1)     #true    (1)******** #in  an and (&) operator if theirs both values are true then and only then value is true 

#print(b1&b2)     #false   (0)      anywhere it is false.    

#print(b2&b1)     #false   (0)

#print(b2&b2)     #false   (0)


#print(b2 | b2)    #false  (0) **********in or ( | ) operator both values are false then and only then value become false 

#print(b1 | b2)    #true   (1)         anywhere it is  true.

#print(b2 | b1)    #true   (1)

#print(b1 | b1)    #true   (1)



#python tokens  "The smallest meaningfull component in a programme"


#1. Keywords : "Special reserved words"

#like :

#   False None True class  finally is return  continue for

#    lambda try  def from nonlocal while and del global not with as elif if or yield


#Identifiers  : are names  used for the vaiables functions or objects

#RULES : 1. No special charactor expect _(underscore)

#        2. Identifires are case sensative (meeans they are change when their case is change like upper case to lower )  

#        3. First digit can not be digit.


#Literals : are the constants in python .

# like pie = 3.14

 

#Python strings : Strigs are the sequence of charactor enclosed within single quote (' ') , double quote (" ") or triple quote ("' '")


#  'helow world '  :- this for sigle line or single word

#  "hellow world wellcome to india"  :- this is for single statement or double statement.

#  "' hi we are gather here for the day \n and we are noe doing study  '"  :- this is for multiline statement.


#Extracting idividual charactor:


my_string = "My name is Dnyaneshwar"

# print(my_string[0])       #   ans is --  M         

# print(my_string[5:12])    #   ans is -- me is D



# String functions:


#1.FINDING LENGTH OF STRING

#print(len(my_string))        #ans is 22   

  

#2.CONVERT THE STRING INTO UPPER CASE:

#print(my_string.upper())                     #MY NAME IS DNYANESHWAR


#3.CONVERTING THE STRING INTO THE LOWER CASE

#print(my_string.lower())                      #my name is dnyaneshwar


#4.REPLACING A SUBSTRING

#print(my_string.replace('D','G'))              #My name is Gnyaneshwar


#5.NUMBER OF OCCURANCE OF SUBSTRING

#print(my_string.count("name"))                 #count the word name how many times i.e equal to 1


#string function


#1.find the index of the substring

#s1="This is Dnyaneshwar mauli"               # s1.find () used to find the position of the the string i the line.

#print(s1.find('mauli'))


#2.Spliting of the string                      # split function is used to split the word , symbol that we put inside the round brackets.

#fruit='I like apples , mangoes , bananas , grapes'            # its output is==['I like ', 'pples , m', 'ngoes , b', 'n', 'n', 's , gr', 'pes']

#print(fruit.split('a'))


#Data structures in python :


#1) tuple    2) List      3)Dictionary       4) Set 


#1.TUPLE: tuple is an orders collection of elements of elements inclosed within() . We can store here any value but they are immmutable does not cange later


#tup1=(1,'a',True)

#print(tup1)                       # o/p (1, 'a', True)

#print(type(tup1))                 # o/p <class 'tuple'>


# EXTRACTING INDIVIDUAL ELEMENTS FROM THE TUPLE.

#  tup1=(1,2,'True','False',3.14,6.18,2+3j)               #BY using this we can extracrt the values inside the tuple

#print(tup1[0])                               #o/p :  1

#print(tup1[1])                                # o/p:  2

# print(tup1[2])                                 #0/p:  True

# print(tup1[3])                                 #0/p:  False

# print(tup1[4])                                 #0/p:  3.14

# print(tup1[5])                                 #0/p:  6.18

# print(tup1[-1])                                 #0/p:  2+3j

# print(tup1[-2])                                 #0/p:  6.18

# print(tup1[1:5])                              #o/p : (2, 'True', 'False', 3.14)

# print(tup1[-4])                                #o/p  : FALSE



#We never modufy the yuple bacase it is made fixed when we di=ine it .


# TYPLE BASICS OPERATIONS


#1) Finding the length of the tuple :means element contain inthe tuple

# tup2=(1,2,3,4,5)


# print(len(tup2))                           # o/p : 5


#2) Concatenating of tuples: Adding of the tuple

# tup2=(1,2,3,4,5)

# tup3=(6,7,8,9,10)

# print(tup2+tup3)                              # o/p : (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)


#3) Repeating Tuple Elemnts :

# t1=(9, 10)

# print(t1*3)                                #o/p : (9, 10, 9, 10, 9, 10)


#4) Repeating and cancatanating

# t1=(1,2,3,4,5)

# t2=(True , False)

# print(t1+t2*4)                               # o/p : (1, 2, 3, 4, 5, True, False, True, False, True, False, True, False)


#TUPLE FUNCTIONS ::::::


#Minimum value 

# t1=(1,2,3,4,5)

# print(min(t1))                              #o/p :1


#Maximum value

#  t2=(2,4,56,74,212)

#  max


#LIST IN PYTHONS:List is a ordered collection of element inclose within a [] , List is a mutable means we can modify it in our own need . we can add element in it..

# l1=[12,22,3.14,"mauli","creation",3+4j,True,False]

# print(l1)                                            #o/p :: [12, 22, 3.14, 'mauli', 'creation', (3+4j), True, False]

# print(type(l1))                                      #o/p:: <class 'list'>


#Extracting individual elements in List::;

#  l1=[12,22,3.14,"mauli","creation",3+4j,True,False]

# print(l1[1])                                                #o/p ::: 22

# print(l1[0])                                                #o/p ::: 12

# print(l1[-1])                                                #o/p ::: False

# print(l1[2])                                                #o/p ::: 3.14

# print(l1[-2])                                                #o/p ::: True

# print(l1[2:5])                                            # o/p ::  [3.14, 'mauli', 'creation']



#Modifying LIST::

#1.Changing elements of 0 th index..

# l1=[12,22,3.14,"mauli","creation",3+4j,True,False]

# print(l1)                                                   # o/p :: [12,22,3.14,"mauli","creation",3+4j,True,False]

# l1[0]=32

# print(l1)                                                   # o/p :: [32, 22, 3.14, 'mauli', 'creation', (3+4j), True, False]


#Adding a new element (Appending a new element )

# l1=[12,22,3.14,"mauli","creation",3+4j,True,False]

# l1.append("DNYANESHWAR")

# print(l1)                                                    #o/p :: [12, 22, 3.14, 'mauli', 'creation', (3+4j), True, False, 'DNYANESHWAR']


#Popping the last element :: (Remobing the element from the list)

# l1=[12,22,3.14,"mauli","creation",3+4j,True,False]

# print(l1)                                                      #o/p : [12, 22, 3.14, 'mauli', 'creation', (3+4j), True, False]

# l1.pop()

# print(l1)                                                    #o/p :[12, 22, 3.14, 'mauli', 'creation', (3+4j), True]

# l1=[12, 22, 3.14, 'mauli', 'creation', (3+4j), True, False]

# print(l1)                                                      #o/p :: [12, 22, 3.14, 'mauli', 'creation', (3+4j), True, False]

# l1.pop(2)             # BY USING THIS TYPE WE CAN REMOVE ANY ELEMENTIN THE LIST BY ADDING IT'S INDEX NUMBER IN POP () IN IT.

# print(l1)                                                     # o/p :: [12, 22, 'mauli', 'creation', (3+4j), True, False]


#Reversing of the element in the list::

# l1=[12, 22, 3.14, 'mauli', 'creation', (3+4j), True, False]

# print(l1)                                                      #o/p ::[12, 22, 3.14, 'mauli', 'creation', (3+4j), True, False]

# l1.reverse()    

# print(l1)                                                     #o/p: : [False, True, (3+4j), 'creation', 'mauli', 3.14, 22, 12]


#inserting element in a list in specific index.

# l1=[12, 22, 3.14, 'mauli', 'creation', (3+4j), True, False]

# print(l1)                                                    #o/p :: [12, 22, 3.14, 'mauli', 'creation', (3+4j), True, False]

# l1.insert(1,"dnyaneshwar sharad chakotkar")          # in round bracket 1 is for the index number where we want to add the new data .

# print(l1)                             #o/p :: [12, 'dnyaneshwar sharad chakotkar', 22, 3.14, 'mauli', 'creation', (3+4j), True, False]


#Sorting of the list:::::

# l1=[12, 22,15,12,45,25,4587,264]

# l1. sort ()                     #Sorting tool is used when type of element in it is same , type that time we use ths sorting operaton . on it.

# print(l1)                              # o/p :: [12, 12, 15, 22, 25, 45, 264, 4587]

































 

No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts