如何在不得到SyntaxError的情况下对两个数字进行除法


"car" = input("Enter the name of the car:")
"gas" = float(input("Enter gas used in gallons:"))
"miles" = float(input("Enter number of miles driven:") 
mpg = "miles" / "gas"
print ("Cars Name",car)
print ("Gallons of gas used:,gas)("Number of miles driven:,miles)            
print("Miles per Gallon",mpg)

我尝试了多种方法来编写英里数除以汽油,但我一直遇到语法错误。我相信这很简单,我只是不知道还有什么可以尝试

"car"是一个字符串文字,不能为文字赋值。例如,给10赋值意味着什么?CCD_ 3是一个变量。此外,编程中的细节也很重要。每个左括号都需要一个右括号。每个引号字符还需要一个成对的引号来结束字符串。

只要稍微清理一下,你的程序就能正常运行

car = input("Enter the name of the car:")
gas = float(input("Enter gas used in gallons:"))
miles = float(input("Enter number of miles driven:")) 
mpg = miles / gas
print ("Cars Name",car)
print ("Gallons of gas used: ",gas)
print("Number of miles driven: ",miles)            
print("Miles per Gallon: ", mpg)

相关内容

最新更新