Hướng dẫn how do i get the last 4 digits of a number in python? - làm cách nào để lấy 4 chữ số cuối của một số trong python?

Để có được chữ số cuối cùng của một số trong Python:

  1. Truy cập biểu diễn chuỗi của số. the string representation of the number.
  2. Nhận ký tự cuối cùng của biểu diễn chuỗi. the last character of the string representation.
  3. Chuyển đổi ký tự thành một số nguyên. the character to an integer.

Ví dụ: hãy để Lừa nhận được chữ số cuối cùng của số 162329:162329:

n = 162329

# 1. Get the string representation
num_str = repr[n]

# 2. Access the last string of the digit string:
last_digit_str = num_str[-1]

# 3. Convert the last digit string to an integer:
last_digit = int[last_digit_str]

print[f"The last digit of {n} is {last_digit}"]

Output:

The last digit of 162329 is 9

Cách tiếp cận tốc ký

Bạn cũng có thể làm cho mã trên ngắn hơn một chút bằng cách kết hợp các bước 1-3 thành một biểu thức duy nhất:

n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]

Kết quả:

The last digit of 162329 is 9

Cách tiếp cận tương tự bạn đã học trước đó cũng hoạt động cho các số thập phân.

Để có được chữ số cuối cùng của một số thập phân, hãy chuyển đổi số thành một chuỗi, lấy ký tự cuối cùng và chuyển đổi nó trở lại một số nguyên.

Ví dụ, hãy để Lừa nhận được số thập phân cuối cùng của một xấp xỉ ba thập phân của PI.

pi = 3.141
last_digit = int[repr[pi][-1]]

print[f"The last digit of {pi} is {last_digit}"]

Output:

The last digit of 3.141 is 1

Sự kết luận

Hôm nay bạn đã học được cách lấy số cuối cùng từ một chữ số.

Để tóm tắt lại, lấy biểu diễn chuỗi của số, truy cập ký tự cuối cùng và chuyển đổi nó trở lại sang số nguyên.

Cảm ơn vì đã đọc. Mã hóa hạnh phúc!

Đọc thêm

Thủ thuật Python

Cách ghi vào một tệp trong Python

Với tuyên bố trong Python

n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
2
n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
8
n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
18
The last digit of 3.141 is 1
32

n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
16
The last digit of 162329 is 9
2
n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
18
str = "abcdefgh"
lastFour = str[-4:]
print[lastFour]
5

str = "abcdefgh"

n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
2
n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
8
n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
23
n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
18
The last digit of 3.141 is 1
43

n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
18
The last digit of 3.141 is 1
46

n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
48
The last digit of 162329 is 9
8
n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
18
The last digit of 3.141 is 1
50
pi = 3.141
last_digit = int[repr[pi][-1]]

print[f"The last digit of {pi} is {last_digit}"]
8
The last digit of 3.141 is 1
52

n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
54
The last digit of 162329 is 9
2
n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
18
The last digit of 3.141 is 1
56
n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
58
The last digit of 3.141 is 1
32

Output:

"efgh"

The last digit of 3.141 is 1
5
pi = 3.141
last_digit = int[repr[pi][-1]]

print[f"The last digit of {pi} is {last_digit}"]
10

The last digit of 162329 is 9
21
The last digit of 162329 is 9
22

n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
2
pi = 3.141
last_digit = int[repr[pi][-1]]

print[f"The last digit of {pi} is {last_digit}"]
14
The last digit of 162329 is 9
26
n = 162329

last_digit = int[repr[n][-1]]

print[f"The last digit of {n} is {last_digit}"]
23
The last digit of 162329 is 9
7
pi = 3.141
last_digit = int[repr[pi][-1]]

