photon.py

Created by alex-juge84

Created on November 08, 2020

3.2 KB


from math import *
'''
Prbolèmes dans cette version :
- Probablment des erreures de calculs
- Ne gère pas l'input d'une écriture scientifique
'''

#Définition des constantes
c = 3.0*10**8
h= 6.63*10**-35
p = print

def Menu():
    global choix
    p("")
    p("Saisissez une grandeur :")
    p("1- Energie [eV] ")
    p("2- Energie [J] ")
    p("3- Longueur d'onde [nm]")
    p("4- Longueur d'onde [m]")
    p("5- Frequence [Hz]")
    p("6- Demo De Broglie")
    p("\n"*3)
    choix = int(input("Choix : "))
    result = eval("Menu{}()".format(choix))


def Menu1():
    Eev = ask(1)
    p(""*2)
    p("Lamda(nm)= 1243 / E(ev)")
    p("lamda = {} nm".format(1243/Eev))
    p("Domaine",domaine((1243/Eev)*10**-9))
    p("")
    p("Frequence(Hz) =c / lambda(m)")
    fr = c/(1243/Eev)*10**-9
    p("Frequence={} Hz".format("%E"%fr))
    p(""*1)
    wait()


def Menu2():
    Ej = ask(2)
    p("")
    p("Lamda(m)= h * c / E(J)")
    p("lamda (m)= {} m".format("%E"%(h*c/Ej)))
    lo = (h*c/Ej)*10**9
    p("lamda (nm) = {} nm".format("%E"%lo))
    p("Domaine",domaine(lo))
    p("")
    p("Frequence(Hz) = E(J) / h")
    fr = Ej / h
    p("Frequence = {} Hz".format("%E"%fr))
    p("")
    wait()


def Menu3():
    Lnm = ask(3)
    p("Domaine",domaine(Lnm*10**-9))
    p(""*1)
    p("E(eV)= 1243 / lambda(nm)")
    p("E(eV) = {} eV".format(1243/Lnm))
    p("")
    p("Frequence(Hz) =c / lambda(m)")
    fr = c/Lnm*10**-9
    p("Frequence = {} Hz".format("%E"%fr))
    p(""*2)
    wait()

def Menu4():
    Lm = ask(4)
    p("Domaine",domaine(Lm))
    p(""*1)
    p("E(J)= h*c / Lm")
    p("E(J) = {} J".format(h*c/Lm))
    p("")
    p("Frequence(Hz) =c / lambda(m)")
    fr = c/Lm
    p("Frequence = {} Hz".format("%E"%fr))
    p(""*2)
    wait()

def Menu5():
    V = ask(5)
    p(""*2)
    p("E(J)= h*c / V")
    p("E(J) = {}J".format(h*c/V))
    p("")
    p("Lambda(m) =c / Frequence(Hz)")
    p("Lambda(m) = {} m".format(c/V))
    p("domaine", domaine(c/V))
    p("")
    wait()

def Menu6():
    p("\n"*5)
    p("--Démo De Broglie--")
    p("\n")
    p(">soit 1.6*10^-15 coef J->ev\n")
    p(">E*1.6*10^-15=hc/lambda*10^-9\n")
    p(">E=hc/lambda*10^-9*1.6*10^-15\n")
    p(">E=1243/lambda")
    p("")
    wait()

def wait():
    m = int(input("\t0-->quit, 1-->menu : "))
    if m==0:
        pass
    else:
        Menu()



def ask(n): #A améliorer > détection de l'écriture scientifique
    if n == 1:
        print("\n"*11)
        r = float(input("Energie en ev : "))
    elif n == 2:
        print("\n"*11)
        r = float(input("Energie en J : "))
    elif n == 3:
        print("\n"*11)
        r = float(input("Longueur d'onde en mm : "))
    elif n == 4:
        print("\n"*11)
        r= float(input("Longueur d'onde en m : "))
    elif n == 5:
        print("\n"*11)
        r= float(input("Frequence en Hz : "))

    return r

def domaine(m):
    if m < 10**-11:
        return "des rayons gamma"
    elif m > 10**-11 and m < 10*10**-9:
        return "des rayons X"
    elif m>10*10**-9 and m < 400*10**-9:
        return "des ultraviolets"
    elif m > 400*10**-9 and m < 800*10**-9:
        return "du visible"
    elif m > 800*10**-9 and m<1*10**-8:
        return "des mirco-ondes"
    else :
        return "des ondes radio"

Menu()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.