Informatics Practices
Write a function to display prime numbers below 30.
Python Control Flow
8 Likes
Answer
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
Answered By
3 Likes
Related Questions
WAP to convert binary number to decimal number.
Write a Python program to compute sum of digits of a given number.
WAP to print the sum of the series 1 - x1/2! + x2/3! - x3/4! …………… xn/(n + 1)! — exponential series.
WAP to print the sum of the series 1 - x2/4! + x3/6! - x4/8! + x5/10! …………… xn/(2n)! — exponential series.