Posts

Showing posts from April, 2021

Spam Detector

Image
  text = input ( "Enter the text \n " ) if ( "make of lot of money" in text): spam = True elif ( "buy now" in text): spam = True elif ( "click this" in text): spam = True elif ( "subscribe now" in text): spam = True spam= False if (spam): print ( "This text is spam" ) else : print ( "This text is not a spam" )

Dictionary Practice Question

  dict={} a= input ( "Enter your favoriat language Shubham: \n " ) b= input ( "Enter your favoriat language kartik: \n " ) c= input ( "Enter your favoriat language raghav: \n " ) dict[ 'Shubham' ] = a dict[ 'Kartik' ] = b dict[ 'raghav' ] = c print (dict)

Dictionary in Python

Image
  mydict= { "kartik" : " hero" , 'EkOr' : { 'kartik' : 'Codeeer' } , "laptop" : "An electronic device" , "dog" : "An animal" } print (mydict) Updatedict= { "Mobile " : "A smart phone device" , "dog" : "A Human" } mydict.update(Updatedict) # .update will update dictonary print (mydict) print (mydict[ "dog" ])

Install a external module and play sound

Image
  from playsound import playsound playsound( 'D: \\ manish tiwari mp3 \\ 07.mp3' )

List Slicing Python

  l1 = [ 1 , 8 , 7 , 2 , 21 , 15 ] print (l1) # l1.sort() # sorts the list # l1.reverse() # reverses the list #l1.append(45) # adds 45 at the end of the list # l1.insert(2, 544) # inserts 544 at index 2 # l1.pop(2) # removes element at index 2 l1.remove( 21 ) # removes 21 from the list print (l1)