1.
Python has how many standard data types?
Correct Answer
C. 5
Explanation
Python has five standard data types. These data types include numbers, strings, lists, tuples, and dictionaries. Each data type has its own characteristics and uses in programming. Numbers are used for mathematical calculations, strings are used for text manipulation, lists are used to store multiple items, tuples are used to store immutable sequences, and dictionaries are used to store key-value pairs. These data types provide flexibility and functionality to Python programmers for various tasks and operations.
2.
What is the output of print str[0] if str = ‘Hello World!’?
Correct Answer
C. H
Explanation
The correct answer is "H" because when we access the element at index 0 of the string "Hello World!", it returns the first character of the string which is "H".
3.
What is the difference between tuples and lists?
Correct Answer
A. Tuples are enclosed within parentheses while list are not.
Explanation
Tuples and lists are both used to store multiple items in Python. The main difference between them is that tuples are immutable, meaning their values cannot be changed once they are created, while lists are mutable and can be modified. Tuples are enclosed within parentheses, while lists are not. This difference in syntax allows for easy identification and differentiation between the two data types.
4.
What is the process of retrieving original Python objects from the stored string representation?
Correct Answer
D. Unpicking
Explanation
The process of retrieving original Python objects from the stored string representation is called unpicking.
5.
What manages memory in Python?
Correct Answer
C. Private heap space
Explanation
Private heap space manages memory in Python. In Python, every object is stored in a private heap, and the interpreter takes care of allocating and deallocating the memory for these objects. The private heap space is where all the objects and data structures are stored during the execution of a Python program. The garbage collector, which is responsible for freeing up memory that is no longer in use, also operates within the private heap space.
6.
Which of these statements is true for lists and tuples?
Correct Answer
A. Lists are mutable, tuples are not
Explanation
Lists and tuples are both types of data structures in Python. The correct statement is that lists are mutable, while tuples are not. This means that elements in a list can be modified, added, or removed after the list is created. On the other hand, elements in a tuple cannot be changed once the tuple is created. Tuples are considered immutable because they provide data integrity and are often used to store related pieces of information that should not be modified.
7.
Which of these is not a mutable built-in type Python?
Correct Answer
C. Strings
Explanation
In Python, strings are immutable, which means that once a string is created, it cannot be changed. This is in contrast to lists, sets, and dictionaries, which are mutable and can be modified after creation. Therefore, the correct answer is strings.
8.
What command can you use to delete a file in Python?
Correct Answer
A. Os.remove (filename)
Explanation
The correct answer is os.remove (filename). This command is used in Python to delete a file. The os module provides various functions for interacting with the operating system, and os.remove() specifically allows you to delete a file by specifying its filename as an argument.
9.
What is the use of // operator in Python?
Correct Answer
B. Division
Explanation
The // operator in Python is used for division. It performs floor division, which means it returns the largest integer that is less than or equal to the result of the division. This is different from the / operator, which returns the exact quotient as a float. The // operator can be useful when you want to divide two numbers and obtain an integer result without any decimal places.
10.
What is the output of print tuple[0] if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?
Correct Answer
B. Abcd
Explanation
The correct answer is "abcd" because in Python, tuples are ordered and indexed starting from 0. Therefore, when we access the element at index 0 of the tuple, we get the first element, which is "abcd".