Support Forums

Full Version: My first program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
This was in python 2.6, just testing inputs and stuff

edit it if you want, no reason to :p

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

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

if first == "male":
    print "\nme too!"
if first == "female":
    print "\nthat's what she said :p"


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

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

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

import os
os.system("PAUSE")

good for first?

I am going to make apps now, beginnerones
;p

I was just wondering how raw_input worked

do you know how to make it so

if someone doesn't put male/female then it'll say like

'next time be serious'
Code:
import os
os.system("PAUSE")

so if you put spmething else it closes
Haha that's pretty cool. You should make a really long for the heck of it ;]
(08-06-2010, 06:31 AM)ReaLiTy Wrote: [ -> ];p

I was just wondering how raw_input worked

do you know how to make it so

if someone doesn't put male/female then it'll say like

'next time be serious'
Code:
import os
os.system("PAUSE")

so if you put spmething else it closes

If you want it to say something like that's not a gender than put...

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

If you want to make it exit then...
Import this.
Code:
import time
import sys

And replace your If statements with this.
Code:
if first == "male":
    print "\nme too!"
elif first == "female":
    print "\nthat's what she said :p"
else:
    print "Try to be more serious next time."
    time.sleep(1)
    print "Exiting now..."
    time.sleep(3)
    sys.exit()

I don't know how to make it not give an error in IDLE though.
it causes it to end right after you say anything in first
Don't just put my code.
Add it to your code.

Code:
import os
import sys

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

first = raw_input("\nPlease enter your gender: ")
if first == "male":
    print "\nme too!"

elif first == "female":
    print "\nthat's what she said :p"

else:
    print "Try to be more serious next time."
    time.sleep(1)
    print "Exiting now..."
    time.sleep(3)
    sys.exit()


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

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

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

or

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

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

if first == "male":
    print "\nme too!"
elif first == "female":

    print "\nthat's what she said :p"

else:
    print "\nThat'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"
if second > 5:
    print "\nYou are borderline crazy, or crazy. :P"

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

print "\nYou said you have:  "+str(second)+" pets"
Wil try tomorrow
Well it was really nice to have you post it!
Is there anything that will make it return to the first question if they enter something wrong?

a while statement
There are probably way better ways to go about this, but I'm not that good at python. D:

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


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

if first == "male":
    print "\nme too!"
    correct= True
elif first == "female":
    print "\nthat's what she said :p"
    correct = True
else:
    print "\nPlease be more seriouse next time"
    correct = False

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

    if first == "male":
        print "\nme too!"
        correct= True
    elif first == "female":
        print "\nthat's what she said :p"
        correct = True
    else:
        print "\nPlease be more seriouse next time"
        correct = False


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

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

print "\nYou said you have:  "+str(second)+" pets"
Pages: 1 2 3