I appreciate your help so much. I swear these are my last questions. I am almost completely done. I just have 2 problems.
1. I still cant get the program to stay in the first part UNLESS the user inputs 0, then it should move on to the second part of the program.
2. Still having problems writing results of part 2 of assignment to a file. I think i need to make results into a string then write to a file.
User Profile
Collapse
-
Ok. Getting close to the end. 2 questions.
1. Still have problem listing factors if number is not prime, in part 1 of assignment.
2. How do I output p to a string so I can output p to a file? It is towards end of code.
3. Which code do i use to exit the program if the user enters 0?
Here is what I got.
...Code:n = input ("Please enter a number greater than 1 (0 for exit):") def isprime(n):Leave a comment:
-
Having trouble still with listing the factors if it is not a prime number. Any advice would be great. Here's what I got.
...Code:n = input ("Please enter a number greater than 1 (0 for exit):") def isprime(n): '''check if integer n is a prime''' # range starts with 2 and only needs to go up the squareroot of n for x in range(2, int(n**0.5)+1): if n % x == 0:Leave a comment:
-
Prime Numbers
I have a homework assignment i Am totally confused on. I started with a basic code to determine if a number is prime or not, but need guidance from here. I will post assignment details then what I have so far.
Problem 1: Is it a prime number?
Write a Python program that allows the user to enter a whole number greater than 1 and that determines whether or not this number is a prime number. If it is a prime number, then
... -
Thanks so much for all of your help! I am slowly starting to learn. I eneded up getting it to work. One last question. How would I print to the other file "Sorry, no records found" if there were no results? I am done with this project, just thought id add a little bonusLeave a comment:
-
So i got it to print perfectly in python, but the file i am writing to is messed up. It looks like this:
China BeijingIndia New Delhi
It should look like:
China Beijing
India New Delhi
And how do i tell the user how many results are found? I'm so close to the end, I can smell it. Just a little more help.
...Code:p = input("Please enter the minimum population: ")Leave a comment:
-
File Processing in Python
I have just started using python and am stuck on a particular project. I have been stuck staring at my computer not knowing what to do. I will post details below.
What I am trying to do is use a CSV file named country.csv in which information about countries is recorded. The first line in the file is the header line and describes the content of each column. The first value in a line is the name of the country, the second is an abbreviation...
No activity results to display
Show More
Leave a comment: