I tried that, it didnt work (maybe I didnt put it where it was supposed to go...dunno). But I did get it to work using a different approach, still though i'm not quite getting the results I need.
It does ask the user if they want to continue or not, but after continuing if they enter an odd number or a number less than or equal to 2, the program still quits with no continue message...
Could someone please help me figure...
User Profile
Collapse
-
need help implementing a "continue or quit" prompt in this script
I've been working on this script all weekend and am almost done with it accept for one last detail; implementing a "process another number?" prompt after a user input is processed.
The script works like this: First, the user enters a number to test (to find the two prime numbers that make up that number). Next the program finds the numbers, outputs them, then quits.
What I want to do is create a prompt after... -
Maybe I wasnt clear enough, sorry.
I need the program to detect when a prime number has been entered, then output a "This number is prime!" message, for ALL prime numbers, not just the one even one lol.Leave a comment:
-
Not sure why, but it posted 2 of my messages, so I edited this one... sorry.Leave a comment:
-
Hi and thanks for the help!
How would I incorporate the prime number check and message into this new code?
I had it in my old code. If a prime number was entered it would print "this number is already prime" then print another message "this number is not even..." yadda yadda.
If I could incorporate that into this new code, it will be complete.Leave a comment:
-
Hi and thanks for the help!
How would I incorporate the prime number check and message into this new code?
I had it in my old code. If a prime number was entered it would print "this number is already prime" then print another message "this number is not even..." yadda yadda.
If I could incorporate that into this new code, it will be complete.Leave a comment:
-
Mmkay, done. Is there anything else that could be streamlined?Leave a comment:
-
Need help streamlining this code
Could someone help me streamline this? Like eliminate unnecessary coding and etc?
I got the script to work, although I couldn't figure out how to handle small prime numbers such as 2 and 3. It wouldn't output "this number is prime" (see script below) so I had to force prime detection. Also, 6 = 3 + 3, and 4 = 2 + 2, but it wouldn't output that either, instead it would just return to the python prompt, so I forced those two.... -
-
I tried the code you suggested, but it doesnt do the primary function, which is to print out the two prime numbers that sum the input number.
Here is the result of the code you provided:
Enter number to test: 4
Ener number to test: 4
>>>
Enter number to test: 25
Ener number to test: 25
25 is not even. Please enter only even numbers.
>>>
Ener number to...Leave a comment:
-
Need help making an error message work in a Python script
I'm trying to create a script that will accept a user entered integer and find only one set of prime numbers that add up to that integer but need some help. The script is supposed to only accept even numbers, and if it encounters an odd number it needs to exit with a "please enter only even numbers" message. I've made some progress on the script, but it still isnt quite rite.
I already tried to code an error message for... -
Okay, I tried to do what you suggested. Here is the updated code and the output, but its still doing something strange...
New code:
...Code:import math def main(): print "This program determines if a number you enter is prime or not.\n" n = input ("Please enter a number greater than 1: ") found = False n = abs(n) i = 2 whileLeave a comment:
-
Help, determining if an input value is prime?
I'm doing some reading in a python book and am doing one of the chapter exercises but I cant figure out how to get it to work and was hoping some of you python guru's could help out?
Heres description of the problem to be solved:
"A positive whole number n > 2 is prime if no number between 2 and the square root of n (inclusive) evenly divides n. Write a program that accepts a value of n as input and determines... -
I'm working on an expanded version of this code and am wondering how you would modify it to accept an entire name or several names rather than just one?
When you enter a single, one word name this program works great. But when you enter any spaces, instead of Python ignoring them, it assigns them a numeric value of -64 which messes up the correct numeric value of the name.
I know the unicode value for a space is 32,...Leave a comment:
-
Need help with celcius to fahrenheit converter code
I'm new to Python and am trying to figure out how to streamline the code at bottom to get it more simple but am having trouble. I was hoping that someone here could help me out?
The program I am trying to create simply asks the terminal operator for five different celsius temperatures, processes them into fahrenheit values and outputs them to the screen. The results should look something like this:
...Code:This is a program
No activity results to display
Show More
Leave a comment: