Hướng dẫn find the difference between the sum of odd and even numbers from a list of 5 numbers in python - tìm sự khác biệt giữa tổng các số lẻ và số chẵn từ danh sách 5 số trong python

Xem thảo luận

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

Lưu bài viết

  • Đọc
  • Bàn luận
  • 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 : 40
    
    9
    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    0

    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 : 40
    
    2
    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 : 40
    
    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
    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    7

    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 : 40
    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.
    1
    Odd digit sum : 36
    Even digit sum : 40
    8
    Odd digit sum : 36
    Even digit sum : 40
    9

    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    9
    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    0

    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    2
    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 : 40
    
    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
    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    7

    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. 
    3
    Odd digit sum : 36
    Even digit sum : 40
    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.
    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 : 40
    7
    Odd digit sum : 36
    Even digit sum : 40
    8

    Input : test_list = [345, 893] 
    Output : 
    Odd digit sum : 20 
    Even digit sum : 12 
    Explanation : 4 + 8 = 12, even summation. 
    3num 0 num 1
    Input : 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 : 40
    9

    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 : 40
    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.
    1
    Odd digit sum : 36
    Even digit sum : 40
    8
    Odd digit sum : 36
    Even digit sum : 40
    9

    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    9
    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    0

    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 : 40
    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.
    1
    Odd digit sum : 36
    Even digit sum : 40
    5
    Odd digit sum : 36
    Even digit sum : 40
    9

    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 =2

    Phươ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 : 40
    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.
    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 : 40
    9

    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    9
    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    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.
    65
    Odd digit sum : 36
    Even digit sum : 40
    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.
    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 : 40
    9

    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 : 40
    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.
    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 : 40
    
    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.
    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 : 40
    
    2
    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 : 40
    
    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.
    27

    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    2
    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    9
    The original list is : [345, 893, 1948, 34, 2346]
    Odd digit sum : 36
    Even digit sum : 40
    
    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.
    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 : 40
    
    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.
    27

    Odd digit sum : 36
    Even digit sum : 40
    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.
    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 : 40
    
    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 : 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 : 40
    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.
    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 : 40
    
    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 : 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 : 40
    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.
    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 : 40
    
    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.
    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 : 40
    
    2
    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 : 40
    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.
    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 : 40
    
    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 : 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 : 40
    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.
    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 : 40
    
    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 : 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 : 40
    
    2
    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 : 40
    
    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.
    27

    Odd digit sum : 36
    Even digit sum : 40
    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.
    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 : 40
    
    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 : 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 : 40
    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.
    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 : 40
    
    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 : 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 : 40
    
    2
    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 : 40
    
    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.
    27

    Odd digit sum : 36
    Even digit sum : 40
    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.
    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 : 40
    
    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 : 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 : 40
    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.
    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 : 40
    
    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 : 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


    Làm thế nào để bạn nói sự khác biệt giữa số chẵn và số lẻ trong Python?

    Các mã cần thiết được cung cấp dưới đây. num = int [input [nhập bất kỳ số nào để kiểm tra xem nó là lẻ hay thậm chí: Đầu ra] đầu ra: Nhập bất kỳ số nào để kiểm tra xem nó là lẻ hay thậm chí: 887 887 là lẻ.if [num % 2] == 0: print [“The number is even”] else: print [“The provided number is odd”] Output: Enter any number to test whether it is odd or even: 887 887 is odd.

    Sự khác biệt giữa tổng số chẵn và tổng số lẻ trong khoảng từ 10 đến 20 là gì?

    Hoàn thành Trả lời từng bước: Từ giải pháp trên, sự khác biệt của tổng số chẵn và tổng số lẻ trong khoảng từ 10 đến 20 là 15.15.

    Làm thế nào để bạn tìm thấy tổng số số lẻ trong danh sách trong Python?

    Khoa học dữ liệu thực tế bằng cách sử dụng Python, chúng ta phải tìm tổng của tất cả các yếu tố kỳ lạ từ danh sách.Vì vậy, nếu đầu vào giống như nums = [5,7,6,4,6,9,3,6,2], thì đầu ra sẽ là 24 vì 5+7+9+3 = 24. Trả lại tổng củacác phần tử trong l bằng cách chuyển l vào hàm sum [].return the sum of elements in l by passing l into sum[] function.

    Làm thế nào để bạn tìm thấy tổng số số lẻ và chẵn?

    [i] Tổng của hai số lẻ là một số lẻ.[ii] Tổng của hai số chẵn là một số chẵn.[iii] Tổng số chẵn và số lẻ là một số lẻ.The sum of two odd numbers is an odd number. [ii] The sum of two even numbers is an even number. [iii] The sum of an even number and an odd number is an odd number.

    Bài Viết Liên Quan

    Chủ Đề