Python Forum
help with understanding a program prompt
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with understanding a program prompt
#1
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
Reply
#2
It's a math problem, not a programming problem. You've got the three digits. What math formula with those three digits would produce the reversed number?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
ik that but is the problem is how would I implement that into python
Reply
#4
How would you implement math?

result = 1 + 2 * 3 - 4 / 5
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
i might not be explaining so well but
the line i dint get is
Store the integer equal to these three digits in reverse order into a variable called rev_number.

would the integer be referring to the number entered on prompted
Reply
#6
If 123 is what is entered, you need to store 321.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I need help understanding a program structure using classes CompleteNewb 21 5,863 Feb-24-2022, 07:15 PM
Last Post: deanhystad
  Understanding program blocks newbieAuggie2019 2 1,914 Oct-02-2019, 06:22 PM
Last Post: newbieAuggie2019
  I need help understanding how to use and run this program! Thanks in advance! tc1chosen 6 4,729 Sep-01-2017, 01:56 PM
Last Post: tc1chosen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020