11. Which of the string operations return 1 if both strings are same else return 0. (1 mark)
Question
- Which of the string operations return 1 if both strings are same else return 0. (1 mark)
Solution
The operation that returns 1 if both strings are the same and 0 otherwise is the comparison operation '=='. Here is how you can use it:
-
Define your two strings. For example: string1 = "Hello" string2 = "Hello"
-
Use the '==' operator to compare the two strings. For example: result = (string1 == string2)
-
The variable 'result' will now hold the value 1 if the strings are the same and 0 if they are not. You can print this value to check. For example: print(result)
If the strings are the same, this will print '1'. If they are not the same, it will print '0'.
Similar Questions
What will be the output of the following code?a=(1111,2)print(a)
what is equivalent RE of the language: the set of strings of 0's that contains exactly 4 1's Question 1Select one:a.0*10*10*10*10*b.(0+1)*+(0+1)*1(0+1)*+(1*01*01*)c.((0+1)*10(0+1)*)+((0+1)*01(0+1)*)d.1*(01*01*01*)1*
What will be the output of the following program in Python?print(0 or 1)
what is a string?0.5 Marksare whole numbers, without a decimal point, like 2567are floating-point numbers, like 1.5 or 134.153is a special type that only has one value: NULLhave only two possible values either true or falseClear Answer
If two strings are identical, then what will be the return value of strcmp() function?Select one:0-11
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.