Write a boolean function which takes an integer as argument

Assignment Help Python Programming
Reference no: EM132356987

Question : Python Programming

A prime number is a number that is only evenly divisble by itself and 1.

For example, the number 5 is prime because it can only be evenlly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 2 and 3.

Write a Boolean function named is_prime which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Use the function in a program that prompts the user to enter a number and then prints whether the number is prime.

This is what i have. There's something wrong with the first line but idk what (i do have correct indentations )

num = int(input("Enter an integer: "))

if num > 1:
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
print(i,"times",num//i,"is",num)
break
else:
print(num,"is a prime number")
else:
print(num,"is not a prime number")

Reference no: EM132356987

Questions Cloud

Relevance of economic concepts within healthcare sector : HA415-Writer describes trends in costs of care for treating at least three diseases or conditions. examine burden of health care costs on businesses-governments
Communicate risk management requirements : Provide detailed reasons why it is important to communicate risk management requirements and the requirements of a risk management plan with all stakeholders
Nine matters of national environmental significance : What are the nine matters of national environmental significance that are protected by the EPBC Act?
Are demographic characteristics relating to healthcare : Are demographic characteristics relating to healthcare interrelated, or should they be addressed separately from a policy perspective?
Write a boolean function which takes an integer as argument : Write a Boolean function named is_prime which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise.
Create a user account and checks whether the provided user : Write a Python program which prompts the user to create a user account and checks whether the provided user name and password are legal.
Define a recursive function that finds the result of string : Define a recursive function that finds the result of an arithmetic string. The given string will contain numbers, operators and possibly spaces.
Strategic choices and deciding on strategy : "Strategic Choices and Deciding on a Strategy. Examine the nature of a strengths, weaknesses, opportunities, and threats (SWOT) analysis.
What is the quorum requirement for both : Are the formats for informal and formal meetings different? What is the quorum requirement for both?

Reviews

Write a Review

Python Programming Questions & Answers

  Write a regular expression that will replace all occurrences

Using the sub() method from the re package substitute all occurrences of the 'pattern' with 'substitution'.Output to the console replace_results.

  Create a simple web interface for a to-do list application

Create a simple web interface for a To-Do list application, using what was learned in the reading for week - Flask web development framework

  Write a python program that reads a dumbbasic program

You should write a Python program that reads a DUMBBASIC program from standard input1, and prints the results of executing that program to standard output.

  Write a program that loops through lines of a file

Write a program that loops through lines of a file, assuming each line of input will consist of just a single word and a newline, of course.

  Whatever is done in excel you have to do it in python

Whatever is done in excel you have to do it in python. Like you have to categorize the tweets related to app and other. It should be done by using pandas

  Display the number of names that are stored in a file

Assume a file containing a series of name is named names.txt and exists on the computers disk. Write program that displays the number of names that are stored

  Write a function that accepts a single list argument

Write a function that accepts a single list argument. Your function must return the longest increasing sequence of numbers present in the argument list.

  How education records are protected

Discuss the similarities and the differences in how education records are protected compared to how health information records are protected.

  How is your hub set up and what type of hubs do you use

How is your Hub set up and what type of Hubs do you use and What type of servers are you currently using and

  Do basic trigonometry functions

Create a program that allows the user to do basic trigonometry functions. First, ask the user if he or she would like to do sine, cosine, or tangent (sin, cos, tan).

  Write a python program that will index a set of documents

You are going to write a python program that will index a set of documents and build a function to search through these documents using the index

  Create a python program that accepts two integer numbers

Create a Python program that accepts two integer numbers as input from the user. The program should then add the two numbers and print the sum as output.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd