From 2a701f3c48e07bd53d7b5451940f3bf7ab7519c3 Mon Sep 17 00:00:00 2001
From: Ganesh <cb.en.u4cse16218@cb.students.amrita.edu>
Date: Thu, 13 Dec 2018 00:17:54 +0530
Subject: [PATCH] hi

---
 cse16218_ex2_10.py | 23 +++++++++++++++++++++++
 cse16218_ex2_2.py  |  6 ++++++
 cse16218_ex2_4.py  |  8 ++++++++
 cse16218_ex2_5.py  |  7 +++++++
 cse16218_ex2_6.py  |  3 +++
 cse16218_ex2_7.py  |  3 +++
 cse16218_ex2_8.py  |  3 +++
 cse16218_ex2_9.py  | 16 ++++++++++++++++
 8 files changed, 69 insertions(+)
 create mode 100644 cse16218_ex2_10.py
 create mode 100644 cse16218_ex2_2.py
 create mode 100644 cse16218_ex2_4.py
 create mode 100644 cse16218_ex2_5.py
 create mode 100644 cse16218_ex2_6.py
 create mode 100644 cse16218_ex2_7.py
 create mode 100644 cse16218_ex2_8.py
 create mode 100644 cse16218_ex2_9.py

diff --git a/cse16218_ex2_10.py b/cse16218_ex2_10.py
new file mode 100644
index 0000000..7d45c9c
--- /dev/null
+++ b/cse16218_ex2_10.py
@@ -0,0 +1,23 @@
+def depth(s, n): 
+    current_max = 0
+    final_max = 0
+    
+    for i in range(n): 
+        if s[i] == '(': 
+            current_max += 1
+  
+            if current_max > final_max: 
+                final_max = current_max 
+        elif s[i] == ')': 
+            if current_max > 0: 
+                current_max -= 1
+            else: #unbalanced
+                return -1
+                
+    if current_max != 0: #unbalanced
+        return -1
+  
+    return final_max
+  
+s = input()
+print (depth(s, len(s)))
diff --git a/cse16218_ex2_2.py b/cse16218_ex2_2.py
new file mode 100644
index 0000000..744a6ec
--- /dev/null
+++ b/cse16218_ex2_2.py
@@ -0,0 +1,6 @@
+s = str(input())
+
+for i in range(97, 123):
+	v = s.count(chr(i))
+	if(v>0):
+		print(chr(i) + ": " + str(v))
diff --git a/cse16218_ex2_4.py b/cse16218_ex2_4.py
new file mode 100644
index 0000000..3215086
--- /dev/null
+++ b/cse16218_ex2_4.py
@@ -0,0 +1,8 @@
+s = list(input())
+
+for i in range(1, len(s)):
+	if(s[i] == s[0]):
+		s[i] = "$"
+
+s = "".join(s)
+print(s)
diff --git a/cse16218_ex2_5.py b/cse16218_ex2_5.py
new file mode 100644
index 0000000..d3f23fc
--- /dev/null
+++ b/cse16218_ex2_5.py
@@ -0,0 +1,7 @@
+a = input("Enter the first string")
+x = a[:2]
+x1 = a[2:]
+b = input("Enter the Second String")
+y = b[:2]
+y1 = b[2:]
+print (y+x1+" "+x+y1)
diff --git a/cse16218_ex2_6.py b/cse16218_ex2_6.py
new file mode 100644
index 0000000..ddd30b7
--- /dev/null
+++ b/cse16218_ex2_6.py
@@ -0,0 +1,3 @@
+str=["PHP", "Exercises", "Backend"]
+c=max(str,key=len)
+print(c)
diff --git a/cse16218_ex2_7.py b/cse16218_ex2_7.py
new file mode 100644
index 0000000..2deaa12
--- /dev/null
+++ b/cse16218_ex2_7.py
@@ -0,0 +1,3 @@
+str = "Ganesh"
+print(str.upper())
+print(str.lower())
diff --git a/cse16218_ex2_8.py b/cse16218_ex2_8.py
new file mode 100644
index 0000000..c14aadd
--- /dev/null
+++ b/cse16218_ex2_8.py
@@ -0,0 +1,3 @@
+n=input("Enter the String :")
+if len(n)%4 == 0:
+  print(n[::-1])
diff --git a/cse16218_ex2_9.py b/cse16218_ex2_9.py
new file mode 100644
index 0000000..4939509
--- /dev/null
+++ b/cse16218_ex2_9.py
@@ -0,0 +1,16 @@
+def encrypt(string, shift):
+ 
+  cipher = ''
+  for char in string: 
+    if char == ' ':
+      cipher = cipher + char
+    elif  char.isupper():
+      cipher = cipher + chr((ord(char) + shift - 65) % 26 + 65)
+    else:
+      cipher = cipher + chr((ord(char) + shift - 97) % 26 + 97)
+  
+  return cipher
+ 
+s= input("String: ")
+shift = int(input("Shift: "))
+print("Encrypted String: ", encrypt(s, shift))
-- 
GitLab