Điều gì sẽ là đầu ra của mã Python sau list1 1 3 4 2 x list1 pop 2 print set x

A list is a container which holds comma-separated values (items or elements) between square brackets where items or elements need not all have the same type

You may read our Python list tutorial before solving the following exercises

[An editor is available at the bottom of the page to write and execute the scripts. ]

1. Write a Python program to sum all the items in a list. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

2. Write a Python program to multiply all the items in a list. Go to the editor
Click me to see the sample solution

3. Write a Python program to get the largest number from a list. Go to the editor
Click me to see the sample solution

4. Write a Python program to get the smallest number from a list. Go to the editor
Click me to see the sample solution

5. Viết chương trình Python để đếm số lượng chuỗi có độ dài chuỗi từ 2 trở lên và ký tự đầu tiên và ký tự cuối cùng giống nhau từ một danh sách các chuỗi đã cho. Chuyển đến trình chỉnh sửa
Danh sách mẫu. ['abc', 'xyz', 'aba', '1221']
Expected Result . 2
Click me to see the sample solution

6. Write a Python program to get a list, sorted in increasing order by the last element in each tuple from a given list of non-empty tuples. Go to the editor
Sample List . [(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]
Expected Result . [(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)]
Nhấp vào tôi để xem giải pháp mẫu

7. Viết chương trình Python để loại bỏ các bản sao khỏi danh sách. Go to the editor
Click me to see the sample solution

8. Write a Python program to check a list is empty or not. Go to the editor
Click me to see the sample solution

9. Write a Python program to clone or copy a list. Go to the editor
Click me to see the sample solution

10. Write a Python program to find the list of words that are longer than n from a given list of words. Go to the editor
Click me to see the sample solution

11. Viết hàm Python nhận hai danh sách và trả về True nếu chúng có ít nhất một thành viên chung. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

12. Write a Python program to print a specified list after removing the 0th, 4th and 5th elements. Go to the editor
Sample List . ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']
Expected Output . ['Green', 'White', 'Black']
Click me to see the sample solution

13. Write a Python program to generate a 3*4*6 3D array whose each element is *. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

14. Write a Python program to print the numbers of a specified list after removing even numbers from it. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

15. Viết chương trình Python để xáo trộn và in một danh sách đã chỉ định. Go to the editor
Click me to see the sample solution

16. Write a Python program to generate and print a list of first and last 5 elements where the values are square of numbers between 1 and 30 (both included). Go to the editor
Click me to see the sample solution

17. Write a Python program to generate and print a list except for the first 5 elements, where the values are square of numbers between 1 and 30 (both included). Go to the editor
Click me to see the sample solution

18. Viết chương trình Python để tạo tất cả các hoán vị của một danh sách trong Python. Go to the editor
Click me to see the sample solution

19. Write a Python program to get the difference between the two lists. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

20. Viết chương trình Python truy cập chỉ mục của danh sách. Go to the editor
Click me to see the sample solution

21. Write a Python program to convert a list of characters into a string. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

22. Write a Python program to find the index of an item in a specified list. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

23. Viết chương trình Python để làm phẳng một danh sách nông. Go to the editor
Click me to see the sample solution

24. Viết chương trình Python để thêm danh sách vào danh sách thứ hai. Go to the editor
Click me to see the sample solution

25. Write a Python program to select an item randomly from a list. Go to the editor
Click me to see the sample solution

26. Viết chương trình python để kiểm tra xem hai danh sách có giống nhau không. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

27. Viết chương trình Python để tìm số nhỏ thứ hai trong danh sách. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

28. Viết chương trình Python để tìm số lớn thứ hai trong danh sách. Go to the editor
Click me to see the sample solution

29. Viết chương trình Python để lấy các giá trị duy nhất từ ​​​​danh sách. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

30. Write a Python program to get the frequency of the elements in a list. Go to the editor
Click me to see the sample solution

31. Viết chương trình Python để đếm số phần tử trong danh sách trong một phạm vi xác định. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

32. Write a Python program to check whether a list contains a sublist. Go to the editor
Click me to see the sample solution

33. Viết chương trình Python để tạo tất cả các danh sách con của danh sách. Go to the editor
Click me to see the sample solution

34. Write a Python program using Sieve of Eratosthenes method for computing primes upto a specified number. Go to the editor
Note. In mathematics, the sieve of Eratosthenes, (Ancient Greek. κόσκινον Ἐρατοσθένους, kóskinon Eratosthénous) một trong số các sàng số nguyên tố, là một thuật toán cổ xưa, đơn giản để tìm tất cả các số nguyên tố cho đến bất kỳ giới hạn nào.
Nhấp vào tôi để xem giải pháp mẫu

35. Write a Python program to create a list by concatenating a given list which range goes from 1 to n. Go to the editor
Sample list . ['p', 'q']
n =5
Sample Output . ['p1', 'q1', 'p2', 'q2', 'p3', 'q3', 'p4', 'q4', 'p5', 'q5']
Click me to see the sample solution

36. Viết chương trình Python để lấy số hoặc chuỗi nhận dạng duy nhất của biến. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

37. Write a Python program to find common items from two lists. Go to the editor
Click me to see the sample solution

38. Viết chương trình Python để thay đổi vị trí của mọi giá trị thứ n với (n+1)th trong danh sách. Chuyển đến trình chỉnh sửa
Danh sách mẫu. [0,1,2,3,4,5]
Expected Output. [1, 0, 3, 2, 5, 4]
Click me to see the sample solution

39. Write a Python program to convert a list of multiple integers into a single integer. Chuyển đến trình chỉnh sửa
Danh sách mẫu. [11, 33, 50]
Kết quả dự kiến. 113350
Click me to see the sample solution

40. Viết chương trình Python để chia danh sách dựa trên ký tự đầu tiên của từ. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

41. Viết chương trình Python để tạo nhiều danh sách. Go to the editor
Click me to see the sample solution

42. Viết chương trình Python để tìm các giá trị bị thiếu và bổ sung trong hai danh sách. Chuyển đến trình chỉnh sửa
Dữ liệu mẫu. Missing values in second list. b,a,c
Additional values in second list. g,h
Click me to see the sample solution

43. Viết chương trình Python để chia danh sách thành các biến khác nhau. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

44. Write a Python program to generate groups of five consecutive numbers in a list. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

45. Write a Python program to convert a pair of values into a sorted unique array. Go to the editor
Click me to see the sample solution

46. Viết chương trình Python để chọn các mục lẻ của danh sách. Go to the editor
Click me to see the sample solution

47. Write a Python program to insert an element before each element of a list. Go to the editor
Click me to see the sample solution

48. Write a Python program to print a nested lists (each list on a new line) using the print() function. Go to the editor
Click me to see the sample solution

49. Viết chương trình Python để chuyển đổi danh sách thành danh sách từ điển. Chuyển đến trình chỉnh sửa
Danh sách mẫu. ["Đen", "Đỏ", "Hạt dẻ", "Vàng"], ["#000000", "#FF0000", "#800000", "#FFFF00"]
Kết quả dự kiến. [{'color_name'. 'Đen', 'mã_màu'. '#000000'}, {'color_name'. 'Đỏ', 'mã_màu'. '#FF0000'}, {'tên_màu'. 'Maroon', 'color_code'. '#800000'}, {'color_name'. 'Vàng', 'mã_màu'. '#FFFF00'}]
Nhấp vào tôi để xem giải pháp mẫu

50. Viết chương trình Python để sắp xếp danh sách các từ điển lồng nhau. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

51. Viết chương trình Python để tách danh sách mọi phần tử thứ N. Chuyển đến trình chỉnh sửa
Danh sách mẫu. ['a', 'b', 'c', 'd', 'e', ​​'f', 'g', 'h', 'i', 'j', 'k', 'l', ' . [['a', 'd', 'g', 'j', 'm'], ['b', 'e', ​​'h', 'k', 'n'], ['c',
Expected Output: [['a', 'd', 'g', 'j', 'm'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']]
Click me to see the sample solution

52. Viết chương trình Python để tính toán sự khác biệt giữa hai danh sách. Chuyển đến trình chỉnh sửa
Dữ liệu mẫu. ["đỏ", "cam", "lục", "lam", "trắng"], ["đen", "vàng", "lục", "lam"]
Kết quả dự kiến.
Color1-Color2. ['trắng', 'cam', 'đỏ']
Color2-Color1. ['đen', 'vàng']
Nhấp vào tôi để xem giải pháp mẫu

53. Viết chương trình Python tạo danh sách có vô số phần tử. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

54. Viết chương trình Python nối các phần tử của một danh sách. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

55. Viết chương trình Python để xóa các cặp giá trị khóa khỏi danh sách từ điển. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

56. Viết chương trình Python để chuyển đổi một chuỗi thành một danh sách. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

57. Viết chương trình Python để kiểm tra xem tất cả các phần tử của một danh sách các chuỗi đã cho có bằng một chuỗi đã cho hay không. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

58. Viết chương trình Python để thay thế phần tử cuối cùng trong một danh sách bằng một danh sách khác. Chuyển đến trình chỉnh sửa
Dữ liệu mẫu. [1, 3, 5, 7, 9, 10], [2, 4, 6, 8]
Kết quả dự kiến. [1, 3, 5, 7, 9, 2, 4, 6, 8]
Nhấp vào tôi để xem giải pháp mẫu

59. Viết chương trình Python để kiểm tra xem phần tử thứ n có tồn tại trong một danh sách đã cho hay không. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

60. Viết chương trình Python để tìm một bộ, giá trị chỉ số thứ hai nhỏ nhất từ ​​​​danh sách các bộ. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

61. Viết chương trình Python để tạo danh sách từ điển trống. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

62. Viết chương trình Python để in danh sách các phần tử được phân tách bằng dấu cách. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

63. Viết chương trình Python để chèn một chuỗi đã cho vào đầu tất cả các mục trong danh sách. Chuyển đến trình chỉnh sửa
Danh sách mẫu. [1,2,3,4], chuỗi. emp
Đầu ra dự kiến. ['emp1', 'emp2', 'emp3', 'emp4']
Nhấp vào tôi để xem giải pháp mẫu

64. Viết chương trình Python để duyệt đồng thời hai danh sách. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

65. Viết chương trình Python để di chuyển tất cả các chữ số 0 đến cuối một danh sách các số đã cho. Chuyển đến trình chỉnh sửa
Đầu ra dự kiến.
Danh sách gốc.
[3, 4, 0, 0, 0, 6, 2, 0, 6, 7, 6, 0, 0, 0, 9, 10, 7, 4, 4, 5, .
Move all zero digits to end of the said list of numbers:
[3, 4, 6, 2, 6, 7, 6, 9, 10, 7, 4, 4, 5, 3, 2, 9, 7, 1, 0, 0,
Click me to see the sample solution

66. Viết chương trình Python tìm danh sách trong danh sách có tổng các phần tử lớn nhất. Chuyển đến trình chỉnh sửa
Danh sách mẫu. [1,2,3], [4,5,6], [10,11,12], [7,8,9]
Kết quả dự kiến. [10, 11, 12]
Nhấp vào tôi để xem giải pháp mẫu

67. Viết chương trình Python để tìm tất cả các giá trị trong danh sách lớn hơn một số đã chỉ định. Chuyển đến trình chỉnh sửa
Nhấp vào tôi để xem giải pháp mẫu

68. Write a Python program to extend a list without append. Go to the editor
Sample data. [10, 20, 30]
[40, 50, 60]
Kết quả dự kiến. [40, 50, 60, 10, 20, 30]
Nhấp vào tôi để xem giải pháp mẫu

69. Write a Python program to remove duplicates from a list of lists. Chuyển đến trình chỉnh sửa
Danh sách mẫu. [[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]
Danh sách mới. [[10, 20], [30, 56, 25], [33], [40]]
Nhấp vào tôi để xem giải pháp mẫu

70. Viết chương trình Python để tìm các mục bắt đầu bằng ký tự cụ thể từ một danh sách nhất định. Go to the editor
Expected Output.
Original list.
['abcd', 'abc', 'bcd', 'bike', 'cder', 'cdsw', 'sdfsdf', 'dagfa', 'acid']
Items start with a from the said list:
['abcd', 'abc', 'acjd']
Items start with d from the said list.
['dagfa']
Các mục bắt đầu bằng w từ danh sách đã nêu.
[]
Click me to see the sample solution

71. Write a Python program to check whether all dictionaries in a list are empty or not. Go to the editor
Sample list . [{},{},{}]
Trả về giá trị. True
Sample list . [{1,2},{},{}]
Return value . Sai
Nhấp vào tôi để xem giải pháp mẫu

72. Write a Python program to flatten a given nested list structure. Chuyển đến trình chỉnh sửa
Danh sách gốc. [0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]
Flatten list.
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]
Click me to see the sample solution

73. Write a Python program to remove consecutive duplicates of a given list. Go to the editor
Original list.
[0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]
After removing consecutive duplicates:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]
Nhấp vào tôi để xem giải pháp mẫu

74. Write a Python program to pack consecutive duplicates of a given list elements into sublists. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]
After packing consecutive duplicates of the said list elements into sublists:
[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7],
Click me to see the sample solution

75. Viết chương trình Python để tạo danh sách phản ánh mã hóa độ dài chạy từ danh sách số nguyên đã cho hoặc danh sách ký tự đã cho. Go to the editor
Original list.
[1, 1, 2, 3, 4, 4. 3, 5, 1]
Danh sách phản ánh mã hóa thời lượng chạy từ danh sách nói trên.
[[2, 1], [1, 2], [1, 3], [1, 4], [1, 4. 3], [1, 5], [1, 1]]
Original String.
automatically
List reflecting the run-length encoding from the said string.
[[1, 'a'], [1, 'u'], [1, 't'], [1, 'o'], [1, 'm'],
Click me to see the sample solution

76. Viết chương trình Python để tạo danh sách phản ánh mã hóa độ dài chạy đã sửa đổi từ danh sách số nguyên đã cho hoặc danh sách ký tự đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[1, 1, 2, 3, 4, 4, 5, 1]
Danh sách phản ánh mã hóa thời lượng chạy đã sửa đổi từ danh sách nói trên.
[[2, 1], 2, 3, [2, 4], 5, 1]
Chuỗi gốc.
aabcddddadnss
Danh sách phản ánh mã hóa thời lượng chạy đã sửa đổi từ chuỗi đã nói.
[[2, 'a'], 'b', 'c', [4, 'd'], 'a', 'd', 'n', [2, '
Click me to see the sample solution

77. Viết chương trình Python để giải mã danh sách đã cho được mã hóa theo độ dài chạy. Chuyển đến trình chỉnh sửa
Danh sách gốc được mã hóa.
[[2, 1], 2, 3, [2, 4], 5, 1]
Giải mã danh sách cho biết đã mã hóa thời lượng chạy.
[1, 1, 2, 3, 4, 4, 5, 1]
Nhấp vào tôi để xem giải pháp mẫu

78. Viết chương trình Python để chia một danh sách đã cho thành hai phần trong đó cho trước độ dài của phần đầu tiên của danh sách. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[1, 1, 2, 3, 4, 4, 5, 1]
Độ dài của phần đầu tiên của danh sách. 3
Chia danh sách nói trên thành hai phần.
([1, 1, 2], [3, 4, 4, 5, 1])
Nhấp vào tôi để xem giải pháp mẫu

79. Viết chương trình Python để xóa phần tử thứ K khỏi danh sách đã cho, in danh sách mới. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[1, 1, 2, 3, 4, 4, 5, 1]
Sau khi loại bỏ phần tử ở vị trí thứ k của danh sách nói trên.
[1, 1, 3, 4, 4, 5, 1]
Nhấp vào tôi để xem giải pháp mẫu

80. Viết chương trình Python để chèn một phần tử tại một vị trí xác định vào một danh sách nhất định. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[1, 1, 2, 3, 4, 4, 5, 1]
Sau khi chèn phần tử vào vị trí thứ k trong danh sách nói trên.
[1, 1, 12, 2, 3, 4, 4, 5, 1]
Nhấp vào tôi để xem giải pháp mẫu

81. Viết chương trình Python để trích xuất một số phần tử được chọn ngẫu nhiên từ một danh sách nhất định. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[1, 1, 2, 3, 4, 4, 5, 1]
Được chọn ngẫu nhiên 3 số trong danh sách trên.
[4, 4, 1]
Nhấp vào tôi để xem giải pháp mẫu

82. Viết chương trình Python để tạo tổ hợp n đối tượng riêng biệt được lấy từ các phần tử của danh sách đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc. [1, 2, 3, 4, 5, 6, 7, 8, 9] Tổ hợp của 2 đối tượng riêng biệt. [1, 2] [1, 3] [1, 4] [1, 5]. [7, 8] [7, 9] [8, 9]
Nhấp vào tôi để xem giải pháp mẫu

83. Viết chương trình Python để làm tròn mọi số của một danh sách các số đã cho và in tổng tổng nhân với độ dài của danh sách. Chuyển đến trình chỉnh sửa
Danh sách gốc. [22. 4, 4. 0, -16. 22, -9. 1, 11. 0, -12. 22, 14. 2, -5. 2, 17. 5]
Kết quả.
243
Nhấp vào tôi để xem giải pháp mẫu

84. Viết chương trình Python để làm tròn số của một danh sách đã cho, in các số nhỏ nhất và lớn nhất và nhân các số đó với 5. In các số duy nhất theo thứ tự tăng dần được phân tách bằng dấu cách. Chuyển đến trình chỉnh sửa
Danh sách gốc. [22. 4, 4. 0, 16. 22, 9. 1, 11. 0, 12. 22, 14. 2, 5. 2, 17. 5]
Giá trị tối thiểu. 4
Giá trị tối đa. 22
Kết quả.
20 25 45 55 60 70 80 90 110
Nhấp vào tôi để xem giải pháp mẫu

85. Viết chương trình Python để tạo danh sách đa chiều (danh sách các danh sách) với các số không. Chuyển đến trình chỉnh sửa
Danh sách đa chiều. [[0, 0], [0, 0], [0, 0]]
Nhấp vào tôi để xem giải pháp mẫu

86. Viết chương trình Python để tạo lưới 3X3 với các số. Chuyển đến trình chỉnh sửa
lưới 3X3 có số.
[[1, 2, 3], [1, 2, 3], [1, 2, 3]]
Nhấp vào tôi để xem giải pháp mẫu

87. Viết chương trình Python để đọc ma trận từ bàn điều khiển và in tổng cho mỗi cột. Chấp nhận các hàng, cột và thành phần ma trận cho mỗi cột được phân tách bằng khoảng trắng (cho mỗi hàng) làm đầu vào từ người dùng. Chuyển đến trình chỉnh sửa
Nhập hàng. 2
Cột đầu vào. 2
Nhập số phần tử liên tiếp (1, 2, 3).
1 2
3 4
tổng cho mỗi cột.
4 6
Nhấp vào tôi để xem giải pháp mẫu

88. Viết chương trình Python đọc ma trận vuông từ bàn điều khiển và in tổng đường chéo chính của ma trận. Chấp nhận kích thước của ma trận vuông và các phần tử cho mỗi cột được phân tách bằng khoảng trắng (cho mỗi hàng) làm đầu vào từ người dùng. Go to the editor
Input the size of the matrix. 3
2 3 4
4 5 6
3 4 7
Sum of matrix primary diagonal.
14
Click me to see the sample solution

89. Write a Python program to Zip two given lists of lists. Go to the editor
Original lists.
[[1, 3], [5, 7], [9, 11]]
[[2, 4], [6, 8], [10, 12, 14]]
Zipped list.
[[1, 3, 2, 4], [5, 7, 6, 8], [9, 11, 10, 12, 14]]
Click me to see the sample solution

90. Viết chương trình Python để đếm số danh sách trong một danh sách cho trước. Go to the editor
Original list.
[[1, 3], [5, 7], [9, 11], [13, 15, 17]]
Number of lists in said list of lists.
4
Original list.
[[2, 4], [[6, 8], [4, 5, 8]], [10, 12, 14]]
Number of lists in said list of lists.
3
Click me to see the sample solution

91. Write a Python program to find the list with maximum and minimum length. Go to the editor
Original list.
[[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]
List with maximum length of lists.
(3, [13, 15, 17])
List with minimum length of lists.
(1, [0])
Original list.
[[0], [1, 3], [5, 7], [9, 11], [3, 5, 7]]
List with maximum length of lists.
(3, [3, 5, 7])
List with minimum length of lists.
(1, [0])
Original list.
[[12], [1, 3], [1, 34, 5, 7], [9, 11], [3, 5, 7]]
List with maximum length of lists.
(4, [1, 34, 5, 7])
List with minimum length of lists.
(1, [12])
Click me to see the sample solution

92. Write a Python program to check if a nested list is a subset of another nested list. Go to the editor
Original list.
[[1, 3], [5, 7], [9, 11], [13, 15, 17]]
[[1, 3], [13, 15, 17]]
If the one of the said list is a subset of another.
True
Original list.
[[[1, 2], [2, 3]], [[3, 4], [5, 6]]]
[[[3, 4], [5, 6]]]
If the one of the said list is a subset of another.
True
Original list.
[[[1, 2], [2, 3]], [[3, 4], [5, 7]]]
[[[3, 4], [5, 6]]]
If the one of the said list is a subset of another.
False
Click me to see the sample solution

93. Write a Python program to count the number of sublists contain a particular element. Go to the editor
Original list.
[[1, 3], [5, 7], [1, 11], [1, 15, 7]]
Đếm 1 trong số đã nói .
3
Đếm 7 trong danh sách nói trên.
2
Danh sách gốc.
[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', ' .
Count 'A' in the said list:
3
Đếm 'E' trong danh sách nói trên.
1
Nhấp vào tôi để xem giải pháp mẫu

94. Viết chương trình Python để đếm số lượng danh sách con duy nhất trong một danh sách nhất định. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]]
Number of unique lists of the said list:
{(1, 3). 2, (5, 7). 2, (13, 15, 17). 1, (9, 11). 1}
Danh sách gốc.
[['xanh', 'cam'], ['đen'], ['xanh', 'cam'], ['trắng']]
Number of unique lists of the said list:
{('xanh', 'cam'). 2, ('đen',). 1, ('trắng',). 1}
Nhấp vào tôi để xem giải pháp mẫu

95. Write a Python program to sort each sublist of strings in a given list of lists. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]]
Sort the list of lists by length and value:
[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]
Click me to see the sample solution

96. Write a Python program to sort a given list of lists by length and value. Go to the editor
Original list.
[[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]]
Sort the list of lists by length and value.
[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]
Click me to see the sample solution

97. Write a Python program to remove sublists from a given list of lists, which contains an element outside a given range. Go to the editor
Original list.
[[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]]
After removing sublists from a given list of lists, which contains an element outside the given range.
[[13, 14, 15, 17]]
Click me to see the sample solution

98. Write a Python program to scramble the letters of string in a given list. Go to the editor
Original list.
['Python', 'list', 'exercises', 'practice', 'solution']
After scrambling the letters of the strings of the said list.
['tnPhyo', 'tlis', 'ecrsseiex', 'ccpitear', 'noiltuos']
Click me to see the sample solution

99. Write a Python program to find the maximum and minimum values in a given heterogeneous list. Go to the editor
Original list.
['Python', 3, 2, 4, 5, 'version']
Maximum and Minimum values in the said list.
(5, 2)
Click me to see the sample solution

100. Write a Python program to extract common index elements from more than one given list. Go to the editor
Original lists.
[1, 1, 3, 4, 5, 6, 7]
[0, 1, 2, 3, 4, 5, 7]
[0, 1, 2, 3, 4, 5, 7]
Common index elements of the said lists.
[1, 7]
Click me to see the sample solution

101. Write a Python program to sort a given matrix in ascending order according to the sum of its rows. Go to the editor
Original Matrix.
[[1, 2, 3], [2, 4, 5], [1, 1, 1]]
Sort the said matrix in ascending order according to the sum of its rows
[[1, 1, 1], [1, 2, 3], [2, 4, 5]]
Original Matrix.
[[1, 2, 3], [-2, 4, -5], [1, -1, 1]]
Sort the said matrix in ascending order according to the sum of its rows
[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]
Click me to see the sample solution

102. Write a Python program to extract specified size of strings from a give list of string values. Go to the editor
Original list.
['Python', 'list', 'exercises', 'practice', 'solution']
length of the string to extract.
8
After extracting strings of specified length from the said list.
['practice', 'solution']
Click me to see the sample solution

103. Write a Python program to extract specified number of elements from a given list, which follows each other continuously. Go to the editor
Original list.
[1, 1, 3, 4, 4, 5, 6, 7]
Extract 2 number of elements from the said list which follows each other continuously.
[1, 4]
Original lists.
[0, 1, 2, 3, 4, 4, 4, 4, 5, 7]
Extract 4 number of elements from the said list which follows each other continuously.
[4]
Click me to see the sample solution

104. Write a Python program to find the difference between consecutive numbers in a given list. Go to the editor
Original list.
[1, 1, 3, 4, 4, 5, 6, 7]
Difference between consecutive numbers of the said list.
[0, 2, 1, 0, 1, 1, 1]
Original list.
[4, 5, 8, 9, 6, 10]
Difference between consecutive numbers of the said list.
[1, 3, 1, -3, 4]
Click me to see the sample solution

105. Write a Python program to compute average of two given lists. Go to the editor
Original list.
[1, 1, 3, 4, 4, 5, 6, 7]
[0, 1, 2, 3, 4, 4, 5, 7, 8]
Average of two lists.
3. 823529411764706
Click me to see the sample solution

106. Write a Python program to count integer in a given mixed list. Go to the editor
Original list.
[1, 'abcd', 3, 1. 2, 4, 'xyz', 5, 'pqr', 7, -5, -12. 22]
Number of integers in the said mixed list.
6
Click me to see the sample solution

107. Write a Python program to remove a specified column from a given nested list. Go to the editor
Original Nested list.
[[1, 2, 3], [2, 4, 5], [1, 1, 1]]
After removing 1st column.
[[2, 3], [4, 5], [1, 1]]
Original Nested list.
[[1, 2, 3], [-2, 4, -5], [1, -1, 1]]
After removing 3rd column.
[[1, 2], [-2, 4], [1, -1]]
Click me to see the sample solution

108. Write a Python program to extract a specified column from a given nested list. Go to the editor
Original Nested list.
[[1, 2, 3], [2, 4, 5], [1, 1, 1]]
Extract 1st column.
[1, 2, 1]
Original Nested list.
[[1, 2, 3], [-2, 4, -5], [1, -1, 1]]
Extract 3rd column.
[3, -5, 1]
Click me to see the sample solution

109. Write a Python program to rotate a given list by specified number of items to the right or left direction. Go to the editor
original List.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Rotate the said list in left direction by 4.
[4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]
Rotate the said list in left direction by 2.
[3, 4, 5, 6, 7, 8, 9, 10, 1, 2]
Rotate the said list in Right direction by 4.
[8, 9, 10, 1, 2, 3, 4, 5, 6]
Rotate the said list in Right direction by 2.
[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]
Click me to see the sample solution

110. Write a Python program to find the item with maximum occurrences in a given list. Go to the editor
Original list.
[2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2]
Item with maximum occurrences of the said list.
2
Click me to see the sample solution

111. Write a Python program to access multiple elements of specified index from a given list. Go to the editor
Original list.
[2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2]
Index list.
[0, 3, 5, 7, 10]
Items with specified index of the said list.
[2, 4, 9, 2, 1]
Click me to see the sample solution

112. Write a Python program to check whether a specified list is sorted or not. Go to the editor
Original list.
[1, 2, 4, 6, 8, 10, 12, 14, 16, 17]
Is the said list is sorted.
True
Original list.
[1, 2, 4, 6, 8, 10, 12, 14, 16, 17]
Is the said list is sorted.
False
Click me to see the sample solution

113. Write a Python program to remove duplicate dictionary from a given list. Go to the editor
Original list with duplicate dictionary.
[{'Green'. '#008000'}, {'Black'. '#000000'}, {'Blue'. '#0000FF'}, {'Green'. '#008000'}]
After removing duplicate dictionary of the said list.
[{'Black'. '#000000'}, {'Blue'. '#0000FF'}, {'Xanh lục'. '#008000'}]
Click me to see the sample solution

114. Write a Python program to extract the nth element from a given list of tuples. Go to the editor
Original list.
[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)]
Extract nth element ( n = 0 ) from the said list of tuples.
['Greyson Fulton', 'Brady Kent', 'Wyatt Knott', 'Beau Turnbull']
Extract nth element ( n = 2 ) from the said list of tuples.
[99, 96, 94, 98]
Click me to see the sample solution

115. Write a Python program to check if the elements of a given list are unique or not. Go to the editor
Original list.
[1, 2, 4, 6, 8, 2, 1, 4, 10, 12, 14, 12, 16, 17]
Is the said list contains all unique elements.
False
Original list.
[2, 4, 6, 8, 10, 12, 14]
Is the said list contains all unique elements.
True
Click me to see the sample solution

116. Viết chương trình Python để sắp xếp danh sách các danh sách theo chỉ số cho trước của danh sách bên trong. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94
Sort the said list of lists by a given index ( Index = 0 ) of the inner list
[('Beau Turnbull', 94, 98), ('Brady Kent', 97, 96), ('Greyson Fulton', 98, 99), ('Wyatt Knott', 91, 94)]
Sort the said list of lists by a given index ( Index = 2 ) of the inner list
[('Wyatt Knott', 91, 94), ('Brady Kent', 97, 96), ('Beau Turnbull', 94, 98), ('Greyson Fulton', 98, 99)]
Click me to see the sample solution

117. Viết chương trình Python để xóa tất cả các phần tử khỏi danh sách đã cho có trong danh sách khác. Chuyển đến trình chỉnh sửa
Danh sách gốc.
danh sách1. [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2. [2, 4, 6, 8]
Remove all elements from 'list1' present in 'list2.
[1, 3, 5, 7, 9, 10]
Click me to see the sample solution

118. Write a Python program to find the difference between elements (n+1th - nth) of a given list of numeric values. Go to the editor
Original list.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Dfference between elements (n+1th - nth) of the said list .
[1, 1, 1, 1, 1, 1, 1, 1, 1]
Danh sách gốc.
[2, 4, 6, 8]
Dfference between elements (n+1th - nth) of the said list .
[2, 2, 2]
Click me to see the sample solution

119. Write a Python program to check if a substring presents in a given list of string values. Go to the editor
Original list.
['red', 'black', 'white', 'green', 'orange']
Substring to search.
ack
Check if a substring presents in the said list of string values.
True
Substring to search.
abc
Check if a substring presents in the said list of string values.
False
Click me to see the sample solution

120. Write a Python program to create a list taking alternate elements from a given list. Go to the editor
Original list.
['red', 'black', 'white', 'green', 'orange']
List with alternate elements from the said list.
['red', 'white', 'orange']
Original list.
[2, 0, 3, 4, 0, 2, 8, 3, 4, 2]
List with alternate elements from the said list.
[2, 3, 0, 8, 4]
Click me to see the sample solution

121. Write a Python program to find the nested lists elements which are present in another list. Go to the editor
Original lists.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
[[12, 18, 23, 25, 45], [7, 11, 19, 24, 28], [1, 5, 8, 18, 15, 16]]
Intersection of said nested lists.
[[12], [7, 11], [1, 5, 8]]
Click me to see the sample solution

122. Write a Python program to find common element(s) in a given nested lists. Go to the editor
Original lists.
[[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]
Common element(s) in nested lists.
[18, 12]
Click me to see the sample solution

123. Write a Python program to reverse strings in a given list of string values. Go to the editor
Original lists.
['Red', 'Green', 'Blue', 'White', 'Black']
Reverse strings of the said given list.
['deR', 'neerG', 'eulB', 'etihW', 'kcalB']
Click me to see the sample solution

124. Write a Python program to find the maximum and minimum product from the pairs of tuple within a given list. Go to the editor
The original list, tuple .
[(2, 7), (2, 6), (1, 8), (4, 9)]
Maximum and minimum product from the pairs of the said tuple of list.
(36, 8)
Click me to see the sample solution

125. Write a Python program to calculate the product of the unique numbers of a given list. Go to the editor
Original List . [10, 20, 30, 40, 20, 50, 60, 40]
Product of the unique numbers of the said list. 720000000
Click me to see the sample solution

126. Write a Python program to interleave multiple lists of the same length. Chuyển đến trình chỉnh sửa
Danh sách gốc.
list1. [1, 2, 3, 4, 5, 6, 7]
list2. [10, 20, 30, 40, 50, 60, 70]
list3. [100, 200, 300, 400, 500, 600, 700]
Interleave multiple lists.
[1, 10, 100, 2, 20, 200, 3, 30, 300, 4, 40, 400, 5, 50, 500, 6, 60, 600, 7, 70, 700]
Click me to see the sample solution

127. Write a Python program to remove words from a given list of strings containing a character or string. Go to the editor
Original list.
list1. ['Red color', 'Orange#', 'Green', 'Orange @', 'White']
Character list.
['#', 'color', '@']
New list.
['Red', '', 'Green', 'Orange', 'White']
Click me to see the sample solution

128. Write a Python program to calculate the sum of the numbers in a list between the indices of a specified range. Go to the editor
Original list.
[2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12]
Range. 8 , 10
Sum of the specified range.
29
Click me to see the sample solution

129. Write a Python program to reverse each list in a given list of lists. Go to the editor
Original list of lists.
[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
Reverse each list in the said list of lists.
[[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]
Click me to see the sample solution

130. Write a Python program to count the same pair in three given lists. Go to the editor
Original lists.
[1, 2, 3, 4, 5, 6, 7, 8]
[2, 2, 3, 1, 2, 6, 7, 9]
[2, 1, 3, 1, 2, 6, 7, 9]
Number of same pair of the said three given lists.
3
Click me to see the sample solution

131. Write a Python program to count the frequency of consecutive duplicate elements in a given list of numbers. Go to the editor
Original lists.
[1, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5]
Consecutive duplicate elements and their frequency.
([1, 2, 4, 5], [1, 3, 3, 4])
Click me to see the sample solution

132. Write a Python program to find all index positions of the maximum and minimum values in a given list of numbers. Go to the editor
Original list.
[12, 33, 23, 10, 67, 89, 45, 667, 23, 12, 11, 10, 54]
Index positions of the maximum value of the said list.
7
Index positions of the minimum value of the said list.
3, 11
Click me to see the sample solution

133. Write a Python program to check common elements between two given list are in same order or not. Go to the editor
Original lists.
['red', 'green', 'black', 'orange']
['red', 'pink', 'green', 'white', 'black']
['white', 'orange', 'pink', 'black']
Test common elements between color1 and color2 are in same order?
True
Test common elements between color1 and color3 are in same order?
False
Test common elements between color2 and color3 are in same order?
False
Click me to see the sample solution

134. Write a Python program to find the difference between two list including duplicate elements. Go to the editor
Original lists.
[1, 1, 2, 3, 3, 4, 4, 5, 6, 7]
[1, 1, 2, 4, 5, 6]
Difference between two said list including duplicate elements).
[3, 3, 4, 7]
Nhấp vào tôi để xem giải pháp mẫu

135. Write a Python program to iterate over all pairs of consecutive items in a given list. Go to the editor
Original lists.
[1, 1, 2, 3, 3, 4, 4, 5]
Iterate over all pairs of consecutive items of the said list.
[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]
Click me to see the sample solution

136. Write a Python program to remove duplicate words from a given list of strings. Go to the editor
Original String.
['Python', 'Exercises', 'Practice', 'Solution', 'Exercises']
After removing duplicate words from the said list of strings.
['Python', 'Exercises', 'Practice', 'Solution']
Click me to see the sample solution

137. Write a Python program to find a first even and odd number in a given list of numbers. Go to the editor
Original list.
[1, 3, 5, 7, 4, 1, 6, 8]
First even and odd number of the said list of numbers.
(4, 1)
Click me to see the sample solution

138. Write a Python program to sort a given mixed list of integers and strings. Numbers must be sorted before strings. Go to the editor
Original list.
[19, 'red', 12, 'green', 'blue', 10, 'white', 'green', 1]
Sort the said mixed list of integers and strings.
[1, 10, 12, 19, 'blue', 'green', 'green', 'red', 'white']
Click me to see the sample solution

139. Write a Python program to sort a given list of strings(numbers) numerically. Go to the editor
Original list.
['4', '12', '45', '7', '0', '100', '200', '-12', '-500']
Sort the said list of strings(numbers) numerically.
[-500, -12, 0, 4, 7, 12, 45, 100, 200]
Click me to see the sample solution

140. Write a Python program to remove the specific item from a given list of lists. Go to the editor
Original list of lists.
[['Red', 'Maroon', 'Yellow', 'Olive'], ['#FF0000', '#800000', '#FFFF00', '#808000'], ['rgb(255,0,0)', 'rgb(128,0,0)', 'rgb(255,255,0)', 'rgb(128,128,0)']]
Remove 1st list from the saod given list of lists.
[['Maroon', 'Yellow', 'Olive'], ['#800000', '#FFFF00', '#808000'], ['rgb(128,0,0)', 'rgb(255,255,0)', 'rgb(128,128,0)']]
Remove 2nd list from the saod given list of lists.
[['Red', 'Yellow', 'Olive'], ['#FF0000', '#FFFF00', '#808000'], ['rgb(255,0,0)', 'rgb(255,255,0)', 'rgb(128,128,0)']]
Remove 4th list from the saod given list of lists.
[['Red', 'Maroon', 'Yellow'], ['#FF0000', '#800000', '#FFFF00'], ['rgb(255,0,0)', 'rgb(128,0,0)', 'rgb(255,255,0)']]
Click me to see the sample solution

141. Write a Python program to remove empty lists from a given list of lists. Go to the editor
Original list.
[[], [], [], 'Red', 'Green', [1, 2], 'Blue', [], []]
After deleting the empty lists from the said lists of lists
['Red', 'Green', [1, 2], 'Blue']
Click me to see the sample solution

142. Write a Python program to sum a specific column of a list in a given list of lists. Chuyển đến trình chỉnh sửa
Danh sách gốc của danh sách.
[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]
Sum. 1st column of the said list of lists.
12
Sum. 2nd column of the said list of lists.
15
Sum. 4th column of the said list of lists.
9
Click me to see the sample solution

143. Write a Python program to get the frequency of the elements in a given list of lists. Go to the editor
Original list of lists.
[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]
Tần suất .
{1. 1, 2. 3, 3. 1, 4. 1, 5. 2, 6. 1, 7. 1, 8. 1, 9. 1}
Click me to see the sample solution

144. Write a Python program to extract every first or specified element from a given two-dimensional list. Go to the editor
Original list of lists.
[[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]]
Trích xuất .
[1, 4, 7]
Extract every third element from the said given two dimensional list.
[3, 6, 9]
Click me to see the sample solution

145. Viết chương trình Python để tạo một số trong một phạm vi được chỉ định ngoại trừ một số số cụ thể. Go to the editor
Generate a number in a specified range (1, 10) except [2, 9, 10]
7
Generate a number in a specified range (-5, 5) except [-5,0,4,3,2]
-4
Click me to see the sample solution

146. Write a Python program to compute the sum of digits of each number of a given list. Go to the editor
Original tuple.
[10, 2, 56]
Sum of digits of each number of the said list of integers.
14
Original tuple.
[10, 20, 4, 5, 'b', 70, 'a']
Sum of digits of each number of the said list of integers.
19
Bộ gốc.
[10, 20, -4, 5, -70]
Sum of digits of each number of the said list of integers.
19
Click me to see the sample solution

147. Write a Python program to interleave two given list into another list randomly. Go to the editor
Original lists.
[1, 2, 7, 8, 3, 7]
[4, 3, 8, 9, 4, 3, 8, 9]
Interleave two given list into another list randomly.
[4, 1, 2, 3, 8, 9, 4, 3, 7, 8, 9, 8, 3, 7]
Nhấp vào tôi để

148. Viết chương trình Python để xóa các từ cụ thể khỏi danh sách đã cho. Go to the editor
Original list.
['red', 'green', 'blue', 'white', 'black', 'orange']
Xóa từ.
['white', 'orange']
After removing the specified words from the said list.
['red', 'green', 'blue', 'black']
Click me to see the sample solution

149. Write a Python program to get all possible combinations of the elements of a given list. Chuyển đến trình chỉnh sửa
Danh sách gốc.
['orange', 'red', 'green', 'blue']
All possible combinations of the said list's elements.
[[], ['orange'], ['red'], ['red', 'orange'], ['green'], ['green', 'orange'], ['green', 'red'], ['green', 'red', 'orange'], ['blue'], ['blue', 'orange'], ['blue', 'red'], ['blue', 'red', 'orange'], ['blue', 'green'], ['blue', 'green', 'orange'], ['blue', 'green', 'red'], ['blue', 'green', 'red', 'orange']]
Click me to see the sample solution

150. Viết chương trình Python để đảo ngược một danh sách các danh sách đã cho. Go to the editor
Original list.
[['cam', 'đỏ'], ['lục', 'lam'], ['trắng', 'đen', 'hồng']]
Reverse said list of lists:
[['white', 'black', 'pink'], ['green', 'blue'], ['orange', 'red']]
Original list.
[[1, 2, 3, 4], [0, 2, 4, 5], [2, 3, 4, 2, 4]]
Reverse said list of lists.
[[2, 3, 4, 2, 4], [0, 2, 4, 5], [1, 2, 3, 4]]
Click me to see the sample solution

151. Write a Python program to find the maximum and minimum values in a given list within specified index range. Go to the editor
Original list.
[4, 3, 0, 5, 3, 0, 2, 3, 4, 2, 4, 3, 5]
Phạm vi chỉ số.
3 to 8
Maximum and minimum values of the said given list within index range.
(5, 0)
Click me to see the sample solution

152. Write a Python program to combine two given sorted lists using heapq module. Chuyển đến trình chỉnh sửa
Danh sách được sắp xếp ban đầu.
[1, 3, 5, 7, 9, 11]
[0, 2, 4, 6, 8, 10]
After merging the said two sorted lists.
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Click me to see the sample solution

153. Viết chương trình Python để kiểm tra xem một phần tử đã cho có xuất hiện ít nhất n lần trong danh sách không. Go to the editor
Original list.
[0, 1, 3, 5, 0, 3, 4, 5, 0, 8, 0, 3, 6, 0, 3, 1, 1, 0]
Check if 3 occurs at least 4 times in a list:
True
Check if 0 occurs at least 5 times in a list.
True
Check if 8 occurs at least 3 times in a list.
Sai
Nhấp vào tôi để xem giải pháp mẫu

154. Viết chương trình Python để nối hai danh sách đã cho gồm các danh sách có cùng độ dài, phần tử khôn ngoan. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[[10, 20], [30, 40], [50, 60], [30, 20, 80]]
[[61], [12, 14, 15], [12, 13, 19, 20], [12]]
Join the said two lists element wise.
[[10, 20, 61], [30, 40, 12, 14, 15], [50, 60, 12, 13, 19, 20], [30, 20, 80, 12]]
Original lists.
[['a', 'b'], ['b', 'c', 'd'], ['e', 'f']]
[['p', 'q'], ['p', 's', 't'], ['u', 'v', 'w']]
Join the said two lists element wise:
[['a', 'b', 'p', 'q'], ['b', 'c', 'd', 'p', 's', '
Click me to see the sample solution

155. Viết chương trình Python để thêm hai danh sách đã cho có độ dài khác nhau, bắt đầu từ trái. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[2, 4, 7, 0, 5, 8]
[3, 3, -1, 7]
Add said two lists from left.
[5, 7, 6, 7, 5, 8]
Danh sách gốc.
[1, 2, 3, 4, 5, 6]
[2, 4, -3]
Add said two lists from left.
[3, 6, 0, 4, 5, 6]
Click me to see the sample solution

156. Viết chương trình Python để thêm hai danh sách đã cho có độ dài khác nhau, bắt đầu từ bên phải. Go to the editor
Original lists.
[2, 4, 7, 0, 5, 8]
[3, 3, -1, 7]
Add said two lists from left.
[2, 4, 10, 3, 4, 15]
Danh sách gốc.
[1, 2, 3, 4, 5, 6]
[2, 4, -3]
Add said two lists from left.
[1, 2, 3, 6, 9, 3]
Click me to see the sample solution

157. Viết chương trình Python để xen kẽ nhiều danh sách đã cho có độ dài khác nhau. Go to the editor
Original lists.
[2, 4, 7, 0, 5, 8]
[2, 5, 8]
[0, .
[3, 3, -1, 7]
Interleave said lists of different lengths:
[2, 2, 0, 3, 4, 5, 1, 3, 7, 8, -1, 0, 7, 5, 8]
Click me to see the sample solution

158. Viết chương trình Python để tìm các giá trị lớn nhất và nhỏ nhất trong một danh sách các bộ dữ liệu đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc có bộ dữ liệu.
[('V', 60), ('VI', 70), ('VII', 75), ('VIII', 72), ('IX', 78), .
Maximum and minimum values of the said list of tuples:
(78, 60)
Click me to see the sample solution

159. Write a Python program to append the same value /a list multiple times to a list/list-of-lists. Chuyển đến trình chỉnh sửa
Thêm giá trị (7), 5 lần, vào danh sách.
['7', '7', '7', '7', '7']
Thêm 5, 6 lần vào danh sách.
[1, 2, 3, 4, 5, 5, 5, 5, 5, 5]
Thêm danh sách, 4 lần, vào danh sách .
[[1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5]]
Add a list, 3 times, to a list of lists:
[[5, 6, 7], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5]]
Click me to see the sample solution

160. Write a Python program to remove first specified number of elements from a given list satisfying a condition. Chuyển đến trình chỉnh sửa
Xóa 4 số đầu tiên của số chẵn khỏi danh sách sau.
[3,10,4,7,5,7,8,3,3,4,5,9,3,4,9,8,5]
Output:
[3, 7, 5, 7, 3, 3, 5, 9, 3, 4, 9, 8, 5]
Danh sách gốc.
[3, 10, 4, 7, 5, 7, 8, 3, 3, 4, 5, 9, 3, 4, 9, 8, 5]
Remove first 4 even numbers from the said list.
[3, 7, 5, 7, 3, 3, 5, 9, 3, 4, 9, 8, 5]
Nhấp vào tôi để xem

161. Viết chương trình Python để kiểm tra xem một danh sách đã cho có tăng nghiêm ngặt hay không. Hơn nữa, nếu chỉ xóa một phần tử khỏi danh sách dẫn đến danh sách tăng nghiêm ngặt, chúng tôi vẫn coi danh sách là đúng. Go to the editor
True
True
True
True
True
True
True
True
True
True
True
False
False
False
False
False
Click me to see the sample solution

162. Viết chương trình Python để tìm lần xuất hiện cuối cùng của một mục đã chỉ định trong một danh sách đã cho. Go to the editor
Original list.
['s', 'd', 'f', 's', 'd', 'f', 's', 'f', 'k', 'o', .
Last occurrence of f in the said list:
7
Last occurrence of c in the said list.
15
K xuất hiện cuối cùng trong danh sách nói trên.
14
Last occurrence of w in the said list.
12
Nhấp vào tôi để xem giải pháp mẫu

163. Viết chương trình Python để lấy chỉ số của phần tử đầu tiên lớn hơn phần tử đã chỉ định. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[12, 45, 23, 67, 78, 90, 100, 76, 38, 62, 73, 29, 83]
Index of the first element which is greater than 73 in the said list.
4
Index of the first element which is greater than 21 in the said list.
1
Chỉ số của phần tử đầu tiên lớn hơn 80 trong danh sách nói trên.
5
Chỉ số của phần tử đầu tiên lớn hơn 55 trong danh sách nói trên.
3
Click me to see the sample solution

164. Viết chương trình Python để lấy các mục từ một danh sách nhất định với điều kiện cụ thể. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[12, 45, 23, 67, 78, 90, 45, 32, 100, 76, 38, 62, 73, 29, 83]
Số
5
Click me to see the sample solution

165. Viết chương trình Python để chia một danh sách đã cho thành các phần có kích thước được chỉ định. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[12, 45, 23, 67, 78, 90, 45, 32, 100, 76, 38, 62, 73, 29, 83]
Split the said list into equal size 3
[[12, 45, 23], [67, 78, 90], [45, 32, 100], [76, 38, 62], [73, 29, 83]]
Split the said list into equal size 4
[[12, 45, 23, 67], [78, 90, 45, 32], [100, 76, 38, 62], [73, 29, 83]]
Split the said list into equal size 5
[[12, 45, 23, 67, 78], [90, 45, 32, 100, 76], [38, 62, 73, 29, 83]]
Click me to see the sample solution

166. Viết chương trình Python để xóa giá trị Không có khỏi danh sách đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[12, 0, Không có, 23, Không có, -55, 234, 89, Không có, 0, 6, -12]
Xóa giá trị Không khỏi .
[12, 0, 23, -55, 234, 89, 0, 6, -12]
Nhấp vào tôi để xem giải pháp mẫu

167. Viết chương trình Python để chuyển đổi một danh sách các chuỗi đã cho thành danh sách các danh sách. Chuyển đến trình chỉnh sửa
Danh sách chuỗi gốc.
['Red', 'Maroon', 'Yellow', 'Olive']
Convert the said list of strings into list of lists.
[['R', 'e', ​​'d'], ['M', 'a', 'r', 'o', 'o', 'n'],
Click me to see the sample solution

168. Viết chương trình Python để hiển thị theo chiều dọc từng phần tử của một danh sách cho trước, danh sách các danh sách. Chuyển đến trình chỉnh sửa
Danh sách gốc.
['a', 'b', 'c', 'd', 'e', ​​'f']
Hiển thị từng phần tử theo chiều dọc của phần tử đã nói .
a
b
c
d
e .
f
Original list:
[[1, 2, 5], [4, 5, 8], [7, 3, 6]]
Hiển thị từng phần tử theo chiều dọc của phần tử đã nói .
1 4 7
2 5 3
5 8 6
Nhấp vào tôi để xem

169. Viết chương trình Python để chuyển đổi một danh sách các chuỗi và ký tự đã cho thành một danh sách các ký tự. Chuyển đến trình chỉnh sửa
Danh sách gốc.
['red', 'white', 'a', 'b', 'black', 'f']
Chuyển đổi danh sách các chuỗi đã nói và .
['r', 'e', ​​'d', 'w', 'h', 'i', 't', 'e', ​​'a', 'b',
Click me to see the sample solution

170. Viết chương trình Python để chèn một phần tử vào một danh sách đã cho sau mỗi vị trí thứ n. Go to the editor
Original list.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
Insert a in the said list after 2 nd element.
[1, 2, 'a', 3, 4, 'a', 5, 6, 'a', 7, 8, 'a', 9, 0]
Insert b in the said list after 4 th element.
[1, 2, 3, 4, 'b', 5, 6, 7, 8, 'b', 9, 0]
Click me to see the sample solution

171. Write a Python program to concatenate element-wise three given lists. Go to the editor
Original lists.
['0', '1', '2', '3', '4']
['red', 'green', 'black', 'blue', 'white']
['100', '200', '300', '400', '500']
Concatenate element-wise three said lists.
['0red100', '1green200', '2black300', '3blue400', '4white500']
Nhấp vào tôi để xem giải pháp mẫu

172. Write a Python program to remove the last N number of elements from a given list. Go to the editor
Original lists.
[2, 3, 9, 8, 2, 0, 39, 84, 2, 2, 34, 2, 34, 5, 3, 5]
Remove the last 3 elements from the said list:
[2, 3, 9, 8, 2, 0, 39, 84, 2, 2, 34, 2, 34]
Xóa 5 phần tử cuối cùng .
[2, 3, 9, 8, 2, 0, 39, 84, 2, 2, 34]
Xóa 1 phần tử cuối cùng khỏi danh sách đã nói.
[2, 3, 9, 8, 2, 0, 39, 84, 2, 2, 34, 2, 34, 5, 3]
Nhấp

173. Viết chương trình Python để hợp nhất một số mục danh sách trong danh sách đã cho bằng cách sử dụng giá trị chỉ mục. Chuyển đến trình chỉnh sửa
Danh sách gốc.
['a', 'b', 'c', 'd', 'e', ​​'f', 'g']
Hợp nhất các mục từ .
['a', 'b', 'cd', 'e', ​​'f', 'g']
Hợp nhất các mục từ 3 đến 7 trong .
['a', 'b', 'c', 'defg']
Nhấp vào tôi để xem giải pháp mẫu

174. Viết chương trình Python để thêm một số vào mỗi phần tử trong một danh sách các số đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[3, 8, 9, 4, 5, 0, 5, 0, 3]
Thêm 3 vào mỗi phần tử trong danh sách đã nói.
[6, 11, 12, 7, 8, 3, 8, 3, 6]
Danh sách gốc.
[3. 2, 8, 9. 9, 4. 2, 5, 0. 1, 5, 3. 11, 0]
Thêm 0. 51 cho mỗi phần tử trong danh sách đã nói.
[3. 71, 8. 51, 10. 41, 4. 71, 5. 51, 0. 61, 5. 51, 3. 62, 0. 51]
Click me to see the sample solution

175. Viết chương trình Python để tìm giá trị nhỏ nhất, lớn nhất cho từng vị trí bộ dữ liệu trong danh sách bộ dữ liệu đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[(2, 3), (2, 4), (0, 6), (7, 1)]
Giá trị tối đa cho mỗi vị trí bộ trong .
[7, 6]
Giá trị tối thiểu cho mỗi vị trí bộ trong danh sách bộ đã nói.
[0, 1]
Nhấp vào tôi để xem giải pháp mẫu

176. Viết chương trình Python để tạo một danh sách mới chia hai danh sách các số đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[7, 2, 3, 4, 9, 2, 3]
[7, 2, 3, 4, 9, 2, 3]
[0. 7777777777777778, 0. 25, 1. 5, 1. 3333333333333333, 3. 0, 2. 0, 1. 5]
Nhấp vào tôi để xem giải pháp mẫu

177. Write a Python program to find common elements in a given list of lists. Go to the editor
Original list.
[[7, 2, 3, 4, 7], [9, 2, 3, 2, 5], [8, 2, 3, 4, 4]]
Common elements of the said list of lists:
[2, 3]
Danh sách gốc.
[['a', 'b', 'c'], ['b', 'c', 'd'], ['c', 'd', 'e']]
Common elements of the said list of lists.
['c']
Nhấp vào tôi để xem giải pháp mẫu

178. Write a Python program to insert a specified element in a given list after every nth element. Go to the editor
Original list.
[1, 3, 5, 7, 9, 11, 0, 2, 4, 6, 8, 10, 8, 9, 0, 4, 3, 0]
Insert 20 in said list after every 4 th element.
[1, 3, 5, 7, 20, 9, 11, 0, 2, 20, 4, 6, 8, 10, 20, 8, 9, 0, 4, 20, .
Original list:
['s', 'd', 'f', 'j', 's', 'a', 'j', 'd', 'f', 'd'] .
Insert Z in said list after every 3 th element:
['s', 'd', 'f', 'Z', 'j', 's', 'a', 'Z', 'j', 'd', 'f', 'Z', 'd']
Click me to see the sample solution

179. Write a Python program to create the largest possible number using the elements of a given list of positive integers. Go to the editor
Original list.
[3, 40, 41, 43, 74, 9]
Largest possible number using the elements of the said list of positive integers.
9744341403
Original list.
[10, 40, 20, 30, 50, 60]
Số lớn nhất có thể sử dụng các phần tử trong danh sách các số nguyên dương đã nêu.
605040302010
Original list.
[8, 4, 2, 9, 5, 6, 1, 0]
Largest possible number using the elements of the said list of positive integers.
98654210
Nhấp vào tôi để xem giải pháp mẫu

180. Viết chương trình Python để tạo số nhỏ nhất có thể bằng cách sử dụng các phần tử của danh sách các số nguyên dương đã cho. Go to the editor
Original list.
[3, 40, 41, 43, 74, 9]
Số nhỏ nhất có thể sử dụng các phần tử của danh sách các số nguyên dương đã cho.
3404143749
Danh sách gốc.
[10, 40, 20, 30, 50, 60]
Smallest possible number using the elements of the said list of positive integers.
102030405060
Original list.
[8, 4, 2, 9, 5, 6, 1, 0]
Smallest possible number using the elements of the said list of positive integers.
01245689
Click me to see the sample solution

181. Write a Python program to iterate a given list cyclically on specific index position. Chuyển đến trình chỉnh sửa
Danh sách gốc.
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
Iterate the said list cyclically on specific index position 3 .
['d', 'e', 'f', 'g', 'h', 'a', 'b', 'c']
Iterate the said list cyclically on specific index position 5 .
['f', 'g', 'h', 'a', 'b', 'c', 'd', 'e']
Click me to see the sample solution

182. Viết chương trình Python để tính tổng lớn nhất và nhỏ nhất của một danh sách con trong một danh sách các danh sách cho trước. Go to the editor
Original list.
[[1, 2, 3, 5], [2, 3, 5, 4], [0, 5, 4, 1], [3, 7, 2, 1], .
Maximum sum of sub list of the said list of lists:
[2, 3, 5, 4]
Minimum sum of sub list of the said list of lists.
[1, 2, 1, 2]
Click me to see the sample solution

183. Viết chương trình Python để lấy các giá trị duy nhất trong một danh sách các danh sách đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[[1, 2, 3, 5], [2, 3, 5, 4], [0, 5, 4, 1], [3, 7, 2, 1], [1, 2, 1, 2]]
Unique values of the said list of lists.
[0, 1, 2, 3, 4, 5, 7]
Danh sách gốc.
[['h', 'g', 'l', 'k'], ['a', 'b', 'd', 'e', 'c'], ['j', 'i', 'y'], ['n', 'b', 'v', 'c'], ['x', 'z']]
Unique values of the said list of lists.
['e', 'd', 'c', 'b', 'x', 'k', 'n', 'h', 'g', 'j',
Click me to see the sample solution

184. Viết chương trình Python để tạo Bigram các từ trong một danh sách các chuỗi đã cho. Go to the editor
From Wikipedia.
A bigram or digram is a sequence of two adjacent elements from a string of tokens, which are typically letters, syllables, or words. Một bigram là một n-gram cho n=2. The frequency distribution of every bigram in a string is commonly used for simple statistical analysis of text in many applications, including in computational linguistics, cryptography, speech recognition, and so on.
Original list.
['Tính tổng tất cả các mục trong danh sách', 'Tìm số nhỏ thứ hai trong danh sách']
Chuỗi biggram của danh sách đã nói.
[('Sum', 'all'), ('all', 'the'), ('the', 'item'), ('item', 'in'),
Click me to see the sample solution

185. Write a Python program to convert a given decimal number to binary list. Go to the editor
Original Number. 8
Số thập phân ( 8 ) sang danh sách nhị phân.
[1, 0, 0, 0]
Số gốc. 45
Số thập phân ( 45 ) sang danh sách nhị phân.
[1, 0, 1, 1, 0, 1]
Số gốc. 100
Số thập phân ( 100 ) sang danh sách nhị phân.
[1, 1, 0, 0, 1, 0, 0]
Nhấp vào tôi để xem giải pháp mẫu

186. Viết chương trình Python để hoán đổi hai danh sách con trong một danh sách nhất định. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
Swap two sublists of the said list:
[0, 6, 7, 8, 9, 3, 4, 5, 1, 2, 10, 11, 12, 13, 14, 15]
Swap two sublists of the said list:
[0, 9, 3, 8, 6, 7, 4, 5, 1, 2, 10, 11, 12, 13, 14, 15]
Click me to see the sample solution

187. Viết chương trình Python để chuyển đổi một danh sách các bộ dữ liệu đã cho thành một danh sách các chuỗi. Chuyển đến trình chỉnh sửa
Danh sách bộ gốc.
[('đỏ', 'xanh'), ('đen', 'trắng'), ('cam', 'hồng')]
Chuyển đổi .
['đỏ xanh', 'đen trắng', 'hồng cam']
Danh sách ban đầu của các bộ.
[('Laiba', 'Delacruz'), ('Mali', 'Stacey', 'Drummond'), ('Raja', 'Welch'), ('Saarah', ' .
Convert the said list of tuples to a list of strings:
['Laiba Delacruz', 'Mali Stacey Drummond', 'Raja Welch', 'Saarah Stone']
Nhấp vào tôi để xem giải pháp mẫu

188. Viết chương trình Python để sắp xếp một danh sách các bộ dữ liệu đã cho trên phần tử đã chỉ định. Chuyển đến trình chỉnh sửa
Danh sách bộ gốc.
[('item2', 10, 10. 12), ('mục3', 15, 25. 1), ('mục1', 11, 24. 5), ('mục4', 12, 22. 5)]
Sắp xếp theo phần tử đầu tiên của bộ dữ liệu của danh sách đã nói.
[('item1', 11, 24. 5), ('mục2', 10, 10. 12), ('mục3', 15, 25. 1), ('mục4', 12, 22. 5)]
Sắp xếp theo phần tử thứ 2 của bộ của danh sách đã nói.
[('item2', 10, 10. 12), ('mục1', 11, 24. 5), ('mục4', 12, 22. 5), ('mục3', 15, 25. 1)]
Sắp xếp theo phần tử thứ 3 của bộ của danh sách đã nói.
[('item2', 10, 10. 12), ('mục4', 12, 22. 5), ('mục1', 11, 24. 5), ('mục3', 15, 25. 1)]
Nhấp vào tôi để xem giải pháp mẫu

189. Viết chương trình Python để chuyển phần tử cuối cùng sang vị trí đầu tiên và phần tử đầu tiên sang vị trí cuối cùng trong một danh sách đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[1, 2, 3, 4, 5, 6, 7]
Chuyển phần tử cuối cùng sang vị trí đầu tiên và phần tử đầu tiên sang vị trí cuối cùng của danh sách đã nói.
[7, 2, 3, 4, 5, 6, 1]
Danh sách gốc.
['s', 'd', 'f', 'd', 's', 's', 'd', 'f']
Shift last element to first position and first element to last position of the said list:
['f', 'd', 'f', 'd', 's', 's', 'd', 's']
Click me to see the sample solution

190. Viết chương trình Python để tìm số lượng sản phẩm lớn nhất được chỉ định từ hai danh sách đã cho, nhân một phần tử từ mỗi danh sách. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[1, 2, 3, 4, 5, 6]
[3, 6, 8, 9, 10, 6]
3 Number of largest products from the said two lists:
[60, 54, 50]
4 Number of largest products from the said two lists.
[60, 54, 50, 48]
Nhấp vào tôi để xem giải pháp mẫu

191. Viết chương trình Python tìm giá trị lớn nhất và nhỏ nhất của 3 danh sách đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[2, 3, 5, 8, 7, 2, 3]
[4, 3, 9, 0, 4, 3, 9]
[2, 1, 5, 6, 5, 5, 4]
Maximum value of the said three lists:
9
Giá trị nhỏ nhất của 3 danh sách trên.
0
Nhấp vào tôi để xem giải pháp mẫu

192. Viết chương trình Python để xóa tất cả các chuỗi khỏi danh sách các bộ dữ liệu đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[(100, 'Toán'), (80, 'Toán'), (90, 'Toán'), (88, 'Khoa học', 89), (90, 'Khoa học' .
Remove all strings from the said list of tuples:
[(100,), (80,), (90,), (88, 89), (90, 92)]
Nhấp vào tôi để xem

193. Viết chương trình Python tìm số chiều của một ma trận cho trước. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[[1, 2], [2, 4]]
Kích thước của ma trận nói trên.
(2, 2)
Danh sách gốc.
[[0, 1, 2], [2, 4, 5]]
Chiều của ma trận nói trên.
(2, 3)
Danh sách gốc.
[[0, 1, 2], [2, 4, 5], [2, 3, 4]]
Kích thước của ma trận nói trên.
(3, 3)
Nhấp vào tôi để xem giải pháp mẫu

194. Viết chương trình Python tính tổng hai hay nhiều danh sách, độ dài của các danh sách có thể khác nhau. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[[1, 2, 4], [2, 4, 4], [1, 2]]
Tính tổng các danh sách đã nói với độ dài khác nhau.
[4, 8, 8]
Danh sách gốc.
[[1], [2, 4, 4], [1, 2], [4]]
Tính tổng các danh sách đã nói với độ dài khác nhau.
[8, 6, 4]
Nhấp vào tôi để xem giải pháp mẫu

195. Viết chương trình Python để duyệt một danh sách đã cho theo thứ tự ngược lại, đồng thời in các phần tử có chỉ số ban đầu. Chuyển đến trình chỉnh sửa
Danh sách gốc.
['red', 'green', 'white', 'black']
Duyệt qua danh sách đã nói theo thứ tự ngược lại.
đen
trắng
xanh lá cây
đỏ
Di chuyển .
3 đen
2 trắng
1 xanh
0 đỏ
Click me to see the sample solution

196. Viết chương trình Python để di chuyển một phần tử đã chỉ định trong một danh sách nhất định. Go to the editor
Original list.
['red', 'green', 'white', 'black', 'orange']
Di chuyển màu trắng vào cuối danh sách đã nói.
['đỏ', 'xanh lục', 'đen', 'cam', 'trắng']
Danh sách gốc.
['red', 'green', 'white', 'black', 'orange']
Di chuyển màu đỏ vào cuối danh sách đã nói.
['green', 'white', 'black', 'orange', 'red']
Original list.
['red', 'green', 'white', 'black', 'orange']
Move black at the end of the said list.
['red', 'green', 'white', 'orange', 'black']
Click me to see the sample solution

197. Write a Python program to compute the average of nth elements in a given list of lists with different lengths. Go to the editor
Original list.
[[0, 1, 2], [2, 3, 4], [3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14]]
Average of n-th elements in the said list of lists with different lengths.
[4. 8, 5. 8, 6. 8, 8. 0, 11. 0]
Click me to see the sample solution

198. Write a Python program to compare two given lists and find the indices of the values present in both lists. Go to the editor
Original lists.
[1, 2, 3, 4, 5, 6]
[7, 8, 5, 2, 10, 12]
Compare said two lists and get the indices of the values present in both lists.
[1, 4]
Original lists.
[1, 2, 3, 4, 5, 6]
[7, 8, 5, 7, 10, 12]
Compare said two lists and get the indices of the values present in both lists.
[4]
Original lists.
[1, 2, 3, 4, 15, 6]
[7, 8, 5, 7, 10, 12]
Compare said two lists and get the indices of the values present in both lists.
[]
Click me to see the sample solution

199. Write a Python program to convert a given unicode list to a list contains strings. Go to the editor
Original lists.
['S001', 'S002', 'S003', 'S004']
Convert the said unicode list to a list contains strings.
['S001', 'S002', 'S003', 'S004']
Click me to see the sample solution

200. Write a Python program to pair up the consecutive elements of a given list. Go to the editor
Original lists.
[1, 2, 3, 4, 5, 6]
Pair up the consecutive elements of the said list.
[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]
Original lists.
[1, 2, 3, 4, 5]
Pair up the consecutive elements of the said list.
[[1, 2], [2, 3], [3, 4], [4, 5]]
Nhấp vào tôi để xem giải pháp mẫu

201. Write a Python program to check if a given string contains an element, which is present in a list. Go to the editor
The original string and list.
https. //www. w3resource. com/python-exercises/list/
['. com', '. edu', '. tv']
Check if https. //www. w3resource. com/python-exercises/list/ contains an element, which is present in the list ['. com', '. edu', '. tv']
True
The original string and list. https. //www. w3resource. net
https. //www. w3resource. net
['. com', '. edu', '. tv']
Check if https. //www. w3resource. net contains an element, which is present in the list ['. com', '. edu', '. tv']
False
Click me to see the sample solution

202. Write a Python program to find the indexes of all None items in a given list. Go to the editor
Original list.
[1, None, 5, 4, None, 0, None, None]
Indexes of all None items of the list.
[1, 4, 6, 7]
Click me to see the sample solution

203. Write a Python program to join adjacent members of a given list. Go to the editor
Original list.
['1', '2', '3', '4', '5', '6', '7', '8']
Join adjacent members of a given list.
['12', '34', '56', '78']
Original list.
['1', '2', '3']
Join adjacent members of a given list.
['12']
Click me to see the sample solution

204. Write a Python program to check if first digit/character of each element in a given list is same or not. Go to the editor
Original list.
[1234, 122, 1984, 19372, 100]
Kiểm tra xem chữ số đầu tiên trong mỗi phần tử của danh sách đã cho có giống nhau hay không.
Đúng
Danh sách gốc.
[1234, 922, 1984, 19372, 100]
Kiểm tra xem chữ số đầu tiên trong mỗi phần tử của danh sách đã cho có giống nhau hay không.
Sai
Danh sách gốc.
['aabc', 'abc', 'ab', 'a']
Kiểm tra xem ký tự đầu tiên trong mỗi thành phần của danh sách đã cho có giống nhau hay không .
Đúng
Danh sách gốc.
['aabc', 'abc', 'ab', 'ha']
Kiểm tra xem ký tự đầu tiên trong mỗi thành phần của danh sách đã cho có giống nhau hay không .
Sai
Nhấp vào tôi để xem giải pháp mẫu

205. Viết chương trình Python để tìm các chỉ số của các phần tử của một danh sách nhất định, lớn hơn một giá trị được chỉ định. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[1234, 1522, 1984, 19372, 1000, 2342, 7626]
Chỉ số của các phần tử trong danh sách nói trên, lớn hơn 3000
[3, 6]
Original list:
[1234, 1522, 1984, 19372, 1000, 2342, 7626]
Chỉ số của các phần tử trong danh sách nói trên, lớn hơn 20000
[]
Click me to see the sample solution

206. Viết chương trình Python để xóa các khoảng trắng bổ sung trong một danh sách đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
['abc ', ' ', ' ', 'sdfds ', ' ', ' ', 'sdfds ', 'huy']
Xóa khoảng trắng thừa .
['abc', '', '', 'sdfds', '', '', 'sdfds', 'huy']
Nhấp vào tôi để

207. Viết chương trình Python để tìm các bộ chung giữa hai danh sách đã cho. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[('đỏ', 'xanh'), ('đen', 'trắng'), ('cam', 'hồng')]
[ .
Common tuples between two said lists
[('orange', 'pink'), ('red', 'green')]
Original lists:
[('đỏ', 'xanh lục'), ('cam', 'hồng')]
[('đỏ', 'xanh lục'),
Common tuples between two said lists
[('orange', 'pink'), ('red', 'green')]
Click me to see the sample solution

208. Tính tổng một danh sách các số. Viết chương trình Python để tính tổng số thứ nhất với số thứ hai và chia cho 2, sau đó tổng số thứ hai với số thứ ba và chia cho 2, v.v. Chuyển đến trình chỉnh sửa
Danh sách gốc.
[1, 2, 3, 4, 5, 6, 7]
Tính tổng của dãy số đã cho.
[1. 5, 2. 5, 3. 5, 4. 5, 5. 5, 6. 5]
Danh sách gốc.
[0, 1, -3, 3, 7, -5, 6, 7, 11]
Tính tổng của dãy số đã cho.
[0. 5, -1. 0, 0. 0, 5. 0, 1. 0, 0. 5, 6. 5, 9. 0]
Click me to see the sample solution

209. Write a Python program to count the number of groups of non-zero numbers separated by zeros of a given list of numbers. Go to the editor
Original list.
[3, 4, 6, 2, 0, 0, 0, 0, 0, 0, 6, 7, 6, 9, 10, 0, 0, 0, 0, 0, 5, 9, 9, 7, 4, 4, 0, 0, 0, 0, 0, 0, 5, 3, 2, 9, 7, 1]
Number of groups of non-zero numbers separated by zeros of the said list. 4
Click me to see the sample solution

210. Write a Python program to compute the sum of non-zero groups (separated by zeros) of a given list of numbers. Go to the editor
Original list.
[3, 4, 6, 2, 0, 0, 0, 0, 0, 0, 6, 7, 6, 9, 10, 0, 0, 0, 0, 0, 7, 4, 4, 0, 0, 0, 0, 0, 0, 5, 3, 2, 9, 7, 1, 0, 0, 0]
Compute the sum of non-zero groups (separated by zeros) of the said list of numbers. [15, 38, 15, 27]
Click me to see the sample solution

211. Write a Python program to remove an element from a given list. Go to the editor
Original list.
['Ricky Rivera', 98, 'Math', 90, 'Science']
After deleting an element. , using index of the element. [98, 'Math', 90, 'Science']
Click me to see the sample solution

212. Write a Python program to remove all the values except integer values from a given array of mixed values. Go to the editor
Original list. [34. 67, 12, -94. 89, 'Python', 0, 'C#']
After removing all the values except integer values from the said array of mixed values. [12, 0]
Click me to see the sample solution

213. Write a Python program to calculate the sum of two lowest negative numbers of a given array of integers. Go to the editor
An integer (from the Latin integer meaning "whole") is colloquially defined as a number that can be written without a fractional component. Ví dụ: 21, 4, 0 và -2048 là các số nguyên.
Original list elements. [-14, 15, -10, -11, -12, -13, 16, 17, 18, 19, 20]
Sum of two lowest negative numbers of the said array of integers. -27
Original list elements. [-4, 5, -2, 0, 3, -1, 4, 9]
Sum of two lowest negative numbers of the said array of integers. -6
Click me to see the sample solution

214. Write a Python program to sort a given positive number in descending/ascending order. Go to the editor
Descending -> Highest to lowest.
Ascending -> Lowest to highest
Original Number. 134543
Descending order of the said number. 544331
Ascending order of the said number. 133445
Original Number. 43750973
Descending order of the said number. 97754330
Ascending order of the said number. 3345779
Click me to see the sample solution

215. Write a Python program to merge two or more lists into a list of lists, combining elements from each of the input lists based on their positions. Go to the editor
Sample Output.
After merging lists into a list of lists.
[['a', 1, True], ['b', 2, False]]
[['a', 1, True], [None, 2, False]]
[['a', 1, True], ['_', 2, False]]
Click me to see the sample solution

216. Write a Python program to group the elements of a list based on the given function and returns the count of elements in each group. Go to the editor
Sample Output.
{6. 2, 4. 1}
{3. 2, 5. 1}
Click me to see the sample solution

217. Write a Python program to split values into two groups, based on the result of the given filtering function. Go to the editor
Sample Output.
[['white'], ['red', 'green', 'black']]
Click me to see the sample solution

218. Write a Python program to sort one list based on another list containing the desired indexes. Go to the editor
Sample Output.
['apples', 'bread', 'eggs', 'jam', 'milk', 'oranges']
['oranges', 'milk', 'jam', 'eggs', 'bread', 'apples']
Click me to see the sample solution

219. Write a Python program to build a list, using an iterator function and an initial seed value. Go to the editor
Sample Output.
[-10, -20, -30, -40]
Click me to see the sample solution

220. Write a Python program to map the values of a list to a dictionary using a function, where the key-value pairs consist of the original value as the key and the result of the function as the value. Go to the editor
Sample Output.
{1. 1, 2. 4, 3. 9}
Click me to see the sample solution

221. Write a Python program to randomize the order of the values of an list, returning a new list. Go to the editor
Sample Output.
Original list. [1, 2, 3, 4, 5, 6]
Shuffle the elements of the said list.
[3, 2, 4, 1, 6, 5]
Click me to see the sample solution

222. Viết chương trình Python để lấy sự khác biệt giữa hai danh sách đã cho, sau khi áp dụng hàm được cung cấp cho từng phần tử danh sách của cả hai. Go to the editor
Sample Output.
[1. 2]
[{'x'. 2}]
Click me to see the sample solution

223. Write a Python program to create a list with the non-unique values filtered out. Go to the editor
Sample Output.
[1, 3, 5]
Click me to see the sample solution

224. Write a Python program to create a list with the unique values filtered out. Go to the editor
Sample Output.
[2, 4]
Click me to see the sample solution

225. Write a Python program to retrieve the value of the nested key indicated by the given selector list from a dictionary or list. Go to the editor
Sample Output.
Harwood
2
Click me to see the sample solution

226. Write a Python program to get a list of elements that exist in both lists, after applying the provided function to each list element of both. Go to the editor
Sample Output.
[2. 1]
Click me to see the sample solution

227. Write a Python program to get the symmetric difference between two lists, after applying the provided function to each list element of both. Go to the editor
Sample Output.
[1. 2, 3. 4]
Click me to see the sample solution

228. Write a Python program to get every element that exists in any of the two given lists once, after applying the provided function to each element of both. Go to the editor
Sample Output.
[2. 2, 4. 1]
Click me to see the sample solution

229. Write a Python program to find the index of the first element in the given list that satisfies the provided testing function. Go to the editor
Sample Output.
0
Click me to see the sample solution

230. Write a Python program to find the indexes of all elements in the given list that satisfy the provided testing function. Go to the editor
Sample Output.
[0, 2]
Click me to see the sample solution

231. Write a Python program to split values into two groups, based on the result of the given filter list. Go to the editor
Sample Output.
[['red', 'green', 'pink'], ['blue']]
Click me to see the sample solution

232. Write a Python program to chunk a given list into smaller lists of a specified size. Go to the editor
Sample Output.
[[1, 2, 3], [4, 5, 6], [7, 8]]
Click me to see the sample solution

233. Write a Python program to chunk a given list into n smaller lists. Go to the editor
Sample Output.
[[1, 2], [3, 4], [5, 6], [7]]
Click me to see the sample solution

234. Write a Python program to convert a given number (integer) to a list of digits. Go to the editor
Sample Output.
[1, 2, 3]
[1, 3, 4, 7, 8, 2, 3]
Click me to see the sample solution

235. Write a Python program to find the index of the last element in the given list that satisfies the provided testing function. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
2
Click me to see the sample solution

236. Write a Python program to find the items that are parity outliers in a given list. Go to the editor
Sample Output.
[1, 3]
[2, 4, 6]
Click me to see the sample solution

237. Write a Python program to convert a given list of dictionaries into a list of values corresponding to the specified key. Go to the editor
Sample Output.
[8, 36, 34, 10]
Click me to see the sample solution

238. Write a Python program to calculate the average of a given list, after mapping each element to a value using the provided function. Go to the editor
Sample Output.
5. 0
15. 0
Click me to see the sample solution

239. Write a Python program to find the value of the first element in the given list that satisfies the provided testing function. Go to the editor
Sample Output.
1
2
Click me to see the sample solution

240. Write a Python program to find the value of the last element in the given list that satisfies the provided testing function. Go to the editor
Sample Output.
3
4
Click me to see the sample solution

241. Write a Python program to create a dictionary with the unique values of a given list as keys and their frequencies as the values. Go to the editor
Sample Output.
{'a'. 4, 'b'. 2, 'f'. 2, 'c'. 1, 'e'. 2}
{3. 4, 4. 2, 7. 1, 5. 2, 9. 1, 0. 1, 2. 1}
Click me to see the sample solution

242. Write a Python program to get the symmetric difference between two iterables, without filtering out duplicate values. Go to the editor
Sample Output.
[30, 40]
Click me to see the sample solution

243. Write a Python program to check if a given function returns True for every element in a list. Go to the editor
Sample Output.
True
False
False
Click me to see the sample solution

244. Write a Python program to initialize a list containing the numbers in the specified range where start and end are inclusive and the ratio between two terms is step. Returns an error if step equals 1. Go to the editor
Sample Output.
[1, 2, 4, 8, 16, 32, 64, 128, 256]
[3, 6, 12, 24, 48, 96,
[1, 4, 16, 64, 256]
Click me to see the sample solution

245. Write a Python program to that takes any number of iterable objects or objects with a length property and returns the longest one. Go to the editor
Sample Output.
Green
[1, 2, 3, 4, 5]
[1, 2, 3, 4]
Click me to see the sample solution

246. Write a Python program to check if a given function returns True for at least one element in the list. Go to the editor
Sample Output.
True
False
Click me to see the sample solution

247. Write a Python program to calculate the difference between two iterables, without filtering duplicate values. Go to the editor
Sample Output.
[3]
Click me to see the sample solution

248. Write a Python program to get the maximum value of a list, after mapping each element to a value using a given function. Go to the editor
Sample Output.
8
Click me to see the sample solution

249. Write a Python program to get the minimum value of a list, after mapping each element to a value using a given function. Go to the editor
Sample Output.
2
Click me to see the sample solution

250. Write a Python program to calculate the sum of a list, after mapping each element to a value using the provided function. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
20
Click me to see the sample solution

251. Write a Python program to initialize and fills a list with the specified value. Go to the editor
Sample Output.
[0, 0, 0, 0, 0, 0, 0]
[3, 3, 3, 3, 3, 3, 3, 3]
[-2, -2, -2, -2, -2]
[3. 2, 3. 2, 3. 2, 3. 2, 3. 2]
Click me to see the sample solution

252. Write a Python program to get the n maximum elements from a given list of numbers. Go to the editor
Sample Output.
Original list elements.
[1, 2, 3]
Giá trị tối đa của danh sách nói trên. [3]
Các phần tử danh sách gốc.
[1, 2, 3]
Hai giá trị lớn nhất của danh sách nói trên. [3, 2]
Các phần tử danh sách gốc.
[-2, -3, -1, -2, -4, 0, -5]
Ba giá trị lớn nhất của danh sách nói trên. [0, -1, -2]
Các phần tử danh sách gốc.
[2. 2, 2, 3. 2, 4. 5, 4. 6, 5. 2, 2. 9]
Hai giá trị lớn nhất của danh sách nói trên. [5. 2, 4. 6]
Nhấp vào tôi để xem giải pháp mẫu

253. Viết chương trình Python để lấy n phần tử tối thiểu từ một danh sách các số đã cho. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
Các phần tử danh sách gốc.
[1, 2, 3]
Minimum values of the said list. [1]
Original list elements.
[1, 2, 3]
Two minimum values of the said list. [1, 2]
Các phần tử danh sách gốc.
[-2, -3, -1, -2, -4, 0, -5]
Ba giá trị nhỏ nhất của danh sách nói trên. [-5, -4, -3]
Các phần tử danh sách gốc.
[2. 2, 2, 3. 2, 4. 5, 4. 6, 5. 2, 2. 9]
Two minimum values of the said list. [2, 2. 2]
Click me to see the sample solution

254. Write a Python program to get the weighted average of two or more numbers. Go to the editor
Sample Output.
Original list elements.
[10, 50, 40]
[2, 5, 3]
Weighted average of the said two list of numbers.
39. 0
Original list elements.
[82, 90, 76, 83]
[0. 2, 0. 35, 0. 45, 32]
Weighted average of the said two list of numbers.
82. 97272727272727
Click me to see the sample solution

255. Write a Python program to perform a deep flattens a list. Go to the editor
Sample Output.
Original list elements.
[1, [2], [[3], [4], 5], 6]
Deep flatten the said list.
[1, 2, 3, 4, 5, 6]
Original list elements.
[[[1, 2, 3], [4, 5]], 6]
Deep flatten the said list.
[1, 2, 3, 4, 5, 6]
Click me to see the sample solution

256. Write a Python program to get the powerset of a given iterable. Go to the editor
Sample Output.
Original list elements.
[1, 2]
Powerset of the said list.
[(), (1,), (2,), (1, 2)]
Original list elements.
[1, 2, 3, 4]
Powerset of the said list.
[(), (1,), (2,), (3,), (4,), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4), (1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4), (1, 2, 3, 4)]
Click me to see the sample solution

257. Write a Python program to check if two given lists contain the same elements regardless of order. Go to the editor
Sample Output.
Original list elements.
[1, 2, 4]
[2, 4, 1]
Check two said lists contain the same elements regardless of order.
True
Original list elements.
[1, 2, 3]
[1, 2, 3]
Check two said lists contain the same elements regardless of order.
True
Original list elements.
[1, 2, 3]
[1, 2, 4]
Check two said lists contain the same elements regardless of order.
False
Click me to see the sample solution

258. Write a Python program to create a given flat list of all the keys in a flat dictionary. Go to the editor
Sample Output.
Original directory elements.
{'Laura'. 10, 'Spencer'. 11, 'Bridget'. 9, 'Howard '. 10}
Flat list of all the keys of the said dictionary.
['Laura', 'Spencer', 'Bridget', 'Howard ']
Click me to see the sample solution

259. Write a Python program to check if a given function returns True for at least one element in the list. Go to the editor
Sample Output.
False
True
False
Click me to see the sample solution

260. Write a Python program to check if all the elements of a list are included in another given list. Go to the editor
Sample Output.
True
False
Click me to see the sample solution

261. Write a Python program to get the most frequent element in a given list of numbers. Go to the editor
Sample Output.
2
Original list.
[2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 2, 4, 6, 9, 1, 2]
Item with maximum frequency of the said list.
2
Original list.
[1, 2, 3, 1, 2, 3, 2, 1, 4, 3, 3]
Item with maximum frequency of the said list.
3
Click me to see the sample solution

262. Write a Python program to move the specified number of elements to the end of the given list. Go to the editor
Sample Output.
[4, 5, 6, 7, 8, 1, 2, 3]
[6, 7, 8, 1, 2, 3, 4,
[1, 2, 3, 4, 5, 6, 7, 8]
[1, 2, 3, 4, 5, 6, 7, 8]
[8, 1, 2, 3, 4, 5, 6, 7]
[2, 3, 4, 5, 6, 7, 8, 1]
Click me to see the sample solution

263. Viết chương trình Python để di chuyển số lượng phần tử đã chỉ định đến đầu danh sách đã cho. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
[4, 5, 6, 7, 8, 1, 2, 3]
[6, 7, 8, 1, 2, 3, 4,
[1, 2, 3, 4, 5, 6, 7, 8]
[1, 2, 3, 4, 5, 6, 7, 8]
[8, 1, 2, 3, 4, 5, 6, 7]
[2, 3, 4, 5, 6, 7, 8, 1]
Click me to see the sample solution

264. Viết chương trình Python để tạo danh sách hai chiều từ danh sách danh sách đã cho. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
[(1, 4, 7, 10), (2, 5, 8, 11), (3, 6, 9, 12)]
[
Click me to see the sample solution

265. Viết chương trình Python để tạo một danh sách, chứa dãy Fibonacci, cho đến số hạng thứ n. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
7 số Fibonacci đầu tiên.
[0, 1, 1, 2, 3, 5, 8, 13]
15 số Fibonacci đầu tiên.
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]
First 50 Fibonacci numbers:
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181,
Click me to see the sample solution

266. Viết chương trình Python để truyền giá trị được cung cấp dưới dạng danh sách nếu nó không phải là một. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.

[1]

['Red', 'Green']

['Green', 'Red']

[1, 2, 3]
Click me to see the sample solution

267. Write a Python program to get the cumulative sum of the elements of a given list. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
Các phần tử danh sách gốc.
[1, 2, 3, 4]
Tổng tích lũy của các phần tử trong danh sách nói trên.
[1, 3, 6, 10]
Các phần tử danh sách gốc.
[-1, -2, -3, 4]
Cumulative sum of the elements of the said list.
[-1, -3, -6, -2]
Nhấp vào tôi để xem giải pháp mẫu

268. Viết chương trình Python lấy một danh sách có n phần tử bị xóa từ trái sang phải. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
Các phần tử danh sách gốc.
[1, 2, 3]
Xóa 1 phần tử bên trái danh sách đã nói.
[2, 3]
Xóa 1 phần tử bên phải danh sách đã nói.
[1, 2]
Các phần tử danh sách gốc.
[1, 2, 3, 4]
Xóa 2 phần tử bên trái danh sách đã nói.
[3, 4]
Remove 2 elements from right of the said list.
[1, 2]
Các phần tử danh sách gốc.
[1, 2, 3, 4, 5, 6]
Xóa 7 phần tử bên trái danh sách đã nói.
[2, 3, 4, 5, 6]
Xóa 7 phần tử bên phải danh sách đã nói.
[1, 2, 3, 4, 5]
Nhấp vào tôi để xem giải pháp mẫu

269. Viết chương trình Python để lấy mọi phần tử thứ n trong một danh sách đã cho. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[2, 4, 6, 8, 10]
[5, 10]
[6]
Click me to see the sample solution

270. Viết chương trình Python để kiểm tra xem các phần tử của danh sách đầu tiên có được chứa trong danh sách thứ hai không phân biệt thứ tự. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
True
True
Sai
True
Nhấp chuột

271. Viết chương trình Python để kiểm tra xem có các giá trị trùng lặp trong một danh sách cố định không. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
Danh sách gốc.
[1, 2, 3, 4, 5, 6, 7]
Kiểm tra xem có giá trị trùng lặp trong danh sách phẳng đã cho không.
Sai
Danh sách gốc.
[1, 2, 3, 3, 4, 5, 5, 6, 7]
Kiểm tra xem có giá trị trùng lặp trong danh sách phẳng đã cho không.
Đúng
Nhấp vào tôi để xem giải pháp mẫu

272. Viết chương trình Python để tạo danh sách các số trong cấp số cộng bắt đầu bằng số nguyên dương đã cho và cho đến giới hạn đã chỉ định. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
[
[5, 10, 15, 20, 25]
Click me to see the sample solution

273. Viết chương trình Python để tìm một phần tử chia một danh sách các số nguyên đã cho có cùng giá trị tổng. Chuyển đến trình chỉnh sửa
Đầu ra mẫu.
Original list.
[0, 9, 2, 4, 5, 6]
Phần tử chia danh sách các số nguyên đã nói có cùng giá trị tổng.
4
Danh sách gốc.
[-4, 0, 6, 1, 0, 2]
Phần tử chia danh sách các số nguyên đã nói có cùng giá trị tổng.
1
Danh sách gốc.
[1, 2, 3, 4]
Element that devides the said list of integers with the same sum value.
Không có phần tử nào như vậy.
Danh sách gốc.
[-4, 0, 5, 1, 0, 1]
Phần tử chia danh sách các số nguyên đã nói có cùng giá trị tổng.
1
Click me to see the sample solution

274. Viết chương trình Python để đếm các chữ cái viết thường trong một danh sách các từ cho trước. Chuyển đến trình chỉnh sửa
Dữ liệu mẫu.
(["Đỏ", "Xanh lục", "Xanh dương", "Trắng"]) -> 13
(["SQL", "C++",
Click me to see the sample solution

275. Viết chương trình Python để thêm tất cả các phần tử của danh sách các số nguyên trừ số tại chỉ mục. Trả về chuỗi mới. Chuyển đến trình chỉnh sửa
Dữ liệu mẫu.
([0, 9, 2, 4, 5, 6] -> [26, 17, 24, 22, 21, 20]
([-
([1, 2, 3]) -> [5, 4, 3]
([-4, 0, 5, 1, 0, 1]) -> [7, 3, -2, 2, 3, 2]
Click me to see the sample solution

276. Viết chương trình Python để tìm số lẻ lớn nhất trong một danh sách các số nguyên đã cho. Chuyển đến trình chỉnh sửa
Dữ liệu mẫu.
([0, 9, 2, 4, 5, 6]) -> 9
([-4, 0, 6, 1, 0, 2
([1, 2, 3]) -> 3
([-4, 0, 5, 1, 0, 1]) -> 5
Click me to see the sample solution

277. Viết chương trình Python để tính giá trị lớn nhất và khoảng cách nhỏ nhất giữa các phần tử đã sắp xếp của danh sách các số nguyên. Chuyển đến trình chỉnh sửa
Dữ liệu mẫu.
{1, 2 ,9, 0, 4, 6} -> 3
{23, -2, 45, 38, 12, 4, 6}
Click me to see the sample solution

278. Viết chương trình Python tính tổng các số còn thiếu của một danh sách các số nguyên cho trước. Chuyển đến trình chỉnh sửa
Dữ liệu mẫu.
([0, 3, 4, 7, 9]) -> 22
([44, 45, 48]) -> 93
([-7, -5, -4, 0]) -> -12
Click me to see the sample solution

279. Viết chương trình Python để kiểm tra xem mỗi số có phải là số nguyên tố trong một danh sách các số đã cho không. Trả về True nếu tất cả các số đều là số nguyên tố, ngược lại trả về Sai. Chuyển đến trình chỉnh sửa
Dữ liệu mẫu.
([0, 3, 4, 7, 9]) -> Sai
([3, 5, 7, 13]) -> Đúng([1, 5, 3]) -> False
Click me to see the sample solution

280. Viết chương trình Python để trích xuất số nguyên âm được chỉ định đầu tiên từ một chuỗi đã cho. Nếu số được chỉ định nhỏ hơn số nguyên âm có trong chuỗi thì hiển thị "n nhỏ hơn số nguyên âm có trong chuỗi". Chuyển đến trình chỉnh sửa
Dữ liệu mẫu.
("Python", 2) -> "n nhỏ hơn số nguyên âm có trong chuỗi. "
("Bài tập Python", 3) -> "oEe"
("aeiou") -> "AEI"
Click me to see the sample solution

281. Write a Python program that takes a list of integers and finds all pairs of integers that differ by three. Trả về tất cả các cặp số nguyên trong một danh sách. Chuyển đến trình chỉnh sửa
Dữ liệu mẫu.
([0, 3, 4, 7, 9]) -> [[0, 3], [4, 7]]
[0, -
([1, 2, 3, 4, 5]) -> [[1, 4], [2, 5]]
([100, 102, 103, 114, 115]) -> [[100, 103]]
Click me to see the sample solution

Danh sách. Bảng gian lận

Đang tạo danh sách

colors = ['Red', 'Blue', 'Green', 'Black', 'White']

Truy cập các phần tử

# Getting the first element
first_col = colors[0]
# Getting the second element
second_col = colors[1]
# Getting the last element
newest_col = colors[-1]

Sửa đổi các mục riêng lẻ

# Changing an element
colors[0] = 'Yellow'
colors[-2] = 'Red'

Thêm phần tử

# Adding an element to the end of the list
colors.append('Orange')
# Starting with an empty list
colors = []
colors.append('Red')
colors.append('Blue')
colors.append('Green')
# Inserting elements at a particular position
colors.insert(0, 'Violet')
colors.insert(2, 'Purple')

Loại bỏ các yếu tố

# Deleting an element by its position
del colors[-1]
# Removing an item by its value
colors.remove('Green')

yếu tố popping

# Pop the last item from a list
most_recent_col = colors.pop()
print(most_recent_col)
# Pop the first item in a list
first_col = colors.pop(0)
print(first_col)

Độ dài danh sách

# Find the length of a list
num_colors = len(colors)
print("We have " + str(num_colors) + " colors.")

Sorting a list

# Sorting a list permanently
colors.sort()
# Sorting a list permanently in reverse alphabetical order
colors.sort(reverse=True)
# Sorting a list temporarily
print(sorted(colors))
print(sorted(colors, reverse=True))
# Reversing the order of a list
colors.reverse()

Vòng qua một danh sách

________số 8

Hàm phạm vi ()

# Printing the numbers 0 to 2000
for num in range(2001):
 print(num)
# Printing the numbers 1 to 2000
for num in range(1, 2001):
 print(num)
# Making a list of numbers from 1 to a million
nums = list(range(1, 1000001))

thống kê đơn giản

# Getting the first element
first_col = colors[0]
# Getting the second element
second_col = colors[1]
# Getting the last element
newest_col = colors[-1]
0

Cắt một danh sách

# Getting the first element
first_col = colors[0]
# Getting the second element
second_col = colors[1]
# Getting the last element
newest_col = colors[-1]
1

Sao chép một danh sách

# Getting the first element
first_col = colors[0]
# Getting the second element
second_col = colors[1]
# Getting the last element
newest_col = colors[-1]
2

Danh sách hiểu

# Getting the first element
first_col = colors[0]
# Getting the second element
second_col = colors[1]
# Getting the last element
newest_col = colors[-1]
3

Trình chỉnh sửa mã Python

Nhiều hơn để đến

Không gửi bài giải các bài tập trên tại đây, nếu muốn đóng góp hãy vào trang bài tập phù hợp

What will be the output of the following Python code L =[ 1 2 3 4 5?

1. Đầu ra của mã Python sau đây sẽ là gì? . Trong mã hiển thị ở trên, mỗi số trong danh sách, nghĩa là 1, 2, 3, 4 và 5 được AND-ed với 1 và kết quả được in dưới dạng danh sách. Do đó, đầu ra là [1, 0, 1, 0, 1] .

Đầu ra của mã Python sau T =( 1 2 4 3 print T 1 3 ]) sẽ là gì?

Danh sách đã cho. t = [1,2,3,4] t{1. 3] trả về các phần tử của danh sách t từ chỉ mục 1 (phạm vi bắt đầu) đến chỉ mục 2 (phạm vi kết thúc - 10. Các phần tử từ chỉ số 1 đến 2 là - [2,3]. Do đó, đầu ra. [2,3] .

Mã Python nào sau đây sẽ cho cùng một đầu ra TUPL =( 1 2 3 4 I print TUPL [

Giải thích. print(tupl[. -1]) và in(tupl[0. 4]) hai mã Python sẽ cho cùng một đầu ra.

Câu lệnh nào sau đây tạo ra một danh sách các số từ 1 đến 1000 chia hết cho 3 là đúng?

Giải thích. việc hiểu danh sách [x for x in range(1000) if x%3==0] tạo danh sách các số từ 1 đến 1000 có thể chia hết .