Question 1
+
-
*
+=
Good Job!
Oops!
+ ==> concatenate two strings * ==> multiply string += concatenate and assign to a variable
Please login to submit your explanation
You can check your performance of this question after Login/Signup
Start
Question 2
True
False
true
false
a+b="PrepInsta" 2*(a+b)="PrepInstaPrepInsta" in is a membership operator and checks "InstaP" is there in 2*(a+b) and returns True if present else False
Question 3
97
97 98 99
65 66 67
Error
ord() function accepts only unit length string(character) and returns integer value for a given character.
Question 4
st="PrepInsta" x="" for i in st: if(i.islower()): x+=i.upper() print(x)
PREPINSTA
pREPiNSTA
REPNSTA
REPINSTA
If character is lower , it will convert it into uppercase and concatenate to another variable
Question 5
rChocolate
r Chocolate
\nChocolate
None of the above
When prefixed with ‘r’ a string becomes rawstring and escape sequences are not converted.
Question 6
7
9
3
6
x=st.split('a') x becomes , x=['C', 'dbury D', 'iry Milk'] length of x is 3
Question 7
Xn xpple x day
An xpple x day
An xpple x dxy
Xn apple x dxy
replaces "a" with "x" for first two occurrences in the string
Question 8
st="Happy Christmas and Happy new year" if(st.startswith("Happy")): x=st.rsplit("Happy") print(len(x))
5
4
rstrip()-splits string at specified separator and returns string startswith()-returns true if the string starts with specified value.
Question 9
import math st="10.57" x=st.zfill(10) print(x.count("0"))
10
zfill() - adds zeroes at the beginning of string until it reaches the specified length.
Question 10
x="ababcabcab" s=x.lstrip("ab") print(len(s)*s.count("a"))
24
12
18
lstrip removes the string in the argument present on the left side of the original string.
Please login to report
Completed
0/0
Accuracy
0%