Translate to Traditional Chinese (δΈ­ζ–‡):

<< Prev   🏠 A B C D E F G Next >>


F.py - Get Second Last Digit

Write a Python program that asks the user to enter an integer num and then extracts the second last digit of the number. Display the result on the screen as the example bellow.

Hint:
To get the second last digit, first, you need to remove the last digit of a number.
To remove the last digit of a number, you can use integer division (//) by 10.
Then, take the modulus (%) of the result with 10 to extract the second last digit.


Example 1:
EnEnter a number: 4567
Second last digit: 6
Explaination: (4567//10) = 456. Then 456%10 = 6

Example 2:
Enter a number: 54328
Second last digit: 2
Explaination: (54328//10) = 5432. Then 5432%10 = 2


<< Prev   🏠 A B C D E F G    Next >>