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
xenn [34]
3 years ago
7

Assume the availability of a function is_prime. Assume a variable n has been associated with positive integer. Write the stateme

nts needed to find out how many prime numbers (starting with 2 and going in increasing order with successively higher primes [2,3,5,7,11,13,...]) can be added before exceeding n. Associate this number with the variable k. SUBMIT
Computers and Technology
1 answer:
My name is Ann [436]3 years ago
5 0

Answer:

def main():

   # Accept data from the user

   n=int(input('Enter the value of n:'))

   k=2;

   sum=0

   print('The list of the prime numbers are as follows:')

   # This loop runs from k to n

   while k<=n:

       # Call is_prime() method,

       # to check whether k is a prime or not

       sum=sum+is_prime(k)

       k=k+1

   print('Sum of the prime numbers:',sum)

# is_prime() Method

def is_prime(k):

   prime=0        

   i=1

   # Check k is a prime or not

   while i<=int(k):

       # Find the factors of k

       if (k % i) == 0:

           prime=prime+1

       i=i+1

   # If k as two factors

   if(prime==2):        

       print(k)

       return k;

   # If k as more than two factors

   else:        

       return 0;

# Call the main() method

main()

Explanation:

You might be interested in
Which of the following correctly stores 45 squared in the variable x?
timama [110]

Answer:

x = 45

x = x ** 2

6 0
3 years ago
Anyone here good with PS4's?
Nookie1986 [14]
I can help you out ! What do you need to know bud ?
6 0
3 years ago
Read 2 more answers
Which of the following are characteristics of conditional formatting? Choose all that apply.
Leona [35]
Formatting that is selected for each cell individually related to a specific condition
8 0
3 years ago
Read 2 more answers
Why is haptic feedback important?
ExtremeBDS [4]

\huge\underline{\red{A}\green{n}\blue{s}\purple{w}\pink{e}\orange{r} →}

Haptic feedback is used to engage more of the user's senses to provide a deeper and more immersive experience. Products that offer haptic feedback, such as some game controllers, often provide different kinds of sensations to correspond with different visual and audio stimuli.

Explanation:

<h3>Hope it helps you !!</h3>
7 0
2 years ago
Complete the divisible_by(list1, int1) function below. As input, it takes a list of integers list1 and an integer int1. It shoul
damaskus [11]

Answer:

The function is as follows:

def divisible_by(listi, n):

   mylist = []

   for i in listi:

       if i%n == 0:

           mylist.append(i)

   return mylist

   pass

Explanation:

This defines the function

def divisible_by(listi, n):

This creates an empty list

   mylist = []

This iterates through the list

   for i in listi:

This checks if the elements of the list is divisible by n

       if i%n == 0:

If yes, the number is appended to the list

           mylist.append(i)

This returns the list

   return mylist

   pass

5 0
3 years ago
Other questions:
  • which student organization helps students with career development by having them become interms to sponsor conferences?
    9·1 answer
  • How can i appear offline without fb messenger saying "last active 1 minute ago"?
    5·1 answer
  • All of the following are qualities of an aprenticeship except
    12·1 answer
  • An application programming interface (API) is ________. A) the code the application software uses to take advantage of code writ
    11·1 answer
  • An ironworker standing 30 feet in the air is safe wearing a full body harness that is not tied off
    15·2 answers
  • How dependent are we on technology? ​
    15·2 answers
  • Which statement is true of integrating an expert system into the database component of a decision support system (DSS)? a. It re
    14·2 answers
  • Someone who wants to learn a skilled trade on the job should consider
    6·2 answers
  • A program that will read each player’s name and golf score as keyboard input,
    9·1 answer
  • HELPPPPP 20 POINTS CORRECT ANSWER GETS BRAINLIEST<br>sorry wrong amount of points ;-;
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!