Sunday, August 30, 2020

Eaglesoft Assistant Source code

import pyttsx3
import datetime
import speech_recognition as sr
import wikipedia
import webbrowser
import os
import smtplib

engine=pyttsx3.init('sapi5')
voices=engine.getProperty('voices')
# print(voices[0].id)
engine.setProperty('voice',voices[0].id)

def spkeak(audio):
engine.say(audio)
engine.runAndWait()
def wishme():
hour=int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
spkeak("Good Morning")

elif hour>=12 and hour<18:
spkeak("Good Afternoon")
else:
spkeak("Good Evening")

spkeak("I am Eaglesoft Assistant sir. Please tell me how may help you")

def takeCommand():
#it takes input from microphone and return string
r=sr.Recognizer()
with sr.Microphone() as source :
print("Listening...")
r.pause_threshold=1
audio=r.listen(source)
try:
print("Recognizing...")
qurey=r.recognize_google(audio,language='en-in')
print(f"User said: {qurey}\n")

except Exception as e:
# print(e)
print("Say that again please...")
return "None"
return qurey
def sendemail(to,content):
server=smtplib.SMTP("smtp@gmail.com",587)
server.ehlo()
server.starttls()
server.login("youreemail@gmail.com","you're-password")
server.sendmail("you'reemail@gmail.com",to,content)
server.close()




if __name__ == '__main__':
wishme()
while True:
query=takeCommand().lower()
#Logic for executing base on query
if "wikipedia" in query:
spkeak("Searching Wikipedia...")
query=query.replace("wikipedia","")
results=wikipedia.summary(query,sentences=2)
spkeak("According to Wikipedai")
print(results)
spkeak(results)
elif "open youtube" in query:
webbrowser.open("youtube.com")
elif "open google" in query:
webbrowser.open("google.com")
#elif "open Developer of this program" in query:
# webbrowser.open("https://eaglesoftpk.blogspot.com/")
elif "open facebook" in query:
webbrowser.open("facebook.com")
elif "open stackoverflow" in query:
webbrowser.open("stackoverflow.com")
elif "Play music" in query:
music_dir='G:\\Media\\audio tool'
songs=os.listdir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir,songs[0]))
elif "The time" in query:
strTime=datetime.datetime.now().strftime("%H:%M:%S")
spkeak(f"Sir, the time is {strTime}")
print(strTime)
elif "open code" in query:
codePath="C:\\Users\\Eaglesoft\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
os.startfile(codePath)
elif "open Chrome" in query:
Gpath="C:\\Users\\Eaglesoft\\AppData\\Local\\Google\Chrome\\Application\\chrome.exe"
os.startfile(Gpath)
elif "Email to Ansir" in query:
try:
spkeak("What should I say?")
content=takeCommand()
to="ansar.eaglesoft@gmail.com"
sendemail(to,content)
spkeak("Email has been sent!")
except Exception as e:
print(e)
spkeak("Sorry sir. I am not able to send email")
elif "quit" in query:
exit()



# spkeak("Eaglesoft is one of the best Software Company in Pakistan")

Arithmetic operator in java full source code | java with Eaglesoft

public class Arthematic_operator 

{

    public static void main(String[] args)

     {

       double x,y,res=0;

       //You can also use int type instead of double

       x=23;

       y=12;

       res=x/y; 

       //+,-,*,& change operators what you want to use

       System.out.println("Result is: "+ res);    

    }   

}

Basic input output in java | java source file

package Newin;

import java.util.Scanner;


public class Newin

 {

    public static void main(String[] args)

     {

         //integer input

        Scanner sc=new Scanner(System.in);

        System.out.println("Enter some number:");

        int n =sc.nextInt();

        System.out.println("The Entered value is:");

        System.out.println(n);

        //character input

        Scanner sc1=new Scanner(System.in);

        System.out.println("Enter some String");

        String ch=sc1.nextLine();

        System.out.println("Entered String is:");

        System.out.println(ch);

    }

}

