Pure Programmer
Blue Matrix


Cluster Map

Tuples

L1

This page is under construction. Please come back later.

Tuples1.py
#!/usr/bin/env python3;
import Utils

# Begin Main
pair1 = ("Hello", 5)

pair2 = [3, 3.1415926]
pair3 = ["Goodbye", 1.5]

print(pair1[0] + "," + str(pair1[1]))
print(str(pair2[0]) + "," + str(pair2[1]))
print(Utils.tupleToString(pair3))

Output
$ python3 Tuples1.py Hello,5 3,3.1415926 <"Goodbye", 1.5>
Tuples2.py
#!/usr/bin/env python3;
# Begin Main
pair1 = ("Hello", 5)
tuple1 = ("Goodbye", 3, 3.1415926)
tuple2 = (1.6, 2.5, 5, "C")

print(pair1[0] + "," + str(pair1[1]))
print(tuple1[0] + "," + str(tuple1[1]) + "," + str(tuple1[2]))
print(str(tuple2[0]) + "," + str(tuple2[1]) + "," + str(tuple2[2]) + "," + tuple2[3])

Output
$ python3 Tuples2.py Hello,5 Goodbye,3,3.1415926 1.6,2.5,5,C
python

Questions

Projects

More ★'s indicate higher difficulty level.

References