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
Write a programme to find the sum of first three cube number?
aleksandrvk [35]

// Simple Java program to find sum of series

// with cubes of first n natural numbers

import java.util.*;

import java.lang.*;

class GFG {

/* Returns the sum of series */

public static int sumOfSeries(int n)

{

int sum = 0;

for (int x = 1; x <= n; x++)

sum += x * x * x;

return sum;

}

// Driver Function

public static void main(String[] args)

{

int n = 5;

System.out.println(sumOfSeries(n));

}

}

// Code Contributed by Mohit Gupta_OMG <(0_o)>

7 0
3 years ago
What does coding mean​
NeTakaya
The process or activity of writing computer programs.
3 0
3 years ago
Read 2 more answers
Explain the difference between IPv4 and IPv6.
Leni [432]

Answer:

The Internet Protocol version 4 (IPv4) is a protocol for use on packet-switched Link Layer networks (e.g. Ethernet). IPv4 provides an addressing capability of approximately 4.3 billion addresses. The Internet Protocol version 6 (IPv6) is more advanced and has better features compared to IPv4.

Explanation:

Without IP addresses, computers would not be able to communicate and send data to each other. It's essential to the infrastructure of the web. A: IPv6 is the sixth revision to the Internet Protocol and the successor to IPv4

5 0
3 years ago
A technician, joe, has replaced a faulty 500 gb hard drive in a pc system with a 1 tb hard drive. however, after the replacement
Brums [2.3K]

The best possible solution for the technician to do is to go into the disk management and find out what exactly is going on. The technician should check whether there is partition that has unallocated space. It is 100% the case that the rest of the 500 GB is in the unallocated space.

The techie need to grow his partition. Possible option for a scenario like this is delete the unallocated 500 GB space using NTFS. He can then recreate the available 500 GB free space as 1TB partition.

5 0
3 years ago
Describe a situation involving making a copy of a computer program or an entertainment file of some sort for which you think it
Margaret [11]

Answer:

Copying anything may be the computer program or an entertainment file, it is not a good thing as the original developers or the writers are going to feel bad since their hard work is being used by others without letting them know. However, if you are using it for academic purposes, or give them credit in your work, then the original writer will not feel that bad as he is being credited, and hence you can reuse in that case definitely, but always ensure to give the credit to the original writer.

As an example, if a film is copied like many in the past the Directors always feel bad, and they have the reason for feeling bad. The same thing is to technology.

Explanation:

The answer is self explanatory.

8 0
3 years ago
Other questions:
  • To instruct Oracle11 g to sort data in ascending order, enter ____ after the column name in the ORDER BY clause.
    15·2 answers
  • How can you differentiate between standard and protocol? Write at least on example of each of these terminologies?
    12·1 answer
  • Typohunting is registering a domain name that is similar to a trademark or domain name but that is slightly misspelled in hopes
    5·1 answer
  • After saving her presentation initially, Leah realizes she needs to add another content slide. She adds the slide and is ready t
    7·1 answer
  • Who invented the ENIAC? More than one answer may apply.
    14·1 answer
  • JavaBeans are?A special Java classfileServletsAppletsA Special form of JSPNone of Given
    8·1 answer
  • How to add more then one picture on a brainy question really need this
    8·1 answer
  • Question 2 of 10
    15·1 answer
  • Why is the computer uses binary why not trinary?​
    11·1 answer
  • Provide 3to 4 sentence overview of microsoft windows features?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!