By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,222 Members | 2,478 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,222 IT Pros & Developers. It's quick & easy.

How can i accomplish this? IF statement. fast reply.!!

P: 1
assuming i have data for students names,credit hours, totalpoint or qualitypoints. i have trouble with both counting that is total number of students who fall under each category. printing students.

To do:
Count and print the number of students in each classification. Use the following classification scheme:
0-31 credits Freshman
32-63 credits Sophomore
64-95 credits Junior
over 96 credits Senior
Apr 3 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 849
What you seem to need is the if: elif: else: setup. It works like this:

Expand|Select|Wrap|Line Numbers
  1. if condition:
  2.  #do stuff
  3. elif condition:
  4.  #do other stuff
  5.  #elif is short for else if, so it's only checked if the 'if' was false
  6.  #any number of elif blocks can be associated with a single if
  7. else:
  8.  #do the stuff that happens if none of the above are true
Apr 3 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.