1# There are more ways to create a TUPLE in Python.
2
3# First of all, a TUPLE is usually created by:
4# (STEP 1) creating a Parethesis ()
5# (STEP 2) putting a value in Parenthesis. Example: (3)
6# (STEP 3) putting more value by adding Comma. Example: (3, 4)
7# (STEP 4) Repeat Step 3 if u want to add more value. Example: (3, 4, coffee)
8# That's how to create TUPLE
9
10# EXAMPLE
11adsdfawea = (123, 56.3, 'cheese')
12
13# But did you know, you can create TUPLE without any value inside the () ???
14wallet = ()
15print(type(wallet))
16
17# But did you know, you can create TUPLE without parenthesis () ???
18plate = 'cake',
19print(type(plate))
20
21# As you can see, STRING is possible in TUPLE, not just INTEGERS or FLOATS.
22
23
1# Let's have a look here first.
2coffee = (3.14,) # coffee is a VARIABLE, 3.14 is a FLOAT NUMBER
3
4# What is the TYPE inside the VARIABLE coffee?
5
6#Let's see
7print(type(coffee)) #It will print what TYPE the VARIABLE it is
8
9# It will print: <class 'tuple'>
10
11
12
13# Why it printed <class 'tuple'> and not <class 'float'>???
14
15
16# ANSWER: #
17
18# Because we put the comma --> , <-- after the 3.14
19# That's why it became a tuple type. (not a float type)
20
21
22# HOW TO CREATE a TUPLE?
23
24# To create a tuple, create a Parenthesis --> () <--
25# Then add value inside, for example I add 4 inside the parenthesis --> (4) <--
26# Last, add comma --> , <-- like this --> (4,) <--
27# Then add more like this --> (4, 5) <--
28# If you want to add more, just use --> , <-- like this --> (4, 5, 6) <--
29
30
31# Wait, I don't understand, what's the purpose of TUPLE?
32# it let you store an ordered sequence of items.
33# It's similar to LIST but data inside the TUPLE can't be change.
34
35# NOTES
36# STRING is also possible in TUPLE
37food = ('cake', 'cupcake', 1997, 2000);
38# As you can see, the 'cake' and 'cupcake' are STRINGS, while 1997 and 2000 are INTEGER NUMBERS.