A three-way model for collective learning on multi-relational data
Answers
Answered by
0
Answer:
Explanation:
number = input("Enter a five digit number: ")
total = 0
#loop to repeat five times
for x in range(0,5):
#x is used to see how many digits have been checked
#if x is 0 this is the first time through the loop, therefore digit 1 is being checked, 2 is digit 3 and 4 is digit 5.
if x == 0 or x == 2 or x == 4:
#if it is digit 1,3 or 5 then it will add the number to the total
#the number is retrieved from the variable number by using x to get the correct digit
total = total + int(number[x])
else:
#if it is digit 2 or 4 then it will subtract the number from the total
total = total - int(number[x])
#the final total will be printed, this is after the loop has finished
print("The final total is: " + str(total))
Attachments:
Similar questions
Computer Science,
6 months ago
English,
6 months ago
Environmental Sciences,
11 months ago
Science,
1 year ago