Skip to content

Commit cf68da0

Browse files
authored
Adding more files
1 parent 9d39cb7 commit cf68da0

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

Caesar_Cypher.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
class Caesar():
2+
def __init__(self, text):
3+
self.text = text
4+
5+
def encryption(self):
6+
alphabets = "abcdefghijklmnopqrstuvwxyz"
7+
encrypted_text = ""
8+
9+
for char in text:
10+
for alpha in alphabets:
11+
if char == alpha:
12+
encrypted_text += alphabets[(alphabets.index(alpha) + 3) % 26]
13+
if char not in alphabets:
14+
encrypted_text += char
15+
print("Encrypted Text: ", encrypted_text)
16+
17+
def decryption(self):
18+
alphabets = "abcdefghijklmnopqrstuvwxyz"
19+
decrypted_text = ""
20+
21+
for char in text:
22+
for alpha in alphabets:
23+
if char == alpha:
24+
decrypted_text += alphabets[(alphabets.index(alpha) - 3) % 26]
25+
if char not in alphabets:
26+
decrypted_text += char
27+
print("Decrypted Text: ", decrypted_text)
28+
29+
30+
while True:
31+
choice = input(
32+
"\n========================CAESAR-CYPHER========================\n1. Encryption\n2. Decryption\n3. Exit\nChoose operation: ")
33+
if choice == str(1):
34+
text = input("Enter the text to Encrypt: ")
35+
obj = Caesar(text)
36+
obj.encryption()
37+
elif choice == str(2):
38+
text = input("Enter the text to Decrypt: ")
39+
obj = Caesar(text)
40+
obj.decryption()
41+
elif choice == str(3):
42+
print("Bye")
43+
break
44+
else:
45+
print("Please enter a valid choice.")

Function_Arguments.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def normal_function(first, second):
2+
print("First argument is: ", first)
3+
print("Second argument is: ", second)
4+
5+
6+
def fruits(*fruits_tuple):
7+
for fruit in fruits_tuple:
8+
print(fruit)
9+
print(type(fruits_tuple))
10+
11+
12+
def vegetables(**vegetables_list):
13+
print(vegetables_list["good"], " is a good vegetable.")
14+
print(vegetables_list["bad"], " is a bad vegetable.")
15+
print(type(vegetables_list))
16+
17+
18+
print()
19+
normal_function("one", 2)
20+
print()
21+
fruits("Mango", "Banana", "Pineapple", "Apple")
22+
print()
23+
vegetables(good="Carrot", bad="Bitter gourd")

Lambda_Function.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
sum = lambda a, b: a + b
2+
print("Sum of 20,30 = ", sum(20, 30))
3+
4+
ages = [20, 21, 8, 19, 22, 14, 8, 6]
5+
print("Ages above 18 are: ", list(filter(lambda x: x > 18, ages)))
6+
7+
fruits = ["Mango", "Strawberry", "Litchy", "Banana", "Apple", "Pear", "Blue Berries"]
8+
startsWithA = list(filter(lambda x: x.startswith("A"), fruits))
9+
print("Fruits which start with 'A' are:", startsWithA)
10+
11+
num_list = [10, 20, 40, 22, 33]
12+
doubled_list = list(map(lambda x: x * 2, num_list))
13+
print("Doubled elements are: ", doubled_list)

0 commit comments

Comments
 (0)