CBSE Class 11 Computer Science Question 63 of 80

Conditional and Looping Constructs — Question 33

Back to all questions
33
Question

Question 17

Write a function to display prime numbers below 30.

Solution
def prime_numbers():
    for num in range(2, 30):
        for i in range(2, num):
            if num % i == 0:
                break
        else:
                print(num)
    
prime_numbers()
Output
2
3
5
7
11
13
17
19
23
29
Answer