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
Betty removed a web page from her website. Some users were browsing on her website. One of them clicked on a particular link and
Fittoniya [83]
To prevent users from seeing error pages and ensure that they have a pleasant experience in your application you can add the customErrors element to your Web.config file.  <span>Handling error codes and exceptions by the web.xml, you can configure </span>error-page elements<span> that act upon some error-code or exception-type.</span>
4 0
4 years ago
Which is the correct process for selecting consecutive rows in a worksheet?
bekas [8.4K]
<span>Click the heading of the first row in the selection, hold down the Shift key, and click the heading of the last row in the selection</span>
5 0
3 years ago
Given a String named word. Display the letters of the word, one letter per line.
nata0808 [166]

Answer:

kk imo its jk ima programmer

4 0
3 years ago
Without using any additional variables, and without changing the values of ndays or the elements of the parkingTickets array, wr
dusya [7]

Answer:

Explanation:

mostTickets=0;

for (k=0; k< ndays; k++){

if (parkingTickets[k]>mostTickets) mostTickets=parkingTickets[k];

}

7 0
3 years ago
There is a feature that allows you to lock the document, to avoid others making changes. True or False
Burka [1]

Answer:

yes there is

Explanation:

6 0
3 years ago
Other questions:
  • Which of the following accurately completes this sentence? The Internet is ____.
    6·2 answers
  • Chole enjoys her math classes, and she would like to find a career that will allow her to continue use her math skillls which ca
    10·1 answer
  • According to Fourman, Informatics is _______________ with a very _____________ scope.
    5·2 answers
  • Which step is common to both creating a new document and saving a document?
    11·2 answers
  • Jennifer is trying to install an anti-malware program on a computer that she believes might be infected. During the installation
    14·1 answer
  • What was the first stored prograam electronic digital computer
    11·2 answers
  • What is a bin range?
    14·1 answer
  • 8. A sprite is a simple spider shaped thing with n legs coming out from a center point. The angle
    10·1 answer
  • Hannah wanted to watch a movie. She typed the movie name on the search engine. In result she found the downloadable link of the
    10·1 answer
  • "Automated Deployment" is one of the prerequisite for DevOps implementation.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!