Apr-24-2023, 11:22 AM
Hi, I am new to the forum and posting on behalf of my son, who has just started doing Python at school. He has done the code below to show someone getting a £20 bonus for working more than 8 hours and an extra 30% bonus for working more than 12 hours.
It works and gives the desired output, but he can't submit it via the online homework software as it is saying there is a logic error. He thinks it might be something to do with an infinite loop but can't work out why. He isn't trying to cheat but reckons it must be a simple error. He has put the code in replit but it doesn't show an error. I think he has missed the submission date for this question anyway (today), but it would be useful to know why it is wrong so he doesn't do it again. Thank you.
It works and gives the desired output, but he can't submit it via the online homework software as it is saying there is a logic error. He thinks it might be something to do with an infinite loop but can't work out why. He isn't trying to cheat but reckons it must be a simple error. He has put the code in replit but it doesn't show an error. I think he has missed the submission date for this question anyway (today), but it would be useful to know why it is wrong so he doesn't do it again. Thank you.
hours = int(input("How many hours did you work today? ")) pay = 15 pay = pay * hours if hours > 8: pay = pay + 20 if hours > 12: pay = pay + 20 * 1.3 elif pay < 8: pay print("You earned ",pay) hourly = pay / hours print("You earned ",hourly,"per hour")