File

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 14

MAIN.

py
import pyttsx3
import simple_colors
import speech_recognition as rec
import datetime
import webbrowser
import smtplib
from email.message import EmailMessage
import wikipedia
import os
import matplotlib.pyplot as plot
import cartopy.crs as cart
import random
import wolframalpha
import requests
from PIL import Image
import pyautogui as pg
from os import startfile
from pyautogui import click
from keyboard import press
from keyboard import press_and_release
from keyboard import write
from time import sleep
from geopy.distance import great_circle
from pyautogui import hotkey
from playsound import playsound
bot= pyttsx3.init('sapi5')
voices= bot.getProperty('voices')
bot.setProperty('voices',voices[1].id)
bot.setProperty('rate',170)
def speak(audio):
print(" ")
print('zero : ', simple_colors.green(f'{audio}', 'bold'))
print(" ")
bot.say(audio)
bot.runAndWait()

def takecommand():
r = rec.Recognizer()
with rec.Microphone() as source:
speak("Listening ....")
r.pause_threshold = 1
audio = r.listen(source)

try:
print("Recognizing ....")

query = r.recognize_google(audio, language='en-in')


print(f":your Command : ",simple_colors.blue(f'{query}', 'bold'))

except Exception as e:
speak("say that again please !!")
return "None"
return query
def wish_me():
hour=int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak("Good Morning Sir!")
elif hour>=12 and hour<=18:
speak("Good Afternoon Sir!")
else:
speak("Good Evening Sir!")
speak('my name is Zero . How can i Help you ?')
def Alarm(query):
Time = open("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\data.txt",'a')
Time.write(query)
Time.close()
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\FEATURES\\ALARM.PY")
def downyoutube():
from pytube import YouTube
from pyautogui import click
from pyautogui import hotkey
import pyperclip

from time import sleep

sleep(2)

click(x=205,y=62)

hotkey('ctrl','c')

value= pyperclip.paste()

link = str(value)

def download(link):

url = YouTube(link)
vedio = url.streams.get_highest_resolution()
speak("sir the download has been started")
vedio.download('C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\Youtube')
download(link)
speak("sir i have downloaded the vedio")
speak("you can check it out")
os.startfile('C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\Youtube')
def Speedtest():
from time import sleep
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\gui program\\
SpeedTestGui.py")
sleep(60)
def teach(query):
api_key = "7RAJ2A-8YUGV5Q2WG"
request = wolframalpha.Client(api_key)
requested = request.query(query)

try:
answer = next(requested.results).text
return answer
except:
speak(" According to my database this Question is not Answerable")
def My_location():
open = 'https://www.google.co.in/maps/@28.4729472,77.0363116,613a,35y,39.13t/
data=!3m1!1e3?entry=ttu'
speak("checking....")
webbrowser.open(open)

ip_add = requests.get('https://api.ipify.org').text
url = 'https://get.geojs.io/v1/ip/geo/' + ip_add + '.json'
geo_q = requests.get(url)
geo_d = geo_q.json()
state = geo_d['city']
country = geo_d['country']
speak(f"sir you are now in {state, country}")

def calculator(query):
term =str(query)
term = term.replace("multiply","*")
term = term.replace("plus","+")
term = term.replace("multiply","*")
term = term.replace("devide by","/")
term = term.replace("minus","-")
term = term.replace("into","*")

final = str(term)
result=teach(final)
speak(f"Output is :{result}")
def temp(query):
term = str(query)

term=term.replace("zero","")
term=term.replace("in","")
term=term.replace("what is","")
term=term.replace("temperature","")

temp_query = str(term)

if 'outside' in temp_query:
var1 = "Temperature in Haryana"
answer = teach(var1)
speak(f"{var1} is {answer}")

else:
var2 = "Temperature in"+temp_query
answer = teach(var2)
speak(f"{var2} is {answer}")
def close():
click(1341,11)
def whatsapp(name,message):
click(x=503, y=744)
sleep(2)
key='whatsapp'
write(key)
sleep(2)
click(x=568, y=175)
sleep(2)
write(name)
sleep(2)
click(x=233, y=169)
sleep(2)
write(message)
press('enter')
close()

speak(f" Sir i have sent the message to {name}")


