-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogic-pass
80 lines (53 loc) · 1.32 KB
/
logic-pass
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#Mohammed Qasim Kadhim
#Q1
str = "AI 4 Climate "
print (" String: " + str)
str2 = str.replace('4', '')
print (" String after remove one character : " + str2)
print("**********************************************************")
#Q2
#to Ceak Number Prime or not Prime
n=int(input("Enter a Number: "))
for i in range(2,n):
if n%2==0:
print("Not Prime Number")
else:
print("Prime Number")
break
#Q2
"""
Another solution for Q1
to Find Prime Numbers
"""
r=int(input("Enter a Number: "))
for i in range(2,r+1):
k=0
for j in range(2,i//2+1):
if(i%j==0):
k=k+1
if(k<=0):
print(i)
#Q2
#another solution by using primePy library
from primePy import primes
print(primes.check(7))
print("**********************************************************")
#Q3
def count_letter(String):
for i in range(0, len(String)):
count = 1;
for j in range(i+1, len(String)):
if(String[i] == String[j] and String[i] != ' '):
count = count + 1;
String = String[:j] + '0' + String[j+1:]
if(count > 1 and String[i] != '0'):
print(String[i],"=",count)
Str1 = "AI dojo "
Str2="computiq"
Str3="mosul space"
print("str1 :")
count_letter(Str1)
print("str2 :")
count_letter(Str2)
print("str3 :")
count_letter(Str3)