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 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"))