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
Alexus [3.1K]
3 years ago
8

Write a python program that requests a positive integer from the user, determines if it is a composite, a prime or neither prime

or composite and prints the message. You can choose to use iterative loops to repeatedly run this script or have the user run the script for every input.
Computers and Technology
1 answer:
Serjik [45]3 years ago
3 0

Answer:

num = int(input("Num: "))

if num > 1:

    for i in range(2,num):

         if (num % i) == 0:

              print(num,"is a composite number")

              break

         else:

              print(num,"is a prime number")

else:

    print(num,"is neither prime nor composite")

Explanation:

This line prompts user for input

num = int(input("Num: "))

The following if condition check for prime, composite or neither both

if num > 1:

The following iteration checks for prime or composite

    for i in range(2,num):

This if condition tests if a valid divisor can be gotten. If yes, then input number is composite

<em>          if (num % i) == 0: </em>

<em>               print(num,"is a composite number")</em>

<em>           break</em>

<em />

If otherwise, then input number is prime

<em>          else:</em>

<em>               print(num,"is a prime number")</em>

<em />

All numbers less than 2 are neither composite nor prime

else:

    print(num,"is neither prime nor composite")

You might be interested in
2 ways to assign a value to a variable
Art [367]
Assigning values at run time
Assigning values as command line argument, before execution of the program

4 0
3 years ago
the mail merge feature can be used to address the same letter to several different people , true or false
sergij07 [2.7K]
The answer is that it is true.
4 0
3 years ago
Read 2 more answers
Need help with this please and thanks
Kryger [21]

Answer:

<h3>Connector names are written below Picture vise:</h3>
  • USB-C
  • USB 2.0
  • Micro USB
<h3 />

Explanation:

Following is the brie Illustration of the terms used:

  • USB-C:

              It is the newest connector in the market with the             reversible/symmetrical design. It can be adapted to work with the legacy connectors such as USB-A, USB-B, USB-C and Micro USB.

  • USB 2.0:

              It is used mostly in the connections of electronic devices such as printers and smartphones. It has A to B connectors as well as micro USB connectors and mini USB connectors.

  • Micro USB:

              It is used for the connection o compact devices such as smartphone and mp3 players. They are further grouped into three categories: Micro A, Micro B and micro USB 3.

<h3>I hope it will help you!</h3>
7 0
3 years ago
import java.util.ArrayList; // Needed for ArrayList class /** This program demonstrates how to store BankAccount objects in an A
slega [8]

Answer:

import java.util.ArrayList; // Needed for ArrayList class

/** This program demonstrates how to store BankAccount objects in an ArrayList. */

// Class ArrayListDemo6 is defined

public class ArrayListDemo6 {

// main method that begin program execution

public static void main(String[] args) {

// Create an ArrayList to hold BankAccount objects.

// The arraylist is called list

ArrayList list = new ArrayList();

// Add three BankAccount objects to the ArrayList.

list.add(new bankAccount(100.0)); list.add(new bankAccount(500.0)); list.add(new bankAccount(1500.0)); // Display each item using a for loop

for (int index = 0; index < array.size(); index++)

{ BankAccount account = list.get(index);

System.out.println("Account at index " + index + "\nBalance: " + account.getBalance());

}

}

}

Explanation:

The code is written in Java and more comments has been added to make it more explanatory.

The code snippet is a demonstration on Arraylist.

First Arraylist is imported. Then, ArrayListDemo6 class is defined. Then the main method which begin program execution.

Inside the main method, a new Arraylist is created called list.

Then we add three BankAccount object to the list.

Lastly, we use a for loop to display each added BankAccount object.

7 0
3 years ago
When companies charge different prices for the same product, they're using
Maksim231197 [3]

Answer: When companies charge different

prices for the same product, they're using

B.) Dynamic Pricing

Is the most accurate

Explanation: If a firm can find a way to charge every customer the price he/she values a good at, the firm can capture more profits than it could with a single price, in a given market.

7 0
1 year ago
Other questions:
  • The term used to describe an electronic device, operating under the control of instructions stored in its own memory, that can a
    7·1 answer
  • What kind of game was Pole Position?
    14·1 answer
  • Which item refers to an illusion of figures and shapes in motion, which we commonly see in movies and video games?
    9·1 answer
  • What is unique about being an administrative professional in a government job?
    8·2 answers
  • Drivers should scan 10-12 secound down the road looking of potential hazards
    5·1 answer
  • Define a function CoordTransform() that transforms the function's first two input parameters xVal and yVal into two output param
    12·1 answer
  • What is the definition of a digital signal?
    14·1 answer
  • Why computer manufacturers constantly releasing faster computers ?
    14·1 answer
  • Kristi, an event planner, wants to store caterers’ names and contact information in an organized manner. Kristi will MOST LIKELY
    13·1 answer
  • Using a third-party package of your choice, write a program that reads the contents of a csv file and saves it to an Excel file.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!