Functions on Tuple

10 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€64.90
List Price:  €92.72
You save:  €27.82
£55.48
List Price:  £79.26
You save:  £23.78
CA$94.84
List Price:  CA$135.49
You save:  CA$40.65
A$107.44
List Price:  A$153.49
You save:  A$46.05
S$94.44
List Price:  S$134.92
You save:  S$40.48
HK$547.73
List Price:  HK$782.50
You save:  HK$234.77
CHF 63.11
List Price:  CHF 90.16
You save:  CHF 27.05
NOK kr759.51
List Price:  NOK kr1,085.06
You save:  NOK kr325.55
DKK kr484.31
List Price:  DKK kr691.90
You save:  DKK kr207.59
NZ$117.18
List Price:  NZ$167.41
You save:  NZ$50.23
د.إ257.02
List Price:  د.إ367.19
You save:  د.إ110.16
৳7,686.18
List Price:  ৳10,980.73
You save:  ৳3,294.54
₹5,834.28
List Price:  ₹8,335.04
You save:  ₹2,500.76
RM330.66
List Price:  RM472.40
You save:  RM141.73
₦97,668.24
List Price:  ₦139,532.04
You save:  ₦41,863.80
₨19,468.63
List Price:  ₨27,813.53
You save:  ₨8,344.89
฿2,546.70
List Price:  ฿3,638.31
You save:  ฿1,091.60
₺2,265.91
List Price:  ₺3,237.16
You save:  ₺971.24
B$351.06
List Price:  B$501.53
You save:  B$150.47
R1,322.01
List Price:  R1,888.66
You save:  R566.65
Лв126.52
List Price:  Лв180.76
You save:  Лв54.23
₩94,315.14
List Price:  ₩134,741.70
You save:  ₩40,426.55
₪257.38
List Price:  ₪367.71
You save:  ₪110.32
₱3,931.96
List Price:  ₱5,617.33
You save:  ₱1,685.37
¥10,592.26
List Price:  ¥15,132.45
You save:  ¥4,540.19
MX$1,160.67
List Price:  MX$1,658.17
You save:  MX$497.50
QR255.40
List Price:  QR364.88
You save:  QR109.47
P964.60
List Price:  P1,378.06
You save:  P413.46
KSh9,279.27
List Price:  KSh13,256.67
You save:  KSh3,977.40
E£3,320.75
List Price:  E£4,744.14
You save:  E£1,423.38
ብር3,980.93
List Price:  ብር5,687.29
You save:  ብር1,706.36
Kz58,401.19
List Price:  Kz83,433.85
You save:  Kz25,032.66
CLP$68,800.17
List Price:  CLP$98,290.17
You save:  CLP$29,490
CN¥505.43
List Price:  CN¥722.08
You save:  CN¥216.64
RD$4,147
List Price:  RD$5,924.54
You save:  RD$1,777.54
DA9,435.57
List Price:  DA13,479.97
You save:  DA4,044.39
FJ$157.96
List Price:  FJ$225.66
You save:  FJ$67.70
Q546.07
List Price:  Q780.13
You save:  Q234.06
GY$14,663.88
List Price:  GY$20,949.30
You save:  GY$6,285.42
ISK kr9,758.70
List Price:  ISK kr13,941.60
You save:  ISK kr4,182.90
DH709.58
List Price:  DH1,013.74
You save:  DH304.15
L1,235.01
List Price:  L1,764.37
You save:  L529.36
ден3,991.30
List Price:  ден5,702.11
You save:  ден1,710.80
MOP$564.38
List Price:  MOP$806.29
You save:  MOP$241.91
N$1,336.41
List Price:  N$1,909.24
You save:  N$572.83
C$2,577.43
List Price:  C$3,682.20
You save:  C$1,104.77
रु9,342.84
List Price:  रु13,347.49
You save:  रु4,004.64
S/260.45
List Price:  S/372.08
You save:  S/111.63
K268
List Price:  K382.87
You save:  K114.87
SAR262.59
List Price:  SAR375.15
You save:  SAR112.55
ZK1,736.79
List Price:  ZK2,481.24
You save:  ZK744.44
L322.64
List Price:  L460.94
You save:  L138.29
Kč1,642.49
List Price:  Kč2,346.52
You save:  Kč704.02
Ft25,571.54
List Price:  Ft36,532.34
You save:  Ft10,960.80
SEK kr748.30
List Price:  SEK kr1,069.05
You save:  SEK kr320.74
ARS$60,059.22
List Price:  ARS$85,802.56
You save:  ARS$25,743.34
Bs483.92
List Price:  Bs691.35
You save:  Bs207.42
COP$270,819.36
List Price:  COP$386,901.39
You save:  COP$116,082.02
₡35,222.95
List Price:  ₡50,320.66
You save:  ₡15,097.70
L1,728.74
List Price:  L2,469.73
You save:  L740.99
₲517,758.37
List Price:  ₲739,686.52
You save:  ₲221,928.15
$U2,629.19
List Price:  $U3,756.16
You save:  $U1,126.96
zł279.29
List Price:  zł399
You save:  zł119.71
Already have an account? Log In

Transcript