def vediocall(name):
click(x=547, y=743)
sleep(2)
key='whatsapp'
write(key)
sleep(2)
click(x=568, y=175)
sleep(2)
write(name)
sleep(2)
click(x=233, y=169)
sleep(2)
click(x=1218, y=64)
def call(name):
click(x=547, y=743)
sleep(2)
key='whatsapp'
write(key)
sleep(2)
click(x=568, y=175)
sleep(2)
write(name)
sleep(2)
click(x=233, y=169)
sleep(2)
click(x=1270, y=71)
def chat(name):
click(x=547, y=743)
sleep(2)
key='whatsapp'
write(key)
sleep(2)
click(x=568, y=175)
sleep(2)
write(name)
sleep(2)
click(x=233, y=169)

def youtube(command):
query=str(command)
if 'pause' in query:
press_and_release('k')
elif 'mute' in query:
press_and_release('m')
elif 'unmute' in query:
press_and_release('m')
elif 'seek back' in query:
press_and_release('j')
elif 'seek front' in query:
press_and_release('l')
elif 'full screen' in query:
press_and_release('f')
elif 'film' in query:
press_and_release('t')
elif 'skip' in query:
press_and_release('l')
elif 'increase' in query:
press_and_release('shift + >')
elif 'decrease' in query:
press_and_release('shift + <')
elif 'previous' in query:
press_and_release('shift + p')
elif 'next' in query:
press_and_release('shift + n')
elif 'search' in query:
click(x=550, y=98)
search=query.replace("youtube","")
search1=search.replace("search","")
write(search1)
sleep(1)
press('enter')
def date_converter(query):
date = query.replace(" and ","-")
date = query.replace(" and","-")
date = query.replace("and ","-")
date = query.replace("and","-")
date = query.replace(" ","")
return str(date)
def NasaNews(date):
api_key="XNN3qHB7sIu5egaoKKBcUhJ4aM4yGodEHLBYfHnh"
url = "http://api.nasa.gov/planetary/apod?api_key=" + str(api_key)
Para = {'date':str(date)}
r=requests.get(url,params = Para)
data = r.json()
info = data['explanation']
title =data['title']

Img_url=data['url']
image_r = requests.get(Img_url)
FileName = str(date)+'.jpg'
with open(FileName,'wb') as f:
f.write(image_r.content)
path1="C:\\Users\\abc\\Desktop\\MY AI PROJECT\\"+str(FileName)
path2="C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
img_space\\"+str(FileName)
os.rename(path1,path2)
img=Image.open(path2)
img.show()
speak(title)
speak(f"According to nasa:{info}")

def Summary(body):
value=str(random.randrange(1,16))
if '1' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\1.jpeg")
elif '2' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\2.jpeg")
elif '3' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\3.jpeg")
elif '4' in value:
os.startfile("C:C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\4.jpeg")
elif '5' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\5.jpeg")
elif '6' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\6.jpeg")
elif '7' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\7.jpeg")
elif '8' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\.jpeg")
elif '9' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\9.jpeg")
elif '10' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\10.jpeg")
elif '11' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\11.jpeg")
elif '12' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\12.jpeg")
elif '13' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\13.jpeg")
elif '14' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\14.jpg")
elif '15' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\15.jpg")

name = str(body)
url = "https://hubblesite.org/api/glossary/"+str(name)
url1=url.replace(" ","")
r=requests.get(url1)
data=r.json()
if len(data) != 0:
info = data['defination']
speak(f'according to my database : \n{info}')
else:
speak("No data available , Try Again later")
def isstracker():
url = "http://api.open-notify.org/iss-now.json"
r=requests.get(url)
data=r.json()
dt=data['timestamp']
lat = data['iss_position']['latitude']
long = data['iss_position']['longitude']
print(f"time and date:{dt}")
print(f"latitude:{lat}")
print(f"longitude:{long}")
plot.figure()
ax=plot.axes(projection = cart.PlateCarree())
ax.stock_img()
plot.scatter(float(long),float(lat),color = 'blue',marker = ".")
plot.show()

def email_alert(subject,body,to):
msg=EmailMessage()
msg.set_content(body)
msg['subject']=subject
msg['to']=to
user="[email protected]"
msg['from']=user
password="wvekznfuyqhihyot"

