第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么我總是從這段代碼中收到錯誤

為什么我總是從這段代碼中收到錯誤

冉冉說 2023-12-29 17:12:17
所以我不斷收到此錯誤 print(float(side / (math.sin(math.radians(float( Degree)))))) TypeError: unsupported operand type(s) for /: 'str' and 'float'import math# for anyone looking at this input opp, 10.7, 65, sin, noprint("This only works for right triangles")print("opp = opposite   adj = adjacent")# variablesside1 = input("Input if your trying to find opposite or adjacent: ")side = input("input length of one side: ")degree = input("Input angle cant use the right angle: ")trig_ratio = input("Input either sin cos tan: ")pos_angle = input("is the right angle below the angle: ")# sinif trig_ratio == "sin"\        and pos_angle == "no"\        and side1 == "opp":    print(float(side / (math.sin(math.radians(float(degree))))))
查看完整描述

4 回答

?
ibeautiful

TA貢獻1993條經(jīng)驗 獲得超6個贊

問題是你試圖將字符串除以浮點數(shù)。該變量side永遠不會轉(zhuǎn)換為浮點數(shù),這就是“TypeError: unsupported operand type(s) for /: 'str' and 'float'”所討論的內(nèi)容。

使用side = float(input("input length of one side: "))print(float(side) / (math.sin(math.radians(float(degree)))))代替


查看完整回答
反對 回復(fù) 2023-12-29
?
一只萌萌小番薯

TA貢獻1795條經(jīng)驗 獲得超7個贊

您輸入的side變量是,在進行任何算術(shù)運算之前str將其轉(zhuǎn)換為。float

side = float(input("input length of one side: "))


查看完整回答
反對 回復(fù) 2023-12-29
?
躍然一笑

TA貢獻1826條經(jīng)驗 獲得超6個贊

輸入函數(shù)總是返回一個字符串,嘗試在輸入時將 side 轉(zhuǎn)換為 int 或 float

side = float(input("input length of one side: "))


查看完整回答
反對 回復(fù) 2023-12-29
?
開心每一天1111

TA貢獻1836條經(jīng)驗 獲得超13個贊

您正在嘗試用字符串值除法,即,您需要先將“side”值轉(zhuǎn)換為浮點數(shù),然后嘗試除法。

使用下面的代碼:

print(float(side) / (math.sin(math.radians(float(度)))))


查看完整回答
反對 回復(fù) 2023-12-29
  • 4 回答
  • 0 關(guān)注
  • 243 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號