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
IRISSAK [1]
2 years ago
7

Implement a function inValues() that asks the user to input a set of nonzero floating-point values. When the user enters a value

that is not a number, give the user a second chance to enter a value. After two mistakes in a row, quit the program. When the user enters 0, the function should return the sum of all correctly entered values. Use exception handling to detect improper inputs.
Computers and Technology
1 answer:
elena-s [515]2 years ago
5 0

Answer:

Explanation:

The following is written in Python and uses exception handling to do exactly as requested. It then goes adding all of the integer values to an array called num_list and finally adding them all together when the function ends.

def in_values():

   num_list = []

   while True:

       try:

           num = input("Input non-zero floating point: ")

           num = int(num)

           if num == 0:

               break

           else:

               num_list.append(num)

       except ValueError:

           print("No valid integer! Please try again ...")

           try:

               num = input("Input non-zero floating point: ")

               num = int(num)

               break

           except ValueError:

               break

   sum = 0

   for number in num_list:

       sum += number

   return sum

You might be interested in
Jessica has a balance of $2,200 on her credit card with an 18% interest rate. Her credit card company doesn’t require a minimum
professor190 [17]
By doing 2200/18 you get 122 which is how many times you can have 18 go into 2200 and its also how long it will take in days to get her balance doubled.
3 0
3 years ago
Write a loop that continually asks the user what pets the user has until the user enters stop, in which case the loop ends. It s
Nataliya [291]

Answer:

int counter = 0;
String userInput = "";
while (userInput != "stop") {
print "What pet do you have? ";
userInput = readInputLine();
if (userInput != "stop" ){
counter = counter + 1;
print "\nYou have one ";
print userInput;
print ". Total # of Pets: ";
print counter;
}
}

Explanation:

not sure what programming language you use, therefore the answer is pseudocode but it should give you an idea how to implement a piece of code for this problem.
Also, from the way you described the exercise I'm not sure if you always are supposed to reply with "you have one" + the pet or if you should count how often the same pet was entered.

6 0
1 year ago
If we assume the modern view of existential import, why is the following syllogism invalid? No computer is made of clay. All com
Papessa [141]

Answer:

<u>because the conclusion is not in agreement with the two premises.</u>

Explanation:

<em>Remember</em>, the term<u> syllogism</u> refers to the form of reasoning that draws its conclusion based on the stated premises. In other words, a conclusion is reached if it satisfies <em>all or part </em>of the premises.

In this case, the statement "No computer is made of clay" and  "All computers are electronic devices" should be inferred to mean, <em><u>No </u></em><em>electronic devices are made of clay" </em>not<em> </em><em>"Some electronic devices are not made of clay," </em>since the two premises neither suggest that electronic devices are made from clay.

5 0
2 years ago
Write a generator function named count_seq that doesn't take any parameters and generates a sequence that starts like this: 2, 1
-BARSIC- [3]

Answer:

#required generator function

def count_seq():

   #starting with number 2. using string instead of integers for easy manipulation

   n='2'

   #looping indefinitely

   while True:

       #yielding the integer value of current n

       yield int(n)

       #initializing an empty string

       next_value=''

       #looping until n is an empty string

       while len(n)>0:

           #extracting first digit (as char)

           first=n[0]

           #consecutive count of this digit

           count=0

           #looping as long as n is non empty and first digit of n is same as first

           while len(n)>0 and n[0]==first:

               #incrementing count

               count+=1

               #removing first digit from n

               n=n[1:]

           #now appending count and first digit to next_value

           next_value+='{}{}'.format(count,first)

       #replacing n with next_value

       n=next_value

#testing, remove if you don't need this

if __name__ == '__main__':

   #creating a generator from count_seq()

   gen=count_seq()

   #looping for 10 times, printing next value

   for i in range(10):

       print(next(gen))

Explanation:

6 0
3 years ago
What Windows utility can enable you to shut down an unresponsive application?
boyakko [2]

Answer:

Task manager

Explanation:

Allows you to force quit applications.

4 0
2 years ago
Read 2 more answers
Other questions:
  • Which statement describes the word "iterative"?
    9·1 answer
  • Which of the following is NOT a Boolean Search term used to refine search engine results? A. AND B. With C. OR D. NOT
    14·2 answers
  • In cell h15 enter a vlookup function to determine the 2018 percentage of total attendance for the city listed in cell h14. Use t
    7·1 answer
  • You are working on an excel table and realize that you need to add a row to the middle of your table. what is one way to do this
    12·1 answer
  • You asked your colleague to provide feedback on a blog post you recently wrote. When they sent you their feedback, they made edi
    10·1 answer
  • Which career path includes the work duties of hiring and managing farm laborers?
    6·2 answers
  • Which one is correct
    8·1 answer
  • This is a program that calculates information about orders of shirts and pants. All orders have a quantity and a color. Write a
    7·1 answer
  • what will allow you to immediately exit the program without rebooting the computer, when you realize your browser is not respond
    7·1 answer
  • Const x = 0;
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!