Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment Descript Write a Python program that takes a positive number input from the user: If the number is a prime number, print Number X

Assignment Descript
Write a Python program that takes a positive number input from the user:
If the number is a prime number, print "Number X is PRIME" (where x is the user input).
If the number is NOT a prime number, print "Number X is NOT PRIME" (where X is the user input)
If the number is negative, your code should print "Number x is not allowed" (where x is the user
Your .py file should start like this:
# Your Name
# Your University ID
myNum = eval (input('Enter a number: '))
Requirements:
Use myNum as the testing variable.
Check if myNum is a positive number. If not, display an error message.
Use appropriate string concatenation and formatting to display the results neatly (no extra space
Example Outputs:
Enter a number: 5
Number 5 is NOT PRIME
Enter a number: 4
Number 4 is PRIME
Enter a number: -1
Number -1 is not allowed
Hints:
A prime number can only be divided by itself and 1. Use the modulus operator (%) to check if the number.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Public Finance

Authors: Harvey S. Rosen

5th Edition

025617329X, 978-0256173291