nerdexam
Cisco

300-735 · Question #78

Refer to the exhibit. Which expression is used in the code to give the result 12?

The correct answer is D. new_string=num1+str(num2). Since num1 is a string ("1") and num2 is an integer (2), using the str() function converts num2 to a string, allowing the concatenation of the two string values. This results in the string "12" when the values of num1 and num2 are combined.

Integrations

Question

Refer to the exhibit. Which expression is used in the code to give the result 12?

Exhibit

300-735 question #78 exhibit

Options

  • Anew_string=num3+num2
  • Bnew_string=num1+num2
  • Cnew_string=num2+num3
  • Dnew_string=num1+str(num2)

How the community answered

(50 responses)
  • A
    2% (1)
  • B
    10% (5)
  • C
    4% (2)
  • D
    84% (42)

Explanation

Since num1 is a string ("1") and num2 is an integer (2), using the str() function converts num2 to a string, allowing the concatenation of the two string values. This results in the string "12" when the values of num1 and num2 are combined.

Topics

#Python#type conversion#string concatenation#str()

Community Discussion

No community discussion yet for this question.

Full 300-735 Practice