Ok, im taking this tutorial that was found on pythong.org. I love it. Its fun to read, and its easy. On a certain chapter, (I forget which) it gives a little assignment to integrate a question program with a number program. Heres the two.
average2.py
#keeps asking for numbers until count have been entered.
#Prints the average value.
sum = 0.0
print "This program will take several numbers than average them"
count = input("How many numbers would you like to sum:")
current_count = 0
while current_count < count:
current_count = current_count + 1
print "Number ",current_count
number = input("Enter a number:")
sum = sum + number
print "The average was:",sum/count
---------------------------------------------------------------------------------------------------------------------
The question program...
Password.py
# Waits until a password has been entered. Use control-C to break out with out
# the password
#Note that this must not be the password so that the
# while loop runs at least once.
password = "foobar"
#note that != means not equal
while password != "unicorn":
password = raw_input("Password:")
print "Welcome in"
Sample run:
Password:auo
Password:y22
Password
assword
Password
pen sesame
Password:unicorn
Welcome in
---------------------------------------------------------------------------------------------------------------------
I would just like to know how would I integrate these 2 together, so I could get how many times I tried to get the password, and if I did over 3 times, how would I say something line "that was hard wasn't it?" This is what I thought, but this is not my full, messy program, since its confusing to hell anyways. Do I put somewhere in these 2 programs this...?
n = input("Number? ")
if n < 0:
print "The absolute value of",n,"is",-n
else:
print "The absolute value of",n,"is",n
Thought obviously I think I would change the ineger to the "count" shown in program one, and I would take out the input, so the user doesn't add a number before they are told how many times it took them to find out the password.
Thanx in advance! Oya, im a
when it comes to programing. Plz don't flame me to death.