Posts

Showing posts from 2020

Print string with any combination

  from   itertools   import   permutations   str = "abcdefghijklmnopqrstuvwxyz" y = int ( input ( "Enter range of letters of alphabet =" )) your_str = str [ 0 : y ] print ( "You entered  =" ,  your_str )  m = int ( input ( "How many string do you want? =" )) r = int ( input ( "Enter range of letters Combination =" )) permutation  = [ '' . join ( x )  for   x   in   permutations ( your_str , r )]  x = tuple ( permutation ) print ( ', ' . join ( x [ 0 : m ]))

Jarvis voice

  import  pyttsx3 engine  =  pyttsx3 .init() voices = engine .getProperty( 'voices' ) engine .setProperty( 'voice' ,  voices [ 1 ].id) engine .setProperty( 'rate' ,  125 ) engine .setProperty( 'volume' , 0.2 ) engine .say( "Hello, How are you?" ) engine .save_to_file( 'Hello World' ,  'test.mp3' )  engine .runAndWait()

Notepad using Python

  from  tkinter  import * import  tkinter.messagebox  as  tmsg from  tkinter.filedialog  import  askopenfilename, asksaveasfilename import  os def   newFile ():      global   file     root.title( "Untitled-Notepad" )      file = None     TextArea.delete( 1.0 , END) def   openFile ():      global   file      file =askopenfilename( defaultextension = ".txt" ,  filetypes =[( "All Files" ,  "*.*" ), ( "Text Documents" ,  "*.txt" )])      if   file == "" :          file = None      else :         root.title(os.path.basename( file )+  "- Notepad by Elalita" )         TextArea.delete( 1.0 , END)         f= open ( file ,  "r" )         TextArea.insert( 1.0 , f.read())         f.close  def   saveFile ():      global   file      if   file == None :          file =asksaveasfilename( defaultextension = ".txt" ,  filetypes =[( "All Files" ,  "*.*" ), ( "Text Documents" ,

Basic Calc using Python Tkinter

  from  tkinter  import * root=Tk() root.geometry( "300x520" ) root.title( "Calculator by Elalita" ) scvalue=StringVar() scvalue.set( " " ) screen=Entry(root,  textvar =scvalue, font = "lucida 40 bold" ) screen.pack( fill  =X, ipadx = 8 ,  padx = 10 ,  pady = 10 ) def   click ( event ):      global  scvalue     text=event.widget.cget( "text" )      print (text)      if  text== "=" :          if   scvalue.get().isdigit():             vlaue= int (scvalue.get())          else :              try :                 value= eval (screen.get())              except   Exception   as  Error:                 value= "Error!"                      scvalue.set(value)         screen.update()      elif  text== "C" :         scvalue.set( "" )         screen.update()      else :         scvalue.set(scvalue.get()+text)         screen.update() f1=Frame(root, bg = "grey" ) b=Button(f1, text = "9" , pa

Python Slider

  from  tkinter  import * import  tkinter.messagebox  as  tmsg root=Tk() root.title( "My Slider" ) root.geometry( "750x450" ) # myslider=Scale(root, from_=0, to=450) # myslider.pack() def   getdollor ():      print  ( f "We have credit  { myslider2.get() }  $ in your account" )     tmsg.showinfo( "Amount Credited!" ,  f "We have credited  { myslider2.get() }  $ in your account." )      f= open ( "file3.txt" ,  "w" )     a=f.write( f " { myslider2.get() }  $ credited in your account. \n " )      with   open ( "file3.txt" ,  "a" )  as  f:         f.write( f "Thanks for giving rate us >>>   { name_value.get() } " )      Label(root, text = "How many dolor do you want" ).pack() myslider2=Scale(root,  from_ = 0 ,  to = 450 ,  orient =HORIZONTAL) myslider2.set( 0 ) myslider2.pack() Label(root, text = "Please give us rate from 1 to 10" ).pack() name_value=S

Notepad software with Python

  from  tkinter  import * import  tkinter.messagebox  as  tmsg root=Tk() root.geometry( "700x500" ) root.title( "My Notepad" ) def   myfunc ():      print ( "I am visual studio code" ) def   help ():     tmsg.showinfo( "Help" ,  "www.elalita.com" ) def   rate ():      # print("Rate Us")     value=tmsg.askquestion( "Was your experiance good" )      print (value)      if  value== "yes" :         msg= "Great Please rate us on www.elalita.com"      else :         msg= "thansk for suggation, we resolve the problem"     tmsg.showinfo( "Experiance" , msg)      yourmenubar=Menu(root) m1=Menu(yourmenubar) m1.add_command( label = "New Project" ,  command =myfunc) m1.add_command( label = "Save" ,  command =myfunc) m1.add_command( label = "Save As" ,  command =myfunc) m1.add_separator() m1.add_command( label = "Print" ,  command =myfunc) m1.add_comma

File handling in JAVA

package com.lalita_ent ; import java.io.File ; public class Main { public static void main (String[ ] args) { File x = new File( "C: \\ test.txt" ) ; if (x.exists()) { System. out .println(x.getName() + " Its exists!" ) ; } else { System. out .println( "The file does not exist" ) ; } } }

Java(Take input from user)

package com.lalita_ent ; import java.util.Scanner ; public class Main{ public static void main (String args[]) { Scanner scan= new Scanner(System. in ) ; System. out .println( "Enter the value of x >>>" ) ; int x= scan.nextInt() ; if (x>= 18 ) { System. out .println( "Congratulations!! You are eligible for voting." ) ; } else { System. out .println( "Sorry!! You are not eligible for voting." ) ; } } }

Java First Program

package com.lalita_ent ; public class Main { public static void main (String args[]) { System. out .println( "Hello Lalita" ) ; String name= "Manan" ; System. out .println(name) ; int a= 4 ; float c , b= 22.32f ; c=a+b ; boolean stat1= false; System. out .println(b) ; System. out .println(c) ; System. out .println(stat1) ; } }

Python class method

class   Employee ():     no_of_leave= 8        def   __init__ ( self ,  aname ,  arole ,  asalary ):          self .name=aname          self .role=arole          self .salary=asalary      def   printdetails ( self ):          return   f "Name is  {self .name } , his role is  {self .role }  and salary is  {self .salary }  "      @ classmethod      def   change_leaves ( cls ,  new_leaves ):          cls .no_of_leave=new_leaves          manu=Employee( "Manan" ,  "Manager" ,  50000 ) chanu=Employee( "Manan" ,  "Engineer" ,  70000 )    # manu.name="Manan" # manu.role="Manager"    # manu.salary=50000 # chanu.name="Ketan" # chanu.role="Engineer"    # chanu.salary=70000 print (manu.salary,manu.no_of_leave, manu.name) print (manu. __dict__ ) print (chanu. __dict__ ) print (manu.salary) manu.change_leaves( 34 ) print (manu.no_of_leave)

python>>self and __init__

class   Employee ():     no_of_leave= 8        def   __init__ ( self ,  aname ,  arole ,  asalary ):          self .name=aname          self .role=arole          self .salary=asalary      def   printdetails ( self ):          return   f "Name is  {self .name } , his role is  {self .role }  and salary is  {self .salary }  " manu=Employee( "Manan" ,  "Manager" ,  50000 ) chanu=Employee( "Manan" ,  "Engineer" ,  70000 ) # manu.name="Manan" # manu.role="Manager"    # manu.salary=50000 chanu.name= "Ketan" chanu.role= "Engineer"     chanu.salary= 70000 print (manu.salary,manu.no_of_leave, manu.name) print (manu. __dict__ ) print (chanu. __dict__ ) print (manu.)

Learning Python language

# This commnent # import cv2 # import math # # print("Hello World") # # print(7+7) # # print(math.gcd(3,6)) # a=34 # # b="Devendra" # # c=45.32 # d=2 # # print(a+c) # # print(c/d) # # typeA=type(a) # # typeB=type(b) # # typeC=type(c) # # print(typeC) # # print(a+c) # # e="31" # # e=int(e) # # print(e+2) # # e=type(e) # # print(e) # name="  Devendra, Manan, Ketan  " # # print(name) # # print(name[2:6]) # # print(name.strip()) # # print(len(name)) # # var=name.lower() # # var=name.upper() # # print(var) # # var=name.replace("e", "a") # # var=name.replace(",","\n") # # # print(var) # # stri1="This is a" # # stri2="This not ok" # # print(stri1+stri2) # # print(stri1+name) # # name1="Manan" # # name2="Ketan" # # temp="This is a {1} and he is good boy named {0}.". format(name1, name2) # # temp=f"This is a {name2} and he is good boy named {name1}" # # pri