Error saying that name 'math' is not defined when trying to use asin()

后端 未结 3 1946
时光说笑
时光说笑 2020-12-11 20:41

I have made a Trignometric calculator (Kind of - it only uses the sine ratio as of now) but I can\'t get it to work right. I get an error that says math is not defined when

3条回答
  •  情书的邮戳
    2020-12-11 21:19

    You need to import math before you can use it -- otherwise Python doesn't know what you're talking about.

    Once you do that, you'll get another error: your inputs are strings, and you need to convert them to numbers (with float()) before you can pass them as arguments to math functions. As nye17 pointed out, if the user inputs the angle in degrees, you'll also need to convert it to radians before passing it to asin.

提交回复
热议问题