menu

Python Basics

Python Basics - Important Points


6. Which of the following is the correct syntax for defining a function in Python?

A. function my_function():

B. def my_function():

C. define my_function():

D. func my_function():

Discuss Work Space

Answer: option b

Explanation:

The def keyword is used to define a function in Python.

7. Which of the following is NOT a comparison operator in Python?

A. ==

B. !=

C. <=

D. <>

Discuss Work Space

Answer: option d

Explanation:

The <> operator was used for inequality comparison in older versions of Python, but it is not supported in Python 3.x.

8. Which of the following is NOT a comparison operator in Python?

A. ==

B. >

C. <

D. +

Discuss Work Space

Answer: option d

Explanation:

The + operator is used for addition in Python, not comparison.

9.

What is the output of the following code?

print("Hello" + " World")

A. Hello

B. World

C. Hello World

D. Type Error

Discuss Work Space

Answer: option c

Explanation:

The + operator concatenates two strings.


10. Which of the following is the correct syntax for a while loop in Python?

A. while i in range(10):

B. while (i < 10)

C. while (i != 10)

D. while i = 10

Discuss Work Space

Answer: option b

Explanation:

A while loop in Python continues to execute as long as the specified condition is True.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now