Q: What will be the output of the following Python statement? >>>"a"+"bc"
Solution: + operator is concatenation operator.
Q: What will be the output of the following Python statement? >>>"abcd"[2:]
Solution: Slice operation is performed on string.
Q: The output of executing string.ascii_letters can also be achieved by:
Solution: Execute in shell and check.
Q: What arithmetic operators cannot be used with strings?
Solution: + is used to concatenate and * is used to multiply strings.
Q: What will be the output of the following Python code? >>>print (r" hello")
Solution: When prefixed with the letter ‘r’ or ‘R’ a string literal becomes a raw string and the escape sequences such as are not converted.
Q: What will be the output of the following Python code? >>>str1="helloworld" >>>str1[::-1]
Solution: Execute in shell to verify.
Q: What will be the output of the following Python code? print(0xA + 0xB + 0xC)
Solution: 0xA and 0xB and 0xC are hexadecimal integer literals representing the decimal values 10, 11 and 12 respectively. There sum is 33.
You Have Score    | /7 |