Tôi có bài tập sau:
Tạo một bộ gọi là 'C' với tất cả các số lẻ nhỏ hơn 10.set called 'c' with all the odd numbers less than 10.
Tôi tạo bộ được thiết lập thủ công:
c={'1', '3', '5', '7', '9'}
Làm thế nào tôi có thể tạo tập hợp này bằng một công thức để nó cũng khả thi với quy mô lớn hơn?
Cảm ơn bạn vì sự giúp đỡ của bạn?
hỏi ngày 3 tháng 2 năm 2020 lúc 6:20Feb 3, 2020 at 6:20
1
Sử dụng range
, như thế này:
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
Đã trả lời ngày 3 tháng 2 năm 2020 lúc 6:27Feb 3, 2020 at 6:27
Bogdan doicinbogdan doicinBogdan Doicin
2.2725 huy hiệu vàng26 Huy hiệu bạc32 Huy hiệu đồng5 gold badges26 silver badges32 bronze badges
3
Cải thiện bài viết
Lưu bài viết
Cải thiện bài viết
Lưu bài viết
Đọc
Example:
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 11
Bàn luận Print all odd numbers from the given list using for loop
- Được đưa ra bắt đầu và điểm cuối, hãy viết một chương trình Python để in tất cả các số lẻ trong phạm vi đã cho. & NBSP;
- Ví dụ #1: In tất cả các số lẻ từ danh sách đã cho bằng cách sử dụng cho Loop & nbsp;
- Xác định giới hạn bắt đầu và kết thúc của phạm vi.
- Lặp lại từ bắt đầu cho đến phạm vi trong danh sách sử dụng cho Loop và & NBSP;
Python3
Kiểm tra xem Num % 2! = 0. & nbsp;
Nếu điều kiện thỏa mãn, thì chỉ in số. & Nbsp;
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
0____11 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
2c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
3c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
4c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
5 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
6c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
7 range
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
9Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 110
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 111
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 112
Output:
5 7 9 11 13 15 17 19
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 113
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 114
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
6Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 116
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 117
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 118
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 5 7 9 11 13 15 17 190
5 7 9 11 13 15 17 191Example #2: Taking range limit from user input
Python3
5 7 9 11 13 15 17 192
5 7 9 11 13 15 17 193
5 7 9 11 13 15 17 194
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 5 7 9 11 13 15 17 196
5 7 9 11 13 15 17 197
& nbsp; Ví dụ #2: Lấy giới hạn phạm vi từ đầu vào của người dùng & nbsp;
Nếu điều kiện thỏa mãn, thì chỉ in số. & Nbsp;
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
0____11 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
2c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
3c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
45 7 9 11 13 15 17 192
5 7 9 11 13 15 17 193
[5, 7, 9, 11, 13, 15]3
Output:
Enter the start of range: 3 Enter the end of range: 7 3 5 7
5 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
6c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
7 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
range
9c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
Input: start = 4, end = 15
Output: 5, 7, 9, 11, 13, 15
Input: start = 3, end = 11
Output: 3, 5, 7, 9, 11
0 Input: start = 4, end = 15
Output: 5, 7, 9, 11, 13, 15
Input: start = 3, end = 11
Output: 3, 5, 7, 9, 11
1Input: start = 4, end = 15
Output: 5, 7, 9, 11, 13, 15
Input: start = 3, end = 11
Output: 3, 5, 7, 9, 11
2 Taking range limit from user input or with static inputs to reduce code execution time and to increase code performance.
Python3
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 113
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 114
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
6Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 116
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 117
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 118
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 5 7 9 11 13 15 17 190
5 7 9 11 13 15 17 191
5 7 9 11 13 15 17 192
5 7 9 11 13 15 17 193
5 7 9 11 13 15 17 194
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 5 7 9 11 13 15 17 196
5 7 9 11 13 15 17 197
& nbsp; Ví dụ #2: Lấy giới hạn phạm vi từ đầu vào của người dùng & nbsp;
5 7 9 11 13 15 17 198
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 Enter the start of range: 3 Enter the end of range: 7 3 5 70
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Enter the start of range: 3 Enter the end of range: 7 3 5 72
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Enter the start of range: 3 Enter the end of range: 7 3 5 7445
5 7 9 11 13 15 17 192
5 7 9 11 13 15 17 193
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
01c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
15 7 9 11 13 15 17 196
5 7 9 11 13 15 17 197
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
055 7 9 11 13 15 17 191
Enter the start of range: 3 Enter the end of range: 7 3 5 76
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 Enter the start of range: 3 Enter the end of range: 7 3 5 70
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Enter the start of range: 3 Enter the end of range: 7 3 5 72
Enter the start of range: 3 Enter the end of range: 7 3 5 71
5 7 9 11 13 15 17 1922
5 7 9 11 13 15 17 192
5 7 9 11 13 15 17 193
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
01c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
15 7 9 11 13 15 17 196
5 7 9 11 13 15 17 197
Ví dụ #3: Lấy giới hạn phạm vi từ đầu vào của người dùng hoặc với đầu vào tĩnh để giảm thời gian thực hiện mã và tăng hiệu suất mã.
5 7 9 11 13 15 17 19
5 7 9 11 13 15 17 19
8
1 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
[5, 7, 9, 11, 13, 15]
6 Taking range limit from
user input
Python3
Enter the start of range: 3 Enter the end of range: 7 3 5 76
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 [5, 7, 9, 11, 13, 15]9
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 114
5 7 9 11 13 15 17 198
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 116
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 117
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 118
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 5 7 9 11 13 15 17 190
5 7 9 11 13 15 17 191
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 113
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
5 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
6c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
7Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 113
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
5 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
6c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
7Đầu ra
Enter the start of range: 3 Enter the end of range: 11 3 5 7 9 11
Ví dụ #4: Lấy giới hạn phạm vi từ đầu vào của người dùng & nbsp;
Python3
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
65c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
67c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
68c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
70c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
71c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
735 7 9 11 13 15 17 198
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 Enter the start of range: 3 Enter the end of range: 7 3 5 70
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Enter the start of range: 3 Enter the end of range: 7 3 5 72
Enter the start of range: 3 Enter the end of range: 7 3 5 71
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
33Enter the start of range: 3 Enter the end of range: 7 3 5 75
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 113
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
83Enter the start of range: 3 Enter the end of range: 7 3 5 76
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 Enter the start of range: 3 Enter the end of range: 7 3 5 70
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Enter the start of range: 3 Enter the end of range: 7 3 5 72
Enter the start of range: 3 Enter the end of range: 7 3 5 71
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
41Enter the start of range: 3 Enter the end of range: 7 3 5 75
5 7 9 11 13 15 17 193
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
99Các
Python3
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
5 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
6c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
7 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
58Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 113
5 7 9 11 13 15 17 193
5 7 9 11 13 15 17 194
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 5 7 9 11 13 15 17 196
5 7 9 11 13 15 17 197
5 7 9 11 13 15 17 192
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1106
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 113
5 7 9 11 13 15 17 193
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1109
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 110
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 111
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1112
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
15 7 9 11 13 15 17 196
5 7 9 11 13 15 17 197
Phương pháp: Sử dụng chức năng Lambda
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1122
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
2Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1125
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1127
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1128
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
5 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
75c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
7 range
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
78Input: start = 4, end = 15
Output: 5, 7, 9, 11, 13, 15
Input: start = 3, end = 11
Output: 3, 5, 7, 9, 11
0Input: start = 4, end = 15
Output: 5, 7, 9, 11, 13, 15
Input: start = 3, end = 11
Output: 3, 5, 7, 9, 11
1Input: start = 4, end = 15
Output: 5, 7, 9, 11, 13, 15
Input: start = 3, end = 11
Output: 3, 5, 7, 9, 11
2
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
Python3
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
84___5 7 9 11 13 15 17 193
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1153
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1154
Phương pháp: Sử dụng đệ quy & nbsp;
Python3
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
65c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
2c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
68c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1127
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1161
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
735 7 9 11 13 15 17 198
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 Enter the start of range: 3 Enter the end of range: 7 3 5 70
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Enter the start of range: 3 Enter the end of range: 7 3 5 72
Enter the start of range: 3 Enter the end of range: 7 3 5 71
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
33Enter the start of range: 3 Enter the end of range: 7 3 5 75
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1172
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1173
Enter the start of range: 3 Enter the end of range: 7 3 5 76
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 Enter the start of range: 3 Enter the end of range: 7 3 5 70
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Enter the start of range: 3 Enter the end of range: 7 3 5 72
Enter the start of range: 3 Enter the end of range: 7 3 5 71
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
41Enter the start of range: 3 Enter the end of range: 7 3 5 75
Ví dụ #3: Lấy giới hạn phạm vi từ đầu vào của người dùng hoặc với đầu vào tĩnh để giảm thời gian thực hiện mã và tăng hiệu suất mã.
[5, 7, 9, 11, 13, 15]
5 7 9 11 13 15 17 19
8c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 [5, 7, 9, 11, 13, 15]
6
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
Python3
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
65c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
2c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
68c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1127
5 7 9 11 13 15 17 198
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 Enter the start of range: 3 Enter the end of range: 7 3 5 70
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Enter the start of range: 3 Enter the end of range: 7 3 5 72
Enter the start of range: 3 Enter the end of range: 7 3 5 71
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
33Enter the start of range: 3 Enter the end of range: 7 3 5 75
Enter the start of range: 3 Enter the end of range: 7 3 5 76
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 Enter the start of range: 3 Enter the end of range: 7 3 5 70
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Enter the start of range: 3 Enter the end of range: 7 3 5 72
Enter the start of range: 3 Enter the end of range: 7 3 5 71
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
41Enter the start of range: 3 Enter the end of range: 7 3 5 75
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 113
5 7 9 11 13 15 17 1913
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1172
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
055 7 9 11 13 15 17 191
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 113
5 7 9 11 13 15 17 193
5 7 9 11 13 15 17 1919
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
15 7 9 11 13 15 17 196
5 7 9 11 13 15 17 197
Phương pháp: Sử dụng Phương pháp bộ lọc:
Python3
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
65c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
25 7 9 11 13 15 17 1926
5 7 9 11 13 15 17 1927
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1127
5 7 9 11 13 15 17 1926
5 7 9 11 13 15 17 1931
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
1 c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
88Enter the start of range: 3 Enter the end of range: 7 3 5 71
c = set[]
for i in range[1, 10, 2]:
c.add[i]
print[c]
90 5 7 9 11 13 15 17 1936
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 116
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 117
5 7 9 11 13 15 17 193
Enter the start of range: 3 Enter the end of range: 7 3 5 71
Input: start = 4, end = 15 Output: 5, 7, 9, 11, 13, 15 Input: start = 3, end = 11 Output: 3, 5, 7, 9, 1153
5 7 9 11 13 15 17 1948
Output:
5 7 9 11 13 15