Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.
Question was 6 or more.if he consider 7 word string then ans was A.if he consider 6 words string then answer was B
>>> str = 'examtop'
>>> str[1:-2]
'xamt'
>>>
print(string[1:-2]): Print the slice of string from index 1 (inclusive) to the second-to-last index (exclusive).
The slice includes characters from index 1 to index -3.
B. 3. Analyze these three cases and it will be easily visible that it always 3:
string="ABCDEFGHIJ"
print(string[1:-2])
string="ABCDEFGHI"
print(string[1:-2])
string="ABCDEFG"
print(string[1:-2])
if the string has 6 letters, the ans is B, if we keep on increasing the length of string, the output string length will also increase.
for example:
>>> str = '1234567'
>>> str[1:-2]
2345
>>> str = '12345678'
>>> str[1:-2]
23456
input 7 letter string--output 4 letter
input 8 letter string--output 5 letter
the -2 portion of the slice means that the sliced string will always proportionally increase in size as well compared to the original string. It only ever slices up to the last 2 characters in the string.
the question is asking for the difference in length between the original string and the sliced string. So you have to subtract the length of the slice from the original. Youll find its 3 every time
If the word has 6 letters, for example
str='naveen'
print(str[1:-2])
The answer is B, which is 3 chars
If the word has 7 letters then the answer is 4 chars
str1='Atharva'
print(str1[1:-2])
The answer is A, it has 4 chars
There is not a right answer on here because it really depends on how long the string is. If it has six letters then print will produce three of those letters. It'll increase depending on how many letters are in the string.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Avidulam
Highly Voted 4 years, 1 month agopshdreddy
Highly Voted 3 years, 11 months agoM7mdAl7aj
3 years, 9 months agoDarkhorse7979
3 years, 8 months agozantrz
Most Recent 2 months, 1 week agozantrz
2 months, 1 week agoTheFivePips
4 months, 2 weeks agovarshu_0708
11 months, 2 weeks agovarshu_0708
11 months, 2 weeks agoTheFivePips
4 months, 2 weeks agoTheFivePips
4 months, 2 weeks agonaveenbv80
1 year, 4 months agoN9
1 year, 7 months agoBenM1911
2 years, 3 months agoAtulVSharma
2 years, 6 months agoJesuisfort
2 years, 10 months agoJesuisfort
2 years, 11 months agoecko
3 years, 7 months agoFR99
3 years, 5 months agowolverin3
3 years, 5 months agowolverin3
3 years, 5 months agoNehuuu
3 years, 7 months agopremaseem
3 years, 8 months agoSaifu
3 years, 11 months ago