1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
SOVA2 [1]
3 years ago
14

. Write a function called is_sorted that takes a list as a parameter and returns True if the list is sorted in ascending order a

nd False otherwise. Here, I want you to make use of the input function, where users could provide an input that would be the members of the list.

Computers and Technology
1 answer:
aalyn [17]3 years ago
8 0

Answer:

There are multiple ways to solve the given problem, I will be presenting the most simple and easy way of solving this problem in few lines of code.

Python code:

def is_sorted(user_list):

   return user_list == sorted(user_list)

user_list=input("Please enter a list: ")

user_list = user_list.split()

print(is_sorted(user_list))

print("Your list: ", user_list)

Explanation:

A function is_sorted is created which takes a list as input and using the sorted() function of python which returns true when the list is sorted in ascending order and returns false when the list is not sorted in ascending order.

Driver code includes getting input list from the user and using split() function to create a list separated by space then printing the output of is_sorted function and in the last printing the contents of that list.

Output:

Please enter a list: 1 3 6 9

True

Your list:  ['1', '3', '6', '9']

Please enter a list: 15 7  2 20

False

Your list:  ['15', '7', '2', '20']

You might be interested in
Difference between academic library and school Library
GREYUIT [131]
I think Academic is like books about subjects so educational and school library are like fun books enjoyable
8 0
2 years ago
What should you do when you are working on an unclassified system and receive an email.
koban [17]

Answer:

Don't respond to it. Either leave it there, or just delete it. It is most likely spam or a scammer trying to get your information. Don't respond, please.

3 0
2 years ago
A drink costs 3 dollars. A pizza costs 6 dollars. Given the number of each, compute total cost and assign to totalCost. Ex: 2 dr
steposvetlana [31]

I think it's correct

.

.

.

.

.

.

.

.

.

5 0
2 years ago
Can i get some help please .
Alex787 [66]

Answer:

Interest

So, lets say that you took a loan from the bank of 20,000. But, when you are supposed to pay it back, you need to pay 25,000. This is because of interest. When the bank gives you the money, they cannot give it to you just like that. There is no profit coming from it. So, there is the thing called interest which basically says that since you took money from the bank, you need to pay a little more because you borrowed money from them.

4 0
2 years ago
Read 2 more answers
Sarah wants to calculate how much of a profit she would make on producing and selling a new product. Sarah should use a _____.
vagabundo [1.1K]
The answer is spreadsheet. I just did this lesson and I got all of the answers right so I know it's correct.
4 0
3 years ago
Other questions:
  • Row array gameScores contains all player scores. Construct a row array highScores than contains all player scores greater than m
    15·1 answer
  • The adjustable contact of a potentiometer is placed at the center of its adjustment. If the total resistance is 5 kOhms, what is
    9·1 answer
  • The Fibonacci numbers are the numbers
    15·1 answer
  • The ________ phase is a technical blueprint for a whole system which captures all aspects of how the system's components will fu
    9·1 answer
  • If you are logged on to Windows Live Messenger, why would you be unable to engage
    6·1 answer
  • In the __________ Standard, chemical manufacturers, importers, and distributors are required to provide hazard information by wa
    10·1 answer
  • A function ________ contains the statements that make up the function.
    5·1 answer
  • 1. When the Cisco 2950 switch is first turned on, it behaves like a hub. Why is this so, and what must happen before the switch
    5·1 answer
  • Follow me on Tik-Tok​
    7·2 answers
  • How to test someone elese internet speed from a distance
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!