Skip to content

Instantly share code, notes, and snippets.

@chrisy
Last active March 14, 2022 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisy/f4bc11cd29509be22ed9304d1ad2c4c4 to your computer and use it in GitHub Desktop.
Save chrisy/f4bc11cd29509be22ed9304d1ad2c4c4 to your computer and use it in GitHub Desktop.
Is a number odd and divisible by 7?
#!/usr/bin/env python
def is_odd(number):
if number % 2 == 0:
return False
else:
return True
def is_mul_seven(number):
return number % 7 == 0
print("I'm looking for an odd number that is a multiple of seven.")
while True:
number = int(raw_input("Give me a number: "))
if is_odd(number):
print("Your number is odd! W00t!")
if is_mul_seven(number):
print("Your number is also a multiple of seven! Great!")
break
else:
print("But it doesn't divide by seven! One more time?")
else:
print("That number isn't even vaguely odd!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment