Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
23 views

Question Python

Lists and tuples are sequence data types that can store collections of objects in Python. The key difference is that lists are mutable while tuples are immutable.

Uploaded by

Trần Anh Hùng
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)
23 views

Question Python

Lists and tuples are sequence data types that can store collections of objects in Python. The key difference is that lists are mutable while tuples are immutable.

Uploaded by

Trần Anh Hùng
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/ 2

7. What are lists and tuples? What is the key difference between the two?

Lists and Tuples are both sequence data types that can store a collection of objects in Python.
The objects stored in both sequences can have different data types. Lists are represented with square
brackets [], while tuples are represented with round brackets ().
Difference between the two is that while lists are mutable, tuples are immutable objects. This means
that lists can be modified, appended or sliced on the go but tuples remain constant and cannot be
modified in any manner
19. What is the difference between Python Arrays and lists?
 Arrays in python can only contain elements of same data types
 Lists in python can contain elements of different data types
 List consuming large memory more than Arrays

6. What is Scope in Python?


A variable is only available from inside the region it is created. This is called scope.
 Local Scope: A variable created inside a function belongs to the local scope of that function,
and can only be used inside that function.
 Global Scope: A variable created in the main body of the Python code is a global variable and
belongs to the global scope. Global variables are available from within any scope, global and
local.
 If you need to create a global variable, but are stuck in the local scope, you can use the global
keyword. It’s mean Local scope objects can be synced with global scope objects using
keywords such as global
25. What is lambda in Python? Why is it used?
Lambda is an anonymous function in Python, that can accept any number of arguments, but can
only have a single expression. The expression is evaluated and returned.
In Python, an anonymous function is a function that is defined without a name. While normal
functions are defined using the def keyword in Python, anonymous functions are defined using the
lambda keyword.
We should use it in situations require an anonymous function for a short time period.
30. What is PYTHONPATH in Python?
PYTHONPATH is an environment variable which you can set to add additional directories where
Python will look for modules and packages.
38. What does *args and **kwargs mean?
 *args is a special syntax used in the function definition to pass variable-length arguments.
 **kwargs is a special syntax used in the function definition to pass variable-length
keyworded arguments. Also, “kwargs” is used just by convention. You can use any other
name.
23. What are decorators in Python?
Decorators in Python are essentially functions that add functionality to an existing function in Python
without changing the structure of the function itself.
Use Decorators with @and name function decorator
1. Explain Django Architecture?
 Django follows the MVT (Model View Template) pattern which is based on the Model View
Controller architecture.

You might also like