Author name: admin

What is abstraction in Python OOP?

What is abstraction in Python OOP? a) Hiding implementation details while showing only essential features b) Creating multiple instances of a class c) Defining a method with no body d) Inheriting properties from another class Answer: a) Hiding implementation details while showing only essential features Explanation: Abstraction in Python OOP involves hiding the complex implementation […]

What is abstraction in Python OOP? Read More »

Which of the following is an example of encapsulation in Python?

Which of the following is an example of encapsulation in Python? a) Using private variables and methods within a class b) Creating multiple classes in a module c) Inheriting from a base class d) Overloading methods Answer: a) Using private variables and methods within a class Explanation: Encapsulation in Python refers to the practice of

Which of the following is an example of encapsulation in Python? Read More »

What will happen if the user inputs a non-numeric value when using int() to convert the input?

What will happen if the user inputs a non-numeric value when using int() to convert the input? a) The value is converted to 0 b) A ValueError is raised c) The value is converted to a float d) The program continues with no error Answer: b) A ValueError is raised Explanation: If the user inputs

What will happen if the user inputs a non-numeric value when using int() to convert the input? Read More »

Which string method in Python is used to replace parts of a string?

Which string method in Python is used to replace parts of a string? a) replace() b) swap() c) change() d) substitute() Answer: a) replace() Explanation: The .replace() method in Python is used to replace occurrences of a specified substring within a string with another substring. It returns a new string with the replacements made. text

Which string method in Python is used to replace parts of a string? Read More »

What is the output of the following code? print(“Python”.upper())

What is the output of the following code? print(“Python”.upper()) a) python b) PYTHON c) Python d) pYTHON Answer: b) PYTHON Explanation: The .upper() method in Python converts all the characters in a string to uppercase. When applied to the string "Python", it returns "PYTHON". result = "Python".upper() print(result) # Prints "PYTHON" String methods like .upper()

What is the output of the following code? print(“Python”.upper()) Read More »

How do you import a specific function from a module in Python?

How do you import a specific function from a module in Python? a) Using the import function keyword b) Using the import keyword c) Using the from…import statement d) Using the include keyword Answer: c) Using the from…import statement Explanation: To import a specific function from a module in Python, you use the from…import statement.

How do you import a specific function from a module in Python? Read More »

Which of the following is an example of a built-in function in Python?

Which of the following is an example of a built-in function in Python? a) print() b) my_function() c) loop() d) variable() Answer: a) print() Explanation: print() is an example of a built-in function in Python. Built-in functions are pre-defined functions that are available by default in Python without the need for importing any additional modules.

Which of the following is an example of a built-in function in Python? Read More »

Scroll to Top