Làm thế nào để bạn tìm thấy hai chữ số đầu tiên của một số trong python?
Chương trình phải chấp nhận một số nguyên N làm đầu vào. Chương trình phải in hiệu tuyệt đối giữa hai chữ số đầu tiên và hai chữ số cuối cùng trong N làm đầu ra Show (Các) Điều kiện biên. Định dạng đầu vào. Định dạng đầu ra. Ví dụ Đầu vào/Đầu ra 1. Đầu ra. Giải thích. Ví dụ Đầu vào/Đầu ra 2. Đầu ra.
Đăng lạiPhản ứng của bạn là gì?Kinh ngạc 0đang yêu 1Rất hữu ích 0vỗ tay 0
01626 Cho số nguyên dương N (ít nhất chứa hai chữ số). Nhiệm vụ là viết chương trình Python để cộng chữ số đầu tiên và chữ số cuối cùng của số N đã cho ví dụ Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8. Input: N = 73 Output: 10 Phương pháp 1. Triển khai chuỗi
Biểu diễn chuỗi Python3Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.50 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.51 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.52 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.53
Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.54 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.51 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.52 Input: N = 73 Output: 100 Input: N = 73 Output: 101
Input: N = 73 Output: 102 Input: N = 73 Output: 103 Input: N = 73 Output: 104 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.52 Input: N = 73 Output: 106 Input: N = 73 Output: 107 Input: N = 73 Output: 108 Input: N = 73 Output: 109 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.20 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.52 Input: N = 73 Output: 106 Input: N = 73 Output: 107 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.24 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.25 Input: N = 73 Output: 109
Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.27 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.28 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.52 Input: N = 73 Output: 104 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.501 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.20
Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.503 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.504 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.505____1506 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.507 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.508 Input: N = 1247 Output: 8 Explanation: First digit is 1 and Last digit is 7. So, addition of these two (1 + 7) is equal to 8.509 đầu ra
Phương pháp 2. Giải nó bằng một số nguyên
|