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
Write a program that declares and initializes a variable representing the weight in milligrams from the keyboard. The program di
Burka [1]

Answer:

weight = int(input("Enter weight in milligrams: "))

kilograms = int(weight / 1000000)

grams = int((weight - (kilograms * 1000000)) / 1000)

milligrams = weight - ((kilograms * 1000000) + (grams * 1000))

print("{} milligrams are equivalent to {} kilogram(s), {} gram(s), and {} milligram(s)".format(weight, kilograms, grams, milligrams))

Explanation:

*The code is in Python.

Ask the user to enter the weight and set it to the variable weight

Calculate the kilograms, divide the weight by 1000000 and cast the result to the int (If the weight is 1050042, kilograms would be 1050042/1000000 = 1)

Calculate the grams, subtract the kilograms from the weight, divide it by 1000 and cast the result to the int (If the weight is 1050042, grams would be int((1050042 - (1 * 1000000)) / 1000) = 50)

Calculate the milligrams, subtract the kilograms and grams from the weight (If the weight is 1050042, milligrams would be 1050042 - ((1 * 1000000) + (50 * 1000)) = 42)

Print the weight, kilograms, grams, and milligrams in the required format

3 0
3 years ago
Why might you need to convert a file to another file type
Alex17521 [72]
This depends on what program you're using. Some programs can only read certain files exclusive to that program, such as .psd files can usually only be read in Photoshop or other adobe programs. Many fields of work (Journalism, the Arts, Design, etc.) ask for .psd files to be converted to either .png, .jpg, or .tiff so that it can be seen on many other platforms.

For images especially, files are more compatible either on a program or printed. for example, .png files are good for storing color data from computer to computer, but if you print a .png file, the quality is poor. hence it's recommended to save files you want to print for designs as .jpeg, because .jpeg can more easily be printed and will then be presented at a high quality.

Sometimes color quality changes depending on CMYK as well but that's a whole other ball of wax.
8 0
3 years ago
The primary reason for the creation of the Federal Reserve System LOADING... ​was: A. to create a single central bank similar to
Gelneren [198K]

Answer: (C) to reduce or eliminate future bank panics.

Explanation:

The Federal Reserve System being the central reserve system in the US was created with the primary objective of reducing and eliminating bank panics in periods of recessions and depressions and other bank related matters.

3 0
3 years ago
Which agency coordinates the internet's IP addressing and DNS systems?
german
ICANN is the agency which coordinates the internet's IP addressing and DNS systems.

ICANN stands for Internet Corporation for Assigned Names and Numbers. Aside from coordinating the Domain Name System (DNS) and Internet Protocol (IP) addresses, it also coordinates the technical protocol parameters of ARPA top level domain, Internet DNS root zone management (gTLD and ccTLD), allocates Internet number resources, and other services which will fulfill their vision of "one world, one Internet".

The performance of ICAANs services is all under a U.S Government contract.
4 0
3 years ago
By the mid-1990s, how did revenue generated from video games compare to revenue generated from movies?
Vlad [161]

By the mid-1990s, the revenue generated from video games was two and a half times the revenue generated from movies.

Research shows that in 1994, the revenue generated from arcades in the United States was about $7 billion quarterly while the revenue generated from home console sales was about $6 billion dollars.

When combined, this revenue from games was two and a half times the amount generated from movies.

Learn more about video games here:

brainly.com/question/8870121

4 0
2 years ago
Other questions:
  • Consider the following class definitions.
    10·1 answer
  • A(n) _____ can be used to convert digitized documents into ascii (american standard code for information interchange) text that
    6·1 answer
  • The first widely adopted windows product, ____, featured a standardized look and feel, similar to the one made popular by apple'
    11·1 answer
  • Generate an array x that has n=100 random numbers that are uniformly distributed over the interval [0,1) . Look up how to use th
    8·1 answer
  • Which of the following is non-volatile storage?
    6·1 answer
  • To whom the script most important
    13·1 answer
  • A person who creates a computer virus is a (1)system analyst (2) techician(3) programmer​
    11·2 answers
  • A system analyst generally needs to have a number of skills. For example, technical and analytical skills are required for this
    7·1 answer
  • In what ways are super computer different from mainframe computers.​
    10·1 answer
  • What causes the hidden node problem in a wireless local area network (wlan)?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!