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
Inessa05 [86]
3 years ago
13

In python please!! Write the definition of a function named countPos that needs integer values from standard input until there a

re none left and returns the number that are positive. The function must not use a loop of any kind.
Computers and Technology
1 answer:
jek_recluse [69]3 years ago
8 0

Answer:

Explanation:

The following code is written in Python it doesn't use any loops, instead it uses a recursive function in order to continue asking the user for the inputs and count the number of positive values. If anything other than a number is passed it automatically ends the program.

def countPos(number=input("Enter number: "), counter=0):

   try:

       number = int(number)

       if number > 0:

           counter += 1

           newNumber = input("Enter number: ")

           return countPos(newNumber, counter)

       else:

           newNumber = input("Enter number: ")

           return countPos(newNumber, counter)

   except:

       print(counter)

       print("Program Finished")

countPos()

You might be interested in
Individuals and IT professionals have a responsibility to be aware of security threats and the damage they might do.
Veseljchak [2.6K]
The answer is true they will have to be responsible
6 0
3 years ago
25 POINTS!!!!!!!!!!!!!
Paladinen [302]
A leaking data exhaust
7 0
3 years ago
Read 2 more answers
Which network component connects a device with the transmission media and allows it to send?
yanalaym [24]
The wireless network I believe
5 0
3 years ago
Where is the video card located in a computer?
Rama09 [41]
Video card??????????
3 0
3 years ago
Read 2 more answers
What is a method that invokes itself called?
Anna11 [10]

Answer:

D. recursive method

Explanation:

I took the test on PLATO

6 0
3 years ago
Other questions:
  • What is an example of constructive criticism for an employee who frequently arrives late?
    10·2 answers
  • An online game is played with two dice, explain why decomposition will be used in creating the algorithm for the game?
    9·2 answers
  • Operating systems are often written in ________, a very low-level computer programming language that allows the computer to oper
    10·1 answer
  • Syntax errors ________. a. result from an attempt to perform an operation that cannot executeb. are errors such as misspelled ke
    14·1 answer
  • What is one method that can be used to open the Microsoft Word application?
    8·1 answer
  • Hulu suggestions? I just got it and I wanna know what's good :)
    5·2 answers
  • _______ an embedded Word table to activate the Word features.
    6·1 answer
  • A CPU has 32 KB cache, 2-way set associative, 16-byte block size. How many bits are required to use index each set in this cache
    6·1 answer
  • Which of these is an aggregator?
    9·2 answers
  • Name at least TWO kinds of gaming experiences that are possible with these new control devices but were not possible on original
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!