Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Đọc
Examples:
Input : 1212112 Output : Yes Explanation:- the odd position element is 2+2+1=5 the even position element is 1+1+1+2=5 the difference is 5-5=0.so print yes.
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.
Bàn luậnOne by one traverse digits and find the two sums. If the difference between two sums is 0, print yes, else no.
Python3
Cho một số nguyên dài, chúng ta cần tìm xem sự khác biệt giữa tổng các chữ số lẻ và tổng các chữ số chẵn là 0 hay không. Các chỉ mục bắt đầu từ số 0 [0 chỉ mục dành cho chữ số ngoài cùng bên trái].
Phương pháp 1: Từng một chữ số Traverse và tìm hai tổng. Nếu sự khác biệt giữa hai tổng là 0, in có, khác không.
num
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1__12
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.4
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.7
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.8
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.1
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.4
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.5
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.7
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.0
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.1
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.2
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.3
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 409
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 400
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.3
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.4
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.5
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.6
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.7
=
=
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 402
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.8
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 407
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.3
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Odd digit sum : 36 Even digit sum : 408
Odd digit sum : 36 Even digit sum : 409
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 409
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 400
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 402
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.1
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 407
Các This can be easily solved using divisibility of 11. This condition is only satisfied if the number is divisible by 11. So check the number is divisible by 11 or not.
Input : test_list = [345, 893]
Output :
Odd digit sum : 20
Even digit sum : 12
Explanation : 4 + 8 = 12, even summation.
3Odd digit sum : 36
Even digit sum : 40
6Input :12345
Output : No
Explanation:-
the odd position element is 1+3+5=9
the even position element is 2+4=6
the difference is 9-6=3 not equal
to zero. So print no.
1______755
Phương pháp 2: Điều này có thể dễ dàng giải quyết bằng cách sử dụng khả năng chia rẽ 11. Điều kiện này chỉ được thỏa mãn nếu số này chia hết cho 11. Vì vậy, hãy kiểm tra số được chia cho 11 hoặc không. & NBSP;
Thí dụ
Python
Odd digit sum : 36 Even digit sum : 407
Odd digit sum : 36 Even digit sum : 408
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.3
num
0 num
1Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.6
num
3 =
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Odd digit sum : 36 Even digit sum : 409
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.3
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Odd digit sum : 36 Even digit sum : 408
Odd digit sum : 36 Even digit sum : 409
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 409
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 400
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.3
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Odd digit sum : 36 Even digit sum : 405
Odd digit sum : 36 Even digit sum : 409
num
8=
=
0
Python3
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.05
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.07
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.4
=
2Phương pháp: Sử dụng phương pháp hiểu danh sách và chức năng liệt kê
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.08
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.10____10
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.122
Is
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.65
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.68
Odd digit sum : 36 Even digit sum : 409
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 409
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 400
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.65
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.75
Odd digit sum : 36 Even digit sum : 409
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.36
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.10____10
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.122
Bài viết sau đây cho thấy cách đưa ra một danh sách số nguyên, chúng ta có thể tạo ra tổng của tất cả các chữ số lẻ và thậm chí của nó.
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.
Phương pháp 1: Sử dụng vòng lặp, str [] và int []Using loop, str[] and int[]
Trong đó, trước tiên chúng tôi chuyển đổi từng phần tử thành chuỗi và sau đó lặp lại cho từng phần tử của nó và thêm vào tổng hợp tương ứng bằng cách chuyển đổi sang số nguyên.
Python3
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.77___
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.92
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.95
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.96
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.99
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.4
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.03
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.05
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.3
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.4
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.08
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.6
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.11
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 402
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.4
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.15
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.6
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.7
=
__Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.222
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.99
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.27
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 402
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 409
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 400
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.222
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.96
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.27
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.39
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.42
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.45
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.48
Đầu ra
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 40
Phương pháp 2: Sử dụng Loop và Sum []Using loop and sum[]
Trong đó, chúng tôi thực hiện nhiệm vụ nhận tổng hợp bằng Sum [] và Loop được sử dụng để thực hiện nhiệm vụ lặp qua từng phần tử.
Python3
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.77___
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.92
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.95
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.96
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.99
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.4
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.03
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.05
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.3
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.4
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.08
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.6
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.11
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 402
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.4
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.15
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.6
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.7
=
__Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.39
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.42
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.45
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.48
Đầu ra
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 40
Phương pháp 2: Sử dụng Loop và Sum [] Using list comprehension
Python3
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.77___
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.96
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.99
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.4
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.03
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.05
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.3
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.4
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.08
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.6
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.11
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 402
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.4
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.15
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.6
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.7
=
__Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.222
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.99
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.27
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.39
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.42
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.45
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.48
Đầu ra
Odd digit sum : 36 Even digit sum : 40
Phương pháp 2: Sử dụng Loop và Sum [] Using the enumerate function
Python3
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.77___
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.96
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.99
=
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.4
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.03
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.05
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.3
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.4
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.08
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.6
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.11
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 402
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.4
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.15
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.6
Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation.7
=
__Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.222
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.99
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
=
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.0
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.27
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.39
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.42
Odd digit sum : 36 Even digit sum : 406
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.1
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.45
The original list is : [345, 893, 1948, 34, 2346] Odd digit sum : 36 Even digit sum : 404
Input :12345 Output : No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.6
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.48
Đầu ra
Odd digit sum : 36 Even digit sum : 40