python - if 和 else 函数中的无效语法 | 带变量的数学方程
问题描述
我正在尝试创建一个程序,用户可以在其中输入他们所知道的关于金字塔的值并轻松获取所有值。
NA = 0
width = 20
print ('Welcome To The \"Big Bertha Of Right Rectangle Equations\"'.rjust(width,'-'))
print("Enter In All The Measurements You Have")
print("If You Don't Have A Measurement Please Enter \"NA\"")
print(" ")
BaseLength = ( input ("Enter Base Length: ") )
BaseWidth = ( input ("Enter A Base Width: ") )
PyramidHeight = ( input ("Enter Pyramid Height: ") )
PyramidVolume = (input ("Enter Pyramid Volume: ") )
if BaseLength == NA:
print("No Worries We\'ll Find Base Width For You!")
BaseLengthCalc = int((PyramidVolume / (PyramidHeight * BaseWidth) * 3))
if BaseWidth == NA:
print("No Worries We\'ll Find Base Width For You!")
BaseWidthCalc = int((PyramidVolume/(PyramidHeight*BaseLength))*3)
if PyramidHeight == NA:
print("No Worries We\'ll Find Pyramid Height For You!")
PyramidHeightCalc = int((PyramidVolume/(BaseLength*BaseWidth))*3)
if PyramidVolume == NA:
print("No Worries We\'ll Find Pyramid Volume For You!")
PyramidVolumeCalc = int((BaseLength*BaseWidth*PyramidHeight/3))
print("Here's All The Calculations Boss!")
print(" ")
if BaseLength == NA:
print(BaseLengthCalc)
else BaseLength == BaseLength:
print("Base Length" + BaseLengthCalc)
if BaseWidth == NA:
print(BaseWidthCalc)
else = BaseWidth == BaseWidth:
print("Base Width" + BaseWidth)
if PyramidHeight == NA:
print(PyramidHeight)
else :PyramidHeight == PyramidHeight:
print("Pyramid Height" + PyramidHeight)
if PyramidVolume == NA:
print(PyramidVolumeCalc)
else PyramidVolume == PyramidVolume:
print("Pyramid Volume" + PyramidVolume)
else 和变量之间的预期语句,我是新手,只是渴望学习,所以请善待!谢谢!
解决方案
if BaseLength == NA:
print(BaseLengthCalc)\
else not BaseLength != BaseLength
print("Base Length" + BaseLengthCalc)
后面那句话是什么else
?那不是 Python 语法。也许你elif
在这里需要一个和一个冒号,但这个表达式也没有意义。我也不确定您要对线路延续做什么。
推荐阅读
- java - Azure 文件存储内容类型始终更改为应用程序/八位字节流建议解决方案我该如何修复
- ionic-framework - 在 IONIC 中呈现常规 HTML
- angular - 当我首先在数组中添加项目时,ngFor 重新打印所有 dom
- node.js - 为什么我无法在节点 js 中更新 env 变量
- ios - 动画 UIPopoverPresentationController 视图的中心位置
- php - 如何通过 MySQL 查询或 PHP 代码删除无法识别的字符?
- java - Arraylist 索引超出范围
- javascript - 在香草 JS 闹钟上选择值时遇到问题
- tensorflow - tensorflow.layers.batchnormalization 中批量标准化中的 Const 节点是什么
- c++ - 为什么我得到 munmap_chunk(): invalid pointer: error