Skip to content

Commit cc0040f

Browse files
Update a.py
1 parent a106226 commit cc0040f

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

a.py

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
"""first code"""
2-
A=10
3-
B=5
4-
C=A+B
5-
print(A+B)
6-
if C>10:
7-
print("sum is greater thankhjabfr 10")
8-
elif C<=10:
9-
print("sum is smaller tha or equal to 10")
10-
D=10
11-
E=5
12-
F=D+E
13-
print(F)
14-
if F>10:
15-
print("sum is greater than 10")
16-
elif F<=10:
17-
print("sum is smaller tha or equal to 10")
18-
G=10
19-
H=5
20-
I=G+H
21-
print(I)
22-
if I>10:
23-
print("sum is greater than 10")
24-
elif I<=10:
25-
print("sum is smaller tha or equal to 10")
26-
J=10
27-
K=5
28-
L=J+K
29-
print(L)
30-
if L>10:
31-
print("sum is greater than 10")
32-
elif L<=10:
33-
print("sum is smaller tha or equal to 10")
34-
#first comment
1+
def is_prime(num):
2+
"""
3+
Check if a number is a prime number.
4+
"""
5+
if num <= 1:
6+
return False
7+
for i in range(2, int(num ** 0.5) + 1):
8+
if num % i == 0:
9+
return False
10+
return True
11+
12+
def count_primes(numbers):
13+
"""
14+
Count the number of prime numbers in a list.
15+
"""
16+
prime_count = 0
17+
for number in numbers:
18+
if is_prime(number):
19+
prime_count += 1
20+
return prime_count
21+
22+
def main():
23+
"""
24+
Main function to demonstrate prime number checking.
25+
"""
26+
numbers = [2, 3, 4, 5, 10, 15, 17, 19, 20, 23, 29]
27+
primes = [num for num in numbers if is_prime(num)]
28+
prime_count = count_primes(numbers)
29+
30+
print(f"Numbers: {numbers}")
31+
print(f"Prime numbers: {primes}")
32+
print(f"Total prime count: {prime_count}")
33+
34+
if __name__ == "__main__":
35+
main()

0 commit comments

Comments
 (0)