1. Which of the following is correct about dictionaries in Python? Python\'s dic
ID: 3756321 • Letter: 1
Question
1.
Which of the following is correct about dictionaries in Python?
Python's dictionaries are a kind of hash-table type
They work like associative arrays of hashes found in Perl and consist of key-value pairs
A dictionary key can be almost any Python type, but are usually numbers or strings. Values on the other hand, can be any arbitrary Python object
All the above
2.
Which of the following is a built-in function used to convert an int value to a float?
int_to_float()
float()
convert()
int()
3.
Which of the following functions return the maximum alphabetical character from a given string str?
lower()
lstrip()
max(str)
min(str)
4.
A string literal in Python must be enclosed in
parentheses
single quotes
double quotes
either single quotes or double quotes
5.
The last index in a string is given by
1
99
0
The size of the string minus 1
a.Python's dictionaries are a kind of hash-table type
b.They work like associative arrays of hashes found in Perl and consist of key-value pairs
c.A dictionary key can be almost any Python type, but are usually numbers or strings. Values on the other hand, can be any arbitrary Python object
d.All the above
Explanation / Answer
1. d) All of above
Explanation: All these points are valid for a dictionary in Python. Lets see an example:
Clearly, A1 looks like a hash table with key value pairs. This dictionary A1 stores strings as keys and list objects as values. C
2. b) float()
Explanation: Type float(x) to convert any value x to a floating-point number.
3. c) max(str)
Explanation:max() is an inbuilt function in Python programming language that returns the highest alphabetical character in a string.
4. d) either single quotes or double quotes
Explanation: Self-explanatory.
5. d) The size of the string minus 1
Explanation: A string contains values indexed from 0. This means that the index of the last character in the string is length(string) - 1.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.