//Written by Eaglesoft programmers

Saturday, August 29, 2020

Opp in python | opp in python full source code at Eaglesoft

#Source code

 class Employee:

    no_leaves=8
def __init__(self,namea,rolea,salarya):
self.name=namea
self.role=rolea
self.salary=salarya
def printdetails(self):
return f"Name: {self.name} Role: {self.role} Salary: {self.salary}"
@classmethod
def change_leaves(cls,new_leaves):
cls.no_leaves=new_leaves
@classmethod
def from_dash(cls,string):
params=string.split("-")
return cls(params[0],params[1],params[2])
@staticmethod
def printgood(string):
print("Eaglesoftpk is good and " + string)
return print("Eaglesoftpk.blogspot.com")

pass
ashfaq=Employee('Muhammad Ashfaq','Programmer',100000)
zoya=Employee('Zoya Ali','Graphic Designer',100000)
noman=Employee.from_dash("Noman Ahmad-SEO-40000")
print(ashfaq.printdetails())
print(zoya.printdetails())
print(noman.printdetails())
print(Employee.printgood("Best"))

Thursday, August 27, 2020

Decorators source code in python | What is decorators in python

 def dec1(func1):

    print("Muhammad Ashfaq is a good programmer")
func1()
print("This is Eaglesoft")
return 0
@dec1
def ashfaq():
print("Who is Ashfaq?")
#Another method that is
# alernative of @dec1
#val=dec1(ashfaq)
#print(val)

What is Map, Filter and Reduce in python full source code of project available on Eaglesoft.

#note: source code is commited first revmove comments command to run
#Developed by Eaglesoft programmers
#--------------MAP---------------------
"""
lis=["45","45","5","80","04"]
lis = list(map(int,lis))
lis[1]=lis[1]+5
print(lis[1])
def func(x):
return x*x


lis=["45","45","5","80","04"]
lis = list(map(int,lis))
lis=list(map(lambda x:x*x,lis))
print(lis)
def squre(a):
return a*a
def cube(a):
return a*a*a
func=[squre,cube]
for i in range(5):
val=list(map(lambda x:x(i),func))
print(val)
"""
# ---------------FILTER---------------------
"""
def is_greater_5(num):
return num>5
list_1=[1,2,3,4,5,6,7,8,9]
list_1=list(filter(is_greater_5,list_1))
print(list_1)
"""
#---------------FILTER---------------------
from functools import reduce
list1=[1,2,3,4,5]


#sove with more lines command
#num=0
#for i in list1:
# num=num+i

num=reduce(lambda x,y:x+y,list1)
print(num)

Thursday, August 20, 2020

Python game Snake , Gun and Water very easy to develop and play. Here is full source code of game.

 #Python game Snake , Gun and Water

#Developed by Eaglesoft programmer Muhammad Ashfaq

import random

lst=['s','g','w']

chance=10

no_of_chance=0

human_score=0

computer_score=0

_tie=0

invaild_input=0

print("********Game********")

_user=str(input("Enter you're name:"))

print(f"Dear {_user} Please input you're choice")

print("s for:Snake\ng for:Gun\nw for:Water")

while(no_of_chance<chance :="" _input="=" _random="=" _tie="_tie+1" again="" ame="" and="" choice="" computer="" computer_score="" elif="" else:="" f="" g="" human_score="" ie="" if="" input="" invaild_input="invaild_input+1" is:="" is="" no_of_chance="no_of_chance+1" nter="" nvaild="" or="" ou="" please="" print="" random="" re="" s="" score="" summary="" try="" w="" win="" you="">computer_score:

    print(f"Congratulation! {_user} You win")

elif computer_score&gt;human_score:

    print("Computer win")

else:

    print("Tie")

print(f"{_user} You're Total score is :{human_score}")

print(f"Computer total score is:{computer_score}")

print(f"Number of times Tie :{_tie}")

print(f"Number of Times invaild input:{invaild_input}")</chance>