User Profile

Collapse

Profile Sidebar

Collapse
electric916
electric916
Last Activity: Mar 12 '08, 06:01 PM
Joined: Feb 18 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • electric916
    replied to Prime Numbers
    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.
    See more | Go to post

    Leave a comment:


  • electric916
    replied to Prime Numbers
    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):
    ...
    See more | Go to post

    Leave a comment:


  • electric916
    replied to Prime Numbers
    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:
    ...
    See more | Go to post

    Leave a comment:


  • electric916
    started a topic Prime Numbers

    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
    ...
    See more | Go to post

  • electric916
    replied to File Processing in Python
    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 bonus
    See more | Go to post

    Leave a comment:


  • electric916
    replied to File Processing in Python
    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: ")
    ...
    See more | Go to post

    Leave a comment:


  • electric916
    started a topic File Processing in Python

    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...
    See more | Go to post
No activity results to display
Show More
Working...