All pastes #159778 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-09-03 14:23 UTC
rendered paste body
def check(n):
	d = 0
	if n%2==0:
		d = 1
	return d

e = 1

while e == 1:
	a = input("What number shall we start at? ")
	print e
	b = input("What number shall we stop at? ")
	c = raw_input("Shall we display odds, evens, or both? ")

	b = b + 1

	print 'If you would like to stop, type in 0 for both numbers and none for what we shall display.'

	if a == 0 and b == 0:
		e = 0
		break 

	if c == 'even' or c == 'evens':
		for n in range(a, b):
			if check(n) == 1:
				print n, 'is even.' 

	if c == 'odd' or c == 'odds':
		for n in range(a, b):
			if check(n) == 0:
				print n, 'is odd.'

	if c == 'both':
		for n in range(a, b):
			if check(n) == 1:
				print n, 'is even.'

			if check(n) == 0:
				print n, 'is odd.'