WorksheetsPython Test 5A
Total questions: 10
Worksheet time: 5mins
Select the correct output of the following String operations.
str1 = "my isname isisis jameis isis bond";
sub = "is";
print(str1.count(sub, 4))
5
6
7
3
Select the correct output of the following String operations
str1 = 'Welcome'
print (str1[:6] + ' PYnative')
Welcome PYnative
WelcomPYnative
Welcom PYnative
WelcomePYnative
Guess the correct output of the following String operations
str1 = 'Welcome'
print(str1*2)
WelcomeWelcome
TypeError unsupported operand type(s)
Welcome Welcome
ValueError unsupported operand type(s)
Choose the correct function to get the ASCII code of a character
char('char')
ord('char')
ascii('char')
asc('char')
Choose the correct function to get the character from ASCII number
ascii(number)
char(number)
chr(number)
asc(number)
What will be the output of above Python code?
str1="6/4"
print("str1")
1
6/4
1.5
str1
Which of the following will result in an error?
str1="python"
print(str1[2])
str1[1]="x"
print(str1[0:9])
Both (b) and (c)
What will be the output of below Python code?
str1="Aplication"
str2=str1.replace('a','A')
print(str2)
application
Application
ApplicAtion
applicAtion
What will be the output of below Python code?
str1="poWer"
str1.upper()
print(str1)
POWER
Power
power
poWer
Which of the following will give "Simon" as output?
If str1="John,Simon,Aryan"
print(str1[-7:-12])
print(str1[-11:-7])
print(str1[-11:-6])
print(str1[-7:-11])
