Python вопросы и ответы для интервью
Связанные сравнения
Вопрос 11. How does a function return values?
Functions return values using the return statement.
Ex:
def func():
num = 10
return num
Вопрос 12. Define slicing in Python?
Slicing is a procedure used to select a particular range of items from sequence types such as Strings, lists, and so on.
a = ("a", "b", "c", "d", "e", "f", "g", "h")
x = slice(3, 5)
print(a[x])
Output:
('d', 'e')
Вопрос 13. Define package in Python.
In Python packages are defined as the collection of different modules.
Вопрос 14. Which command is used to delete files in Python?
OS.unlink(filename) or OS.remove(filename) are the commands used to delete files in Python Programming. Example:
import OS
OS.remove('hello.txt')
Вопрос 15. Explain the difference between local and global namespaces?
- Local namespaces are created within a function when that function is called.
- Global namespaces are created when the program starts.
Самое полезное по оценкам пользователей:
- What is Python?
- How do I share global variables across modules?
- How do you set a global variable in a function in Python?
- What type of language is Python? Programming or Scripting?
- Why can't I use an assignment in an expression?