woooee's Profile User Rating: -----

Reputation: 22 Tradesman
Group:
Active Members
Active Posts:
88 (0.13 per day)
Joined:
21-November 12
Profile Views:
512
Last Active:
User is offline Yesterday, 07:59 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   woooee has not set their status

Posts I've Made

  1. In Topic: Write a function using the gregory-liebiniz series to estimate pi

    Posted 19 Oct 2014

    Two is added to the divisor in each iteration, and the sign is reversed (adds one time, subtracts the next), so partial code would be
    divisor += 2
    numerator = numerator * -1 
    
    Note also that the calculations are accumulated and then multiplied by 4 (after the for() loop).

    If you still have problems, post the formula you want to calculate here in your own words. If you can not state the formula then you can not put it to code.
  2. In Topic: How To Get A List Of Variable Values For All Instances Of Class Object

    Posted 16 Oct 2014

    You can use instance attributes or a function that will return the values when called.
  3. In Topic: Filing in a python code

    Posted 14 Oct 2014

    You will have to use 2 files, one contains "Start Pic 1" records, the second contains everything else. Note that you will get a synatx error on the fread line you posted above
    fread = open("code1.txt")
    fwrite_pic = open("filename.txt", 'w')
    fwrite_orig=open("original_file.txt", 'w')
    
    pic_found=False
    for line in fread:
        if "Start pic1" in line :
            pic_found=True
        if pic_found:
            fwrite_pic.write(line)
        else:
            fwrite_orig.write(line)
    
        ## test after the write because we want
        ## to write the "End" rec to the "pic" file
        if "End of pic1" in line :
            pic_found=False
    
    fwrite_pic.close()
    fwrite_orig.close()
    fread.close() 
    



    Is This A Good Question/Topic?
    0

    Report
    Mu
  4. In Topic: Print turtle based on input

    Posted 14 Oct 2014

    One function is all that is required as the only things that change are the starting position, and the width of the line to be drawn (which you have not included yet). I am not that familiar with Turtle so this is more pseudocode
    def draw_line(t, start_x, start_y, width):
        moveTo(start_x, start_y)
        ## draw how ever many lines to get width
        ## or use a box/rectangle and fill
        for ctr in range(something_to_determine_width):
           line(t)  
    
        ## move to right side
        moveTo(start_x+distance_to_right, start_y)
        for ctr in range(something_to_determine_width):
           line(t)
    
    
  5. In Topic: Using selection to find median from unsorted list

    Posted 7 Oct 2014

    A selection sort uses two for loop generally. The outer for loop iterates through the list to n-1 and compares each item to all items after it, and swaps it with the smallest value, unless it is already the smallest
    for x in range(0, n-1):
        for y in range(x+1, n)
            if some_list[y] < some_list[x]: 
    
    You can then find the middle or median value in the sorted list, and you should allow for an even number of items in the list and decide what to do in that case.

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

woooee hasn't added any friends yet.

Comments

woooee has no profile comments yet. Why not say hello?