MTEL Digital Literacy and Computer Science

Category - Digital Lit and CS

A programmer wants to represent the number 1234 as a string. The programmer creates a string variable named num_text. Which of the following statements will correctly assign the string 1234 to this variable?
  1. num_text = 1234
  2. num_text = /*1234*/
  3. num_text = "1234"
  4. num_text = [1234]
Explanation
Correct Response: C. Quotation marks surround the characters of a string. A is incorrect because without the surrounding quotation marks, 1234 is a number. B is incorrect because surrounded by /* and */, 1234 is a comment. D is incorrect because surrounded by [ and ], 1234 is an element of a list or array.
Was this helpful? Upvote!
Login to contribute your own answer or details

Top questions

Related questions

Most popular on PracticeQuiz