def myFunc(word1="", word2=""):
return word1+" "+word2
# passes tuple elements as separate arguments
print(myFunc(*("hello","world"))) # or
print(myFunc(*("oneArgument",))) # , to imply its an interable
>>> b = ("Bob", 19, "CS")
>>> (name, age, studies) = b # tuple unpacking
>>> name
'Bob'
>>> age
19
>>> studies
'CS'
#tuple unpacking
myTuple = ("Tim","9","Smith")
#tuple unpacking allows us to store each tuple element in a variable
#syntax - vars = tuple
"""NOTE: no of vars must equal no of elements in tuple"""
name,age,sirname = myTuple
print(name)
print(age)
print(sirname)
#extra
#this alows us to easily switch values of variables
name,sirname = sirname,name
print(name)
print(sirname)
>>> def f():
return 1,2
>>> a,b=f()
>>> a
1
>>> b
2
tuple1 = ("python","c#","c++")
(programming_language_1,programming_language_2,programming_language_3) = tuple1
print(programming_language_1, "
",programming_language_2,"
",programming_language_3)
odd_numbers = (1, 3, 5)
even_numbers = (2, 4, 6)
Code language: Python (python)
count, fruit, price = (2, 'apple', 3.5)