Question 9 - Week 5 Practice | Prasnya
Prasnya
Continue with Google
Practice path
Dashboard
Exam
Qualifier / Quiz 1
Go to subject
Programing with python
Go to chapter
Week 5
Question 9
00:00
Est. 3 min
Marks:
+4.00
0.00
Select all correct implementations of a program that prints the first
10
10
prime numbers to the console, one number on each line. The first
10
10
prime numbers are less than
30
30
and the
11
11
th prime number is more than
30
30
.
Multiple correct
Hard Difficulty
16 July 2023
A
``` for i in range(2, 30): flag = False for j in range(2, int(i / 2) + 1): if i % j == 0: flag = True break if flag == False: print(i) ```
B
``` for i in range(2, 30): flag = False for j in range(2, i): if i % j == 0: flag = True break if flag == False: print(i) ```
C
``` count = 0 i = 2 while count < 10: flag = True for j in range(2, i // 2 + 1): if i % j == 0: flag = False break if flag: print(i) count += 1 i += 1 ```
D
``` count = 0 i = 2 while count < 10: flag = True for j in range(2, i // 2 + 1): if i % j != 0: break else: flag = False if flag: print(i) count += 1 i += 1 ```