menu

Python Basics

Python Basics - Important Points


36. Which of the following is the correct way to concatenate two strings in Python?

A. string1.join(string2)

B. string1.concat(string2)

C. string1 + string2

D. All of the above

Discuss Work Space

Answer: option c

Explanation:

The + operator is used to concatenate two strings in Python.

37.

What is the output of the following code?

x = 3
if x > 5:print("x is greater than 5")
elif x > 2:print("x is greater than 2")
else:print("x is less than or equal to 2")

A. x is greater than 5

B. x is greater than 2

C. x is less than or equal to 2

D. None of the above

Discuss Work Space

Answer: option b

Explanation:

The variable x is greater than 2, so the code in the elif block will be executed.


38.

What is the output of the following code?

x = 2
y = 5
z = x + y
print("The sum of", x, "and", y, "is", z)

A. The sum of 2 and 5 is 7

B. The sum of x and y is z

C. The sum of x and y is 7

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

The print() function is used to output the sum of x and y as a string with the appropriate values included.



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