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
Write a program that has the following String variables: firstName, middleName, and lastName. Initialize these with your first,
Licemer1 [7]

Answer:

The programming language is not stated; However, I'll answer your question using C++ programming language.

Comments are used for explanatory purpose

Program starts here

#include<iostream>

#include <string>

using namespace std;

int main()

{

//Declare Variables

string firstName, middleName, lastName;

char firstInitial, middleInitial, lastInitial;

/*Initialize firstName, middleName and lastName (Replace values with your details)*/

firstName = "First Name";

middleName = "Middle Name";

lastName = "Last Name";

 

// Get Initials

firstInitial = firstName.at(0);

middleInitial = middleName.at(0);

lastInitial = lastName.at(0);

 

//Print Results

cout<<"Lastname: "<<lastName<<endl;

cout<<"Firstname: "<<firstName<<endl;

cout<<"Middlename: "<<middleName<<endl;

cout<<"Last Initial: "<<lastInitial<<endl;

cout<<"First Initial: "<<firstInitial<<endl;

cout<<"Middle Initial: "<<middleInitial<<endl;

return 0;

}

3 0
2 years ago
What is the argument in this function =AVERAGE(F3:F26)
monitta
The argument for the function would be answer "D".
5 0
1 year ago
You have been tasked with building a URL file validator for a web crawler. A web crawler is an application that fetches a web pa
mixas84 [53]

Answer:

Python Code:

def validate_url(url):

#Creating the list of valid protocols and file name extensions

valid_protocols = ['http', 'https', 'ftp']

valid_fileinfo = ['.html', '.csv', '.docx']

#splitting the url into two parts

url_split = url.split('://')

isProtocolValid = False

isFileValid = False

#iterating over the valid protocols and file names for validity

for x in valid_protocols:

if x in url_split[0]:

isProtocolValid = True

break

for x in valid_fileinfo:

if x in url_split[1]:

isFileValid = True

break

#Returning the result if the URL has both valid protocol and file extension

return (isProtocolValid and isFileValid)

url = input("Enter an URL: ")

print(validate_url(url))

Explanation:

The image of the output code is attached. Hope it helps.

4 0
1 year ago
Which telecommunications device is widely used in industries that require closed communication?
Stella [2.4K]

The telecommunications device that  is widely used in industries that require closed communication are walkie-talkies. Correct answer: D

Walkie-talkies are hand-held, portable, two-way radio transceivers which enable secure communication between the two points, without being part of a network.

3 0
2 years ago
Read 2 more answers
Assume your friend just sent you 32 bits of pixel data (just the 0s and 1s for black and white pixels) that were encoded after s
lara31 [8.8K]

Answer:

your friend just sent you 32 bits of pixel data (just the 0s and 1s for black and white pixels) that were encoded after sampling an image. Choose the two statements that are true.

------------------

The 32 bits of pixel data is enough to produce the image using the widget. Nothing else is needed.

------------------------

The digital image would be an exact copy of the analog image.

-----------------------------The correct width and height must be input into the pixelation widget to produce the image.

---------------------------The fact that only 32 bits were used to represent the image indicates relatively large sample squares were used. The digital image may vary from the analog image significantly

Explanation:

3 0
2 years ago
Other questions:
  • Let's assume that the smallest possible message is 64 bytes (including the 33-byte overhead). if we use 100base-t, how long (in
    10·1 answer
  • Edward has started up a new company with his friend, Matthew. Currently, he has only two people working with him. Which type of
    8·1 answer
  • Identify the normalized form of the mantissa in 111.01.
    14·1 answer
  • Carrie works on a help desk and is assigned a ticket that was automatically generated by a server because of an error. The error
    5·1 answer
  • An organization has a datacenter manned 24 hours a day that processes highly sensitive information. The datacenter includes emai
    5·1 answer
  • Write a program that prints the U.S. presidential election years from 1792 to present day, knowing that such elections occur eve
    9·1 answer
  • Earlier in the day, you created a user account for Brenda Cassini (bcassini). When she tries to log in, she can't. You realize t
    9·2 answers
  • A colleague sent you an awesome article about using proper ergonomics while sitting at the computer. You don't have time to read
    11·1 answer
  • Accenture has partnered with a global construction company that specializes in building skyscrapers. The company wants better ma
    12·1 answer
  • The code below assigns the 5th letter of each word in food to the new list fifth. However, the code currently produces errors. I
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!