print[f"The last digit of {pi} is {last_digit}"]
18

  • Các
  • The last digit of 162329 is 9
    21
    The last digit of 162329 is 9
    41
  • The last digit of 3.141 is 1
    5
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    10

    Cải thiện bài viết

    Lưu bài viết

    Đưa ra một số và để tìm chữ số đầu tiên và cuối cùng của một số.examples: & nbsp; & nbsp;
    Examples: 
     

    Input : 12345 
    Output : First digit: 1
             last digit : 5
    
    Input : 98562
    Output : First digit: 9
             last digit : 2

    Để tìm chữ số cuối cùng của một số, chúng tôi sử dụng toán tử modulo %. Khi modulo chia cho 10 trả về chữ số cuối cùng của nó. Để tìm chữ số đầu tiên của một số, chúng tôi chia số đã cho 10 cho đến khi số lớn hơn 10. Ở cuối, chúng tôi còn lại với chữ số đầu tiên. & NBSP;modulo operator %. When modulo divided by 10 returns its last digit. 
    Suppose if n = 1234 
    then last Digit = n % 10 => 4 
    To finding first digit of a number is little expensive than last digit. To find first digit of a number we divide the given number by 10 until number is greater than 10. At the end we are left with the first digit.
     

    Cách tiếp cận 1 [với vòng lặp]:

    C++

    The last digit of 162329 is 9
    3

    The last digit of 162329 is 9
    4
    The last digit of 162329 is 9
    5
    The last digit of 162329 is 9
    6

    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    8
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    3
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    4

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    6

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    9

    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    2
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 162329 is 9
    8

    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    7
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    7
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    5

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    7
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 3.141 is 1
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 3.141 is 1
    3

    The last digit of 162329 is 9
    0

    Java

    The last digit of 3.141 is 1
    5
    The last digit of 3.141 is 1
    6

    The last digit of 3.141 is 1
    5
    The last digit of 3.141 is 1
    8

    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    0
    str = "abcdefgh"
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    8
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    3
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    3
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    5

    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    6
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    7
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    2
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    Input : 12345 
    Output : First digit: 1
             last digit : 5
    
    Input : 98562
    Output : First digit: 9
             last digit : 2
    6
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    Input : 12345 
    Output : First digit: 1
             last digit : 5
    
    Input : 98562
    Output : First digit: 9
             last digit : 2
    8

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    04
    The last digit of 162329 is 9
    05

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    10
    The last digit of 162329 is 9
    11
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    14
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    17

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    0

    Python3

    The last digit of 162329 is 9
    21
    The last digit of 162329 is 9
    22

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    3
    The last digit of 162329 is 9
    25
    The last digit of 162329 is 9
    26
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    The last digit of 162329 is 9
    28

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    30
    The last digit of 162329 is 9
    26
    The last digit of 162329 is 9
    30
    The last digit of 162329 is 9
    33
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    39

    The last digit of 162329 is 9
    21
    The last digit of 162329 is 9
    41

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 162329 is 9
    44
    The last digit of 162329 is 9
    45
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    The last digit of 162329 is 9
    47

    The last digit of 162329 is 9
    30
    The last digit of 162329 is 9
    26
    The last digit of 162329 is 9
    11
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9

    The last digit of 162329 is 9
    52
    The last digit of 162329 is 9
    53
    The last digit of 162329 is 9
    26
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    5

    The last digit of 162329 is 9
    52
    The last digit of 162329 is 9
    58

    C#

    The last digit of 162329 is 9
    4
    The last digit of 162329 is 9
    60

    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    0
    str = "abcdefgh"
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    8
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    3
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    3
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    5

    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    6
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    6

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    2
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    Input : 12345 
    Output : First digit: 1
             last digit : 5
    
    Input : 98562
    Output : First digit: 9
             last digit : 2
    6
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    Input : 12345 
    Output : First digit: 1
             last digit : 5
    
    Input : 98562
    Output : First digit: 9
             last digit : 2
    8

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    04
    The last digit of 162329 is 9
    05

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    10
    The last digit of 162329 is 9
    11
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    08
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    17

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    21
    The last digit of 162329 is 9
    22

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    15

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    3
    The last digit of 162329 is 9
    25
    The last digit of 162329 is 9
    26
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    The last digit of 162329 is 9
    28

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    30
    The last digit of 162329 is 9
    26
    The last digit of 162329 is 9
    30
    The last digit of 162329 is 9
    33
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    39

    The last digit of 162329 is 9
    21
    The last digit of 162329 is 9
    41

    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 162329 is 9
    44
    The last digit of 162329 is 9
    45
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    The last digit of 162329 is 9
    47

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    The last digit of 162329 is 9
    30
    The last digit of 162329 is 9
    26
    The last digit of 162329 is 9
    11
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9

    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    52
    The last digit of 162329 is 9
    53
    The last digit of 162329 is 9
    26
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    5

    The last digit of 162329 is 9
    4
    The last digit of 162329 is 9
    60

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    54
    The last digit of 162329 is 9
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    51
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    58
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    3
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    4

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    60

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 162329 is 9
    8

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    04
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    01

    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    6
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    6

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    7
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    5

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    PHP

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    16
    The last digit of 162329 is 9
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    The last digit of 162329 is 9
    47

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    86
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    87

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    89
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    17

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    93

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    3
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    23
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    25
    O[log10n]
    Auxiliary Space: O[1] 

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    28

    C++

    The last digit of 162329 is 9
    3

    The last digit of 162329 is 9
    4
    The last digit of 162329 is 9
    5
    The last digit of 162329 is 9
    6

    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    8
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    3
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    4

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    11
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    13
    The last digit of 162329 is 9
    14
    The last digit of 162329 is 9
    15

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    9

    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    2
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 162329 is 9
    8

    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    7
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    7
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    5

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 3.141 is 1
    3

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    86
    The last digit of 3.141 is 1
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 3.141 is 1
    3

    The last digit of 162329 is 9
    0

    Java

    The last digit of 3.141 is 1
    5
    The last digit of 3.141 is 1
    6

    The last digit of 3.141 is 1
    5
    The last digit of 3.141 is 1
    8

    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    0
    str = "abcdefgh"
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    8
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    11
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    64
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    66
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    The last digit of 162329 is 9
    68

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    2
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    Input : 12345 
    Output : First digit: 1
             last digit : 5
    
    Input : 98562
    Output : First digit: 9
             last digit : 2
    6
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    Input : 12345 
    Output : First digit: 1
             last digit : 5
    
    Input : 98562
    Output : First digit: 9
             last digit : 2
    8

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    04
    The last digit of 162329 is 9
    93

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    10
    The last digit of 162329 is 9
    11
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    02

    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    03
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8
    The last digit of 162329 is 9
    17

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    0

    Python3

    The last digit of 3.141 is 1
    5
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    10

    The last digit of 162329 is 9
    21
    The last digit of 162329 is 9
    22

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    14
    The last digit of 162329 is 9
    26
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    23
    The last digit of 162329 is 9
    7
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    18

    Các

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    9

    The last digit of 162329 is 9
    21
    The last digit of 162329 is 9
    41

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 162329 is 9
    44
    The last digit of 162329 is 9
    45
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    The last digit of 162329 is 9
    47

    The last digit of 162329 is 9
    30
    The last digit of 162329 is 9
    26
    The last digit of 162329 is 9
    11
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9

    The last digit of 162329 is 9
    52
    The last digit of 162329 is 9
    53
    The last digit of 162329 is 9
    26
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    5

    The last digit of 162329 is 9
    52
    The last digit of 162329 is 9
    58

    C#

    The last digit of 162329 is 9
    4
    The last digit of 162329 is 9
    60

    str = "abcdefgh"
    0
    The last digit of 162329 is 9
    47

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    8
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    05
    The last digit of 162329 is 9
    7
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    68

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    11
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    64
    The last digit of 162329 is 9
    7
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    74

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    9

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    7
    The last digit of 162329 is 9
    2
    The last digit of 162329 is 9
    7
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 162329 is 9
    8

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    9
    str = "abcdefgh"
    4
    The last digit of 162329 is 9
    04
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    01

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 162329 is 9
    7
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    5

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    5
    The last digit of 3.141 is 1
    04

    The last digit of 3.141 is 1
    05
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8
    The last digit of 162329 is 9
    17

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    0

    PHP

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    15

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    16
    The last digit of 162329 is 9
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    5

    The last digit of 3.141 is 1
    16

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    18
    The last digit of 3.141 is 1
    19
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    The last digit of 3.141 is 1
    21

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    The last digit of 3.141 is 1
    24
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    The last digit of 3.141 is 1
    26
    The last digit of 3.141 is 1
    18
    The last digit of 3.141 is 1
    28

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    The last digit of 3.141 is 1
    32

    The last digit of 3.141 is 1
    33

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    16
    The last digit of 162329 is 9
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    5

    The last digit of 3.141 is 1
    16

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    23
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    The last digit of 3.141 is 1
    43

    The last digit of 3.141 is 1
    33

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    The last digit of 3.141 is 1
    46

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    48
    The last digit of 162329 is 9
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    The last digit of 3.141 is 1
    50
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8
    The last digit of 3.141 is 1
    52

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    54
    The last digit of 162329 is 9
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    18
    The last digit of 3.141 is 1
    56
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    58
    The last digit of 3.141 is 1
    32

    The last digit of 3.141 is 1
    59

    JavaScript

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    60

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    16
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    63

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    1

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    65

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    The last digit of 3.141 is 1
    67

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    9

    The last digit of 162329 is 9
    0

    The last digit of 162329 is 9
    21
    The last digit of 162329 is 9
    41

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    2
    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    8
    The last digit of 162329 is 9
    44
    The last digit of 162329 is 9
    45
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    4
    The last digit of 162329 is 9
    47

    The last digit of 162329 is 9
    0

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    87

    The last digit of 3.141 is 1
    79
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    5

    The last digit of 3.141 is 1
    82
    The last digit of 3.141 is 1
    83
    The last digit of 162329 is 9
    47

    n = 162329
    
    last_digit = int[repr[n][-1]]
    
    print[f"The last digit of {n} is {last_digit}"]
    93

    The last digit of 162329 is 9
    30
    The last digit of 162329 is 9
    26
    The last digit of 162329 is 9
    11
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    9
    O[1]
    Auxiliary Space: O[1]

    The last digit of 162329 is 9
    52
    The last digit of 162329 is 9
    53
    The last digit of 162329 is 9
    26
    pi = 3.141
    last_digit = int[repr[pi][-1]]
    
    print[f"The last digit of {pi} is {last_digit}"]
    8
    str = "abcdefgh"
    lastFour = str[-4:]
    print[lastFour]
    5
    log10[] is a mathematical function present in math.h header file. It returns log base 10 value of the passed parameter to log10[] function. 


    Làm thế nào để bạn in 4 chữ số cuối cùng của một số trong Python?

    Làm thế nào để có được chữ số cuối cùng của một số thập phân trong Python..
    Pi = 3.141 ..
    last_digit = int [repr [pi] [-1]].
    in [f "chữ số cuối cùng của {pi} là {last_digit}"].

    Làm thế nào để bạn có được chữ số cuối cùng của một số trong Python?

    Để tìm chữ số cuối cùng của một số, chúng tôi sử dụng toán tử modulo %.Khi modulo chia cho 10 trả về chữ số cuối cùng của nó.use modulo operator %. When modulo divided by 10 returns its last digit.

    Làm cách nào để nhận được 3 chữ số cuối cùng của một số trong Python?

    Sử dụng toán tử modulo để có được 3 chữ số cuối cùng của một số, ví dụ:last_three = số % 1000.Toán tử modulo sẽ trả về 3 chữ số cuối cùng của số bằng cách tính phần còn lại chia số cho 1000. được sao chép!, e.g. last_three = number % 1000 . The modulo operator will return the last 3 digits of the number by calculating the remainder of dividing the number by 1000. Copied!

    Làm thế nào để bạn có được số 4 chữ số trong Python?

    Phao Python Float 4 chữ số Câu trả lời..
    in [định dạng [432.456, ".2f"]].
    >> 432,45 ..
    print[format[321,".2f"]].
    >> 321.00 ..

    Bài Viết Liên Quan

    Chủ Đề