Skip to content

Instantly share code, notes, and snippets.

@DuffleOne
Last active October 4, 2017 09:55
Show Gist options
  • Save DuffleOne/1cafe5a4e57ab349e7b91367f17aa8b8 to your computer and use it in GitHub Desktop.
Save DuffleOne/1cafe5a4e57ab349e7b91367f17aa8b8 to your computer and use it in GitHub Desktop.
def makeInt(strVal):
try:
return int(strVal)
except ValueError:
return None
def main():
print("Welcome, let's find out if you are due overtime for your work")
NoCount = 0
UserName = ""
HoursWorked = None
while (UserName == ""):
UserName = str(input("Hello, can I have your name please?: "))
if (UserName.upper() == "NO" or UserName.upper() == "N"):
NoCount += 1
if (NoCount >= 3):
print("Fine. I'll just leave it.")
return;
else:
print("That's quite rude, I really do need your name though.")
UserName = ""
while (HoursWorked is None):
HoursWorked = makeInt(input("Please tell me how many hours you have worked: "))
if (HoursWorked is None):
print("Huh, didn't quite catch that, can you enter a number?")
if (HoursWorked > 40):
print("%s, I am pleased to tell you that you are due overtime" % UserName)
else:
print("I'm sorry %s, You are not due overtime." % UserName)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment