0% found this document useful (0 votes)
9 views3 pages

Python Quizz

Uploaded by

krishnakrisha001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Python Quizz

Uploaded by

krishnakrisha001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Python:
o Question: What is the difference between a list and a tuple in Python?
 A) Lists are mutable, while tuples are immutable.
 B) Tuples are ordered, while lists are not.
 C) Lists can contain elements of different data types, while tuples
cannot.
 D) Tuples can be resized, while lists cannot.
 Answer: A) Lists are mutable, while tuples are immutable.

2. Python:
o Question: How do you open a file in Python for reading?
 A) file = open("myfile.txt", "w")
 B) file = open("myfile.txt", "r")
 C) file = open("myfile.txt", "a")
 D) file = open("myfile.txt", "x")
 Answer: B) file = open("myfile.txt", "r")
3. SQL:
o Question: What is the purpose of the GROUP BY clause in SQL?
 A) To sort the result set in ascending order.
 B) To filter rows based on a condition.
 C) To group rows with similar values into summary rows.
 D) To join two or more tables.
 Answer: C) To group rows with similar values into summary rows.
4. Python:
o Question: How do you remove an element from a list in Python?
 A) list.remove(item)
 B) list.pop(index)
 C) del list[index]
 D) All of the above
 Answer: D) All of the above
5. SQL:
o Question: What is the difference between INNER JOIN and LEFT JOIN?
 A) INNER JOIN returns all rows from both tables, while LEFT JOIN
returns only matching rows.
 B) INNER JOIN returns only matching rows, while LEFT JOIN
returns all rows from both tables.
 C) INNER JOIN is used for self-joins, while LEFT JOIN is used for
joining different tables.
 D) There is no difference; they are interchangeable.
 Answer: A) INNER JOIN returns all rows from both tables, while
LEFT JOIN returns only matching rows.
6. SQL:
o Question: What is a subquery in SQL?
 A) A query that runs in parallel with the main query.
 B) A query that returns a single value.
 C) A query nested inside another query.
 D) A query that joins multiple tables.
 Answer: C) A query nested inside another query.
7. Python:
o Question: How do you reverse a list in Python?
 A) list.reverse()
 B) reversed(list)
 C) list[::-1]
 D) All of the above
 Answer: D) All of the above

Certainly! Here are 10 more intermediate-level interview questions related to Python and
SQL, along with 4 multiple-choice options for each question:
8.Python:

o Question: What is the purpose of the enumerate() function in Python?


 A) To iterate over a sequence while keeping track of the index.
 B) To create an enumerated list.
 C) To find the maximum value in a list.
 D) To reverse the order of elements in a list.
 Answer: A) To iterate over a sequence while keeping track of the
index.
2. SQL:
o Question: What is a self-join in SQL?
 A) A join between two different tables.
 B) A join where the same table is used twice.
 C) A join that includes an aggregate function.
 D) A join that involves subqueries.
 Answer: B) A join where the same table is used twice.
3. Python:
o Question: How do you handle exceptions in Python using
a try and except block?
 A) try { ... } catch { ... }
 B) try: ... except: ...
 C) try except { ... }
 D) try: ... catch: ...
 Answer: B) try: ... except: ...
4. SQL:
o Question: What is the purpose of the HAVING clause in SQL?
 A) To filter rows based on a condition.
 B) To sort the result set.
 C) To group rows by a specific column.
 D) To filter aggregated data.
 Answer: D) To filter aggregated data.
5. SQL:
o Question: What is the difference between a primary key and a unique key in a
database table?
 A) Both keys enforce uniqueness, but a primary key can be NULL
while a unique key cannot.
 B) A primary key is used for sorting, while a unique key is not.
 C) A unique key can have multiple columns, while a primary key
cannot.
 D) There is no difference; they are interchangeable.
 Answer: A) Both keys enforce uniqueness, but a primary key can be
NULL while a unique key cannot.
6. Python:
o Question: How do you sort a list of dictionaries based on a specific key?
 A) sorted(list_of_dicts, key=lambda x: x['key'])
 B) list_of_dicts.sort(key='key')
 C) list_of_dicts.sort(key=lambda x: x['key'])
 D) sorted(list_of_dicts, key='key')
 Answer: A) sorted(list_of_dicts, key=lambda x: x['key'])

7. SQL:
o Question: What is the purpose of the LIKE operator in SQL?
 A) To perform arithmetic operations.
 B) To filter rows based on exact matches.
 C) To search for patterns in string columns.
 D) To join tables.
 Answer: C) To search for patterns in string columns.

8. Python:
o Question: What is the use of a service account?
 A) used to run individual jobs
 B) used to run all application jobs
 C) used to kill any individual jobs
 D) All the above
 Answer: A) string.lower()

You might also like