GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — programmingWithPythonCode/collections/tuples_2.py at main · thomasWeise/programmingWithPythonCode

Expand file tree

/

tuples_2.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
20 lines (14 loc) · 776 Bytes
/

tuples_2.py

Copy path

File metadata and controls

20 lines (14 loc) · 776 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""An example of creating tuples of mixed types."""
mixed: tuple[str, int, float] = ("apple", 12, 1e25) # mixed types
print(f"The mixed tuple is {mixed}.") # Print the tuple.
other: tuple[str, int, float] = ("pear", 1, 1.2) # second such tuple
print(f"the other tuple: {other}.") # Print it as well.
tuples: list[tuple[str, int, float]] = [ # Create a list of 4 tuples.
mixed, ("pear", -2, 4.5), other, ("pear", -2, 3.3)]
print(f"tuples list: {tuples}.") # Print that list.
tuples.sort() # We sort the list of tuples.
print(f"sorted tuples list: {tuples}.")
a, b, c = mixed # We unpack the tuple of length 3 into 3 variables.
print(f"{a = }, {b = }, {c = }")
mixed = "x", 4, 4.5 # Declare a tuple without parentheses.
print(f"mixed is now: {mixed}")
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.