server=smtplib.SMTP("smtp.gmail.com",587)
server.starttls()
server.login(user,password)
server.send_message(msg)
server.quit()
speak("sir i have send the mail to",user)

if __name__ =='__main__':

wish_me()
takecommand()

while True:
query = takecommand().lower()

if 'zero' in query:
try:
speak('Exploring the data....')
query = query.replace("zero","")

results = wikipedia.summary(query,sentences=2)
speak("On Analysing my data i found that ")
speak(results)
except:
speak("i did not get any suitable result")

elif 'hello' in query:


speak('glad to meet you sir how can i help you today')
elif 'open youtube' in query:
webbrowser.open("https://www.youtube.com/")
elif 'open instagram' in query:
webbrowser.open("https://www.instagram.com/")
elif 'open google' in query:
webbrowser.open("https://www.google.com/")
elif 'open stack overflow' in query:
webbrowser.open("https://stackoverflow.com/")
elif 'watch anime' in query:
webbrowser.open("https://aniwatch.to/home")
elif 'sessional marks' in query:

webbrowser.open("https://dronacharya.info/ggnresults/GetResult.aspx")
elif 'news' in query:
webbrowser.open("https://timesofindia.indiatimes.com/?from=mdr")
elif 'search' in query:
name=query.replace("search","")
Name = str(name)
string="https://www."+Name+".com"
string2=string.replace(" ","")
webbrowser.open(string2)

elif 'shop' in query:


webbrowser.open("amazon.com")
elif 'play music' in query:
music_dir = "C:\\Users\\abc\\Desktop\\music\\"
songs = os.listdir(music_dir)
x=len(songs)
n=random.randrange(0,x)
print(songs)
os.startfile(os.path.join(music_dir,songs[n]))
elif 'the time' in query:
curr_time = datetime.datetime.now().strftime("%H:%M")
speak(f"The time is {curr_time}")

elif 'colse' in query:


os.close()
elif "open code" in query:
codepath = "C:\\Users\\abc\\AppData\\Local\\Programs\\Microsoft VS
Code\\Code.exe"
os.startfile(codepath)

elif 'email' in query:


ankit="[email protected]"
try:
speak("to whome should i send the mail sir")
q1=takecommand()
if 'ankit' in q1:
to=ankit
else:
q2=q1.replace(" ","")
to=q2.lower()
speak("what's the subject for mail sir")
subject=takecommand()
speak("what should i write in the mail sir")
body=takecommand()
email_alert(subject,body,to)
speak("Sending the mail")
except:
takecommand()

elif 'set alarm' in query:


Alarm(query)
speak("sir i have set the alarm")

elif 'download' in query:


downyoutube()
elif 'speed test' in query:
Speedtest()
elif 'calculate' in query:
query = query.replace("calculate","")
calculator(query)
elif 'temperature' in query:
temp(query)

elif 'send message' in query:


try:
name=query.replace("send message to", "")
name=name.replace("send ","")
name=name.replace("to", "")
Name=str(name)
speak(f"whats the message for {Name}")
msg=takecommand()
whatsapp(Name,msg)
except:
speak ("incomplete data provided")

elif 'call' in query:


name=query.replace("call", "")
name=name.replace("call ","")

Name=str(name)
call(Name)

elif 'connect video' in query:


name=query.replace("connect video to", "")
name=name.replace("connect video to", "")
Name=str(name)
vediocall(Name)

elif 'show chat' in query:


speak("with whom should i connect ?")
name = takecommand()
chat(name)

elif 'browser' in query:


path="C://Program Files
(x86)//Microsoft//Edge//Application//msedge.exe"
os.startfile(path)
#browser(query)

elif 'youtube' in query:


youtube(query)

elif 'space info' in query:


