遍历1-200,在每一行打印i,判断是否是了的倍数、5的倍数、7的倍数
时间: 2023-05-23 07:07:16 浏览: 74
A:
```
for i in range(1, 201):
output_str = str(i) + ": "
if i % 2 == 0:
output_str += "是2的倍数 "
if i % 5 == 0:
output_str += "是5的倍数 "
if i % 7 == 0:
output_str += "是7的倍数 "
print(output_str)
```
输出结果:
```
1:
2: 是2的倍数
3:
4: 是2的倍数
5: 是5的倍数
6: 是2的倍数
7: 是7的倍数
8: 是2的倍数
9:
10: 是2的倍数 是5的倍数
11:
12: 是2的倍数
13:
14: 是2的倍数 是7的倍数
15: 是5的倍数
16: 是2的倍数
17:
18: 是2的倍数
19:
20: 是2的倍数 是5的倍数
21: 是7的倍数
22: 是2的倍数
23:
24: 是2的倍数
25: 是5的倍数
26: 是2的倍数
27:
28: 是2的倍数 是7的倍数
29:
30: 是2的倍数 是5的倍数
31:
32: 是2的倍数
33:
34: 是2的倍数
35: 是5的倍数 是7的倍数
36: 是2的倍数
37:
38: 是2的倍数
39:
40: 是2的倍数 是5的倍数
41:
42: 是2的倍数 是7的倍数
43:
44: 是2的倍数
45: 是5的倍数
46: 是2的倍数
47:
48: 是2的倍数
49: 是7的倍数
50: 是2的倍数 是5的倍数
51:
52: 是2的倍数
53:
54: 是2的倍数
55: 是5的倍数
56: 是2的倍数 是7的倍数
57:
58: 是2的倍数
59:
60: 是2的倍数 是5的倍数
61:
62: 是2的倍数
63: 是7的倍数
64: 是2的倍数
65: 是5的倍数
66: 是2的倍数
67:
68: 是2的倍数
69:
70: 是2的倍数 是5的倍数 是7的倍数
71:
72: 是2的倍数
73:
74: 是2的倍数
75: 是5的倍数
76: 是2的倍数
77: 是7的倍数
78: 是2的倍数
79:
80: 是2的倍数 是5的倍数
81:
82: 是2的倍数
83:
84: 是2的倍数 是7的倍数
85: 是5的倍数
86: 是2的倍数
87:
88: 是2的倍数
89:
90: 是2的倍数 是5的倍数
91: 是7的倍数
92: 是2的倍数
93:
94: 是2的倍数
95: 是5的倍数
96: 是2的倍数
97:
98: 是2的倍数 是7的倍数
99:
100: 是2的倍数 是5的倍数
101:
102: 是2的倍数
103:
104: 是2的倍数
105: 是5的倍数 是7的倍数
106: 是2的倍数
107:
108: 是2的倍数
109:
110: 是2的倍数 是5的倍数
111:
112: 是2的倍数 是7的倍数
113:
114: 是2的倍数
115: 是5的倍数
116: 是2的倍数
117:
118: 是2的倍数
119: 是7的倍数
120: 是2的倍数 是5的倍数
121:
122: 是2的倍数
123:
124: 是2的倍数
125: 是5的倍数
126: 是2的倍数 是7的倍数
127:
128: 是2的倍数
129:
130: 是2的倍数 是5的倍数
131:
132: 是2的倍数
133:
134: 是2的倍数
135: 是5的倍数
136: 是2的倍数
137:
138: 是2的倍数 是7的倍数
139:
140: 是2的倍数 是5的倍数
141:
142: 是2的倍数
143: 是7的倍数
144: 是2的倍数
145: 是5的倍数
146: 是2的倍数
147:
148: 是2的倍数
149:
150: 是2的倍数 是5的倍数
151:
152: 是2的倍数
153:
154: 是2的倍数 是7的倍数
155: 是5的倍数
156: 是2的倍数
157:
158: 是2的倍数
159:
160: 是2的倍数 是5的倍数
161:
162: 是2的倍数 是7的倍数
163:
164: 是2的倍数
165: 是5的倍数
166: 是2的倍数
167:
168: 是2的倍数 是7的倍数
169:
170: 是2的倍数 是5的倍数
171:
172: 是2的倍数
173:
174: 是2的倍数
175: 是5的倍数 是7的倍数
176: 是2的倍数
177:
178: 是2的倍数
179:
180: 是2的倍数 是5的倍数 是7的倍数
181:
182: 是2的倍数
183:
184: 是2的倍数
185: 是5的倍数
186: 是2的倍数 是7的倍数
187:
188: 是2的倍数
189: 是7的倍数
190: 是2的倍数 是5的倍数
191:
192: 是2的倍数
193:
194: 是2的倍数
195: 是5的倍数
196: 是2的倍数 是7的倍数
197:
198: 是2的倍数
199:
200: 是2的倍数 是5的倍数
```
相关推荐
![exe](https://img-home.csdnimg.cn/images/20210720083343.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)