Python idle python 3.2打印表

Python idle python 3.2打印表,python-idle,python-3.2,Python Idle,Python 3.2,我正在学习Python并试图编写一个程序,但我不知道该如何编写它 鉴于这个问题: “使用函数”computeTax(状态,taxableIncome):“编写一个程序,打印50000至60000美元应税收入的纳税表,所有四种状态的间隔为50美元,如下所示: 我完全不明白这是怎么回事。步骤1:税收计算 def computeTax(status,taxableIncome): """ status is a string such as 'married joint', taxab

我正在学习Python并试图编写一个程序,但我不知道该如何编写它

鉴于这个问题:

“使用函数”computeTax(状态,taxableIncome):“编写一个程序,打印50000至60000美元应税收入的纳税表,所有四种状态的间隔为50美元,如下所示:


我完全不明白这是怎么回事。

步骤1:税收计算

def computeTax(status,taxableIncome):
    """
    status is a string such as 'married joint', taxableIncome is the amount of income
    This function returns the portion of the income that should be paid as tax. This amount is different  depending on the status.
    """
    status_multupliers = {blah} #a dictionary of status to multiplier mappings...
    return taxableIncome * status_multipliers[status]
步骤2:初始化文件:

打开要写入的文件(“w”)。 写标题行

第三步:循环的乐趣

for i in range(however_many_lines_you_want_in_your_table):
    income = 50*i #since we are going up in 50s
    current_line = ''     # this is what you want to write to your file
    for status in statuses: #statuses is a list of the available statuses. make this
        tax = computeTax(status,income)
        current_line += tax + '\'
    current_line += '\n'
    file.write(current_line)   #add the line
我认为格式化并不重要

现在,当你问关于堆栈溢出的问题时,请你自己表现出一点努力。否则你将不太可能得到任何帮助

for i in range(however_many_lines_you_want_in_your_table):
    income = 50*i #since we are going up in 50s
    current_line = ''     # this is what you want to write to your file
    for status in statuses: #statuses is a list of the available statuses. make this
        tax = computeTax(status,income)
        current_line += tax + '\'
    current_line += '\n'
    file.write(current_line)   #add the line