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

Commit a3dde13

Browse files
authored
Solutions
1 parent e3039eb commit a3dde13

6 files changed

+78
-0
lines changed

1_div5not7.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'''program in python to print the sum of numbers
2+
that are divisible by 5 and not divisible by 7'''
3+
sum = 0
4+
for i in range(1, 500): #specify max-range of 500
5+
if (i % 5 == 0 and i % 7 != 0): #initial condition
6+
sum = sum + i
7+
print sum

2_surface_area.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
l=8
2+
b=8
3+
h=10
4+
def tsr1(l,b,h):
5+
area=2*((l*b)+(l*h)+(h*b))
6+
print("The area before increase in 15% of room's dimensions is : ",area)
7+
8+
def tsr2(l,b,h):
9+
l=8+0.15
10+
b=8+0.15
11+
h=10+0.15
12+
area=2*((l*b)+(l*h)+(h*b))
13+
print("The area after increase in 15% of room's dimensions is : ",area)
14+
15+
tsr1(l,b,h)
16+
tsr2(l,b,h)

3_ListSort_concat.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
list1 = ['Ron', 'Hermoine', 'Harry', 'Professor','Potter','Dobby','Granger','Lockhart','Weasly']
2+
list2=['Potter','Gred','Greg','George','Voldemort','Sirius','Dumbledore']
3+
list1.sort();
4+
list2.sort();
5+
print("The sorted list1 is : ",list1)
6+
print("The sorted list2 is : ",list2)
7+
8+
concatlist=list(set(list1+list2))
9+
print("List after concatenation : ",concatlist)
10+
concatlist.sort();
11+
print("list after sorting the concatenated list : ",concatlist)

5_one_twenty.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
primeNo = [2,3,5,7,11,13,17,19]
2+
sno = 1
3+
4+
#def Primefac(n): returns the list of prime factors of 'n'
5+
def Primefac(n):
6+
pfac = []
7+
for j in primeNo:
8+
if i % j == 0:
9+
pfac.append(j)
10+
11+
return pfac
12+
13+
#multiplies all the prime factors of all the numbers
14+
#from 1[1..20]
15+
for i in range(1,20+1):
16+
primelst = Primefac(i)
17+
for i in primelst:
18+
sno *= i
19+
print ('smallest number divisible by [1..20] without remainder ',sno)

6_prime.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
max=int(input("enter max. no. upto which you want find prime numbers : " ))
2+
for i in range(2,max+1):
3+
prime=True
4+
for j in range(2,i):
5+
if i%j==0:
6+
prime=False
7+
if prime:
8+
print(i)
9+
10+

7_palindrome.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'''Program to check for a palindrome string'''
2+
3+
def isPalindrome(str):
4+
rev=str[::-1]
5+
print("String : ",str)
6+
print("reverse : ",rev)
7+
if(str==rev):
8+
return True
9+
else:
10+
return False
11+
x=input("enter a string : ")
12+
if isPalindrome(x):
13+
print("It is a Palindrome Number")
14+
else:
15+
print("It is not a palindrome number")

0 commit comments

Comments
 (0)