Write a sequence of instructions that assigns the largest from three numbers a, b, c to a result variable res. Example: for the numbers
Write a sequence of instructions that assigns the largest from three numbers a, b, c to a result variable res. Example: for the numbers a, b, c = 3, 5, 7, the value of res will be 7 after the execution of your instruction. You are not allowed to use the function max. The following function is supposed to print 'sorted' if the digits of an integer number are sorted from the smallest to largest, where the smallest digit is the right-most (e.g., the 1 in 5021). Otherwise, it is supposed to print 'not sorted'. Examples: check_sorted_digits (8542) prints 'sorted', because 8>5> 4 > 2. check_sorted_digits (9423) prints 'not sorted', because 2 < 3. Complete the missing code. def check_sorted_digits (x): current_digit x%10 res. while True: x = x//10 #Missing code below #Missing code above next_digit x%10 if current_digit > next_digit: res = not sorted' break current_digit next_digit print res
Step by Step Solution
3.51 Rating (164 Votes )
There are 3 Steps involved in it
Step: 1
Solution To find the largest among three numbers a b and c and assign it to a result variable res yo...See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started