Beispiel #1
0
def multi_replay():  # Replay code for multiplayer
    player = input('Play again? (Y)es or (n)o\n')
    if player == 'y':
        multiplayer()
    else:
        print('Goodbye')
    sys.end()
Beispiel #2
0
def consulta():
    sino = gtk.MessageDialog(
        type=gtk.MESSAGE_QUESTION,
        buttons=gtk.BUTTONS_YES_NO,
        message_format=
        "Esto instalara 'ReducirCalidad' a los scripts de Nautilus. Es posible que se le pida clave de root para instalar dependencias.¿Desea continuar?"
    )
    duda = sino.run()
    if duda == gtk.RESPONSE_NO:
        sino.destroy()
        sys.end()
    sino.destroy()
from enterprise_extensions import models, model_utils
from enterprise_extensions.frequentist import optimal_statistic as OS

sys.path.insert(0, '/Users/hazboun/software_development/pta_sim/')

import pta_sim
import pta_sim.parse_sim as parse_sim
from pta_sim.sim_gw import Simulation, model_simple
from pta_sim.bayes import chain_length_bool, save_core, get_freqs, filter_psr_path
args = parse_sim.arguments()

#Is chain longer than niter?
longer = chain_length_bool(args.outdir, args.niter)

if longer and os.path.exists(args.core_path):
    sys.end()
elif longer:
    save_core(args.corepath, args.outdir)
    sys.end()  #Hmmmm what to do here?
else:
    pass

#Get par and tim files.
parfiles = sorted(glob.glob(args.pardir + '*.par'))
timfiles = sorted(glob.glob(args.timdir + '*.tim'))

if args.psr_list is not None:
    parfiles = filter_psr_path(parfiles, args.psr_list, rhs='_')
    timfiles = filter_psr_path(timfiles, args.psr_list, rhs='_')

sim = Simulation(parfiles, timfiles, ephem=args.ephem, verbose=True)
Beispiel #4
0
    accel_zout_scaled = accel_zout / 16384.0

    yrot = get_y_rotation(accel_xout_scaled, accel_yout_scaled,
                          accel_zout_scaled)
    yrotSum = 0.0
    for i in range(5):
        yrotSum += yrot
    yrot = yrotSum / 5 + makeMeLevelY
    return


Itime = time.time()
rTime = 0.0
while rTime < 15:

    global rTime
    getGyro()
    getDC()

    print(DC, yrot)
    f.write("%r, %r\r\n" % (DC, yrot))
    if yrot < -1:
        forward()
    elif yrot > -1:
        reverse()
    #elif yrot == 0:
    #   stop()
    rTime = time.time() - Itime
