L3 11 CS 2022-2023
L3 11 CS 2022-2023
1. Write a program in Python to accept an integer value in variable N from the user and display its
content in the following patterns.
Sample output:
Enter Integer: 5
1 54321 1
12 4321 121
123 321 12321
1234 21 1234321
12345 1 123454321
2. Write a program in Python to accept an integer value in variable N from the user and display its
content in the following patterns.
Sample output:
Enter Integer: 5
1 1 1
22 22 222
333 333 33333
4444 4444 4444444
55555 55555 555555555
3. Write a program in Python to accept a string from a user and display its content in the following
patterns.
Sample output:
Enter String: GOGREEN
G GOGREEN G
GO GOGREE GO
GOG GOGRE GOG
GOGR GOGR
GOGR
GOG
GOGRE GOGRE
GO
GOGREE GOGREE
G
GOGREEN GOGREEN
4. Write a program in Python to accept a string from a user and display its content in the following
patterns.
Sample output:
Enter String: WATER
W R W W
A E A A
T T T T
E A E E
R W R
5. Write a program in Python to accept a string from the user and show only non vowels (display
underscore _ symbol in place of vowel).
Sample output:
Enter String: WATER Enter String: PEACE
W_T_R P_ _C_
6. Write a program in Python to accept a word WRD and a sentence STC as strings from the user.
Find the presence or absence of the word WRD in the sentence STC (Without using in operator).
Sample output:
Sentence: A small box in the big box
Word: box
Status: Found
7. Write a program in Python to accept a sentence as a string from the user. Find the total number
of words present in the string (Without using in operator)
Sample output:
Sentence: A small box in the big box
Total Number of Words: 7
8. Write a program in Python to accept a word WRD and a sentence STC as strings from the user.
Find the positions of each occurrence of word WRD in the sentence STC. (Can use split() function)
Sample output:
Sentence: A small box in the big box
Word: box
Positions: 8, 23,
9. Write a program in Python to accept a string S from a user and display an encoded content of S
containing the reverse of the first 3 characters and last 3 characters.
Sample output:
Enter S: HALF OF THE TEAM Enter S: MOHAN'S TEAM SCORED 345
Coded S: LAHEAM Coded S: HOM345
10. Write a program in Python to accept a string S from a user and display an encoded content of S
containing the reverse of characters of second half of S and original order of characters of first
half of the S.
Sample output:
Enter S: ABCDEFGHI Enter S: ABCDEFGH
Coded S: EFGHIDCBA Coded S: EFGHDCBA
11. Write a program in Python to accept a string from a user and display the count of occurrence of
vowels, digits and consonants in it.
Sample output:
Enter Message: SAVE WATER Enter Message: 10 HAFTE 10 BAJE
VOWELS: 4 VOWELS: 4
CONSONANTS: 5 CONSONANTS: 5
DIGITS: 0 DIGITS: 4
12. Write a program in Python to accept a string from a user and check if it is Palindrome or not.
Sample output:
Enter String: NITIN Enter String: DELHI
It is a PALINDROME It is not a PALINDROME
13. Write a Python code to create a two player word guessing game with the help of following steps.
1. Accept a string Str from User1 [accept only those strings, which are less than 10 alphabets]
2. Scroll the screen with the help of print statements to hide the User1’s string.
3. Display the content of string by showing consonants’ position as underscore _ and vowels as