每当我尝试运行程序时,会弹出一个错误,说"条件中的字符串文字(第10行)".我究竟做错了什么?
puts "Welcome to the best calculator there is. Would you like to (a) calculate the area of a geometric shape or (b) calculate the equation of a parabola? Please enter an 'a' or a 'b' to get started."
response = gets.chomp
if response == "a" or "A"
puts "ok."
elsif response == "b" or "B"
puts "awesome."
else
puts "I'm sorry. I did not get that. Please try again."
end
Run Code Online (Sandbox Code Playgroud) puts "Let's get started calculating your parabola. What is your A value?"
a = gets.chomp
puts "What is your B value?"
b = gets.chomp
puts "What is your C value?"
c = gets.chomp
x = x
2x = (x.to_i**2)
puts "Your parabola equation is 'y = " + a.to_s + 2x.to_s + " + " + b.to_s + x + " + " + c.to_s + "'. Would you like to go back to the beginning?"
Run Code Online (Sandbox Code Playgroud) 我是一个初级程序员。我想调整我的按钮的大小,它被定义为“但是”,它是在 Square 类中定义的。我将使用什么选项来调整此按钮的大小以调整高度和宽度?非常感谢任何帮助,如果您可以在代码中添加注释,那将会很有帮助!
import Tkinter
class TicWindow(Tkinter.Tk):
def __init__(self):
Tkinter.Tk.__init__(self)
self.squares = []
self.turn = 0
for r in range(3):
for c in range(3):
b = Square(self).grid(row=r,column=c)
self.squares.append(b)
self.geometry("500x500")
def turn(self):
return self.turn
def changeTurn(self):
if (self.turn == 0):
self.turn = 1
else:
self.turn = 0
class Square(Tkinter.Button):
def __init__(self,parent):
but = Tkinter.Button.__init__(self,parent, text=" ", command=self.changeButtonText)
self.canClick = True
def changeButtonText(self):
if (self.master.turn == 0) and (self.canClick == True):
self.config(text = "X")
elif (self.master.turn == 1) and (self.canClick == True): …Run Code Online (Sandbox Code Playgroud)