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
dmitriy555 [2]
3 years ago
8

Write a program that takes a list of integers as input. The input begins with an integer indicating the number of integers that

follow. You can safely assume that the number of integers entered is always less than or equal to 10. The program then determines whether these integers are sorted in the ascending order (i.e., from the smallest to the largest). If these integers are sorted in the ascending order, the program will output Sorted; otherwise, it will output Unsorted
Computers and Technology
1 answer:
Naya [18.7K]3 years ago
4 0

Answer:

is_sorted = True

sequence = input("")

data = sequence.split()

count = int(data[0])

for i in range(1, count):

   if int(data[i]) >= int(data[i+1]):

       is_sorted = False

       break

if is_sorted:

   print("Sorted")

else:

   print("Unsorted")

Explanation:

*The code is in Python.

Initialize a variable named is_sorted as True. This variable will be used as a flag if the values are not sorted

Ask the user to enter the input (Since it is not stated, I assumed the values will be entered in one line each having a space between)

Split the input using split method

Since the first indicates the number of integers, set it as count (Note that I converted the value to an int)

Create a for loop. Inside the loop, check if the current value is greater than or equal to the next value, update the is_sorted as False because this implies the values are not sorted (Note that again, I converted the values to an int). Also, stop the loop using break

When the loop is done, check the is_sorted. If it is True, print "Sorted". Otherwise, print "Unsorted"

You might be interested in
Are commonly used to control the number of times that a loop iterates?
pickupchik [31]
Hmm... I feel like this query is much broader than it should be. However, I will start my initial answer, then another potential solution.

My initial answer to your query was: A condition controlled loop is used to control the number​ of times a loop iterates.

The potential answer, my secondary one, is: A count controlled loop iterates a specific number of times.

Two results, but my initial answer is the solution I opted when understanding this.
5 0
3 years ago
Object-oriented systems have three general types of cohesion: _____, _____, and _____. A. method, class, inheritance B. method,
Verdich [7]

Answer:

D. method, class, generalization/specialization

Explanation:

The Cohesion is said to be the level to what an element of a module is related to others. Generally, the cohesion can be understood as an internal adhesive that holds together the modules. If the software is good then it is going to have high cohesion. Method and class are type of cohesion, as they hold the modules together. And generalization/specialization also is a general type of cohesion as generalization tracks the common features among the class, and binds them into one superclass. However, the specialization means creating subclasses out of the classes, and which is the meaning of the specialization. In an ideal situation, there should be high cohesion or single responsibility. However, in the case of inheritance, there can be multiple responsibilities. And hence composition like a generalization, specialization, association, aggregation are used to make use of the composition for reuse rather than inheritance. Have you seen language supporting multiple inheritances. You will never see it though there is some way. And its never allowed to ensure high cohesion. And hence three general types of cohesion are method, class and generalization/specialization. And this is option D.

4 0
3 years ago
Harry is creating a PowerPoint presentation and wants all the slides to have a uniform look.
Ne4ueva [31]

Answer:

✔ Slide Master view

✔ layout and theme

✔ PowerPoint template

Explanation:

On Edg

4 0
3 years ago
What is an ISP?<br> in computer Networking
defon
ISP is an abbreviation for internet service provider.
Hope this helps!
4 0
3 years ago
Read 2 more answers
SOMEONE PLEASE HELP ME I REPOSTED THIS 3 time and no ONE HAD HELPED ME
RoseWind [281]

Answer:

The answer is B

7 0
3 years ago
Other questions:
  • Which of the following is NOT one of the most important elements when designing a website?
    8·2 answers
  • Lewis is using a stylus with his touch screen computer in order to draw a
    8·1 answer
  • Each cout statement has a syntax error. Type the first cout statement, and press Run to observe the error message. Fix the error
    11·1 answer
  • You specify the shape of an oval in a Java applet by defining the oval's:__________.
    5·1 answer
  • Pleaseeee help me w this!
    10·1 answer
  • When using file explorer, the right-hand pane that shows the files and folders of the selected area is called the pane?
    7·1 answer
  • Data ____ refers to the accuracy of the data in a database
    9·1 answer
  • Describe how you will lunch a web browser using the start menu​
    6·2 answers
  • Ginny faced an application error while executing the recorder in opera. Which web browser is generally recommended to use with r
    5·1 answer
  • Any changes done to the software during the operational phase of the software before project wind up is called as maintenance. S
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!