Python Strings MCQ Questions and Answers
Q. What is the output of the following Python code?
    my_string = "Hello, World!"
    print(my_string[::2])
   
    A. Hell, WrdB. Hello, World!
C. Hell, World
D. Error: Invalid slice notation
Q. What is the output of the following Python code?
    my_string = "Python is awesome"
    print(my_string.replace("Python", "Java"))
    
    A. Java is awesomeB. Python is Java
C. Python Java awesome
D. Error: Invalid syntax
Q. What is the output of the following Python code?
    my_string = "Hello"
    print(my_string.upper())
    print(my_string)
    
    A. HELLOHello
B. HELLO
hello
C. Hello
HELLO
D. Hello
hello
Q. What is the output of the following Python code?
    my_string = "   Python   "
    print(my_string.strip())
    
    A.   PythonB. Python
C. Python
D. Error: Invalid syntax
Q. What is the output of the following Python code?
    my_string = "Hello, World!"
    print(my_string[3:8])
   
    A. ello,B. lo, W
C. lo, Wo
D. Error: Invalid slice notation
Q. What is the output of the following Python code?
    my_string = "Hello"
    print(my_string.isalpha())
    
    A. TrueB. False
C. Error: Invalid method
Q. What is the output of the following Python code?
    my_string = "Hello, World!"
    print(my_string.startswith("Hello"))
    
    A. TrueB. False
C. Error: Invalid method
Q. What is the output of the following Python code?
    my_string = "Hello"
    print(my_string.find("ell"))
    
    A. 1B. 2
C. -1
D. Error: Invalid method
Q. What is the output of the following Python code?
    my_string = "Hello, World!"
    print(my_string.split(","))
    
    A. ['Hello', ' World!']B. ['Hello', 'World']
C. ['Hello, World!']
D. Error: Invalid method
Q. What is the output of the following Python code?
    my_string = "Hello"
    print(my_string.isalnum())
    
    A. TrueB. False
C. Error: Invalid method