Tuple Assignment Components Tuple Assigned Individual Variables Example Create Point 3d Sp Q30682623

Tuple Assignment

The components of a tuple can be assigned to individualvariables.

So, for example, if we create a point in 3D space:

pt = (1, 2, 3)

then we can later assign its components to individualvariables:

x, y, z = pt

The str.partition method can be used to separate the componentsof a string:

>>> help(str.partition) Help on method_descriptor:partition(…) S.partition(sep) -> (head, sep, tail) Search forthe separator sep in S, and return the part before it, theseparator itself, and the part after it. If the separator is notfound, return S and two empty strings.

Write a function get_names() which prompts the user to entertheir name, and then returns a tuple containing their first andlast names. You must use str.partition to separate the user’s firstand last names. You must ‘unpack’ the result of str.partition intoseparate variables. You may assume that the user only enters twonames.(using python)

"We Offer Paper Writing Services on all Disciplines, Make an Order Now and we will be Glad to Help"
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.