You are on page 1of 3

POSSIBLE PROGRAMS

SIMPLE PROGRAMS
1) Add natural numbers up to n where n is taken as an input from user
using recursive function Print the sum
PROGRAMS USING FUNCTIONS
1) Prompt the user to enter the password, where a user can enter a
wrong password only 3 times. If the entry is correct display “Login
Successful

PROGRAMS USING STRINGS


1) Write a program (using functions) that takes a long sentence with
multiple words as input and rearranges the words in the sentence in
the reverse order.

Test 1 2 3
Case
Input My name is Kumaraguru College Problem based
python of Technology on Strings
Outp python is Technology of Strings on
ut name My College Kumaraguru based Problem

2) Write a program that accepts a sequence of words that are hyphen separated as
input and prints the words in a hyphen-separated sequence after sorting them
alphabetically.
Test 1 2 3
case
Input green-red-yellow-black- red-yellow- green-yellow-
white black white
Outpu black-green-red-white- black -red- green-white-
t yellow yellow yellow
3) Write a program that accepts a sentence as input and calculates the
number of letters, digits and special characters.
Test Case 1 2
Input sentence hello world! There is a laptop with
@$ 123 #CS123…
Outp Letters 10 20
ut Digits 3 3
Special 3 4
Characters

4) Write a Python function that accepts a string and calculate the


number of upper case letters and lower case letters. 
5) Assuming that we have some email address of the form
"username@companyname.com". Write a program to print the
user name of a given email address. Both user names and company
names consists of letters only.
Test 1 2
case
Input inboxcse@gmail. csedeptgroups#yahoom
com ail.com
Output inboxcse Invalid email
address
6) Write a program that identifies the first character of a given
sentence and replaces all the instances of that character with $
except the first character.
Test Case 1 2
Input my name is Problems based on
mohanakumar Python Programming
Output my na$e is Problems based on
$ohanaku$ar $ython $rogramming
7) Write a program that takes a long sentence with multiple words as
input and swaps the case of all characters.
Test 1 2
Case
Input I am Dr A P J Abdul Kumaraguru College of
Kalam Technology
Output i AM dR a p j aBDUL kUMARAGURU cOLLEGE
kALAM OF tECHNOLOGY

8) Write a program that takes an IP address of the form P.Q.R.S as input, where
P, Q, R and S are decimal numbers in the range 0 to 255, and prints the class
of the address as indicated in the table below.

Value of P Class
1 – 126 A
128 – 191 B
192 – 223 C
224 – 239 D
240 – 254 E

Test 1 2 3 4 5
Case
Input 224.220.206 126.220.206 127.0.0 0.100.100.1 255.255.255.
.91 .91 .1 00 255
Outp Class D Class A Invali Invalid Invalid
ut d

PROGRAMS USING LISTS


1) Given lower and upper limits, generate a given count of random numbers
within a given range, starting from ‘start’ to ‘end’ and store them in list.

You might also like