In Python \"Magic Reasoning. Take your house number and double it. Add five. Mul
ID: 3822511 • Letter: I
Question
In Python
"Magic Reasoning. Take your house number and double it. Add five. Multiply by half a hundred, then add your age (if you are under 100). Add the number of days in the year, and subtract 615. The last two figures will be your age; the others will be your house number."
Create a Python program which will allow any user to see if this "magic reasoning" works for them. The Python program should print out line by line the results of it's calculations to show the user how it is arriving at the final answer.
Explanation / Answer
# patebin code link : https://pastebin.com/iZup3MfU
def magicReasoning(houseNumber, age):
magic = houseNumber
print("house number: " + str(magic))
magic = 2*magic
print("double of house number: " + str(magic))
magic = magic + 5
print("Add five : " + str(magic))
magic = magic * 50
print("Multiply by half a hundred : " + str(magic))
if age < 100:
magic = magic + age
print("Add your age (" +str(age) + ") : " + str(magic))
magic += 365
print("AAdd the number of days in the year: " + str(magic))
magic -= 615
print("subtract 615: " + str(magic))
calcAge = magic%100;
print("Last two digit which is your age: " + str(calcAge))
houseNumber = magic//100
print("Other digits which are your house number: " + str(houseNumber))
magicReasoning(106, 24)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.