Skip to content

Commit 743bf04

Browse files
committed
added python3 code for introduction subdomain
1 parent f1be23e commit 743bf04

File tree

7 files changed

+42
-41
lines changed

7 files changed

+42
-41
lines changed

Introduction/ArithmeticOperators.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
Subdomain : Introduction
44
Domain : Python
55
Author : Ahmedur Rahman Shovon
6-
Created : 15 July 2016
6+
Created : 15 April 2020
77
Problem : https://www.hackerrank.com/challenges/python-arithmetic-operators/problem
88
'''
9-
# Enter your code here. Read input from STDIN. Print output to STDOUT
10-
a=int(raw_input())
11-
b=int(raw_input())
12-
print a+b
13-
print a-b
14-
print a*b
9+
if __name__ == '__main__':
10+
a = int(input())
11+
b = int(input())
12+
print(a+b)
13+
print(a-b)
14+
print(a*b)

Introduction/Loops.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
Subdomain : Introduction
44
Domain : Python
55
Author : Ahmedur Rahman Shovon
6-
Created : 15 July 2016
6+
Created : 13 May 2020
77
Problem : https://www.hackerrank.com/challenges/python-loops/problem
88
'''
9-
# Enter your code here. Read input from STDIN. Print output to STDOUT
10-
a=int(raw_input())
11-
for i in range(0,a):
12-
print i*i
9+
if __name__ == '__main__':
10+
n = int(input())
11+
for i in range(n):
12+
print(i*i)
13+

Introduction/PrintFunction.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@
33
Subdomain : Introduction
44
Domain : Python
55
Author : Ahmedur Rahman Shovon
6-
Created : 15 July 2016
6+
Created : 06 July 2020
77
Problem : https://www.hackerrank.com/challenges/python-print/problem
88
'''
9-
n=int(input())
10-
ar=range(1,n+1)
11-
for i in ar:
12-
print(i,end="")
9+
10+
if __name__ == '__main__':
11+
n = int(input())
12+
ar=range(1,n+1)
13+
for i in ar:
14+
print(i,end="")
15+
16+
"""
17+
Alternate solution:
18+
19+
if __name__ == '__main__':
20+
n = int(input())
21+
print("".join([str(i) for i in range(1,n+1)]))
22+
23+
"""

Introduction/PythonDivision.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
Subdomain : Introduction
44
Domain : Python
55
Author : Ahmedur Rahman Shovon
6-
Created : 15 July 2016
6+
Created : 06 July 2020
77
Problem : https://www.hackerrank.com/challenges/python-division/problem
88
'''
9-
# Enter your code here. Read input from STDIN. Print output to STDOUT
10-
a=int(raw_input())
11-
b=int(raw_input())
12-
print a/b
13-
c=float(a)
14-
print c/b
9+
if __name__ == '__main__':
10+
a = int(input())
11+
b = int(input())
12+
print(a//b)
13+
print(a/b)
14+

Introduction/ReadingRawInput.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

Introduction/Writeafunction.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
Subdomain : Introduction
44
Domain : Python
55
Author : Ahmedur Rahman Shovon
6-
Created : 15 July 2016
6+
Created : 06 July 2020
77
Problem : https://www.hackerrank.com/challenges/write-a-function/problem
88
'''
99
def is_leap(year):
10-
leap = False
11-
if (year % 400 == 0):
12-
leap = True
13-
elif year % 4 == 0 and year % 100 !=0:
14-
leap = True
10+
leap = False
11+
leap = (year%400==0) or (year%4==0 and year%100!=0)
1512
return leap
13+
14+
year = int(input())
15+
print(is_leap(year))

readme.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ My solutions of <strong>Hackerrank Python Domain</strong> challenges. The codes
1919

2020
- Introduction
2121
- [Say Hello, World! With Python](Introduction/SayHelloWorldWithPython.py)
22-
- [Reading Raw Input](Introduction/ReadingRawInput.py)
2322
- [Python If-Else](Introduction/PythonIfElse.py)
2423
- [Arithmetic Operators](Introduction/ArithmeticOperators.py)
2524
- [Python: Division](Introduction/PythonDivision.py)

0 commit comments

Comments
 (0)