Support Forums
My first program - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Python Programming Language (https://www.supportforums.net/forumdisplay.php?fid=32)
+---- Thread: My first program (/showthread.php?tid=10996)

Pages: 1 2 3


My first program - Reality - 08-06-2010

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


RE: My first program - Reality - 08-06-2010

;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


RE: My first program - Kyuubi - 08-09-2010

Haha that's pretty cool. You should make a really long for the heck of it ;]


RE: My first program - Daniel Faraday - 08-09-2010

(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.


RE: My first program - Reality - 08-09-2010

it causes it to end right after you say anything in first


RE: My first program - Daniel Faraday - 08-09-2010

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"



RE: My first program - Reality - 08-09-2010

Wil try tomorrow


RE: My first program - XACTLYSIN - 08-09-2010

Well it was really nice to have you post it!


RE: My first program - Reality - 08-11-2010

Is there anything that will make it return to the first question if they enter something wrong?

a while statement


RE: My first program - Daniel Faraday - 08-11-2010

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"