Để lấy 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 lại thành số nguyên
Ví dụ: hãy lấy số thập phân cuối cùng của xấp xỉ ba số 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}"]
đầu ra
The last digit of 3.141 is 1
Sự kết luận
Hôm nay bạn đã học cách lấy số cuối cùng từ một chữ số
Tóm 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 số nguyên
9 25
9 261
9 257
9 289
9 20
The last digit of 3.141 is 13062
9 264
The last digit of 3.141 is 13116
9 289
The last digit of 3.141 is 1327
The last digit of 3.141 is 13067
9 25____13069
9 25
9 28
9 29
9 274
9 248
9 276
9 25
9 25
9 278
9 25
9 28
9 281
9 282
The last digit of 3.141 is 1327
The last digit of 3.141 is 1328
9 285
9 261
9 257
9 234
The last digit of 3.141 is 1372
9 290____291____257
The last digit of 3.141 is 1302
The last digit of 3.141 is 1328
9 290____296
9 297
C#
The last digit of 3.141 is 13098
The last digit of 3.141 is 13099
The last digit of 3.141 is 142
9 201
The last digit of 3.141 is 1426
The last digit of 3.141 is 13157
9 25
9 25
The last digit of 3.141 is 137
9 25
The last digit of 3.141 is 1463
9 20
9 21
9 20
9 23
9 25
9 24
9 22____13102
9 22
9 20
The last digit of 3.141 is 13105____20
The last digit of 3.141 is 14221
9 25
9 22____13111
9 22______13113
9 20
The last digit of 3.141 is 13182
9 20
The last digit of 3.141 is 14230
9 25
9 22____13119
9 22____28
9 29
9 25
The last digit of 3.141 is 1550
9 25
9 25
The last digit of 3.141 is 1551
9 25
The last digit of 3.141 is 1463
9 20
The last digit of 3.141 is 1553
9 20
9 23
9 25
9 24
9 22____1558
9 22____28
The last digit of 3.141 is 1311
9 25
The last digit of 3.141 is 1550
9 25
9 25
The last digit of 3.141 is 1313
9 25
The last digit of 3.141 is 1425
The last digit of 3.141 is 1463
9 227
9 259
9 25
9 24
9 22____20
The last digit of 3.141 is 1319
9 22____266
The last digit of 3.141 is 14272
The last digit of 3.141 is 1302
9 240
9 25
The last digit of 3.141 is 1550
The last digit of 3.141 is 1550
The last digit of 3.141 is 14278
PHP
9 274
The last digit of 3.141 is 155
The last digit of 3.141 is 131
The last digit of 3.141 is 137
9 278
9 21____280
The last digit of 3.141 is 1328
9 24
9 25
The last digit of 3.141 is 13102
9 25
The last digit of 3.141 is 14291
The last digit of 3.141 is 14292
9 280
9 218
9 25
The last digit of 3.141 is 13111
9 25
9 280
The last digit of 3.141 is 14299
9 280
The last digit of 3.141 is 14601
The last digit of 3.141 is 14291
The last digit of 3.141 is 14603
9 25____13119
9 25
9 28
9 280
The last digit of 3.141 is 1372
The last digit of 3.141 is 1550
The last digit of 3.141 is 1551
9 278
The last digit of 3.141 is 1553____280
The last digit of 3.141 is 1328
9 24
9 25
The last digit of 3.141 is 1558
9 25
9 28
9 289
9 280
The last digit of 3.141 is 15516
The last digit of 3.141 is 1550
The last digit of 3.141 is 15518
9 280
The last digit of 3.141 is 15520
The last digit of 3.141 is 15521
9 21____280
The last digit of 3.141 is 14631
The last digit of 3.141 is 1302
The last digit of 3.141 is 14633
The last digit of 3.141 is 15527
The last digit of 3.141 is 1553
9 280____14637
The last digit of 3.141 is 15531
The last digit of 3.141 is 1372
The last digit of 3.141 is 14640
The last digit of 3.141 is 14641
Javascript
The last digit of 3.141 is 15535
The last digit of 3.141 is 14643
9 276
The last digit of 3.141 is 137
9 278
The last digit of 3.141 is 15542
9 24
9 25
9 25
The last digit of 3.141 is 13102
9 25
The last digit of 3.141 is 14653
9 25
The last digit of 3.141 is 13111
9 25
The last digit of 3.141 is 14657
9 25____13119
9 25
9 28
9 29
The last digit of 3.141 is 1550
The last digit of 3.141 is 1551
9 278
The last digit of 3.141 is 14666
9 25
9 25
The last digit of 3.141 is 1558
9 25
9 28
The last digit of 3.141 is 14672
The last digit of 3.141 is 1550
The last digit of 3.141 is 15518
The last digit of 3.141 is 15579
_______14676____1302____1328
The last digit of 3.141 is 14679
The last digit of 3.141 is 14680
The last digit of 3.141 is 1328
The last digit of 3.141 is 14682
The last digit of 3.141 is 15588
Đầu ra
9 2
Độ phức tạp về thời gian. O[1]
Không gian phụ. Ô[1]
Lưu ý quan trọng. log10[] là một hàm toán học có trong toán học. tập tin tiêu đề h. Nó trả về giá trị nhật ký cơ sở 10 của tham số đã truyền cho hàm log10[].