Ask Question
2 June, 00:19

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

+4
Answers (1)
  1. 2 June, 03:53
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers