Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 13th, 2005, 10:06 PM   #11
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 707
Rep Power: 4 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
I like IR's idea of fucntions for writing data. You could write some functions to write the data of your power program you are creating.
thechristelegacy is offline   Reply With Quote
Old Apr 13th, 2005, 10:06 PM   #12
SaturN
Programmer
 
Join Date: Apr 2005
Location: Uk
Posts: 68
Rep Power: 4 SaturN is on a distinguished road
ohh i get it, so it must be
print 2**x
that makes 2 my constant
and the sums of it look right now..
SaturN is offline   Reply With Quote
Old Apr 13th, 2005, 10:08 PM   #13
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Congrats.

Well from what I can tell your knowledge of Python's commands looks standard, but you just need a bit more exercise in the thinking process of programming. See what you can do with the Primes. I'll be on drsane_@hotmail.com if you wish for help.

Edit: Actually...it's past 11. I better be going to bed. I'll still be willing to help, I just need some sleep. Later.

Last edited by Sane; Apr 13th, 2005 at 10:14 PM.
Sane is offline   Reply With Quote
Old Apr 13th, 2005, 10:19 PM   #14
SaturN
Programmer
 
Join Date: Apr 2005
Location: Uk
Posts: 68
Rep Power: 4 SaturN is on a distinguished road
Prime Numbers is;
number = input("> ")
dif = number % 2

if dif != 0 :
    print number, "Is a prime"
if dif == 0 :
    print number, "is not a prime"

is that right, or am i barking up the wrong tree again, lol.
thanks for you help Sane
SaturN is offline   Reply With Quote
Old Apr 13th, 2005, 10:24 PM   #15
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 707
Rep Power: 4 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Speaking of writing to a disk, I just wrote a small script recently to get catorgize my collection of mp3s since they're scattered all thoughout differnt folders. If you decide to to any IO functions, this is a good example of a practical program.

import os
x = os.listdir("c:/Documents and Settings/Frazier PH&A/Desktop/Anthony's Files/Music")
thing = open("music.txt","w")
for y in x:
    print y
    thing.write(y+"\n")
thing.close()

x = os.listdir("c:/Documents and Settings/Frazier PH&A/Desktop/Anthony's Files/Random")
thing = open("music.txt","a")
for y in x:
    print y
    thing.write(y+"\n")
thing.close()

x = os.listdir("c:/Documents and Settings/Frazier PH&A/Desktop/Anthony's Files/Random/k")
thing = open("music.txt","a")
for y in x:
    print y
    thing.write(y+"\n")
thing.close()

x = os.listdir("c:/Documents and Settings/Frazier PH&A/Desktop/Anthony's Files/Random/k/k")
thing = open("music.txt","a")
for y in x:
    print y
    thing.write(y+"\n")
thing.close()

And also SaturN, the only problem with your prime program is it doesn't test for primes, it only test to see if a program is even or odd, but you're on the right track. Each number is only prime if it isn't divisible by any number less than it.

Last edited by thechristelegacy; Apr 13th, 2005 at 10:58 PM.
thechristelegacy is offline   Reply With Quote
Old Apr 13th, 2005, 10:36 PM   #16
SaturN
Programmer
 
Join Date: Apr 2005
Location: Uk
Posts: 68
Rep Power: 4 SaturN is on a distinguished road
I see your point..
I never was good at math.. lol
SaturN is offline   Reply With Quote
Old Apr 13th, 2005, 11:00 PM   #17
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 707
Rep Power: 4 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Hey it's all good man. I'm not that smart when it comes to math either.
thechristelegacy is offline   Reply With Quote
Old Apr 14th, 2005, 6:18 AM   #18
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
I'm one of those mathy guys, so I help people with math. ^_^

A little nudge on the right tracK:

Primes are only equally divisble by one and itself.
if x%x==0
if x%1==0 (the 0 and 1 could be represented by constant variables)
And all other numbers in between are not.
if x%x-1!=0
if x%x-2!=0
etc...
if x%2!=0 (the (x-1), (x-2), are therefore dependents on the variable x)

It wouldn't be a good idea to do x-1 for the dependents though, there are many reasons why that could create a poorly consistent program. There's a very reasonable and efficient way that I'll see if you can think up by yourself. =P
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:31 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC