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
In a C++ program, one and two are double variables and input values are 10.5 and 30.6. After the statement cin >> one >
SSSSS [86.1K]

Answer:

variable one stores 10.5 and two stores 30.6

Explanation:

In c++ language, the cout keyword is used to write to the standard output. The input from the user is taken by using the cin keyword.

For the input from the user, a variable need is declared first.

datatype variable_name;

The input can be taken one at a time as shown.

cin >> variable_name;

The input for more than one variable can be taken in a single line as given by the syntax below.

1. First, two variables are declared.

datatype variable_name1, variable_name2;

2. Both input is taken simultaneously as shown.

cin >> variable_name1, variable_name2;

For the given scenario, two double variables are declared as below.

double one, two;

The question mentions input values for the two double variables as 10.5 and 30.6.

3. The given scenario takes both the values as input at the same time, in a single line as shown below.

cin >> one >> two;

4. After this statement, both the values entered by the user are accepted.

The values should be separated by space.

First value is stored in the variable one.

Second value is stored in the variable two.

5. The user enters the values as follows.

10.5 30.6

6. The value 10.5 is stored in variable one.

7. The value 30.6 is stored in variable two.

The c++ program to implement the above is given below.

#include <iostream>

using namespace std;

int main() {

   double one, two;      

   cout << " Enter two decimal values " << endl;

   cin >> one >> two;

   cout << " The input values are " << endl;

   cout << " one : " << one << " \t " << " two : " << two << endl;

   return 0;

}

OUTPUT

Enter two decimal values  

10.5 30.6

The input values are  

one : 10    two : 530.6

6 0
3 years ago
Is anyone else excited for sephiroth (I think I spelt it wrong) in smash. And if you arn't are you excited for christmas
Fed [463]

Answer: idek what that is but okay ;v;

7 0
3 years ago
What is HTML ? <br>Give a small description about html
Genrish500 [490]
Hypertext Markup Language, a standardized system for tagging text files to achieve font, colour, graphic, and hyperlink effects on World Wide Web pages.
this information was taken from google
7 0
2 years ago
Read 2 more answers
What is the difference between building a table in word and excel
Anastasy [175]

Answer:

 The main difference between creating a table in word and excel is that there are more number of table tool and the layout section in the excel as compared to the MS word.

Creating a table in word or excel are only depend on the requirements of the particular table. If there is less number of calculations in the table then, it is easy to create the table in word as compared to excel.

And if we want to create a table with maximum numbers of rows and column and also contain high math calculation then, it is good to create in excel.

7 0
3 years ago
¿Cuáles son las ventajas de manejar la nube?
igomit [66]

Answer:

What are the advantages of managing the cloud=(Englishish)What are the advantages of managing the cloud?

Lower IT Costs. Businesses requiring IT services save money using third-party providers vs bringing talent in-house. ...

Computing Resources. Heavy computation cycles need extensive hardware resources. ...

Accessibility. ...

Always Updated. ...

Scaling. ...

Backup/Recovery. ...

Integration. ...

Security.

In spanish.....  (Costos de TI más bajos. Las empresas que requieren servicios de TI ahorran dinero utilizando proveedores externos en lugar de traer talento internamente. ...

Recursos informáticos. Los ciclos de computación intensos necesitan amplios recursos de hardware. ...

Accesibilidad. ...

Siempre actualizado. ...

Escalada. ...

Recuperación de respaldo. ...

Integración. ...

Seguridad.)

Explanation:

8 0
2 years ago
Other questions:
  • After saving her presentation initially, Leah realizes she needs to add another content slide. She adds the slide and is ready t
    7·1 answer
  • Which of the following is likely the cause of the bass from a sound system rattling the windows on your car?
    11·1 answer
  • Why was unicode invented?
    5·2 answers
  • San Diego broker Cal Abrams has avoided the technological trend of the past 20 years. Finally, he's jumped online and realized w
    14·1 answer
  • What does Al stand for?
    10·1 answer
  • Pleassseeeee helppp!!!!
    7·1 answer
  • What were the social, political, cultural, or economic context in which the was invention made?
    14·1 answer
  • The _____________computer function accepts data from input devices and sends it to the computer processor.
    11·1 answer
  • Artificial intelligence (AI) and machine learning are especially important during which security information and event managemen
    8·1 answer
  • The FCFS algorithm is particularly troublesome for ____________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!