Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
D422 7-2 string handeling
1. Name of Students Omkar Rane
Roll No D422
Batch D1
Experiment No EX-7-2
Title of Experiment
EX-7.2: Compare two strings and convert in opposite case in
Python.
Write An Algorithm:
Step1)start
Step2) Take the string from user i.e str1
Step 3) Declare the empty string i.e str1=””
Step4) loop: q=initial character to q=end char
Read the ascii value of q i.e code
If code>=92 and
Then
Add 32 in code
Else
Then
Sub 32 in code
LoopEnd
Step 5:
Read character value m of ascii
step6) str1=str2+j
step10) Display str1
step11) stop
Flow Chart:
2. Paste Your Python Program ( Python Code):
str1=raw_input("Enter string:") # Enter string for conversion
print str1 # blank string
str2=""
for q in str1: #looping
c=ord(q)
if(c>=92):
m=c-32
else:
m=c+32
j=chr(m)
str2=str2+j
print str2
Paste Your Program OUTPUT :
>>>
omkar
OMKAR
>>>