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]
4 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]4 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
Brainstorming the pros and cons of upgrading versus replacing a set of ten desktop computers _________
fomenos
Plan to purchase
Deploy
Support/ upgrade
Retire
Support/ upgrade
Deploy
6 0
4 years ago
Instead of delivering songs that you are likely enjoy services such as offers you a bility to play practically song that you wan
s344n2d4d5 [400]
Use Amazon music you can play any song you want
7 0
4 years ago
Why are new versions of applications packages released often ​
stellarik [79]

Answer:

The answer is "new version of application provides more easy to use".

Explanation:

  • In computer science, an application is a program, that is installed on the computer. There are many types of application software, that are "gaming software, working software, programming software, etc." At the end of time users want some new things in software to know users need programmer developed new versions of the software.
  • The update usually improves the device or service in its current version, whilst an improvement is an entirely new version. Installation is usually free and easy. You also have to wait for updates that are difficult to install.
5 0
3 years ago
Jeroo Bob has just awoken from a long night's sleep and is hungry for some winsum flowers. He walks out of
IgorLugansk [536]

Answer:

bro this is long try something easy

Explanation:

im lazy to read

7 0
3 years ago
Anyone here homeschool
Shalnov [3]

Me im homeschooled

But i relly want to go back to public school too much pressure

6 0
3 years ago
Read 2 more answers
Other questions:
  • When composing a tweet with images attached in hootsuite, bear in mind that _____ characters are used up by the photos?
    9·1 answer
  • The windows desktop contains a start button in its lower-right corner, which can be used to start the computer.
    14·1 answer
  • Why are networked systems beneficial?
    9·2 answers
  • HURRY
    5·1 answer
  • Although Neptune is the farthest planet from the Sun, it travels in a fixed orbit around the Sun and never changes its path. Wha
    8·2 answers
  • Python
    5·1 answer
  • A photograph with more yellows has which mood
    6·2 answers
  • To type a small letter "z", you would use the right little finger. (5 points)True False
    9·1 answer
  • The web lab consists of which elements. Select all that apply. Group of answer choices Files Inspector Tool Preview Hints Work S
    9·1 answer
  • What computing paradigm can solve a problem by describing the requirements, without writing code in a step-wise fashion to solve
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!