try:
speak("sir can you tell me the year to look into")
year=takecommand()
speak(" sir which year i should go for")
if year==None:
year=takecommand()
speak(" sir please tell a valid year in terms of
number")
month=takecommand()
speak(" sir can you tell me date")
if month==None:
month=takecommand()
speak(" sir please tell a valid month in terms of
number")
day=takecommand()
speak(" sir please tell a valid date in terms of number")
if day==None:
year=takecommand()
speak(" sir please tell a valid date in terms of
number")
date=f"{year}-{month}-{day}"
NasaNews(date)
except:
speak("Sir i was not able drive data for the given Date")
elif 'observation center' in query:
isstracker()
elif 'my location' in query:
My_location()

elif 'new tab' in query:


press_and_release('ctrl + t')
elif'close tab' in query:
press_and_release('ctrl + w')
elif 'new window' in query:
press_and_release('ctrl + n')

elif 'show history' in query:


press_and_release('ctrl + h')
elif 'download' in query:
press_and_release('ctrl + j')
elif 'bookmark' in query:
press_and_release('ctrl + d')
press('enter')
elif 'Incognito mode' in query:
press_and_release('Ctrl + Shift + n')
elif 'Reopen closed tab' in query:
press_and_release('Ctrl + Shift + t')
elif 'next tab' in query:
press_and_release('Ctrl + Tab')
elif 'first tab' in query:
press_and_release('Ctrl + 1')
elif 'seacond tab' in query:
press_and_release('Ctrl + 2')
elif 'third tab' in query:
press_and_release('Ctrl + 3')
elif 'fourth tab' in query:
press_and_release('Ctrl + 4')
elif 'fifth tab' in query:
press_and_release('Ctrl + 5')
elif 'sixth tab' in query:
press_and_release('Ctrl + 6')
elif 'seventh tab' in query:
press_and_release('Ctrl + 7')
elif 'eighth tab' in query:
press_and_release('Ctrl + 8')
elif 'right most tab' in query:
press_and_release('Ctrl + 9')
elif 'home page' in query:
press_and_release('Alt + Home')
elif 'back' in query:
press_and_release('Alt + Left arrow')
elif 'forward' in query:
press_and_release('Alt + Right arrow')
elif 'close current tab' in query:
press_and_release('Ctrl + w')
elif 'close window' in query:
press_and_release('Ctrl + Shift + w')
elif 'minimize' in query:
press_and_release('Alt + Space + n')
elif 'maximize' in query:
press_and_release('Alt + Space + x')
elif 'quit' in query:
press_and_release('Alt + f + x')
elif 'move right' in query:
press_and_release('Ctrl + Shift + PgDn')
elif 'move left' in query:
press_and_release('Ctrl + Shift + PgUp')
elif 'menu' in query:
press_and_release('Alt + f')
elif 'show bookmarks' in query:
press_and_release('Ctrl + Shift + b')
elif 'hide bookmarks' in query:
press_and_release('Ctrl + Shift + b')
elif 'bookmark manager' in query:
press_and_release('Ctrl + Shift + o')
elif 'task manager' in query:
press_and_release('Shift + Esc')
elif 'set focus on the first item' in query:
press_and_release('Shift + Alt + t')
elif 'set focus on the rightmost item' in query:
press_and_release('F10')
elif 'switch focus to unfocused dialog' in query:
press_and_release('F6')
elif 'find':
press_and_release('F3')
elif 'next match' in query:
press_and_release('Ctrl + g')
elif 'previous match' in query:
press_and_release('Ctrl + Shift + g')
elif 'developer tools' in query:
press_and_release('Ctrl + Shift + j')
elif 'clear browsing data' in query:
press_and_release('Ctrl + Shift + Delete')
elif 'help center' in query:
press_and_release('F1')
elif 'change user' in query:
press_and_release('Ctrl + Shift + m')
elif 'feedback form' in query:
press_and_release('Alt + Shift + i')
elif 'caret browsing' in query:
press_and_release('F7')
elif 'skip contents' in query:
press_and_release('Ctrl + F6')
elif 'inactive dialogs' in query:
press('Alt + Shift + a')
elif 'search' in query:
Name=query.replace('search','')
Name=query.replace(' ','')
string="https://www."+Name+".com"
string2=string.replace(" ","")
webbrowser.open(string2)

elif 'camera' in query:


os.startfile("C:\\Users\\abc\Desktop\\MY AI PROJECT\\whatsapp.py")
elif 'hack wi-fi' in query:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\bruteX-
master\\bruteWifi.py")

NASA.py
import requests
import os
from PIL import Image
import pyttsx3
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import datetime
import random
api_key="XNN3qHB7sIu5egaoKKBcUhJ4aM4yGodEHLBYfHnh"

def Summary(body):
value=str(random.randrange(1,16))
if '1' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\1.jpeg")
elif '2' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\2.jpeg")
elif '3' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\3.jpeg")
elif '4' in value:
os.startfile("C:C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\4.jpeg")
elif '5' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\5.jpeg")
elif '6' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\6.jpeg")
elif '7' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\7.jpeg")
elif '8' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\.jpeg")
elif '9' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\9.jpeg")
elif '10' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\10.jpeg")
elif '11' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\11.jpeg")
elif '12' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\12.jpeg")
elif '13' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\13.jpeg")
elif '14' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\14.jpg")
elif '15' in value:
os.startfile("C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
images_used\\15.jpg")

name = str(body)
url = "http://hubblesite.org/api/v3/features/"+str(name)

r=requests.get(url)
data=r.json()
if len(data) != 0:
info = data['defination']
speak(f'according to my database : {info}')
else:
speak("No data available , Try Again later")

engine= pyttsx3.init('sapi5')
voices= engine.getProperty('voices')
engine.setProperty('voices',voices[1].id)
engine.setProperty('rate',170)
def speak(audio):
print(" ")
print(f": {audio}")
print(" ")
engine.say(audio)
engine.runAndWait()
def NasaNews(date):

url = "http://api.nasa.gov/planetary/apod?api_key=" + str(api_key)


Para = {'date':str(date)}
r=requests.get(url,params = Para)
data = r.json()
info = data['explanation']
title =data['title']

Img_url=data['url']
image_r = requests.get(Img_url)
FileName = str(date)+'.jpg'
with open(FileName,'wb') as f:
f.write(image_r.content)
path1="C:\\Users\\abc\\Desktop\\MY AI PROJECT\\"+str(FileName)
path2="C:\\Users\\abc\\Desktop\\MY AI PROJECT\\DATABASE\\NASA\\
img_space\\"+str(FileName)
os.rename(path1,path2)
img=Image.open(path2)
img.show()
speak(title)
speak(f"According to nasa:{info}")

def mars():
name='curiosity'
date = '2020-12-3'

api="2WbrclsQaBuGd75awgpZhonwK5cKSKRjQkxZasJQ"
api_ = str(api)
url =f"https://api.nasa.gov/mars-photos/api/v1/rovers/{name}/photos?
earth_date{date}&api_key{api}"
print(url)
def isstracker():
url = "http://api.open-notify.org/iss-now.json"
r=requests.get(url)
data=r.json()
dt=data['timestamp']
lat = data['iss_position']['latitude']
long = data['iss_position']['longitude']
print(f"time and date:{dt}")
print(f"latitude:{lat}")
print(f"longitude:{long}")
plt.figure()
ax=plt.axes(projection = ccrs.PlateCarree())
ax.stock_img()
plt.scatter(float(long),float(lat),color = 'blue',marker = ".")
plt.show()
def Astro(start_date,end_date):
url =f"http://api.nasa.gov/neo/rest/v1/feed?
start_date={start_date}&end_date={end_date}&api_key={api_key}"
try:
r=requests.get(url)
Data=r.json()
tb=Data['element_count']

print(tb)
neo =Data['near_earth_objects']
speak(f"Total asteroid betweer {start_date} and {end_date} is :{tb}")
for body in neo[start_date]:
id = body['id']
name = body['name']
absolute =body['absolute_magnitude_h']
print(id,name,absolute)
except:
speak("Date gap is very large")
def astrobody(body):
url=f"https://api.le-systeme-solaire.net/rest/bodies/"+str(body)
rrr = requests.get(url)
data=rrr.json()
number=len(data)
mass=data['mass']['massValue']
volume = data['vol']['volValue']
density = data['density']
gravity = data['gravity']
escapev = data['escape']
speak(f"number of bodies : {number} ")
speak(f"Mass of {body} : {mass} M?")
speak(f"volume of {body} : {volume}AU ")
speak(f"density of {body} : {density}km3 ")
speak(f"gravity of {body} : {gravity} ")
speak(f"Escape Velocity of {body} : {escapev}m/s ")
astrobody("earth")\\ put name of desired body to be automated***

You might also like