473,796 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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
1 1042
Laharl
849 Recognized Expert Contributor
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
  9.  
Apr 3 '08 #2

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

Similar topics

2
1429
by: Jon Perez | last post by:
There are objects whose repr() is not the same as what gets printed out when you apply the print statement to them. Usually these are complex objects like exceptions. Example: >>> import smtplib >>> server=smtplib.SMTP("smtp.yourisp.com")
14
2376
by: Christopher Subich | last post by:
As a hobby project, I'm writing a MUD client -- this scratches an itch, and is also a good excuse to become familiar with the Python language. I have a conceptual handle on most of the implementation, but the biggest unknown for me is the seemingly trivial matter of text display. My first requirement is raw speed; none of what I'm doing is processing-intensive, so Python itself shouldn't be a problem here. But still, it's highly...
18
3076
by: swaroophr | last post by:
Which of switch statement and if-else statement takes less time to execute?
10
2774
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows 2003 Server or ADO or ODBC issue, I am posting this on all of the three newsgroups. That's the setup: Windows 2003 Server with IIS and ASP.NET actiavted Access 2002 mdb file (and yes, proper rights are set on TMP paths and path,
13
1303
by: Bob Graham | last post by:
'create object array Dim jobnums(1000) Omitted: code that retrieves job numbers (integers) from sql server to put in a combobox I have a combobox (cbJob) that I want to put these values into. If I read them in from a SqlDataReader it takes an eternity, about 7 seconds to accomplish. But if I read them into an array, it takes no measurable time. Then I add the array items to the combobox all at once with the ..AddRange method of the...
4
4973
by: priyanka | last post by:
Hi there, I had a question. Is there any way of testing a string value in a switch statement. I have about 50 string values that can be in a string variable. I tried cheking them with the if else statements but it looked pretty ugly and the string values to be tested is still increasing. The switch statement seems to be a better choice then the if else statement. But it seems that the switch statement accepts integer values as the test...
0
2170
by: U S Contractors Offering Service A Non-profit | last post by:
This Sunday the 26th 2006 there will be Music @ Tue Nov Inbox Reply Craig Somerford to me show details 9:54 pm (26 minutes ago) #1St "CLICK" HeAt frOm A blanket --http://mail.google.com/mail/?realattid=f_3n2tmv&attid=0.1&disp=inline&view=att&th=10f0d56e8cb478be 24 oct 2006
33
2455
by: =?Utf-8?B?RE9UTkVUR1VZ?= | last post by:
Hello, In vb.net there is a with statement, Is there are similar constructor in c#?
5
4628
by: Emerik | last post by:
Hi all, I'm trying to construct a SP like this: <code> CREATE PROCEDURE UpdateInvoice @companyname varchar, @docno int AS BEGIN DECLARE @tablename varchar SET @tablename = ''
0
9683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9529
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10457
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10231
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5576
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4119
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3733
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2927
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.