<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#Comp-1001 Midterm Tutorial
#Code for question number one
#By Ricky Hineman, MUN CompSci Society, October 2019

#No imports are needed

#Take in values for A, B, C, D, W, X, Y, Z:
#Note that by naming convention, all variables start with
#  lower case letter!
a = int(input("Please enter A: "))
b = int(input("Please enter B: "))
c = int(input("Please enter C: "))
d = int(input("Please enter D: "))
w = int(input("Please enter W: "))
x = int(input("Please enter X: "))
y = int(input("Please enter Y: "))
z = int(input("Please enter Z: "))

#Complete computations using given formulas:
oneOne = a-w
twoOne = d+w-z
threeOne = c-x+z
fourOne = b+x
oneTwo = c+w+y
twoTwo = b
threeTwo = a
fourTwo = d-w-y
oneThree = b+x-y
twoThree = c
threeThree = d
fourThree = a-x+y
oneFour = d-x
twoFour = a-w+z
threeFour = b+x-z
fourFour = c+w

#Print the magic square:
print("\nThe magic square is:")
print("%10d" %(oneOne), "%10d" %(oneTwo), "%10d" %(oneThree), "%10d" % (oneFour))
print("%10d" %(twoOne), "%10d" %(twoTwo), "%10d" %(twoThree), "%10d" %(twoFour))
print("%10d" %(threeOne), "%10d" %(threeTwo), "%10d" %(threeThree), "%10d" %(threeFour))
print("%10d" %(fourOne), "%10d" %(fourTwo), "%10d" %(fourThree), "%10d" %(fourFour))

#Print the magic number:
print("\nThe magic number is:", (oneOne + twoOne + threeOne + fourOne))</pre></body></html>