tuple in python
#a tuple is basically the same thing as a
#list, except that it can not be modified.
tup = ('a','b','c')
tuple in python
#a tuple is basically the same thing as a
#list, except that it can not be modified.
tup = ('a','b','c')
make a tuple
#you can put a lotta stuff in tuples
tup = ("string", 2456, True)
ways to create tuple in python
# There are more ways to create a TUPLE in Python.
# First of all, a TUPLE is usually created by:
# (STEP 1) creating a Parethesis ()
# (STEP 2) putting a value in Parenthesis. Example: (3)
# (STEP 3) putting more value by adding Comma. Example: (3, 4)
# (STEP 4) Repeat Step 3 if u want to add more value. Example: (3, 4, coffee)
# That's how to create TUPLE
# EXAMPLE
adsdfawea = (123, 56.3, 'cheese')
# But did you know, you can create TUPLE without any value inside the () ???
wallet = ()
print(type(wallet))
# But did you know, you can create TUPLE without parenthesis () ???
plate = 'cake',
print(type(plate))
# As you can see, STRING is possible in TUPLE, not just INTEGERS or FLOATS.
python tuple create tuple
--It is also possible to use the tuple() constructor to make a tuple.
thistuple = tuple(("apple", "banana", "cherry")) # note the double round-brackets
print(thistuple)
python tuples
#!/usr/bin/python
tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = (1, 2, 3, 4, 5, 6, 7 );
print "tup1[0]: ", tup1[0];
print "tup2[1:5]: ", tup2[1:5];
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us