Write a program that uses a loop to read 10 integers from the user. Each integer will be in the range from -100 to 100. After all 10 integers have been read, output the largest and smallest values that were entered, each on its own line in that order. If you want to best prepare yourself for the exam, avoid using the max or min functions from Python, and definitely use a loop to read the integers instead of 10 input statements. Zybooks won't stop you from doing these things, but you won't be studying the correct topics to prepare for the first exam.

Respuesta :

Answer:

// program in Python

#variables

mx=-1000

mn=1000

#read 10 values from user

for i in range(1,11):

   num=int(input("Enter the number {}:".format(i)))

   #input validation

   while num not in range(-100,100):

       num=int(input("Wrong input!! Enter again:"))

   #find maximum

   if num<mn:

       mn=num

   #find minimum

   if num>mx:

       mx=num

#print maximum

print("largest value is:",mx)

#print minimum

print("smallest value is:",mn)

Explanation:

Create variables "mx" to store maximum and "mn" to store minimum.Read 10 numbers from user.If the input number if less than -100 or greater than 100 then ask again  to enter a number between -100 to 100 only.Find the maximum and minimum from the  all 10 numbers.Print maximum and minimum values.

Output:

Enter the number 1:23                                                                                                      

Enter the number 2:-200                                                                                                    

Wrong input!! Enter again:33                                                                                              

Enter the number 3:-2                                                                                                      

Enter the number 4:45                                                                                                      

Enter the number 5:105                                                                                                    

Wrong input!! Enter again:45                                                                                              

Enter the number 6:-44                                                                                                    

Enter the number 7:-56                                                                                                    

Enter the number 8:79                                                                                                      

Enter the number 9:98                                                                                                      

Enter the number 10:4                                                                                                      

largest value is: 98                                                                                                      

smallest value is: -56  

In this exercise we have to use the knowledge of computational language in python to describe the code, like this:

We can find the code in the attached image.

The code can be written more simply as:

mx=-1000

mn=1000

for i in range(1,11):

  num=int(input("Enter the number {}:".format(i)))

  while num not in range(-100,100):

      num=int(input("Wrong input!! Enter again:"))

  if num<mn:

      mn=num

  if num>mx:

      mx=num

print("largest value is:",mx)

print("smallest value is:",mn)

See more about python at brainly.com/question/26104476

Ver imagen lhmarianateixeira