Follow This Blog For more... 😊

Python Questions 1 to 20 MCQs | Python MCQs 01 |

1. Which character is used in Python to make a single-line comment?
  1. /
  2. //
  3. !
  4. #
2. Which character is used in Python to make a Multiline comment?
  1. /
  2. //
  3. '''  '''
  4. #
3. What will be the output of print(type(2**5)) in python?
  1. int
  2. float
  3. double
  4. integer
Solution:
⇛performed 2**5=32 (Where, 2**5=25)
⇛Output:
4. What will be the output of print(type("Dev's Learning Blog")) in python?
  1. int
  2. float
  3. str
  4. char
5. What will be the output of print(type(3*5/5)) in python?
  1. int
  2. float
  3. str
  4. char
Solution:
⇛ Acording to precedence and associativity.
   Step:1 first performed 3*5=15
   Step:2 then, performed 15/5=3.0
[Note:In python, answer of division is always folat]
So, the ans is float. 
⇛Output:
6. Which of the following is not a boolean expression?
  1. True
  2. 3==4
  3. 3+4
  4. 3+4==7

7. If x=3.123, then int(x) will give ?
  1. 1
  2. 3
  3. 4
  4. 3.14
8. Which is the correct way of declaring and initializing a variable, x with value 5?
  1. int x
    x=5
  2. int x=5
  3. x=5
  4. declare x=5
9. Which of the following is an invalid statement?
  1. abc=1,000,000
  2. a b c = 1000 2000 3000
  3. a,b,c=1000,2000,3000
  4. a_b_c=1,000,000
10. What is the maximum possible length of an identifier?
  1. 31 characters
  2. 63 characters
  3. 79 characters
  4. None
11. Which of the following is invalid?
  1. _x = 1
  2. __x = 1
  3. __x__ = 1
  4. None of this
12. Which of the following cannot be a variable?
  1. __in__
  2. in
  3. it
  4. __it__
13. Which of the following is an invalid variable?
  1. char_1
  2. 1st_char
  3. oopec
  4. _
14. What happens when '2' == 2 is executed?
  1. True
  2. False
  3. ValueError
  4. TypeError
15. What will be the output of this program?
_ = '1 2 3 4 5 6'
print(_)

  1. SyntaxError: EOL while scanning string literal
  2. SyntaxError: invalid syntax
  3. NameError: name '_' is not defined
  4. 1 2 3 4 5 6
16. The following is displayed by a print function call. Select all of the function calls that result in this output.
tom
sam
harry
  1. print('''tom
    \nsam
    \nharry''')
  2. print(”’tomsamharry”’)
  3. print(‘tom\nsam\nharry’)
  4. print('tom
    sam
    harry')
17. What will be the output of the following program on execution?
print(print(print("python")))

  1. None None python
  2. python
    None
    None
  3. Python
  4. Error
18. What will be the output of this program?
word = "python"
print(*word)

  1. python
  2. p y t h o n
  3. *python
  4. Error
19. Which is the correct operator for xy?
  1. x^y
  2. x**y
  3. x^^y
  4. None of this
20. What is the answer to this expression, 34 % 3?
  1. 7
  2. 1
  3. 0
  4. 5

Comments

Popular Posts