Tuples
This page is under construction. Please come back later.
#!/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>
#!/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
Questions
- {{Who's on first?}}
- {{Who's on second?}}
- {{Who's on third?}}
Projects
More ★'s indicate higher difficulty level.
References
- [[Python Language Reference]]
- [[Python Standard Library]]
- [[Python at TutorialsPoint]]