← Back
Question 41 Interview Prep

What are operators in Python?

Operators are symbols used to perform operations on variables and values.

Main types of operators in Python:

Arithmetic operators
Comparison operators
Logical operators
Assignment operators
Membership operators
Identity operators

Example:

a = 10
b = 5

print(a + b)

Question 42 Interview Prep

What are conditional statements in Python?

Conditional statements are used to make decisions in a program based on conditions.

Python mainly uses:

if
elif
else

Example:

age = 18

if age >= 18:
print("Eligible")
else:
print("Not Eligible")

Conditional statements help control program flow.

Question 43 Interview Prep

What is the pass statement in Python?

The pass statement is a placeholder statement that does nothing. It is used when a block of code is required syntactically but no implementation is written yet.

Example:

def my_function():
pass

It is commonly used during development.

Question 44 Interview Prep

What is the use of the range() function?

The range() function generates a sequence of numbers and is commonly used with loops.

Example:

for i in range(5):
print(i)

Output:

0
1
2
3
4

Question 45 Interview Prep

What is enumerate() in Python?

enumerate() is used to get both the index and value while iterating through a sequence.

Example:

names = ["Aman", "Rahul"]

for index, value in enumerate(names):
print(index, value)

It improves readability compared to manually managing indexes.

Question 46 Interview Prep

What is zip() in Python?

zip() combines multiple iterables element by element.

View Detailed Explanation

Example:

names = ["Aman", "Rahul"]
marks = [90, 85]

result = zip(names, marks)

print(list(result))

Output:

[('Aman', 90), ('Rahul', 85)]