So here we have created a string or a character tupple. Now I'll be creating a topple or mixed up and you can say, where I will store both the character value and the numeric value. So I'll write a name here. Suppose T one adherence to a few values suppose your own rate doctor can give a comma and beside that and right then again give a comma right nurse give a comma and here write 20. Now run this and print this T one. So print to school one.

See it printed perfectly because it has no error. So in this way, you can create topples by using just character string by using both character and you ministering Also you can create only numeric strings. So let me create one numeric tupple. So here I write one comma two comma four comma five comma eight, as many as number you want to give it again, so run and then print D score two. So, it has printed my numerator now indexing of a topple. So just like list it the same index of a tupple means the position of the element position of each item of a tupple.

So it will start from zero and then it will go on as 12345 like this. So the first element of the tupple is considered as index zero, then index one, then index two, and then index three. In this way, it will go on now let me just call up index. So I'm writing print within bracket If the tupple name, so my name is T and working on the first step, then within this square bracket provide an index number, so I provide zero here. Let's see what it prints. So, what it prints it prints dog.

So, here in the tupple t zero is the first element. So it has an index number zero, sorry, dog has the dog is the first element. So it has an index number zero. So whenever I give the index number zero here, it printed dog. Now the same way, if you write print T, and given index number three, what it will print, so it will print cow, because here look at here. So 012323 is the index number of cow so it has printed cow here.

Now if you write, print, T, just write minus two Then what happened? See printed mine cow, because look at this list of elements or topples, look at the stubble. Starting from the end, this is minus one, this is minus two. So, just like list it, it can have a negative index also. So, if you start counting from the end, then it will start from minus one. So, minus one minus two minus three minus four and minus five.

Now, if you write print T and minus four what it will print it will print cat because minus one minus two minus three minus four. So, minus four is in its number of cats starting from the end. So, you can print it is printing cat. Now, you can also give a range of index So, if I write two is 247 what are the numbers that it will print? Let me foresee this. So 01234 So, it will print 012 that is starting from here goat and cow monkey it will not print because in the last number is n minus one that is within print n minus one So, four, four minus one is three it will print up to three, index number three, so, just run it, see it printed only goat and cow it is same as list the only difference between lists and adapters you can modify your list, but in tupple you cannot modify now if you just write print T and within this square bracket, right minus five is two minus three So, Ron see credit dog and cat because stopping Hear minus one minus two minus three minus four minus five.

So minus five and minus four it will print it will not print a string, because the next number, just it will print the before number, not the exact index, it will print for the last range that will provide. So in this way you can index tupple. Next thing that we can do is slicing slicing up a tupple. Let's look at that. So slicing that, that is basically a range of values that we provide that we have already done in indexing. The previous example that we have done is basically slicing that is we are providing a range and we're calling a part of a topple that is called slicing.

Now one more thing that you can do in slicing is just provide the end end range don't provide the beginning. So what it will print, it will print everything before 0123. Okay, now, if you provide only the beginning, so just provide One and provide nothing at the end. So, what it will print, it will start printing from the second number second value and then it will print everything after that. So, this is what slicing is. So, if you provide a range from this like this, this is also slicing, if you give like negative index This is also slicing.

And if you provide like this, this is also slicing. Slicing is basically selecting a range of elements in a tupple. This is called slicing. Now, one more thing that I will show you is like print give the tupple name. So here I'll write Apple to element using t to topple. Now here right three numbers starting from one index number, give up to say how many elements I've created over here.

Let's just first look at 1-234-512-3456 six animals out there. So I write here five and then again you semicolon so colon and then give two. So, what this is referring to what this numbers are referring to, this is the range one is to five and then what to what two is defining I've already talked to this in list this too is defining that is it will just omit the contiguity value and it will just print the alternate values see what it printed? it printed two and five, because starting from here, it will print this video will omit this then it will enter in this then again it will omit everything okay. So this is how it will print. Now, if I write zero over here, what it will print, so it has printed 148 because it printed first number then omitted the second one, then it printed this one then again omitted the second one, and then again printed this one, okay?

Do not print this one because the last number is always n minus one I told you. So, it has printed these three numbers, no concatenation of a topple. So I will now do concatenation. Okay. Now, let me first create one more topic then I will do concatenation. So here I write tiger, both lion zebra, okay, take me do with this four elements.

So I run this. Now, I want to join this to double one is d3 and the one that I've created in the beginning that is t this one. So I want to join this too. So what can I do? I need to create a new tupple. So I'll create the for that D for is a new topple now and right here, t plus d3.

Run it and then Print default see it has concatenated that do doubles. So the first values are the from the first apple and then the next four values are from the last couple that we have just now created. So in this way you can concatenate two doubles. Now, in this RT three topic that we have created, let me use an operator here. So I'll write print t three and then I'll use a star operator and write two what it will do, it will repeat the whole topple once again. So, this is the first step and it has now repeated over here now if you just write, print, tea tree into tree start tree what it will do, it will repeat this value three times.

So in this way, you can repeat the tupple as many as number of times you want. So we have used two operators one is plus Enemies start classes for concatenation and star is for repeating those samples, the number of times you specify. So I'll be ending my video over here. Keep practicing. See you in the next video. Thank you

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.