From 448811c4ad2af9af5c3e0589bd62a94338236e45 Mon Sep 17 00:00:00 2001 From: aslesha <cb.en.u4cse16259@cb.students.amrita.edu> Date: Wed, 19 Dec 2018 12:37:39 +0530 Subject: [PATCH] Add new file --- lab2/cse16259_e2_9.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lab2/cse16259_e2_9.py diff --git a/lab2/cse16259_e2_9.py b/lab2/cse16259_e2_9.py new file mode 100644 index 0000000..7b8cfdb --- /dev/null +++ b/lab2/cse16259_e2_9.py @@ -0,0 +1,14 @@ +def encrypt(text,s): + result = "" + for i in range(len(text)): + char = text[i] + if (char.isupper()): + result += chr((ord(char) + s-65) % 26 + 65) + else: + result += chr((ord(char) + s - 97) % 26 + 97) + return result +text=input("enter the sentence to encrypt: ") +s=int(input("enter the no of shift locations to do: ")) +print("given text: "+text) +print("Shift locations: "+str(s)) +print("encrypted text: " +encrypt(text,s)) -- GitLab