Robotics & Artificial Intelligence
What is the difference between list and tuple in Python? Explain with the help of an example.
Getting Started
2 Likes
Answer
| List | Tuple |
|---|---|
Elements of list are enclosed within square brackets [ ]. | Elements of tuple are enclosed within parentheses ( ). |
| List is mutable (elements can be changed). | Tuple is immutable (elements cannot be changed). |
Example: my_list = [1, 1.0+3j, "great", True] | Example: my_tuple = (1, 2, 3, 4) |
Answered By
2 Likes
Related Questions
Fill in the blanks:
- Python is a ……………. which means it may be used to create a broad variety of applications.
- ……………. frameworks are used for web development in Python.
- ……………. is a tool kit in Python for GUI development.
- The suitable data type to store only True or False is …………….. .
- Lists are ……………. and ……………. are immutable in Python.
What do you understand by data type? List names of Python built-in data types.
Write a Python program to declare and print 'list', 'dictionary', and 'tuple'.
Write a Python program to demonstrate use of string operators.