0% found this document useful (0 votes)
5 views4 pages

Coding Exercises with Outputs

This document contains a series of coding snippets in Python, showcasing various print statements and string manipulations. Each snippet includes the code, expected output, and any errors that may occur. The examples cover topics such as string slicing, capitalization, and loop iterations.

Uploaded by

56sameersahil
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Coding Exercises with Outputs

This document contains a series of coding snippets in Python, showcasing various print statements and string manipulations. Each snippet includes the code, expected output, and any errors that may occur. The examples cover topics such as string slicing, capitalization, and loop iterations.

Uploaded by

56sameersahil
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

12 – COMPUTER SCIENCE

LESSON – 8

என்றும் மாணவர்கள் நலனில்


CODING WITH ANSWERS

WRITE THE OUTPUT OF THE FOLLOWING SNIPPETS. / பின்வரும் குறிமுறைகளின் வெளியீட்டை எழுதுக.
1) >>> print (‘I am the best student’)
I am the best student
2) >>> print ('Greater Chennai Corporation's student')
ERROR! (SyntaxError: invalid syntax )
3) str1 = "Chennai Schools"
str1[7] = "-"
ERROR! (Type error)
4) str1 = "Chennai Schools"
str1= "Delhi Schools"
print(str1)
Delhi Schools
5) s="How are you?"
print([Link]("o","e"))
Hew are yeu?
6) s="How are you?"
[Link]("o","e")
print(s)
How are you?
7) str1=" Welcome to "
str1+="Learn Python"
print (str1*3)
Welcome to Learn Python Welcome to Learn Python Welcome to Learn Python
8) str1 = "Welcome to Government School"
print (str1[11:21])
print (str1[11:21:4])
print (str1[11:21:3])
print (str1[11:21:2])
print (str1[::3])
print (str1[::-3])

..1.. A. PRABHAKAR - 9442979144


Government
Grn
Gemt
Gvrmn
Wceoore hl
lh erooecW
9) str1="TamilNadu"
print(str1[::-1]
udaNlimaT
10) str1="THIRUKKURAL"
print (str1[5])
print (str1[:5])
print (str1[5:])
K
THIRU
KKURAL
11) str1="COMPUTER"
index=0
for i in str1:
print (str1[:index+1])
index+=1
C
CO
COM
COMP
COMPU
COMPUT
COMPUTE
COMPUTER

12) str1="COMPUTER"
index=len(str1)
for i in str1:
print (str1[:index])
index-=1

..2.. A. PRABHAKAR - 9442979144


COMPUTER
COMPUTE
COMPUT
COMPU
COMP
COM
CO
C
13) city="chennai"
print([Link]())
print(city)
print([Link]().swapcase())
Chennai
chennai
cHENNAI
14) str1="tech easy"
str2="Tech"
if str2 in str1:
print ("Found")
else:
print ("Not Found")
str4="tech"
if str4 in str1:
print ("Found")
else:
print ("Not Found")
Not Found
Found
15) str1=' * '
i=5
while i>=1:
print (str1*i)
i-=1
* * * * *
* * * *
* * *
* *
*

..3.. A. PRABHAKAR - 9442979144


16) str1="ABCDEFGH"
str2="ate"
for i in str1:
print ((i+str2),end='\t')
Aate Bate Cate Date Eate Fate Gate Hate
17) str1 = "welcome"
str2 = "to school"
str3=str1[:2]+str2[len(str2)-2:]
print(str3)
weol
18) str1 = "welcome"
str2 = "to school"
str3=str1[3:]+str2[:len(str2)]
print(str3)
cometo school
19) str1='education department'
print([Link]())
print([Link]())
print([Link]())
print(str1)
Education department
Education Department
EDUCATION DEPARTMENT
education department
20) str1="Welcome "
str1 + " by Tech Easy"
print(str1)
str1 += " by Tech Easy"
print(str1)
Welcome
Welcome by Tech Easy
21) str1="Tech Easy"
The positive index of the character ‘h’ is 3
The negative index of the character ‘h’ is -6

..4.. A. PRABHAKAR - 9442979144

You might also like