answer.
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
faust18 [17]
2 years ago
11

Produce a list named prime_truths which contains True for prime numbers and False for nonprime numbers in the range [2,100]. We

provide a function is_prime to assist you with this. Call it like this: is_prime( 5 ). Use lambda, map, filter, and list comprehensions as you see fit. You should not need to use a conventional for loop outside of a comprehension.
Computers and Technology
1 answer:
LenKa [72]2 years ago
3 0

Answer:

  1. def is_prime(n):
  2.    for i in range(2, n):
  3.        if(n % i == 0):
  4.            return False  
  5.    return True  
  6. prime_truths = [is_prime(x) for x in range(2,101)]
  7. print(prime_truths)

Explanation:

The solution code is written in Python 3.

Presume there is a given function is_prime (Line 1 - 5) which will return True if the n is a prime number and return False if n is not prime.

Next, we can use the list comprehension to generate a list of True and False based on the prime status (Line 7). To do so, we use is_prime function as the expression in the comprehension list and use for loop to traverse through the number from 2 to 100. The every loop, one value x will be passed to is_prime and the function will return either true or false and add the result to prime_truth list.

After completion of loop within the comprehension list, we can print the generated prime_truths list (Line 8).

You might be interested in
What is one major structural difference between a decision structure (such as a decoder) and a storage structure (such as an RS
Andrej [43]

Answer:

B. The storage structure requires a clock input.

Explanation:

Logic circuits are circuits in electronics that give output based on the logic gate principle and its inputs. It can be a sequential logic circuit or a combinational logic circuit.

Decoders RS latches are combinational logic circuits because they both comprise of a combination of several sequential circuits to make their systems. The difference between decoders and RS latches is that the RS is a storage structure which is made up of flip-flops which require a clock input

8 0
1 year ago
Dan is a Civil Engineer for a company that builds nuclear power plants throughout the world. Which best describes the places he
Yanka [14]
IN a laboratory... C 
4 0
2 years ago
Read 2 more answers
Every employee of your company has a Google account. Your operational team needs to manage a large number of instances on Comput
Blizzard [7]

Answer:

Generate the fresh set of SSH keys. Offer every member of the team that private key. Customize the public key as a public SSH key for a project in the Cloud Platform project as well as require public SSH keys for each instance

Explanation:

Almost many person seems to have a google profile at their corporation. The vast amount of incidents on Compute Machine have to be handled by the operating staff. Any team member just requires operational accessibility towards the network. The safety department needs to ensure that credentials are distributed in such an administratively efficient way and have to be prepared to recognize that has accessed the specified case.

So, they are creating the latest key set for SSH. Offer every members of the team their private key. Customize its public key as just a public SSH key for such a program in the Cloud Platform project as well as require public SSH keys for each instance.

7 0
2 years ago
Modify the guessing-game program so that the user thinks of a number that the computer must guess.
Triss [41]

Answer:

import random

import math

smaller = int(input("Enter the smaller number: "))

larger = int(input("Enter the larger number: "))

count = 0

print()

while True:

   count += 1

   myNumber = (smaller + larger) // 2

   print('%d %d' % (smaller, larger))

   print('Your number is %d' % myNumber)

   choice = input('Enter =, <, or >: ')

   if choice == '=':

       print("Hooray, I've got it in %d tries" % count)

       break

   elif smaller == larger:

       print("I'm out of guesses, and you cheated")

       break

   elif choice == '<':

       larger = myNumber - 1

   else:

       smaller = myNumber + 1

Explanation:

The code to be Modified is as indicated below:

# Modify the code below:

import random

smaller = int(input("Enter the smaller number: "))

larger = int(input("Enter the larger number: "))

myNumber = random.randint(smaller, larger)

count = 0

while True:

   count += 1

   userNumber = int(input("Enter your guess: "))

   if userNumber < myNumber:

       print("Too small")

   elif userNumber > myNumber:

       print("Too large")

   else:

       print("You've got it in", count, "tries!")

       break

Detailed Explanation:

Line 3 and 4 of the codes prompts the user to enter a smaller and larger number. Line 5 we initiate the formula for minimum number of guesses. Line 14 and 17 prints out the output  I'm out of guesses, and you cheated and Hooray, I've got it in X after validating the conditions.

7 0
1 year ago
Python comes with ________ functions that have been already prewritten for the programmer.
Gnoma [55]
Python comes with built-in functions...
6 0
2 years ago
Other questions:
  • Two career fields that lack minority professionals and thus offer many grant opportunities to students are education and _____.
    10·2 answers
  • Which port, along with a special card and cables, supports the connection of microcomputers, modems, and printers in a local are
    6·1 answer
  • 8. In time series, which of the following cannot be predicted? A) large increases in demand B) technological trends C) seasonal
    11·1 answer
  • c++ You are given an array A representing heights of students. All the students are asked to stand in rows. The students arrive
    5·1 answer
  • Cooper Technologies is a technology company that offers many IT services in Chicago. The company's services and products include
    6·1 answer
  • Windows is displaying an error about incompatible hardware. You enter BIOS/UEFI setup to change the boot priority order so that
    8·1 answer
  • You are describing the boot process to a friend and get to the step where the device loads the operating files into RAM, includi
    7·1 answer
  • Which of the following provides a suite of integrated software modules for finance and accounting, human resources, manufacturin
    15·1 answer
  • What do you call the two parts of lift that go down a mine
    13·2 answers
  • Plz help code practice for python
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!