Python Programming - Data Types

Exercise : Data Types - General Questions
  • Data Types - General Questions
26.
Which of the following data types is used to represent a sequence of Unicode characters that cannot be modified?
int
float
str
bytes
Answer: Option
Explanation:
The str data type is used to represent a sequence of Unicode characters that cannot be modified. It is immutable.

27.
What is the correct way to declare a variable?
var x = 5
int x = 5
x = 5
variable x = 5
Answer: Option
Explanation:
In Python, variables can be declared simply by assigning a value to them. No explicit type declaration is needed.

28.
What is the correct way to comment a single-line?
// This is a comment
/* This is a comment */
# This is a comment
-- This is a comment
Answer: Option
Explanation:
In Python, single-line comments are made using the '#' symbol.

29.
Which of the following is a valid Python string?
'Hello, World!"
"Hello, World!'
'Hello, World!'
None of these
Answer: Option
Explanation:
Both single and double quotes are valid for creating strings, but they must be matched properly.

30.
What is the purpose of the len() function?
To calculate the logarithm
To find the length of a string or list
To generate random numbers
To perform mathematical operations
Answer: Option
Explanation:
The len() function is used to determine the number of elements in a string, list, or any other iterable object.