Reputation: 22 Tradesman
- Active Members
- Active Posts:
- 88 (0.13 per day)
- 21-November 12
- Profile Views:
- Last Active:
- Yesterday, 07:59 PM
- Dream Kudos:
Posts I've Made
Posted 19 Oct 2014Two 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 * -1Note 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.
Posted 16 Oct 2014You can use instance attributes or a function that will return the values when called.
Posted 14 Oct 2014You 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?
Posted 14 Oct 2014One 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)
Posted 7 Oct 2014A 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.
- Member Title:
- D.I.C Head
- Age Unknown
- Birthday Unknown
woooee hasn't added any friends yet.