From f45ec05f067c8bc8f8db3ed0a87b03d1ae3ebda6 Mon Sep 17 00:00:00 2001 From: tushar ulhare Date: Thu, 24 Oct 2019 10:54:31 +0530 Subject: [PATCH 1/2] Add ArraySum Sum of elements in Array. --- Basics/ArraySum.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Basics/ArraySum.py diff --git a/Basics/ArraySum.py b/Basics/ArraySum.py new file mode 100644 index 0000000..b1cfab7 --- /dev/null +++ b/Basics/ArraySum.py @@ -0,0 +1,13 @@ + +def _sum(arr,n): + + return(sum(arr)) + +arr=[] +arr = [12, 3, 4, 15] + +n = len(arr) + +ans = _sum(arr,n) + +print (\'Sum of the array is \',ans) \ No newline at end of file From 727290837e687db83e42054961d052d6b1d2724e Mon Sep 17 00:00:00 2001 From: tushar ulhare Date: Thu, 24 Oct 2019 11:09:52 +0530 Subject: [PATCH 2/2] Create TimeConverter.py This is python based program which will convert 12 hours time into 24 hours. --- TimeConverter.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 TimeConverter.py diff --git a/TimeConverter.py b/TimeConverter.py new file mode 100644 index 0000000..05b9a50 --- /dev/null +++ b/TimeConverter.py @@ -0,0 +1,16 @@ +def convert24(str1): + + + if str1[-2:] == "AM" and str1[:2] == "12": + return "00" + str1[2:-2] + + elif str1[-2:] == "AM": + return str1[:-2] + + elif str1[-2:] == "PM" and str1[:2] == "12": + return str1[:-2] + + else: + return str(int(str1[:2]) + 12) + str1[2:8] + +print(convert24("08:05:45 PM"))