PDA

View Full Version : [python] funzioni matematiche


lorenzoakatheking
10-03-2008, 18:50
Ciao a tutti. Sto seguendo il libro on-line "Pensare da informatico - Imparare con Python" e dopo poco mi si è proposta la spiegazione sulle funzioni matematiche.


Pongo un esempio del mio problema.

Secondo quanto ho capito per trovare il risultato della funzione seno devo far così:

import math
angolo=90
sol = math.sin(angolo)

solo che così l'IDLE mi da errore.
Come devo fare? :muro:

m.distrutti
10-03-2008, 18:55
questo errore ?

NameError: global name 'math' is not defined?

lorenzoakatheking
10-03-2008, 19:03
:confused: :confused: :confused: :confused:


ora non so perché ma scrivendo quella sorgente l'IDLE mi mostra una stringa vuota....

m.distrutti
10-03-2008, 19:13
se a video non ti stampa niente allora va bene non e' un errore che ti da.
se vuoi stampare il contenuto di math.sin(angolo) devi accedere allo stream video con print


import math
angolo = 90
lol = math.sin(angolo)
print lol


ora dovrebbe stampartelo senza prob

lorenzoakatheking
10-03-2008, 20:38
vero non ci avevo proprio pensato.


Sono proprio un neofita :D


grazie!

m.distrutti
10-03-2008, 20:53
vero non ci avevo proprio pensato.


Sono proprio un neofita :D


grazie!

nessun problema :)

Hardware Upgrade Forum Database Error
Database Error Database error
The Hardware Upgrade Forum database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.hwupgrade.it home page, then try to open another page.
  • Click the Back button to try another link.
The www.hwupgrade.it forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.