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
What is a good analogy for explaining the actions of a compiler?
kozerog [31]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

This question is about what is a good analogy for explaining the actions of a compiler?  The correct option is <u> automatic programming of kitchen devices .</u>

<u> </u>

a hybrid ability of a car to use multiple energy sources  (false)

this analogy is not correctly mapped on the compiler, becuase the compiler can be designed only for one type of language, for example, the program that calculates the average of students number can be easily programmed in C++ and in C#. But you cannot compile the C# program in C++ compiler and vice versa.  

a street map of a local subdivision  (false)

Because you can design a compiler for a not specific subdivision of programming.

an interpreter who speaks several languages

it is not an analogy, however, an interpreter can handle only one type of language.

an automatic programming of kitchen devices (true)

This is a good analogy of compiler because you give input to the device and that device based on your input gives you back an output. Similarly, you give input to the compiler in form of language syntax, and it automatically give you output based on your input.

3 0
3 years ago
Selective colleges choose to have in-person meetings to learn more about the applicants. These meetings are called:
lubasha [3.4K]
The meeting is called collage interviews
4 0
3 years ago
Read 2 more answers
How to become a web developer ?​
statuscvo [17]

Explanation:

1.By Learning web development Fundamentals.

2.Choose a development specialization.

5 0
3 years ago
If you need to add more data between column A and column B, you should _____. click in column A and paste a column click anywher
Luda [366]

Answer:

Use the insert column command by placing your cursor between A and B. Then insert your data

Explanation:

3 0
3 years ago
Who's better Kapkan or Tachanka?
navik [9.2K]
If you want fun operator, get chanka, if you want good operator, get kapkan it also depends if depends you are a stationary man who likes big guns or a mobile man who likes traps
4 0
3 years ago
Other questions:
  • If we have a priority queue storing approximately million numbers, and the bottom level is "full", which of the following statem
    9·1 answer
  • Write the steps for displaying multiple subtotal functions in excel.
    10·1 answer
  • A resistor bank is connected to a controller with conductor insulation rated 75 °C. The resistors are not used in conjunction wi
    15·1 answer
  • With microprocessors, The integration of a whole _____ onto a single chip or on a few chips greatly reduced the cost of processi
    14·1 answer
  • Which method do software testers use to isolate new code from the rest of the network during the test stage of the software deve
    15·1 answer
  • Write a program in C++ or C that includes two different enumeration types and has a significant number of operations using the e
    15·1 answer
  • QUESTION 56 Use the Windows ________ to check on a nonresponsive program. Backup utility Error-checking System Restore Task Mana
    6·1 answer
  • Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its left and
    11·1 answer
  • I need help fixing this please
    6·2 answers
  • Discuss the impact printer and its types in detail?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!