- Hands-On Data Science and Python Machine Learning
- Frank Kane
- 183字
- 2021-07-15 17:15:01
Tuples
Tuples are just like lists, except they're immutable, so you can't actually extend, append, or sort them. They are what they are, and they behave just like lists, apart from the fact that you can't change them, and you indicate that they are immutable and are tuple, as opposed to a list, using parentheses instead of a square bracket. So you can see they work pretty much the same way otherwise:
#Tuples are just immutable lists. Use () instead of []
x = (1, 2, 3)
len(x)
The output of the previous code is as follows:
3
We can say x= (1, 2, 3). I can still use length - len on that to say that there are three elements in that tuple, and even though, if you're not familiar with the term tuple, a tuple can actually contain as many elements as you want. Even though it sounds like it's Latin based on the number three, it doesn't mean you have three things in it. Usually, it only has two things in it. They can have as many as you want, really.
- C#高級編程(第10版) C# 6 & .NET Core 1.0 (.NET開發經典名著)
- MariaDB High Performance
- HTML5從入門到精通(第4版)
- Fast Data Processing with Spark(Second Edition)
- SQL Server 2016 從入門到實戰(視頻教學版)
- Clojure for Java Developers
- Django 5企業級Web應用開發實戰(視頻教學版)
- Java Hibernate Cookbook
- Drupal 8 Development Cookbook(Second Edition)
- Learn Linux Quickly
- Unity 5 Game Optimization
- Processing開發實戰
- 你好!Python
- HTML5+CSS3+jQuery Mobile+Bootstrap開發APP從入門到精通(視頻教學版)
- HTML 5與CSS 3權威指南(第4版·上冊)