Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 67adfd9

Browse files
authored
Add files via upload
1 parent 19c04a3 commit 67adfd9

7 files changed

+105
-0
lines changed

code/1_sum.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
count=0
2+
for x in range(5,496):
3+
if x%5==0 and x%7!=0:
4+
count=count+x
5+
print(count)
6+
7+
8+

code/2_area.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
height=6
2+
length=7
3+
width=8
4+
height=6+6*(15/100)
5+
length=7+7*(15/100)
6+
width=8+8*(15/100)
7+
area=length*height*width
8+
print(area)
9+

code/3_sort.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
mylist=["Ron",
2+
"Hermione",
3+
"Harry",
4+
"Professor",
5+
"Dobby",
6+
"List Items 2",
7+
"The House Elf",
8+
"Potter",
9+
"Granger",
10+
"Lockhart",
11+
"Weasley"
12+
]
13+
mylist.sort()
14+
for x in sorted(mylist):
15+
print(x)
16+
mylist.extend(["Potter",
17+
"Fred",
18+
"Greg",
19+
"George",
20+
"Voldemort",
21+
"Sirius",
22+
"Dumbledore"])
23+
mylist.sort()
24+
for x in sorted(mylist):
25+
print(x)

code/4_triplet.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
a=0
2+
b=0
3+
c=0
4+
def test(a,b):
5+
for b1 in range(1,b-1):
6+
test1(a,b1,1000-a-b1)
7+
def test1(a,b,c):
8+
if a+b+c==1000:
9+
if a*a+b*b==c*c:
10+
print(a,b,c)
11+
12+
for a in range(1,998):
13+
test(a,1000-a)
14+

code/5_lcm.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def gcd(n1,n2):
2+
while n1!=n2:
3+
if n1>n2:
4+
n1=n1-n2
5+
elif n1<n2:
6+
n2=n2-n1
7+
return n1
8+
def lcm1(num1,num2):
9+
lcm=int(int(num1*num2)/int(gcd(num1,num2)))
10+
return lcm
11+
12+
l = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
13+
14+
num1=l[0]
15+
num2=l[1]
16+
lcm=lcm1(num1,num2)
17+
18+
for i in range(2,len(l)):
19+
lcm=lcm1(lcm,l[i])
20+
21+
print(lcm)

code/6_prime.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
flag=0
2+
for i in range(2,99999):
3+
for j in range(2,((i/2)+1)):
4+
if i%j==0:
5+
flag=1
6+
break
7+
if flag==0:
8+
print(i)
9+
else:
10+
flag=0
11+

code/7_palindrome.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def reverse(s):
2+
return s[::-1]
3+
4+
def Polindrome(s):
5+
rev = reverse(s)
6+
if (s == rev):
7+
return True
8+
return False
9+
10+
11+
s = raw_input("enter the string\n")
12+
ans = Polindrome(s)
13+
14+
if ans == 1:
15+
print("Yes")
16+
else:
17+
print("No")

0 commit comments

Comments
 (0)