Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 1_sum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sum=0
for i in range(1,500):
if (i%5==0)and(i%7!=0):
sum=sum+i
print(sum)
8 changes: 8 additions & 0 deletions 2_area.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
l=6
w=8
h=10
fl=1.15*6
fw=1.15*8
fh=1.15*10
a=2*(fw*fh+fh*fl+fl*fw)
print(a)
6 changes: 6 additions & 0 deletions 3_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
list2=['Potter','Fred','Greg','George','Voldemort','Sirius','Dumbledore']
list1=['Ron','Hermione','Harry','Professor','Dobby','The House Elf','Potter','Granger','Lockhart','Weasly']
print(sorted(list1)+list2)



7 changes: 7 additions & 0 deletions 4_pythagorean_triplet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
for a in range(1,1000):
for b in range(a+1,1000):
c=1000-(a+b)
if(a**2)+(b**2)==(c**2):
if a+b+c==1000:
print(a*b*c)
break
12 changes: 12 additions & 0 deletions 5_lcm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def gcd(a,b):
while b:
a,b=b,a%b
return a

def lcm(a,b):
return (a*b)//gcd(a,b)

x=1
for i in range(2,21):
x=lcm(x,i)
print(x)
12 changes: 12 additions & 0 deletions 6_prime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def isPrime(x):
for i in range(2,int(x**0.5)+1):
if(x%i==0):
return False
return True

def printPrimes(n):
print("primes are")
for i in range(2,n+1):
if(isPrime(i)):
print(i)
printPrimes(9999)
6 changes: 6 additions & 0 deletions 7_palindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
str1=input("enter a string:")
str1_rev=str(str1[::-1])
if(str1==str1_rev):
print("palindrome")
else:
print("not a palindrome")