简体   繁体   English

我似乎无法在我的代码中修复这些错误

[英]I cant seem to fix these erros in my code

My assignment is asking me to:我的任务要求我:

Write a program to fetch employee name and the salary.编写一个程序来获取员工姓名和工资。 Calculate the Federal tax and state tax based on the following criteria: If the salary is greater than 100000 then calculate the federal tax at 20% otherwise calculate the federal tax at 15% Calculate the state tax at 5% Calculate the net salary of the employee.根据以下标准计算联邦税和州税: 如果工资大于 100000 则按 20% 计算联邦税,否则按 15% 计算联邦税 按 5% 计算州税 计算员工的净工资. To calculate the net salary, subtract federal and state tax from the gross salary.要计算净工资,请从总工资中减去联邦税和州税。

I have written a program to solve this and it does run/ calculate everything my instructor asked, but I keep getting the same errors, every time I think I've fixed them.我已经编写了一个程序来解决这个问题,它确实运行/计算了我导师要求的所有内容,但是每次我认为我已经修复了它们时,我总是遇到相同的错误。

Here is my code:这是我的代码:

your_name = input('Please enter your name:')
employee_salary = int(input('Please enter your salary:'))
if employee_salary >= 100000:
    federal_tax = (employee_salary *20) / 100
    state_tax = (employee_salary * 5) / 100
    net_salary = employee_salary - state_tax - federal_tax
    print('Your Federal Tax is:'+str(federal_tax))
    print('Your State Tax is:'+str(state_tax))
    print('Your net salary is:'+str(net_salary))
else:
    employee_salary < 100000
    federal_tax = (employee_salary * 15) / 100
    state_tax = (employee_salary * 5) / 100
    net_salary = employee_salary - state_tax - federal_tax
    print('Your Federal Tax is:'+str(federal_tax))
    print('Your State Tax is:'+str(state_tax))
    print('Your net salary is:'+str(net_salary))

sorry if any of this looks messy, this if my first use of stackoverflow抱歉,如果其中任何一个看起来很乱,这是我第一次使用 stackoverflow

Thank You!谢谢你!

My code errors我的代码错误

Based on the difference between the correct output and your output, your output is not formatted correctly.根据正确输出和您的输出之间的差异,您的输出格式不正确。 Include a space before every colon ( : ) in every print statement包括每一个冒号前的空格( :在每一个) print声明

According to the test case's output and your output, the only difference is the space you are missing in the print statement.根据测试用例的输出和您的输出,唯一的区别是您在打印语句中缺少的空间。

Try below in every print statement:在每个打印语句中尝试以下操作:

print('Your Federal Tax is :'+str(federal_tax))

Just alter the indentations and spacings.I think your grader throws output for spaces.只需更改缩进和间距。我认为您的分级器会为空格抛出输出。 your_name = input('Please enter your name :') employee_salary = int(input('Please enter your salary :')) if employee_salary >= 100000: federal_tax = (employee_salary)*0.2 state_tax = (employee_salary)*0.5 net_salary = employee_salary -(state_tax + federal_tax) print('Your Federal Tax is :'+str(federal_tax)) print('Your State Tax is :'+str(state_tax)) print('Your net salary is :'+str(net_salary)) else: employee_salary < 100000 federal_tax = (employee_salary *0.15) state_tax = (employee_salary *0.05) net_salary = employee_salary -(state_tax + federal_tax) print('Your Federal Tax is :'+str(federal_tax)) print('Your State Tax is :'+str(state_tax)) print('Your net salary is :'+str(net_salary))

You'd better replace the + with a , on the print lines.您最好将print行上的+替换为,

print("abc" + str(1)) # will print 'abc1'
print("abc", str(1))  # will print 'abc 1'

Using a comma will insert a space automatically.使用逗号将自动插入一个空格。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的乌龟代码有一个错误,我似乎无法解决 - My turtle code has an error i cant seem to fix at the end of it 我似乎无法弄清楚它一直给我错误的这段代码。 我正在尝试打印以显示我的姓名年龄和圆圈面积 - I cant seem to figure out this code it keeps giving me erros. I am trying to print so it shows my name age and area of the circle scipy AttributeError,似乎无法修复 - scipy AttributeError, cant seem to fix it Pycharm 上没有显示按钮(使用 Tkinter 模块)? 这是我的代码,但我似乎无法按我的意愿编辑和格式化按钮 - button not being displayed on Pycharm (using the Tkinter module)?. This is my code but I cant seem to edit and format the button as I would like to 我似乎无法将我的 json 文件保存在 python 中? - I cant seem to save my json files in python? 我正在尝试这个问题,但我似乎无法让代码正常工作,在我附上了我的工作图片之后 - im trying this question but i just cant seem to get the code working, after the sentence ive attached a picture of my work 我无法随代码上下移动 - I cant move up and down with my code 我无法修复的 Python 简单代码 help1!1 - Python simple code i cant fix help1!1 我似乎无法让我的烧瓶应用程序显示我的 Form-flask_wtf - I cant seem to get my flask app to display my Form- flask_wtf 不和谐和机器人制作:我似乎无法让我的机器人发布网络解析的资料 - discord and bot making: i cant seem to get my bot to post a web parsed material
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM