Created
January 2, 2011 23:07
-
-
Save zeroeth/762918 to your computer and use it in GitHub Desktop.
a two input primed sentinel loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A Primed two input loop example | |
### INITIALIZE | |
total_cat_age = 0 | |
total_cat_weight = 0 | |
total_cats = 0 | |
print "Enter one or more cats age and weight and . to finish" | |
### LOOP PRIMER | |
cat_age_input = raw_input("How old is the cat?: ") | |
### LOOP | |
while(cat_age_input != "."): | |
cat_weight_input = raw_input("How much does the cat weigh?: ") | |
total_cats += 1 # same as total_cats = total_cats + value | |
total_cat_age += int(cat_age_input) | |
total_cat_weight += int(cat_weight_input) | |
cat_age_input = raw_input("How old is the cat?: ") | |
### SUMMARY | |
print "You have {} cats with {} years of combined fluffiness that weigh {} pounds all together".format(total_cats, total_cat_age, total_cat_weight) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment