Python MCQ questions 1
Python MCQ questions 1
---
6. What will be the output of the following code: `print("Hello " + "World!")`?
- A) HelloWorld!
- B) Hello World!
- C) Error
- D) "Hello " + "World!"
Answer – A) HelloWorld! – the ‘+’ sign will combine two words by removing the space that python gives by default if we use comma(.).
7. Which of the following is used to take input from the user in Python?
- A) input()
- B) get()
- C) read()
- D) fetch()
Answer – A) input()
12. How do you access the first element of a list named `my_list`?
- A) `my_list[1]`
- B) `my_list(0)`
- C) `my_list[0]`
- D) `first(my_list)`
Answer – C) `my_list[0]`- as the indexing starts from 0, to fetch first element we have to call for the 0 th index
16. Which method is used to add an item to the end of a list in Python?
- A) add()
- B) append()
- C) insert()
- D) push()
Answer – B) append() – append() is used to add an item to the end of a list in Python
17. In Python, which keyword is used to handle exceptions?
- A) error
- B) exception
- C) try
- D) catch
Answer – C) try – try and except is used for exception handling in pyhton