Question
Asked Nov 24, 2019
1 views

What are tuples in python?

check_circle

Expert Answer

Step 1

A tuple is a collection of data that are separated by commas. A tuple can have different types of data like string, integer, double and Boolean. It is similar to a list but the basic difference between list and tuple, the list is mutable, and tuple is immutable so that the value presents in a tuple cannot be changed further.

Step 2

In python, parenthesis is used to put data in a tuple. Also, python has a tuple keyword to convert any list into a tuple. If someone attempts the change the tuple data, it will produce error ‘tuple’ object does not support item assignment. To change the tuple data, it will require to convert into the list and then change the list data then again convert it into a tuple.

Step 3

Python code for tuple:

 tuple1=("apple",123,4.34,"he...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Most modern TCP implementations use pseudo-random number generators (PRNG) to determine starting seq...

A: The ith number can be generated if (i-1)th number is generated, and thus the entire series can be ge...

question_answer

Q: What are the SQL query commands to create the tables (attached) with appropriate attributes and data...

A: Primary key:A PRIMARY KEY is used to define each tuple in a table in a unique way. The PRIMARY KEY i...

question_answer

Q: I have to add this solution to a conversion code. This chapter is focused on  strings and string man...

A: Program Instructions:  ⦁ Create a Python3 program for the given problem of string slicing, search, a...

question_answer

Q: Write a program that reads integers from a file, sums the values and calculates the average. Write...

A: The below given C++ program will obey the following rubrics:Importing essential header files.Definin...

question_answer

Q: Make this code more efficient   numb = int(input("What is your favourite number? ")) name = str(inpu...

A: To make this code more efficient do not use NOT and AND operation instead of this use nested if to m...

question_answer

Q: Now that the GPO is created, what is the next step needed to deploy the GPO?

A: After creating GPO (Group Policy Object), the following are the steps needed to deploy the GPO.First...

question_answer

Q: Do research and write a brief report on the impact of mobile advertising on sales and marketing

A: Impact of mobile advertising on sales:A form of advertising through mobile phones is known as mobile...

question_answer

Q: I do not understand why these answer so are what they are. This has to do with string comparison an ...

A: Answer:The string comparison is basically compared with their ASCII values. Here, the ASCII value fo...

question_answer

Q: a. Write the assembly language equivalent of the following MARIE machine language instructions:a) 00...

A: Assembly language equivalent to marie machine languageThe equivalent assembly instruction for given ...