Ask Question

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

+2
Answers (1)
  1. 23 May, 17:46
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers