Feb-14-2019, 03:25 PM
Prompt for a 3 digit number where the first and last digits differ by at least 2 and store the entered number in a variable named number. Note: For our purposes, assume that the user of the program can correctly choose a number.
These next four steps compute and store the reverse of the number. For example, if the user enters 123, you should compute 321.
Store the 100’s digit in a variable called digit1.
Store the 10’s digit in a variable called digit2. Hint: You can get this digit using this expression: (number//10)%10.
Store the 1’s digit in a variable called digit3.
Store the integer equal to these three digits in reverse order into a variable called rev_number.
As a challenge, you can try to do the preceding four steps all in one statement. It is possible to do it that way!
Store the difference between number and rev_number in a variable called difference. We want this result to always be positive, so use the abs function. e.g. abs(4 - 8) is 4.
Store the reverse of difference in a variable called rev_diff. Note that this requires you to do those four steps again, which this new number.
Print the sum of difference and rev_diff
Your program should always print a result of 1089.
I have no idea how to approach the reversing number part of this program I pretty much noob and just started learning python
These next four steps compute and store the reverse of the number. For example, if the user enters 123, you should compute 321.
Store the 100’s digit in a variable called digit1.
Store the 10’s digit in a variable called digit2. Hint: You can get this digit using this expression: (number//10)%10.
Store the 1’s digit in a variable called digit3.
Store the integer equal to these three digits in reverse order into a variable called rev_number.
As a challenge, you can try to do the preceding four steps all in one statement. It is possible to do it that way!
Store the difference between number and rev_number in a variable called difference. We want this result to always be positive, so use the abs function. e.g. abs(4 - 8) is 4.
Store the reverse of difference in a variable called rev_diff. Note that this requires you to do those four steps again, which this new number.
Print the sum of difference and rev_diff
Your program should always print a result of 1089.
I have no idea how to approach the reversing number part of this program I pretty much noob and just started learning python