Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My first program
#11
I'll try that soon, looks good to me anyway thanks
Reply
#12
No problem. =)
Like I said before, though. there are probably better ways.
Reply
#13
a downloadable version would be nice. But just scimming it over, seems like a nice idea for a beginner. Continue to learn and code.
[Image: deities.jpg]
Reply
#14
(08-12-2010, 07:23 AM)Deities Wrote: a downloadable version would be nice. But just scimming it over, seems like a nice idea for a beginner. Continue to learn and code.

I posted the source so all you have to do is safe it as .py and run it Smile
Reply
#15
nice, keep trying u'll make it pro.
Reply
#16
Hey, I added some thing to your program.

Code:
import os
print 'Welcome to your interview :)'
print 'You will be answered a series of questions through this examine.'

while True:
    first = raw_input("\nPlease enter your gender: ")

    if first == "male":
        print "\nme too!"
        break
    elif first == "female":
        print "\nthat's what she said :p"
        break
    else:
        print "\nhey that's not a gender!"



second = int(raw_input("\nPlease enter the number of pets you own: "))
if second < 5:
    print "\nYou aren't crazy! :p"
elif second > 5:
    print "\nYou are borderline crazy, or crazy. :P"
elif second == 5:
    print "\nThat's quite a lot!"


print "\nYou said you are a: "+first

print "\nYou said you have:  "+str(second)+" pets"

os.system("PAUSE")

First, i moved the import os to the top. you should have all imports at the top of the script.

Next, I added a loop, so if somebody does not answer with 'male' or 'female' it askes again.

Finally, when asking about the number of pets, you have values for more and less than 5, but you do not have one for equal to 5, so I added one.

Nice beginning project Oui
[Image: idgjkO.png]
Reply
#17
thanks titan

but what does 'break' mean?
Reply
#18
(08-13-2010, 07:38 PM)ReaLiTy Wrote: thanks titan

but what does 'break' mean?

In my method I just set the variable as true.
The way he did it was the same thing except just stopping it from looping again.

Also replace the part that asks for input with this.
Code:
first = raw_input("\nPlease enter your gender: ").lower()

You set it where if the user inputs MALE it will say it's not a gender.
Reply
#19
Well I have to find out how to install Python now... I deleted windows Smile
Reply
#20
Are you running Linux?
Most distros come with Python.

If you are using Linux and don't have it...

sudo apt-get install python

Will get you where you need to be if your distro is based on Debian.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)