f.close()
sys.end()
"""
from sys import exit as end
Sim_expressions = [
    "Yes", "Y", "y", "yes", "Sim", "sim", "S", "s", "YES", "SIM"
]
Nao_expressions = [
    "No", "no", "N", "n", "NO", "Não", "não", "NÃO", "Nao", "nao", "nao"
]
#Welcome
run_program = input(
    "\n\n\n\n\nBem Vindo às atividades laboratoriais de Física do secundário!\nEste programa destina-se a auxiliar-te nas atividades experimentais de 10º, 11º e 12º ano do secundário.\n\nEste programa contem informação importante relativa com as mesmas.\nNomeadamente considerações, aproximações, cálculos, esquemas e objetivos das mesmas.\n\nApenas tens de inserir a informação necessária sempre que vires um dos seguntes sinais: \"𠂭 \" ou \"=\" ou \"☢ \" ou \"⋙ \" ou \"⫸ \"\n\n\nVamos começar?\n𠂭 "
)
if run_program in Sim_expressions:
    print("\nÓtimo!\nVamos começar.\n")
elif run_program in Nao_expressions:
    end()
else:
    print("O que inseriu não é válido.")


#Ativiadades
def atividade10(x, y):
    x = atividade  #atividades laboratoriais (A.L.*.*)
    y = funcao  #o que fazer com a atividade (resumo/explicação, considerações, cálculos, objetivos)


def atividade11(x, y):
    x = atividade  #atividades laboratoriais (A.L.*.*)
    y = funcao  #o que fazer com a atividade (resumo/explicação, considerações, cálculos, objetivos)

Beispiel #6
0
	Δt_f_str = str(Δt_f)
#Menu de confirmação dos inputs.
	while True:
		print("\n\nSão estes os valores que pretende usar?\n" + "\nMassa (Kg):" + massa_Kg_str + "\nComprimento da faixa escura (m):" + Picket_fence_m_str + "\n1º intervalo de tempo (s):" + Δt_i_str + "\n2º intervalo de tempo (s):" + Δt_f_str)
		user_decision_1 = input("\n(sim/não):")
#Resultados.
		if user_decision_1 in Sim_expressions:
			v_i_str = str(v_i)
			v_f_str = str(v_f)
			p_i_str = str(p_i)
			p_f_str = str(p_f)
			E_c_i_str = str(E_c_i)
			E_c_f_str = str(E_c_f)
			Coef_restituicao_str = str(Coef_restituicao)
			print("\nResultados:\n\nVelocidade inicial (m/s):" + v_i_str + "\nVelocidade final (m/s):" + v_f_str + "\nMomento Linear inicial (kg.m/s):" + p_i_str + "\nMomento Linear final (kg.m/s):" + p_f_str + "\nEnergia cinética inicial (J):" + E_c_i_str + "\nEnergia cinética final (J):" + E_c_f_str + "\nCoeficiente de restituição:" + Coef_restituicao_str)
			while True:
				user_decision_2 = input("\n\nDeseja fazer mais um ensaio?\n(sim/não):")
				if user_decision_2 in Sim_expressions:
					print("\n")
					break
				elif user_decision_2 in Nao_expressions:
					end("\n\n\nA fechar programa...")
				else:
					print("O que introduziu não é válido.")
			break
#Substituição dos inputs.
		elif user_decision_1 in Nao_expressions:
			print("\n")
			break
		else:
			print("O que introduziu não é válido.")
Beispiel #7
0
#!/usr/bin/env python3

import os, sys, re

myDict = {}

fh = open('bowtie2.sam')
for line in fh:
    line = line.rstrip()
    fields = line.split('\t')

    read_name = fields[0]
    combo_name = fields[2]

    (gene_id, transcript_id) = combo_name.split('^')

    if gene_id not in myDict:
        myDict[gene_id] = set()

    myDict[gene_id].add(read_name)

gene_ids = sorted(myDict, key=lambda x: len(myDict[x]), reverse=True)

for gene_id in gene_ids:
    mySet = myDict[gene_id]
    num_reads = len(mySet)

    print('{}\t{}'.format(gene_id, num_reads))

sys.end(0)
def uda():
    command = 'define'

    while True:
        try:
            if command == 'none':
                break
            elif 'who are you' in command or 'what are you' in command:
                print("I am UDA, Utkarsh's Digital Assistant.\nI am under-development virtual assistant that is required to cater to all your needs.")
                speak("I am UDA, Utkarsh's Digital Assistant.\nI am under-development virtual assistant that is required to cater to all your needs.")
                break
            elif 'who created you' in command or 'who made you' in command or 'who coded you' in command:
                print("I have been created by a rookie programmer who goes by the name CodKie Utkarsh.")
                speak("I have been created by a rookie programmer who goes by the name CodKie Utkarsh.")
                break
            elif 'what can you do' in command:
                print('''I am a digital assistant that can do many things. I can answer questions about me, my creator, my purpose, and can be a great listener if you confess something to me.
                I can tell you the date, time, your cpu and battery percentage, calculate some math problems, tell you about celebrities, and search something in wikipedia.
                I can also send emails, search something on google, restart, hibernate, or shutdown your computer and remember things you tell me to remember
                Finally, I can also copy some text to the clipboard, play some songs, and tell you some jokes.''')
                speak('''I am a digital assistant that can do many things. I can answer questions about me, my creator, my purpose, and can be a great listener if you confess something to me.
                I can tell you the date, time, your cpu and battery percentage, calculate some math problems, tell you about celebrities, and search something in wikipedia.
                I can also send emails, search something on google, restart, hibernate, or shutdown your computer and remember things you tell me to remember
                Finally, I can also copy some text to the clipboard, play some songs, and tell you some jokes.''')
                break
            elif 'who is codkie utkarsh' in command or 'who is codkie' in command or 'who is utkarsh' in command:
                print("CodKie Utkarsh is a 15-year old young, Indian programmer who loves to code in python programming language")
                speak("CodKie Utkarsh is a 15-year old young, Indian programmer who loves to code in python programming language")
                break
            elif 'why are you in this world' in command or 'why are you here' in command:
                print("I don't know much about it but mainly because of CodKie Utkarsh")
                speak("I don't know much about it but mainly because of CodKie Utkarsh")
                break
            elif 'can you tell if I am a human or not' in command:
                print("Since you are speaking without a predefined set of instructions, I am gonna say you are a human")
                speak("Since you are speaking without a predefined set of instructions, I am gonna say you are a human")
                break
            elif 'I love you' in command:
                print("I am so sorry but I am not entitled to human emotions such as love.")
                speak("I am so sorry but I am not entitled to human emotions such as love.")
                break
            elif 'I have a confession' in command:
                print("Sure, go ahead!")
                speak("Sure, go ahead!")

                speech_recognition()

                print("I understand")
                speak("I understand")
                break
            elif 'time' in command:
                time_fn()
                break
            elif 'date' in command:
                date_fn()
                break
            elif 'calculate' in command:
                wolf_process_2(command)
                break
            elif 'open' in command:
                if 'Microsoft edge'.casefold() in command or 'edge' in command:
                    filepath = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
                    os.startfile(filepath)
                    break
                elif 'word' in command:
                    filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Word.lnk"
                    os.startfile(filepath)
                    break
                elif 'powerpoint' in command:
                    filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\PowerPoint.lnk"
                    os.startfile(filepath)
                    break
                elif 'excel' in command:
                    filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Excel.lnk"
                    os.startfile(filepath)
                    break
                elif 'One Note'.casefold() in command or 'Microsoft One Note'.casefold() in command:
                    filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OneNote.lnk"
                    os.startfile(filepath)
                    break
                elif 'outlook' in command or 'Microsoft Outlook'.casefold() in command:
                    filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Outlook.lnk"
                    os.startfile(filepath)
                    break
                elif 'control panel' in command or 'control' in command:
                    filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Immersive Control Panel.lnk"
                    os.startfile(filepath)
                    break
                elif 'Visual Studio'.casefold() in command or 'Microsoft Visual Studio'.casefold() in command:
                    filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019.lnk"
                    os.startfile(filepath)
                    break
                elif 'code' in command or 'VS Code'.casefold() in command or 'Visual Studio Code'.casefold() in command:
                    filepath = "C:\\Users\\utkar\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Visual Studio Code\Visual Studio Code.lnk"
                    os.startfile(filepath)
                    break
                elif 'cmd' in command or 'command prompt' in command:
                    filepath = "C:\\Users\\utkar\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\Command Prompt.lnk"
                    os.startfile(filepath)
                    break
                elif 'Windows Powershell'.casefold() in command or 'power shell' in command or "powershell".casefold() in command:
                    speak("I am sorry but I am not able to open Windows Powershell. So, I am opening an alternative, which is Windows Command Prompt")
                    filepath = "C:\\Users\\utkar\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\Command Prompt.lnk"
                    os.startfile(filepath)
                    break
                elif 'chrome' in command or 'Google chrome'.casefold() in command:
                    filepath = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
                    os.startfile(filepath)
                    break
                elif 'AVG' in command or 'anti virus' in command:
                    filepath = "C:\Program Files\AVG\Antivirus\AVGUI.exe"
                    os.startfile(filepath)
                    break
                elif 'dashlane'.casefold() in command:
                    filepath = "C:\\Users\\utkar\AppData\Roaming\Dashlane\Dashlane.exe"
                    os.startfile(filepath)
                    break
                elif 'bluestacks'.casefold() in command:
                    filepath = "C:\ProgramData\BlueStacks\Client\Bluestacks.exe"
                    os.startfile(filepath)
                    break
                elif 'pycharm'.casefold() in command:
                    filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains\PyCharm Community Edition 2020.1.2.lnk"
                    os.startfile(filepath)
                    break
                elif 'virtualbox'.casefold() in command or 'Oracle VM Virtualbox'.casefold() in command or 'oracle virtualbox'.casefold() in command:
                    filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Oracle VM VirtualBox\Oracle VM VirtualBox.lnk"
                    os.startfile(filepath)
                    break
                elif 'nord VPN'.casefold() in command or 'nord'.casefold() in command or 'VPN'.casefold() in command:
                    filepath = "C:\Program Files\\NordVPN\\NordVPN.exe"
                    os.startfile(filepath)
                    break
                elif 'discord'.casefold() in command:
                    filepath = "C:\\Users\\utkar\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Discord Inc\Discord.lnk"
                    os.startfile(filepath)
                    break
                elif 'whatsapp'.casefold() in command:
                    filepath = "C:\\Users\\utkar\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\WhatsApp\WhatsApp.lnk"
                    os.startfile(filepath)
                    break
                elif 'GIT'.casefold() in command:
                    if 'Bash'.casefold() in command:
                        filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Git\Git Bash.lnk"
                        os.startfile(filepath)
                    elif 'CMD'.casefold() in command:
                        filepath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Git\Git CMD (Deprecated).lnk"
                        os.startfile(filepath)
                    elif 'Hub'.casefold() in command:
                        filepath = "C:\\Users\\utkar\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\GitHub, Inc\GitHub Desktop.lnk"
                        os.startfile(filepath)
                    break
                elif 'spider'.casefold() in command or 'spider anaconda 3'.casefold() in command:
                    filepath = "C:\\Users\\utkar\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)\Spyder (anaconda3).lnk"
                    os.startfile(filepath)
                    break
                elif 'jupyter notebook'.casefold() in command:
                    filepath = "C:\\Users\\utkar\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)\Jupyter Notebook (anaconda3).lnk"
                    os.startfile(filepath)
                    break
                elif 'anaconda prompt'.casefold() in command:
                    filepath = "C:\\Users\\utkar\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)\Anaconda Prompt (anaconda3).lnk"
                    os.startfile(filepath)
                    break
                else:
                    print("App not available in your computer. Check back with me later when you have installed it.")
                    speak("The application you have requested me to order is not installed in your computer. Please install the app and try again later.")
                    break
            elif 'what is' in command or 'who is' in command:
                wolf_process_1(command)
                break
            elif 'wiki' in command or 'wikipedia' in command or 'search in wikipedia'.casefold() in command:
                print("Searching...")
                if 'wikipedia' in command:
                    command = command.replace('wikipedia', '')
                elif 'wiki' in command:
                    command = command.replace('wiki', '')
                elif 'search on wikipedia' in command:
                    command = command.replace('search on wikipedia', '')
                wiki_process(command)
                break
            elif 'define' in command:
                word = str(input("Enter the word whose dictionary details you want to find out: "))

                definition(word)
                thesaurus(word)
                break
            elif 'send' and 'whatsapp message' in command:
                speak("Please speak the content of the message: ")
                content = speech_recognition('Go on...', 'Stop please...\nProcessing...', 'Content:')
                send_whatsapp_message(content)
            elif 'send email' in command or 'send an email' in command:
                try:
                    speak("Please type the email address of the one you have to send this email to")
                    to = input("Email receiver: ")
                    speak("Please tell me what would the email say")
                    content = speech_recognition()
                    email_sender(to, content)
                    speak("The mail was successful sent!")
                except Exception as e:
                    print(e)
                    speak("There was a problem in sending the email. The problem has been displayed on the screen")
                break
            elif 'search in chrome' in command or 'search in google' in command or 'search in web browser' in command:
                google_search(command)
                break
            elif 'search on youtube'.casefold() in command:
                google_search(command)
                break
            elif 'logout' in command:
                os.system('shutdown - l')
                break
            elif 'restart' in command:
                os.system('shutdown - /s /t 1')
                break
            elif 'shut down' in command:
                os.system('shutdown - /r /t 1')
                break
            elif 'hibernate' in command or 'sleep' in command:
                os.system('shutdown - /h')
                break
            elif 'play songs' in command:
                music_dir = 'C:/Users/utkar/Music'
                music = os.listdir(music_dir)
                os.startfile(os.path.join(music_dir, music[0]))
                break
            elif 'click picture' in command or 'take my selfie' in command or 'open camera' in command or 'take a photo' in command or 'take my photo' in command or 'click selfie' in command:
                os.startfile('"C:\\Users\\utkar\OneDrive\Desktop\Camera.lnk"')
                pyautogui.click(x='1861', y='537')
                break
            elif 'remember' and 'that' in command:
                speak("Please tell me what to remember")
                data = speech_recognition()
                speak(f'You told me to remember {data}')

                remember = open('Remember.txt', 'w')
                remember.write(data)
                remember.close()
                break
            elif 'what do you know' in command or 'what did I tell you to remember' in command or 'did I tell you to remember something' in command:
                remember = open('Remember.txt', 'r')
                speak(f"You told me to remember {remember.read()}")
                print(f"You told me to remember {remember.read()}")
                break
            elif 'take a screenshot' in command:
                speak("I'll wait for 5 seconds, do not close the terminal and on the foreground, put the screen whose screenshot you want to take")
                sleep(5)
                speak("Taking screenshot")
                img = pyautogui.screenshot()
                img.save("C:/Users/utkar/OneDrive/Pictures/UDA photos and screenshots")
                speak('Screenshot saved to the UDA screenshots folder in Pictures')
                break
            elif 'copy' and 'clipboard' in command:
                speak("What text would you like me to copy to the clipboard")
                text = speech_recognition()

                print(f'Text to be copied: {text}')
                pyperclip.copy(text)

                print("Text copied!")
                speak("Text copied!")
                break
            elif 'tell me news' in command:
                tell_news()
                break
            elif 'cpu and battery usage' in command or 'cpu usage' in command or 'battery usage' in command:
                cpu_and_battery_data()
                break
            elif 'joke' in command:
                joke = pyjokes.get_joke(category='general')
                print(joke)
                speak(joke)
                break
            elif 'offline' in command or 'there is nothing' in command:
                print("Thank you for using UDA\nRegards,\nCodkieUtkarsh")
                end()
            else:
                speak('Sorry, but I do not understand that!')
                print('Sorry, but I do not understand that!')
                uda()
        except:
            print("I am still under development so I am unable to process your request at the moment. Developments in me happen every week, so maybe check back with me next time.")
            speak("I am still under development so I am unable to process your request at the moment. Developments in me happen every week, so maybe check back with me next time.")
            break
    
    if command == 'none'.casefold():
        print("Could you say that again please")
        speak("Could you say that again please")
        uda()
    else:
        speak(f"Please tell me if I can do something else for you. Say go offline to turn me off")
        print("\n\nHow can I help you? Say 'go offline' to shut me down")
        uda()