On Python | More Q&A Click Here
# | Question | Options | Answer |
---|---|---|---|
1 | Using the pack manager, how you can you put the components in a container in the same row? | Component.pack(side=LEFT) | |
2 | Which can be an Identifier among them in Python? | _xy1 | |
3 | Choose the correct function to get the character from ASCII number | chr(number) | |
4 | Strings are immutable in Python, which means a string cannot be modified. | True | |
5 | Python does not support a character type a single character is treated as strings of length one. | True | |
6 | Which method should I use to convert String "welcome to the beautiful world of python" to "Welcome To The Beautiful World Of Python" | title() | |
7 | ________ is an object-oriented programming language. | All the above | |
8 | Python is compiled language. True or False? | False | |
9 | What is used to define a block of code (body of loop, function etc.) in Python? | Indentation | |
10 | ________ is interpreted | Python | |
11 | What is a correct syntax to output "Hello World" in Python? | print("Hello World") | |
12 | Which of the following statements is true? | All of the above. | |
13 | Standard Python implementation can import libraries written in which of the following languages? | C/C++ | |
14 | Which of the following statements is true? | Python 3 is a newer version, but it is not backward compatible with Python 2. | |
15 | Python syntax is case-sensitive | True | |
16 | A ___________ error does not cause the program to abort, but produces incorrect results. | logical | |
17 | What does the expression string1 + string2 do? | Concatenates string1 and string2. | |
18 | Which of these should you include in order to pass variables to a script? | from sys import argv | |
19 | Is it possible to link a Python program to code written in C? | Yes, the C code can be in a form of a dynamically or a statically linked library. | |
20 | To run python script file named test.py, use the command | python test.py | |
21 | What is the correct file extension for Python files? | .py | |
22 | Is it possible to check for more than one error in one except line? | Yes, if the exception types are enclosed in parentheses. | |
23 | What does REPL mean in Python? | Read, Evaluate, Print, Loop | |
24 | Which of the following is a mutable data type? | C) List | |
25 | Which of the following is an immutable data type? | C) Tuple | |
26 | What does bool(0) return? | B) False | |
27 | How can you convert a string to an integer? | A) int("123") | |
28 | How do you access the first character of a string s = "Hello"? | A) s[0] | |
29 | How do you convert a string to lowercase? | A) lower() | |
30 | Which method can be used to remove whitespace from both ends of a string? | B) strip() | |
31 | What does not True evaluate to? | B) False | |
32 | What does 5 != 3 evaluate to? | A) True | |
33 | How do you add an element to the end of a list? | A) append() | |
34 | How do you remove an item from a list? | B) remove(item) | |
35 | How do you create a tuple in Python? | B) (1, 2, 3) | |
36 | How do you access a value in a dictionary? | D) B and C | |
37 | How do you remove a key from a dictionary? | D) A and C | |
38 | How do you raise an exception in Python? | A) raise Exception | |
39 | What does the continue statement do? | B) Skips the current iteration and continues to the next | |
40 | Which of the following can be used to check the data type of a variable? | C) A and B | |
41 | What is the output of print(2 ** 3)? | B) 8 | |
42 | What does list.pop(0) do? | D) B and C | |
43 | Which keyword is used to define a function in Python? | C) def | |
44 | How do you call a function named myFunction? | B) myFunction() | |
45 | Which of the following is a way to return multiple values from a function? | C) Both A and B | |
46 | What is the default return value of a function that does not explicitly return anything? | A) None | |
47 | How do you define a default parameter in a function? | A) def my_function(x=1): | |
48 | How do you define a function that takes no arguments? | A) def my_function(): | |
49 | What is the purpose of the return statement? | C) Both A and B | |
50 | Which of the following can be used to call a function? | B) myFunction() | |
51 | How do you create a lambda function? | A) lambda x: x + 1 | |
52 | What is a class in Python? | A) A blueprint for creating objects | |
53 | How do you create an instance of a class? | A) instance = ClassName() | |
54 | What is inheritance in OOP? | A) A way to create a new class from an existing class | |
55 | What is the purpose of the __init__ method? | B) To initialize an object’s attributes | |
56 | Which of the following is a characteristic of encapsulation? | A) Data hiding | |
57 | What is polymorphism in Python? | A) The ability to define multiple methods with the same name | |
58 | How do you define a subclass in Python? | B) class SubClass(ParentClass): | |
59 | What is method overriding? | B) Defining a method in a subclass that already exists in the parent class | |
60 | What does the self keyword represent? | A) The instance of the class | |
61 | What is a class method? | A) A method that belongs to the class rather than any object | |
62 | How do you define a class method? | B) @classmethod | |
63 | What is an abstract class? | D) Both A and B | |
64 | What is a static method? | A) A method that cannot access instance variables | |
65 | What is the main purpose of using __str__ in a class? | A) To define a string representation of the object | |
66 | How can you prevent a class from being subclassed? | D) By using metaclasses | |
67 | What will happen if you do not implement an abstract method in a subclass? | C) An error will be raised | |
68 | What is method chaining? | B) Returning self in methods to allow further calls | |
69 | Which of the following is true about properties in Python? | D) All of the above | |
70 | What is the difference between a class variable and an instance variable? | A) Class variables are shared across all instances, instance variables are unique to each instance | |
71 | Which module provides the ABC (Abstract Base Class) functionality? | A) abc |