Skip to content

Commit 6cf4b9a

Browse files
committed
First Commit
1 parent d3b0156 commit 6cf4b9a

File tree

120 files changed

+2576
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+2576
-0
lines changed

BuiltIns/AnyorAll.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'''
2+
Title : Any or All
3+
Subdomain : Built-Ins
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 15 July 2016
7+
'''
8+
n = int(input())
9+
ar = list(map(int,input().split()))
10+
ar = sorted(ar)
11+
if(ar[0]<=0):
12+
print(False)
13+
else:
14+
chk = False
15+
for i in ar:
16+
s = str(i)
17+
if (s==s[::-1]):
18+
chk = True
19+
break
20+
print(chk)

BuiltIns/Input.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'''
2+
Title : Input()
3+
Subdomain : Built-Ins
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 15 July 2016
7+
'''
8+
x,k=list(map(int,raw_input().split()))
9+
print(input() == k)

BuiltIns/PythonEvaluation.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'''
2+
Title : Python Evaluation
3+
Subdomain : Built-Ins
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 15 July 2016
7+
'''
8+
eval(input())

BuiltIns/SortData.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'''
2+
Title : Sort Data
3+
Subdomain : Built-Ins
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 15 July 2016
7+
'''
8+
n, m = map(int,input().split())
9+
ar = []
10+
for i in range(n):
11+
ar.append(list(map(int,input().split())))
12+
k = int(input())
13+
ar = sorted(ar,key = lambda x:x[k])
14+
for i in ar:
15+
[print(x,end=' ') for x in i]
16+
print('')

BuiltIns/Zipped.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'''
2+
Title : Zipped!
3+
Subdomain : Built-Ins
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 15 July 2016
7+
'''
8+
n, x = map(int,input().split())
9+
ar = [0 for i in range(n)]
10+
for i in range(x):
11+
temp_ar=list(map(float,input().split()))
12+
for j in range(n):
13+
ar[j] += temp_ar[j]
14+
for i in range(n):
15+
print(ar[i]/x)

BuiltIns/ginortS.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'''
2+
Title : ginortS
3+
Subdomain : Built-Ins
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 15 July 2016
7+
'''
8+
s = input()
9+
s = sorted(s,key = lambda x:(x.isdigit() and int(x)%2==0, x.isdigit(),x.isupper(),x.islower(),x))
10+
print(*(s),sep = '')
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'''
2+
Title : Class 2 - Find the Torsional Angle
3+
Subdomain : Classes
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 15 July 2016
7+
'''
8+
# Enter your code here. Read input from STDIN. Print output to STDOUT
9+
10+
import math
11+
def custom_diff(a,b):
12+
res0 = a[0] - b[0]
13+
res1 = a[1] - b[1]
14+
res2 = a[2] - b[2]
15+
return [res0,res1,res2]
16+
17+
def dot_product(a,b):
18+
return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]
19+
20+
def abs_val(a):
21+
tmp_val=a[0]*a[0]+a[1]*a[1]+a[2]*a[2]
22+
return math.sqrt(tmp_val)
23+
24+
25+
26+
def cross(a, b):
27+
c = [a[1]*b[2] - a[2]*b[1],
28+
a[2]*b[0] - a[0]*b[2],
29+
a[0]*b[1] - a[1]*b[0]]
30+
31+
return c
32+
33+
a_str_ar=raw_input().strip().split()
34+
b_str_ar=raw_input().strip().split()
35+
c_str_ar=raw_input().strip().split()
36+
d_str_ar=raw_input().strip().split()
37+
38+
a=list(map(float,a_str_ar))
39+
b=list(map(float,b_str_ar))
40+
c=list(map(float,c_str_ar))
41+
d=list(map(float,d_str_ar))
42+
43+
ab=custom_diff(b,a)
44+
bc=custom_diff(c,b)
45+
cd=custom_diff(d,c)
46+
47+
x=cross(ab,bc)
48+
y=cross(bc,cd)
49+
50+
cosphi_top=dot_product(x,y)
51+
cosphi_bottom=abs_val(x)*abs_val(y)
52+
cosphi=cosphi_top/cosphi_bottom
53+
54+
res=math.degrees(math.acos(cosphi))
55+
56+
print "%.2f" %res
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'''
2+
Title : Classes: Dealing with Complex Numbers
3+
Subdomain : Classes
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 15 July 2016
7+
'''
8+
# Enter your code here. Read input from STDIN. Print output to
9+
10+
11+
c_str_ar=raw_input().strip().split()
12+
d_str_ar=raw_input().strip().split()
13+
14+
def custom_print(n):
15+
r=n.real
16+
i=n.imag
17+
ret_str=""
18+
if(i==0 and r==0):
19+
ret_str="0.00"
20+
elif(r==0):
21+
tmp_str="%.2f" %i
22+
ret_str=tmp_str+"i"
23+
elif(i==0):
24+
tmp_str="%.2f" %r
25+
ret_str=tmp_str
26+
else:
27+
tmp_str1="%.2f" %r
28+
tmp_str2="%.2f" %i
29+
if(i>0):
30+
ret_str=tmp_str1+" + "+tmp_str2+"i"
31+
else:
32+
i=i*-1
33+
tmp_str2="%.2f" %i
34+
ret_str=tmp_str1+" - "+tmp_str2+"i"
35+
print ret_str
36+
37+
cr=float(c_str_ar[0])
38+
ci=float(c_str_ar[1])
39+
dr=float(d_str_ar[0])
40+
di=float(d_str_ar[1])
41+
c=complex(cr,ci)
42+
d=complex(dr,di)
43+
44+
val_add=c+d
45+
val_sub=c-d
46+
val_mul=c*d
47+
val_div=c/d
48+
mod_c=abs(c)
49+
mod_d=abs(d)
50+
51+
custom_print(val_add)
52+
custom_print(val_sub)
53+
custom_print(val_mul)
54+
custom_print(val_div)
55+
56+
57+
print "%.2f" %mod_c
58+
print "%.2f" %mod_d
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'''
2+
Title : Decorators 2 - Name Directory
3+
Subdomain : Closures and Decorators
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 15 July 2016
7+
'''
8+
# Enter your code here. Read input from STDIN. Print output to STDOUT
9+
ar=[]
10+
n=int(raw_input())
11+
for i in range(0,n):
12+
str_ar=raw_input().strip().split()
13+
user_name=str_ar[0]+" "+str_ar[1]
14+
user_age=int(str_ar[2])
15+
user_sex=str_ar[3]
16+
user_new_name=""
17+
if(user_sex=="M"):
18+
user_new_name="Mr. "+user_name
19+
else:
20+
user_new_name="Ms. "+user_name
21+
ar.append([user_new_name,user_age])
22+
23+
sorted = sorted(ar, key=lambda tup: tup[1])
24+
for i in range(0,n):
25+
print sorted[i][0]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'''
2+
Title : Standardize Mobile Number Using Decorators
3+
Subdomain : Closures and Decorators
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 15 July 2016
7+
'''
8+
# Enter your code here. Read input from STDIN. Print output to STDOUT
9+
n=int(raw_input())
10+
ar=[]
11+
for i in range(0,n):
12+
tmp_str=raw_input()
13+
tmp_str=tmp_str[len(tmp_str)-10:]
14+
ar.append(tmp_str)
15+
16+
ar.sort()
17+
for i in range(0,len(ar)):
18+
print "+91 "+ar[i][:5]+" "+ar[i][5:]

0 commit comments

Comments
 (0)