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
AysviL [449]
2 years ago
15

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.
Computers and Technology
1 answer:
vivado [14]2 years ago
6 0

Answer:

def main():

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

   k=2;

   totalSum = 0

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

   while k <= n:

       totalSum = totalSum+is_prime(k)

       k=k+1

   print('Total sum of the prime numbers:',totalSum)

def is_prime(k):

   primeNumber = 0      

   i=1

   while i<=int(k):

       if (k % i) == 0:

           primeNumber = primeNumber + 1

       i=i+1

   if(primeNumber==2):      

       print(k)

       return k;

   else:        

       return 0;

main()

Explanation:

  • Run the while loop until k is less than n.
  • Determine if the variable k is prime then add it to the totalSum variable.
  • Increment the value of k by 1.
  • Create a function isPrime to check whether the number is prime  or not by determining the factors of k which can be found using the modulus operator.
  • Call the main function at the end.

You might be interested in
Which of the following statements is correct?
vaieri [72.5K]

Answer:

A

Explanation:

I think is A. or maybe search up the topic of the lesson

7 0
3 years ago
Which of these about non-disclosure agreements is accurate?
grandymaker [24]

Answer: number 2

Explanation: number 2

6 0
2 years ago
Read 2 more answers
What is a wireless network that provides communication over a short distance that is intended for use with devices that are owne
andrew11 [14]

Answer: personal area network

Explanation:

it can connect personal devices to make network, the personal network are phone,laptop,printer and soon in order to communicate.

3 0
2 years ago
Read 2 more answers
Which of the following restricts the ability for individuals to reveal information present in some part of the database?
Anni [7]

Answer:

it would have to be flow control which would be C.

Explanation:

8 0
2 years ago
A university wants to schedule the classrooms for final exams. The attributes are given below:
iVinArrow [24]

Answer:

See explaination

Explanation:

Clearly the entities are as follows:-

Course

Section

Room

Test

The relationship among entities are as follows:-

Course has Section

Test is conducted for Course

Test is conducted in Section

Test is conducted in Room

Attributes of each entities are as follows:-

Course (CourseID, Name, Department)

Section (SectionID, Enrollment)

Room (RoomNumber, Capacity, Building)

Test (Time)

Section is a week entity as, there may be same sections for different courses, therefore section uses the primary key of course entity as foreign key.

Also entity Test is dependent upon the entities Room,Section and Course, therefore primary keys of these entities will be used as foreign key in the Test entity.

Check attachment for the ER diagram

5 0
2 years ago
Other questions:
  • __________ is when a person feels compelled to acquire and abuse a drug despite the harm it causes him or her personally, and de
    7·2 answers
  • A(n) _____ might be written by a programmer or it might be created through a DBMS utility program.
    6·1 answer
  • Write a Python program calculate summary statistics about a class assignment. First, prompt the user for the number scores to be
    6·1 answer
  • Which line in the following program will cause a compiler error? #include using namespace std; int main() { int number =5; if (n
    10·1 answer
  • Match the keyboard shortcuts to the function they perform
    10·1 answer
  • Free wifi is typically offered on an <br> a) unencrypted<br> b) encrypted<br> c) open<br> d) private
    14·2 answers
  • True or False: The major advantage of Arrays over ArrayLists in Java is the fact that while ArrayLists are fixed in size, an Arr
    15·1 answer
  • What is the purpose of flight simulator programs, and what are some of the benefits of using them?
    5·2 answers
  • Which type of address is the ip address 232. 111. 255. 250?.
    11·1 answer
  • Which steps of the management science process can either be a recommended decision or information that helps a manager a decisio
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!