Department of Computer Science and Engineering
Introduction to Artificial Intelligence and Machine
Learning
(CSN12601)
Lab Assignment – 4
[Link]. Questions
1. Write a python program to accept a message from a user and perform your own
Encryption/Decryption:
Example:
Message :: “The guy named John is a secret agent”
Encrypted Message :: “vjg"iw{"pcogf"Lqjp"ku"c"ugetgv"cigpv”
Decrypted Message :: “The guy named John is a secret agent”
( Use predefined methods “chr()” and “ord()” )
2. Perform various task using List Comprehension:
1) Input : ["Ramesh","Naveen","Rajesh","Alok"]
Output: ['R', 'N', 'R', 'A']
2) Common elements present in num1 and num2
Input:
num1=[10,20,30,40]
num2=[30,40,50,60]
Output:
[30, 40]
3) Input : ['the', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']
Output: [['the', 3], ['quick', 5], ['brown', 5], ['fox', 3], ['jumps', 5], ['over', 4],['the', 3], ['lazy', 4], ['dog', 3]]
3. Write a program to accept some string from the keyboard and display its characters by
index wise(both positive and negative index):
Example:
Input: Hello
Output:
The character present at positive index 0 and at negative index -5 is h
The character present at positive index 1 and at negative index -4 is e
The character present at positive index 2 and at negative index -3 is l
The character present at positive index 3 and at negative index -2 is l
The character present at positive index 4 and at negative index -1 is o
4. Print the given pattern :
Pattern-5:
ABCDEFGHIJ
ABCDEFGHIJ
ABCDEFGHIJ
ABCDEFGHIJ
ABCDEFGHIJ
ABCDEFGHIJ