0% found this document useful (0 votes)
47 views5 pages

Quiz M3. Data Types

Uploaded by

nick.odessa24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views5 pages

Quiz M3. Data Types

Uploaded by

nick.odessa24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1. Is the following statement true or false?

Hash values of different keys may have duplicates


True
False

2. What is the name of the tool used in the Python code below?
New_list – [expression for item in iterable if condition]
Generators
Comprehensions
Shorted loops

3. Which of these is wrong about the Tuple data type in python?


Tuple can contain any other data types
Tuple is ordered
Tuple elements can be accessed by indexes
Tuple is mutable

4. What is the difference between accessing dictionary elements using “[]” and get()?
There is no difference. It depends on your preferences.
Get() returns the value by key without raising an error if the key doesn’t exist.
“[]” is safer than get().

5. What is the correct definition of the update() built-in method for set data type?
The method updates set elements to the intersection with the given sets.
The method updates set elements to the difference with the given sets.
The method updates set elements to the union with the given sets.
The method is used to add a new element to a set.
6. Which operator is used to compare objects id in Python?
Is
And
==

7. Which of the answers describes the behavior of the following code in Python correctly?
my_list = [1, 2]
Print(id(my_list))
23456

my_list.append(3)
Print(id(my_list))
23456
An iterable object which consists of integers will not change its id if appended only by
integers.
If we append only one value to the list, it will not change its id.
Some objects can be changed after creation but will keep the first-time assigned id. It is
called mutable objects.

8. What is the value of the result variable in Python?


Result = 20 / 2 + 12 * 2 – 9
36
25.0
35.0
25

9. Which statement is used to remove a pair from the dictionary in Python?


Del
Remove
10. Which assignment operator takes modulus using left and right operands and assigns the
result to the left operand?
/=
-=
**=
%=
=

11. What is the Big O notation used for?


It gets the number of computer resoursces needed to implement the algorithm.
It counts the number of iterations in the algorithm.
It classifies the algorithm according to how its runtime or space requirements grow as the
input size grows.
It gets the characteristics of the CPU needed to implement the algorithm.

12. which of these are true about the set data type in Python?
Set elements are ordered
A set is mutable
A set is dynamic like a list
Set elements can be of any hashable type
A set can not contain duplicate elements

13. Choose the correct statements about the dictionary data type in Python.
A dictionary can not contain other dictionaries.
A dictionary is an associative array with arbitrary keys mapped to values.
A dictionary is mutable and dynamic, it can grow and shrink.

14. What is the result of the following code in Python?


City = “Tashkent”
City[0] = “t”
The variable “city” value will be changed to “tTashkent”
It will raise TypeError
The variable “city” value will be changed to “tashkent”

15. What is the definition of the break loop operator?


It is used to run some code once the “while” loop is over.
It allows interrupting loops, possibly depending on some condition.
It allows us to move on to the next iteration, possibly depending on some conditions.

16. Choose Boolean operators in Python.


Not
If
Or
Elif
And
Else

17. Which data types are immutable?


Integer
Float
String
Tuple
Dictionary
List
Set

18. Choose the best definition of the “Object” term in Python:


An object is an entity that has a state and behavior. Or, in other words, attributes,
properties and methods/actions.
An object is a collection of one or more characters, which are put during a quotation mark,
double quote, or triple quote.
An object is an unordered collection

You might also like