I added the link to register for your AP Exam on the right sidebar.
I have to be at a county meeting all day; I apologize for forgetting about this until now. Email me with proposals for tomorrow's Friday Fun Day. Below is my code for the challenge, and I will go over my flowcharting with you on Friday. Please spend today first looking over my code and comparing it to yours. Can you see that digit sum() and diffsum() are abstractions? Where do you see algorithms that contain other algorithms? After that, work on your Create PT. Don't forget to log your work in your Abstraction Notebook. Don't forget to comment your code.
# Nested Loops
# Kate Maloney
# Mon, Nov 14, 2016
def digitsum():
icnt = 1
jcnt = 1
numlist = []
for icnt in range (1,6):
for jcnt in range (1,10):
inum = 10*icnt+jcnt
sumnum = icnt+jcnt
if sumnum > 10:
if inum <= 56:
numlist.append(inum)
print(inum)
print(numlist)
def diffsum():
icnt = 1
jcnt = 1
for icnt in range (1,10):
for jcnt in range (1,10):
num1 = 10*icnt + jcnt
num2 = 10*jcnt + icnt
diffnum = num1-num2
sumnum = icnt+jcnt
if diffnum == sumnum:
print(num1)
while True:
answer = input("""Enter the number for the choice you want.
1 = Generate a list of all two digit numbers which are less than or equal to 56 and the sum of whose digits is greater than 10.
2 = Generate a list of all two digit numbers such that the number itself minus the number reversed is equal to the sum of its digits.
0 = Quit.
Your choice: """)
if answer == '1':
digitsum()
elif answer == '2':
diffsum()
elif answer == '0':
break
else:
print("I dont understand. Please answer 0, 1, or 2.")
I have to be at a county meeting all day; I apologize for forgetting about this until now. Email me with proposals for tomorrow's Friday Fun Day. Below is my code for the challenge, and I will go over my flowcharting with you on Friday. Please spend today first looking over my code and comparing it to yours. Can you see that digit sum() and diffsum() are abstractions? Where do you see algorithms that contain other algorithms? After that, work on your Create PT. Don't forget to log your work in your Abstraction Notebook. Don't forget to comment your code.
# Nested Loops
# Kate Maloney
# Mon, Nov 14, 2016
def digitsum():
icnt = 1
jcnt = 1
numlist = []
for icnt in range (1,6):
for jcnt in range (1,10):
inum = 10*icnt+jcnt
sumnum = icnt+jcnt
if sumnum > 10:
if inum <= 56:
numlist.append(inum)
print(inum)
print(numlist)
def diffsum():
icnt = 1
jcnt = 1
for icnt in range (1,10):
for jcnt in range (1,10):
num1 = 10*icnt + jcnt
num2 = 10*jcnt + icnt
diffnum = num1-num2
sumnum = icnt+jcnt
if diffnum == sumnum:
print(num1)
while True:
answer = input("""Enter the number for the choice you want.
1 = Generate a list of all two digit numbers which are less than or equal to 56 and the sum of whose digits is greater than 10.
2 = Generate a list of all two digit numbers such that the number itself minus the number reversed is equal to the sum of its digits.
0 = Quit.
Your choice: """)
if answer == '1':
digitsum()
elif answer == '2':
diffsum()
elif answer == '0':
break
else:
print("I dont understand. Please answer 0, 1, or 2.")