Assignment Detail

Tutors

What is the output of the code

    Answered

    Assignment Instructions

    Questions –
    Q1. What is the output of the following code?
    example = “snow world”
    example[3] = ‘s’
    print example
    A. snow
    B. snow world
    C. Error
    D. snos world
    Q2. What is the output of “hello”+1+2+3 ?
    A. hello123
    B. hello
    C. Error
    D. hello6
    Q3. What will be the output of the following Python statement?
    “abcd”[2:]
    A. Cd
    B. ab
    C. a
    D. dc
    Q4. The output of executing string.ascii_letters can Also be achieved by:
    A. string.ascii_lowercase_string.digits
    B. string.ascii_lowercase+string.ascii_upercase
    C. string.letters
    D. string.lowercase_string.upercase
    Q5. What will be the output of the following Python code
    str1 = ‘hello’
    str2 = ‘,’
    str3 = ‘world’
    Str1[-1:]
    A. olleh
    B. hello
    C. h
    D. o
    Q6. What will be the output of the following Python statement?
    >>> print(‘x97x98’)
    A. Error
    B. 97
    98
    C. x97
    D. x97x98
    Q7. Which of the following will result in an error?
    str1=””python””
    A. print(str1[2])
    B. str1[1]=”x”
    C. print(str1[0:9])
    D. Both (b) and (c)
    Q8. Which of the following is False?
    A. capitalize() function in string is used to return a string by Converting the whole given string into uppercase.
    B. lower() function in string is used to return a string by converting The whole given string into lowercase.
    C. String is immutable
    D. None of these.
    Q9. What will be the output of below Python code?
    str1=”Information”
    print(str1[2:8])
    A. format
    B. formatio
    C. orma
    D. ormat
    A. format
    B. formatio
    C. orma
    D. ormat
    Q10. What will be the output of below Python code?
    str1=”Aplication”
    str2=str1.replace(‘a’,’A’)
    print(str2)
    A. Application
    B. Application
    C. ApplicAtion
    D. applicAtion
    Q11. What will be the output of below Python code?
    str1=”poWer”
    str1.upper()
    print(str1)
    A. POWER
    B. Power
    C. power
    D. POWer
    Q12. If str1=””save paper,save plants”
    str1.find(“save”)
    A. It returns the first index position Of the first occurance of “save” in The given string str1.
    B. It returns the last index position of the last Occurance of “save” in the given string str1.
    C. It returns the last index position of the first Occurance of “save” in the given string str1.
    D. It returns the first index position of the first Occurance of “save” in the Given string str1.
    Q13. list1=[0,2,5,1]
    str1=””7″”
    for i in list1:
    str1=str1+i
    print(str1)
    A. 70251
    B. 7
    C. 15
    D. Error
    Q14. Which of the following will give “Simon” as output?
    If str1=”John,Simon,Aryan”
    A. print(str1[-7:-12])
    B. print(str1[-11:-7])
    C. print(str1[-11:-6])
    D. print(str1[-7:-11])
    Q15. What will following Python code return?
    str1=”Stack of books”
    print(len(str1))
    A. 13
    B. 14
    C. 15
    D. 16
    Q16. What is the output of the following string operations
    str = “My salary is 7000”;
    print(str.isalnum())
    A. True
    B. FALSE
    C. Error
    D. OK
    Q17. Guess the correct output of the following code?
    str1 = “PYnative”
    print(str1[1:4], str1[:5], str1[4:], str1[0:-1], str1[:-1])
    A. PYn PYnat ive PYnativ vitanYP
    B. Yna PYnat tive PYnativ vitanYP
    C. Yna PYnat tive PYnativ Pynativ
    D. Error
    Q18. Select the correct output of the following String operations
    myString = “pynative”
    stringList = [“abc”, “pynative”, “xyz”]
    print(stringList[1] == myString)
    print(stringList[1] is myString)
    A. true false
    B. true true
    C. FALSE
    D. TRUE
    Q19. Which method should I use to convert String
    “welcome to the beautiful world of python” to
    “Welcome To The Beautiful World of Python”
    A. capitalize()
    B. title()
    C. togglecase()
    Q20. Python does not support a character type;
    A single character is treated as strings of length one.
    A. FALSE
    B. TRUE
    Q21. Select the correct output of the following String operations
    str1 = “my isname isisis jameis isis bond”;
    sub = “is”;
    print(str1.count(sub, 4))
    A. 5
    B. 6
    C. 7
    D. 8
    Q22. What is the output of the following code
    str1 = “My salary is 7000”;
    str2 = “7000”
    print(str1.isdigit())
    print(str2.isdigit())
    A. False
    True
    B. False
    False
    C. TRUE
    D. FALSE
    Q23. Select the correct output of the following String operations
    str = “my name is James bond”;
    print (str.capitalize())
    A. My Name Is James Bond
    B. TypeError: unsupported operand type(s) For * or pow(): ‘str’ and ‘int’
    C. My name is james bond
    D. Error
    Q24. Select the correct output of the following String operations
    str1 = ‘Welcome’
    print (str1[:6] + ‘ PYnative’)
    A. Welcome Pynative
    B. WelcomPYnative
    C. Welcom Pynative
    D. WelcomePYnative
    Q25. Guess the correct output of the following String operations
    str1 = ‘Welcome’
    print(str1*2)
    A. TypeError: unsupported operand type(s) For * or pow(): ‘str’ and ‘int’
    B. WelcomeWelcome
    C. Welcome2
    D. 2welcome
    Q26. Choose the correct function to get the ASCII code of a character
    A. char(‘char’)
    B. ord(‘char’)
    C. ascii(‘char’
    D. none
    Q27. What is the output of the following string comparison
    print(“John” > “Jhon”)
    print(“Emma” < “Emm”)
    A. True
    False
    B. False
    False
    C. TRUE
    D. FALSE
    28. What is the output of the following?
    print(‘The sum of {0:b} and {1:x} is {2:o}’.format(2, 10, 12))
    A. The sum of 2 and 10 is 12
    B. The sum of 10 and a is 14
    C. The sum of 10 and a is c
    D. Error
    Q29. used to know whether a string is ending with a substring or not.
    A. ends_with()
    B. end_with()
    C. endswith()
    D. None of these.
    Q30. What will be the output of the following Python code snippet?
    print(‘for’.isidentifier())
    A. TRUE
    B. FALSE
    C. None
    D. ERROR
    Q31. What will be the output of the following Python code snippet?
    print(‘a@ 1,’.islower())
    A. TRUE
    B. FALSE
    C. None
    D. ERROR
    32. What will be the output of the following Python code snippet?
    print(’11’.isnumeric())
    A. TRUE
    B. FALSE
    C. None
    D. ERROR
    Q33. What will be the output of the following Python code snippet?
    print(””’.isspace())
    A. TRUE
    B. FALSE
    C. None
    D. ERROR
    Q34. What will be the output of the following Python code snippet?
    print(‘HelloWorld’.istitle())
    A. FALSE
    B. TRUE
    C. ERROR
    D. None
    Q35. What will be the output of the following Python code?
    print(”’tfoo”’.lstrip())
    A. tfoo
    B. foo
    C. foo
    D. none of the mentioned
    Q36. What will be the output of the following Python code?
    print(‘xyxxyyzxxy’.lstrip(‘xyy’))
    A. zxxy
    B. xyxxyyzxxy
    C. xyxzxxy
    D. none of the mentioned
    Q37. What will be the output of the following Python code?
    print(‘{0:.2}’.format(1/3))
    A. 0.333333
    B. 0.33
    C. 0.333333:.2
    D. Error
    Q38. What will be the output of the following Python code?
    print(‘Hello!2@#World’.istitle())
    A. None
    B. error
    C. TRUE
    D. FALSE
    Q39. What will be the output of the following Python code?
    print(‘1Rn@’.lower())
    A. n
    B. 1rn@
    C. rn
    D. r
    Q40. To check string is equal ornot which operator we use?
    A. a=b
    B. a==b
    C. a<b
    D. a<b

    Need fresh solution to this Assignment without plagiarism?? Get Quote Now

    Expert Answer

    Asked by: Anonymous
    Plagiarism Checked
    Answer Rating:
    4.6/5

    Plagiarism free Answer files are strictly restricted for download to the student who originally posted this question.

    Related Assignments

    //
    Our customer support team is here to answer your questions. You can send Assignments directly to support team.
    👋 Hi, how can I help?