tuple and list exercise
Tuple:
1. __add__
<span style="color: #008080">1</span> a = (1,2,3,4,5,6,7,8,9<span style="color: #000000">,) </span><span style="color: #008080">2</span> b = (10,11,22,33,44,55,66<span style="color: #000000">,), </span><span style="color: #008080">3</span> c = (110,112,113,114<span style="color: #000000">,), </span><span style="color: #008080">4</span> result = a.<span style="color: #800080">__add__</span><span style="color: #000000">(b) </span><span style="color: #008080">5</span> <span style="color: #0000ff">print</span>(result) <span style="color: #008000">#</span><span style="color: #008000">(1, 2, 3, 4, 5, 6, 7, 8, 9, (10, 11, 22, 33, 44, 55, 66)) add(b)里面只能加一个参数,否则会报错</span> <span style="color: #008080">6</span> <span style="color: #0000ff">print</span>(a+b+c) <span style="color: #008000">#</span><span style="color: #008000">(1, 2, 3, 4, 5, 6, 7, 8, 9, (10, 11, 22, 33, 44, 55, 66), (110, 112, 113, 114))</span>
<span style="color: #008080">1</span> a = (1,2,3,4,5,6,7,8,9<span style="color: #000000">,) </span><span style="color: #008080">2</span> b = (10,11,22,33,44,55,66<span style="color: #000000">,) </span><span style="color: #008080">3</span> c = (110,112,113,114<span style="color: #000000">,) </span><span style="color: #008080">4</span> result = a.<span style="color: #800080">__add__</span><span style="color: #000000">(b) </span><span style="color: #008080">5</span> <span style="color: #0000ff">print</span>(result) <span style="color: #008000">#</span><span style="color: #008000">(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 22, 33, 44, 55, 66) 有没有逗号的区别哈哈</span> <span style="color: #008080">6</span> <span style="color: #0000ff">print</span>(a+b+c) <span style="color: #008000">#</span><span style="color: #008000">(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 22, 33, 44, 55, 66, 110, 112, 113, 114)</span>
The above is the detailed content of tuple and list exercise. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Nowadays, many friends like to use Kingsoft Typing Assistant, but the typing speed seriously affects work efficiency, so I teach you to practice typing speed. So how to use Kingsoft Typing Assistant to practice typing? Today, the editor will give you a tutorial on how to practice typing numbers with Kingsoft Typing Assistant. The following is described, I hope it will be helpful to everyone. First, open the Kingsoft typing software, then click the (Getting Started) button with your mouse, then click the (Number Keys) button in a new window, then click the (Start from Scratch) button below to practice, or click the (Test Mode) button. , just enter numbers for practice. In addition, Kingsoft Typing Assistant has other functions that can help you practice typing better. 1. Select practice mode: On the software interface, you can see that there are different practice modes, such as "New

List operation //Insert a value from the head of the list. $ret=$redis->lPush('city','guangzhou');//Insert a value from the end of the list. $ret=$redis->rPush('city','guangzhou');//Get the elements in the specified range of the list. 0 represents the first element of the list, -1 represents the last element, and -2 represents the penultimate element. $ret=$redis->l

Wubi typing, also known as Wubi input method, is an efficient Chinese character input method. For beginners, mastering Wubi typing requires a certain amount of time and patience. Below, the editor has compiled the learning methods for Wubi typing beginners. Let’s take a look! 1. Understand the principles of Wubi font Wubi font is a type of font based on Input method for strokes and radicals. Each Chinese character can be composed of different strokes and radicals. Therefore, the key to learning Wubi font is to understand the combination rules of strokes and root characters. In the five-stroke font, there are five basic strokes: horizontal, vertical, left, right, and fold. These basic strokes can be combined into different radicals, which in turn can be combined into complete Chinese characters. 2. Learn the radicals and key positions. In Wubi font, each letter key corresponds to one or more radicals. therefore

1: JSONArray to ListJSONArray string to List//Initialize JSONArrayJSONArrayarray=newJSONArray();array.add(0,"a");array.add(1,"b");array.add(2,"c") ;Listlist=JSONObject.parseArray(array.toJSONString(),String.class);System.out.println(list.to

Example In this example, we first look at the usage of list.sort() before continuing. Here, we have created a list and sorted it in ascending order using sort() method - #CreatingaListmyList=["Jacob","Harry","Mark","Anthony"]#DisplayingtheListprint("List=",myList)#SorttheListsinAscendingOrdermyList .sort(

How to sort a list using the List.Sort function in C# In the C# programming language, we often need to sort the list. The Sort function of the List class is a powerful tool designed for this purpose. This article will introduce how to use the List.Sort function in C# to sort a list, and provide specific code examples to help readers better understand and apply this function. The List.Sort function is a member function of the List class, used to sort elements in the list. This function receives

1. The most common way (not necessarily the best) is through Arrays.asList(strArray). After converting the array into List, you cannot add or delete the List, you can only check and modify it, otherwise an exception will be thrown. Key code: Listlist=Arrays.asList(strArray);privatevoidtestArrayCastToListError(){String[]strArray=newString[2];Listlist=Arrays.asList(strArray);//Insert a piece of data into the converted list list.add(" 1"

1. Introduction to List interface List is an ordered collection and a repeatable collection. It inherits the Collection interface. Repeated elements can appear in the List collection, and the element at the specified position can be accessed through the index (subscript). 2. List common methods - voidadd (intindex, Obejctelement) method 1. The voidadd (intindex, Obejctelement) method inserts the element element at the specified position and moves the subsequent element back one element. 2.voidadd(intindex,Obejctelemen
