Ask Question
6 October, 00:12

Given the variables name1 and name2, write a fragment of code that assigns the larger of their associated values to first.

+1
Answers (1)
  1. 6 October, 02:28
    0
    We can compare strings like numbers,

    if "a" > "b":

    do something

    Solutions will be

    Python:

    first = max (name1, name2)

    second = min (name1, name2)

    Or if we are not supposed to use max () and min (), we can achieve the same thing with a conditional,

    Python:

    if name1 > name2: ...
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Given the variables name1 and name2, write a fragment of code that assigns the larger of their associated values to first. ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers