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
Which port must be open on your router to allow you to upload device configuration and firmware updates using trivial file trans
Vika [28.1K]

Answer:

UDP Port 69

<em>Trivial file transfer protocol (TFTP) operates over UDP port 69.</em>

Explanation:

UDP port 69 uses the Datagram Protocol, a communications protocol for the Internet network layer, transport layer, and session layer. This protocol when used over PORT 69 makes possible the transmission of a datagram message from one computer to an application running in another computer. UDP is used with <em>IP (the Internet Protocol)</em> and UDP Port 69 is <em>connectionless </em>which means it does not give reliable communication; it’s up to the application that received the message on Port 69 to process any errors and verify correct delivery.

3 0
2 years ago
What kinds of dogs are there
drek231 [11]
There are al types of dogs what specific breed are you looking for

5 0
3 years ago
Read 2 more answers
Virus warning don’t go on bit l y links it’s a virus
Alinara [238K]

Answer:

tysm

Explanation:

4 0
3 years ago
Read 2 more answers
Is iPhone better than android
andriy [413]

Answer:

It's up to personal preference.

Explanation:

iPhone/Apple gives more compliments to security than Android.

Android has more friendly user GUI and dev tools.

4 0
2 years ago
Read 2 more answers
Any file that contains data but not instructions for your computer is not considered software
DIA [1.3K]
True. 

But then again, partly false. A .deb file (Debian, Ubuntu Linux) contains data, but that data needs to be installed and marked executable to make the software.

But i would still say true.
5 0
2 years ago
Other questions:
  • Cryptolocker is an example of what type of malware?
    11·1 answer
  • A disadvantage of using an arithmetic mean to summarize a set of data is that __________.
    13·1 answer
  • Media messages are communicated through which of the following:
    8·2 answers
  • A process at Host C receiving two incoming UDP segments from two different hosts will know that they originated from two differe
    14·2 answers
  • Autumn suffers from nocturnal dyspnea. This term describes a breathing condition but using the prefixes to translate, it means:
    5·1 answer
  • The Curiosity Rover has recently landed on Mars and likes to send Twitter updates on its progress. If a tweet is posted 10 minut
    6·1 answer
  • Using a third-party package of your choice, write a program that reads the contents of a csv file and saves it to an Excel file.
    10·1 answer
  • Write a program code which asks for 80 numbers between 100 and 1000 to be entered.
    7·1 answer
  • What are basic types of touch screen
    15·2 answers
  • Please answer the following question in Verilog.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!