Computer Science
Assertion (A): Indexing in a string is defined as positive and negative indexing.
Reasoning (R): In forward and backward indexing, the indices start with 1st index.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Python String Manipulation
3 Likes
Answer
A is true but R is false.
Explanation
Indexing in a string can be defined as positive and negative indexing. In Python, positive indexing starts from 0 and moves to the right, while negative indexing starts from -1 and moves to the left.
Answered By
3 Likes
Related Questions
Assertion (A): Slicing a string involves extracting substring(s) from a given string.
Reasoning (R): Slicing does not require start and end index value of the string.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): The swapcase() function converts an input string into a toggle case.
Reasoning (R): The swapcase() function converts all uppercase characters to lowercase and vice versa of the given string and returns it.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): The following code snippet on execution shall return the output as: False True
str1 "Mission 999" str2 = "999" print(str1.isdigit(), str2.isdigit())Reasoning (R): isdigit() function checks for the presence of all the digits in an inputted string.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
How does '*' operator behave on strings?