Michael here, and in today’s post, we’re going to explore the wonderful world of if-else statements (aka conditionals) in C#.
Now, you’ve seen me cover conditionals in Java and Python, but let’s see how we do it in C#.
A truth tables refresher
One thing that is important when writing conditionals or Boolean statements in programming is the concept of truth tables, like so:
The three most common logical operators you will likely use when writing Boolean statements and conditionals in programming are & (and), | (or) and ! (not).
Here are some other things to keep in mind with truth tables:
In C#, much like in other programming tools we’ve covered, statements are read from left to right for the most part, so the leftmost Boolean statements will be evaluated first.
One exception to what I just mentioned-if you have a statement in parentheses, that will be the first one read. For instance, if your statement goes A & B | (C & D), C & D would be read first as it is the statement in parentheses.
Following what I just said, if you have several statements inside several nested parentheses, the innermost statement will be read first. For instance, if your statement goes A | B | C & (D & (E | F)), E | F would be read first as it is the statement in the innermost pair of parentheses.
A basic if-else statement, C# style
Now, how do we write a basic if-else statement, C# style. Take a look at my example below:
Console.WriteLine("Pick a number between 0 and 100");
String userNumber = Console.ReadLine();
int userNumberInt = int.Parse(userNumber);
String grade = "";
if (userNumberInt >= 70 | userNumberInt <= 100)
{
grade = "pass";
}
else
{
grade = "fail";
}
Console.WriteLine("Your grade is a " + grade);
Pick a number between 0 and 100
72
Your grade is a pass
Using the American school grading system as an example, in this script I ask the user for a number from 0 to 100, which represents possible class grades. If the number is between 70 and 100, the grade is set to pass (think of it as needing a C- to pass). Otherwise, the grade is set to fail (think of it as a D+ or lower is failing).
You might be wondering about the int.Parse([insert string here]) method. This is one way to convert strings in C# into integers. It’s also known by the name typecasting, much like in Python when we converted strings into integers simply by typing int([string here]).
If, Else, Nested, C#
Now, as we saw in some of the other tools I’ve covered, it is possible to nest if-else statements inside other if-else statements. How can we do so? Take a look at the code below:
Console.WriteLine("Pick a number between 0 and 100");
String userNumber = Console.ReadLine();
int userNumberInt = int.Parse(userNumber);
String grade = "";
if (userNumberInt >= 90 & userNumberInt <= 100)
{
if (userNumberInt >= 97 & userNumberInt <= 100)
{
grade = "A+";
}
else if (userNumberInt >= 93 & userNumberInt <= 96)
{
grade = "A";
}
else
{
grade = "A-";
}
}
else if (userNumberInt >= 80 & userNumberInt <= 89)
{
if (userNumberInt >= 87 & userNumberInt <= 89)
{
grade = "B+";
}
else if (userNumberInt >= 83 & userNumberInt <= 86)
{
grade = "B";
}
else
{
grade = "B-";
}
}
else if (userNumberInt >= 70 & userNumberInt <= 79)
{
if (userNumberInt >= 77 & userNumberInt <= 79)
{
grade = "C+";
}
else if (userNumberInt >= 73 & userNumberInt <= 76)
{
grade = "C";
}
else
{
grade = "C-";
}
}
else if (userNumberInt >= 60 & userNumberInt <= 69)
{
if (userNumberInt >= 67 & userNumberInt <= 69)
{
grade = "D+";
}
else if (userNumberInt >= 63 & userNumberInt <= 66)
{
grade = "D";
}
else
{
grade = "D-";
}
}
else
{
grade = "F";
}
Console.WriteLine("Your grade is a " + grade);
Pick a number between 0 and 100
88
Your grade is a B+
In this example, I added more dimensions to the grade variable by adding different scenarios for this script. In other words, in this example the grade won’t simply be set to pass or fail but rather to a letter value based on the inputted number. For instance, inputting a 71 will yield a C- but a 78 will yield a C+. For this example, I chose 88 and got a grade of B+.
For all my non-American readers, there is no such thing as an F+ or F-, hence why I don’t have any nested conditionals for the F scenario. Anything under 60 would be a F in the American grading system.
Rest assured, I’ll only use this data to help improve my slate of content going forward. That’s it. It’s my way of getting your feedback on my content slate.
Also, here is my script on GitHub-https://github.com/mfletcher2021/blogcode/blob/main/IfElse.cs. Both examples are on the same script, but I did note which code belongs to which example in the comments so if you wish to test out either example, feel free to comment out the code for the example your not testing.
It’s Michael, and today’s lesson will be on conditional statements in Python. I covered Java conditional statements in Java Lesson 4: IF-ELSE statements & Logical/Comparison Operators, and in case you’re wondering, “conditional statements” is a more technical way of saying “if-else statements” (or “if statements” and “else statements”, for that matter). I will also cover user input in Python.
Just like Java, Python has if, else, and else if statements, except in Python, else if is referred to as elif. The logic behind conditional statements in Python is the same as in Java. By that I mean in any group of conditional statements, if will always come first, followed by any elif statements and an else statement at the end of the group. Here’s an example program with conditional statements (since I wrote this for explanatory purposes, I won’t have any sample output):
if (score >= 300) and (score <= 579); print (“POOR”)
elif (score >= 580) and (score <= 679); print (“FAIR”)
elif (score >= 680) and (score <= 739); print (“GOOD”)
In this program, there is a variable called score (a reference to FICO Credit Score) and based on the value of that variable, one of five things will be displayed-POOR, FAIR, GOOD, VERY GOOD, and EXCEPTIONAL. If the if statement is not true, each of the elif statements will be analyzed from the top down to see which one is true; once a true statement is found, any code on that statement will be executed and the compiler will stop analyzing the group of conditional statements. If neither the if statement nor any of the elif statements are true, then the else statement will execute.
Now. everything I just said will hold true in most cases, provided score falls between 300 and 849 inclusive. But what if the value of score was outside that range? You would simply write another elif statement that goes something like elif (score >= 800) and (score <= 850); print ("EXCEPTIONAL"). You would also have to revise the else statement so that it reads something like else; print ("NOT POSSIBLE"). By writing the new elif statement, the compiler will know to print out ERROR if score isn’t between 300 and 850 inclusive.
Now, let’s demonstrate conditional statements. Here’s a simple example:
rt = 78
if (rt >= 60) and (rt <= 100):
print(“fresh movie”)
else:
print(“rotten movie”)
And here’s the output:
fresh movie
Using Rotten Tomatoes’ movie scoring system as an example (the rt refers to Rotten Tomatoes score), the compiler will print out “fresh movie” if rt is between 60 and 100 and “rotten movie” if rt is below 60. Since rt is 78 (that’s the current score for the movie Good Boys), “fresh movie” will be displayed.
Now, here’s a more complex conditional statements example, with several elif statements:
IGN = 6.6
if (IGN == 10):
print(“MASTERPIECE”)
elif (IGN >= 9) and (IGN <= 9.9):
print(“AMAZING”)
elif (IGN >= 8) and (IGN <= 8.9):
print(“GREAT”)
elif (IGN >= 7) and (IGN <= 7.9):
print(“GOOD”)
elif (IGN >= 6) and (IGN <= 6.9):
print(“OKAY”)
elif (IGN >= 5) and (IGN <= 5.9):
print(“MEDIOCRE”)
elif (IGN >= 4) and (IGN <= 4.9):
print(“BAD”)
elif (IGN >= 3) and (IGN <= 3.9):
print(“AWFUL”)
elif (IGN >= 2) and (IGN <= 2.9):
print(“PAINFUL”)
elif (IGN >= 1) and (IGN <= 1.9):
print(“UNBEARABLE”)
else:
print(“DISASTER”)
And here’s the output:
OKAY
Using IGN’s gaming review scoring system in this example, the compiler will look at the value of IGN (referring to a game’s IGN score) and based on that value, will first analyze the if statement, then all of the elif statements from the top down, and finally the else statement (which will only be analyzed if neither the if statement nor the elif statements are true). Remember that the compilers will stop analyzing once it finds a true statement, which in this case would be elif (IGN >= 6) and (IGN <= 6.9) (which would print out OKAY).
Also remember that a colon would come after each conditional statement (in other words, right before the block of code that’s supposed to be executed with a particular statement). Unlike Java, there’s no need to place the code that goes with conditional statements in brackets (and you’ll likely get an error if you do so).
Now, one thing I would like to mention is that you can sometimes write conditional statements in a handy little shorthand.
Let’s use the if-else Rotten Tomatoes score example. Here’s the shorthand way of writing that program:
print(“fresh movie”) if (rt >= 60) and (rt <= 100) else print(“rotten movie”)
Even though you will need to assign a value to rt on a separate line, you can still write the if–else statement on the same line. However, if you’ve got multiple elif statements (like the IGN example), then this approach will not work.
Now, what if the value of a certain variable wasn’t already set. What if you needed to set the value of a certain variable?
This brings me to the next topic I will cover in this post-user input in Python. Just like Java, Python also allows for user input. Using the IGN scoring program from a previous example, here’s how to handle user input in Python:
IGN = float(input(“Give me an IGN score: “))
if (IGN == 10):
print(“MASTERPIECE”)
elif (IGN >= 9) and (IGN <= 9.9):
print(“AMAZING”)
elif (IGN >= 8) and (IGN <= 8.9):
print(“GREAT”)
elif (IGN >= 7) and (IGN <= 7.9):
print(“GOOD”)
elif (IGN >= 6) and (IGN <= 6.9):
print(“OKAY”)
elif (IGN >= 5) and (IGN <= 5.9):
print(“MEDIOCRE”)
elif (IGN >= 4) and (IGN <= 4.9):
print(“BAD”)
elif (IGN >= 3) and (IGN <= 3.9):
print(“AWFUL”)
elif (IGN >= 2) and (IGN <= 2.9):
print(“PAINFUL”)
elif (IGN >= 1) and (IGN <= 1.9):
print(“UNBEARABLE”)
else:
print(“DISASTER”)
And here’s the output if I use 5.1 as the value of IGN:
Give me an IGN score: 5.1
MEDIOCRE
In Python, user input is much simpler than it is in Java. In Java, you have to import a Scanner class for user input AND create a separate Scanner variable (along with familiarizing yourself with all the methods in the Scanner class). With regards to user input, Python is much simpler to use, as it has a built-in user input function-input()-so there is no need to import anything. As a result, it only take one line of code to handle user input in Python, as opposed to the three or four lines of code it can take in Java.
I have three important tips regarding user input in Python, which include:
You don’t technically need put in any parameters for the input() method, but it’s suggested that you do so, as I did with input(Give me an IGN score: ).
You can set the value of certain variable to the user’s input, as I did with the value of IGN.
The default type of user input in Python is String, so if you want to set the user input to another type, write something like this other type(input(text for input)). In my IGN example, I wanted input of type float, so I wrote IGN = float(input(Give me an IGN score: )). By writing this, my input for IGN would be read as float and not String.
It’s Michael, and today’s Java post will be a little different from the previous six because I am not giving you guys a lesson today. See, when I launched this blog in June 2018, I said I was going to posts lessons and analyses with various programs. However, in the case of Java, I feel it is better to give you guys program demos that cover the concepts I’ve discussed so far (loops, if-else statements, etc.). In this post, I will show you guys two programs that cover all the Java concepts I’ve discussed so far.
public static void main(String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.println(“Please choose a number: “);
int num = sc.nextInt();
int start = 0;
int t2 = 1;
if (num >= 0)
{
while (start <= num)
{
System.out.print(start + ” + “);
int sum = start + t2;
start = t2;
t2 = sum;
}
}
else
{
System.out.println(“Need a 0 or a positive number”);
}
}
}
This program prints every number in the Fibonacci sequence up to a certain point. If you’re wondering, the Fibonacci sequence is a pattern of numbers that starts with 0 and 1 and calculates each subsequent element by finding the sum of the two previous numbers.
Here are the first 10 numbers of the Fibonacci sequence-0,1,1,2,3,5,8,13,21,34,55. Notice how every element after the 3rd is the sum of the previous two numbers (e.g. 13 is found by calculating 5+8-the two numbers that directly precede 13 in the series)
To calculate the Fibonacci sequence, I first ask the user to type in a number. That number will serve as the endpoint for my while loop where I calculate each element in the Fibonacci sequence; in other words, my while loop will find every element in the sequence until it reaches the closest possible number to the user’s input. For instance, if I wanted to find every number in the Fibonacci sequence stopping at 600, the program would stop at the closest possible number to 600-which is 377.
I decided to add an endpoint because the Fibonacci sequence is infinite, and had I decided not to have an endpoint, I would’ve created an infinite loop.
Notice the if-else statement in my program. The loop will only run IF the user inputs a positive number. Otherwise, the user will just see a message that goes Need a 0 or a positive number. I decided to include the if-else statement since Fibonacci sequences don’t have any negative numbers.
run:
Please choose a number:
-5
Need a 0 or a positive number
BUILD SUCCESSFUL (total time: 3 seconds)
As you can see, my first output-112-displays the Fibonacci sequence up to 112 while my second output-negative 5-displays a message that is shown when a negative number is chosen.
Here is the code for my next program (video in link)-Factorial program:
package javalessons;
import java.util.Scanner;
public class JavaLessons
{
public static void main(String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.println(“Please choose a number: “);
int num = sc.nextInt();
long factorial = 1;
if (num >= 1)
{
for(int i = 1; i <= num; ++i)
{
factorial *= i;
}
System.out.println(“The factorial of ” + num + ” is ” + factorial);
}
else
{
System.out.println (“Number is too low”);
}
}
}
This program calculates the factorial of a number greater than 0. For those wondering, a factorial is the product of a positive number and all positive numbers below it (stopping at 1). For instance 3 factorial is 6, since 3*2*1=6. Just so you guys know, factorials are denoted by the exclamation point (!), so 3 factorial is 3!.
I have three conditional statements in this program that account for the three possible scenarios of user input (>0,0, and <0). If the user enters a number greater than 0, then the for loop will execute and the factorial of the number will be calculated. If the user enters 0, then the message The factorial of 0 is 1 will be displayed, since 0!=1. If the user enters a negative number, then the message Number is too low will be displayed, since factorials only involve positive numbers.
If you are wondering why I used long for the factorial variable, I thought it would be more appropriate since factorials can get pretty long (13! is over 6 billion), and long has a wider range than int (9 quintillion as opposed to 2 billion).
Now, let’s see some sample output
run:
Please choose a number:
11
The factorial of 11 is 39916800
BUILD SUCCESSFUL (total time: 12 seconds)
run:
Please choose a number:
0
The factorial of 0 is 1
BUILD SUCCESSFUL (total time: 3 seconds)
run:
Please choose a number:
-14
Number is too low
BUILD SUCCESSFUL (total time: 3 seconds)
run:
Please choose a number:
344
The factorial of 344 is 0
BUILD SUCCESSFUL (total time: 3 seconds)
In the first output sample, I chose 11 and got 39,916,800 as the factorial (11!=39,916,800). In the second output sample, I chose 0 and got 1 as the factorial (remember than 0! is 1). In the third output sample, I chose -14 and got the Number is too low message since factorials only involve positive integers.
Now I know I mentioned that there were three possible scenarios for this program. There are actually 4. See, if you type in a number like 700 or 344 (as I did above), you will get 0 as the factorial, even though the actual factorial will be considerably larger. A 0 will be displayed if the actual factorial is greater than 9 quintillion since long doesn’t extend past 9 quintillion.
This concludes my current series of Java posts, but don’t worry, there will be more Java lessons soon! In the meantime, you can look forward to more R posts.
It’s Michael, and today’s post will be on if-else statements and logical/comparison operators in Java. If-else statements allow your program to choose between two or more alternative actions.
Why are if-else statements so important? Well, with Java programs, as in everyday life, things can go several different ways. Let’s say you just took a final exam for a college class. Depending on how you did on that exam, your grade can come out one of five ways (A, B, C, D, or F). The same sort of thinking applies to programming, as there can be several different actions a program can perform depending on certain scenarios (like if an int is greater than/less than/equal to a certain amount).
Let’s demonstrate using a program example (I had to copy and paste the code since you can’t see all of it from a screenshot):
package javalessons;
import java.util.Scanner;
public class JavaLessons
{
public static void main(String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.println (“Please enter a number: “);
double temperature = sc.nextDouble ();
System.out.println (“C or F: “);
String unit = sc.next();
double temp;
if (“C”.equals(unit))
{
temp = (1.8*temperature)+32;
System.out.println (“The temperature is ” +temp+ ” degrees Farenheit”);
}
else if (“F”.equals(unit))
{
temp = (temperature-32)*0.56;
System.out.println (“The temperature is ” +temp+ ” degrees Celsius”);
}
else
System.out.println(“Not a valid answer”);
}
}
This program is a temperature unit converter; the user enters a number and a “C” or “F” (for Celsius or Fahrenheit) and, depending on what letter was entered, converts the temperature from Celsius to Fahrenheit or vice versa.
I want to clarify that there is a difference between else if and else. Else if acts as another if statement; you would use else if if your program was trying to test two or more conditions, such as whether a “C” or “F” was typed. The else statement would come at the very end of your code since that would be the statement that executes should neither of the if/else if conditions be true; the output I used for the else statement would only display if neither a “C” nor an “F” was typed.
Always use .equals for String variables such as these. Don’t use =.
You need to use brackets if you if or else if statements use more than one line of code. If you only need one line of code, you don’t need the brackets.
Let’s try inputting a number:
run:
Please enter a number:
19
C or F:
C
The temperature is 66.2 degrees Farenheit
BUILD SUCCESSFUL (total time: 17 seconds)
I entered 19 and C, meaning I wanted to find out what 19 degrees Celsius was in Fahrenheit. I got 66.2, which means that 19 degrees Celsius is equal to 66.2 degrees Fahrenheit.
Now let’s see what happens when I don’t type a “C” or an “F”:
run:
Please enter a number:
45
C or F:
W
Not a valid answer
BUILD SUCCESSFUL (total time: 8 seconds)
I typed 45 and W and as a result, “Not a valid answer” displayed (which is the output I had set to display if neither “C” nor “F” was typed).
Now let me introduce some new concepts that perfectly relate to if and else if statements-comparison and logical operators.
Comparison operators are pretty self-explanatory, as they are used to compare two things (usually testing a variable and a value). If you know basic algebra, you’d be familiar with most of these:
== is “equal to” (remember to use .equals for Strings)
!= is “not equal to”
> is “greater than”
>= is “greater than or equal to”
< is “less than”
<= is “less than or equal to”
Logical operators are similar to comparison operators since both compare statements. However, comparison operators are only used for single boolean statements, such as (temperature > 70) while logical operators are used for groups of boolean statements, such as (temperature >= 60) && (temperature <= 80).
Here are the three main logical operators:
&&-AND
||-OR
!-NOT
OK, so even though I said logical operators are used for groups of boolean statements, the NOT operator is more for single boolean statements, such as !(temperature > 70)-meaning that you’re looking for temperatures that aren’t greater than 70 degrees. You can, however, also use the NOT operator for groups of boolean statements, such as (!(temperature >= 50) && (temperature <= 0))-meaning that you’re looking for temperatures that aren’t between 0 and 50 degrees.
Here’s the one takeaway with the NOT operator-it negates boolean statements (whether an individual statement or groups of statements). In other words, it essentially contradicts whatever is in the statement(s).
Now, one more thing I want to cover regarding logical operators-the truth table. The truth table doesn’t involve any coding, rather it’s a helpful guide with regards to boolean statements in your program. The truth table compares two boolean statements, looks at the values of each statement (whether they are true or false), and based on the values of each individual statement, returns true or false for that pair of statements. Here’s the table below:
When dealing with AND, both statements in a pair have to be to true in order for the statement pair to be true. If one or both statements are false, then the statement pair returns false. With OR however, only one statement has to be true for the pair to be true, but if both statements are false, then the pair is false. And as I mentioned earlier, NOT contradicts boolean statement(s), so if you not right by a boolean statement pair that is true, then that pair is false (and vice versa).
Let’s test this logic with an example program:
In this program I have two boolean statements (5 > 7) and (12 < 16). I then use System.out.println to test whether the statement pair greaterThan && lessThan is true or false. Since I used AND and one of the statements is false-greaterThan-both of the statements are false. Remember with AND, if one of the statements are false, then both are false.
Now let’s apply our knowledge of truth tables to more than two boolean statements:
When dealing with more than two boolean statements, logical evaluation is done from left to right. The Java compiler would first read the first pair of statements-greaterThan && lessThan-to evaluate whether that statement pair is true or false (it’s false). The compiler then takes the false result and compares it with the subtraction statement, which is true (thus statements 1-3 are collectively true). Finally, the compiler takes the collective true result from statements 1-3 and compares it with the multiplication statement, which is false. But, since OR is being used to compare the statements, you only need 1 true statement to result in true, which is the case here. After analyzing all 4 statements, the compiler states that the 4 statements together are collectively true.
Now, let’s analyze a program with several if options. In this program, you would type in a year, and the program will tell you what generation you belong to; keep in mind that the dates provided are just approximations, as different sources use different dates to mark the beginning and end of a generation. Here is the code:
package javalessons;
import java.util.Scanner;
public class JavaLessons
{
public static void main(String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.println (“Enter your birth year: “);
int year = sc.nextInt();
if (year >= 1900 && year <= 1928)
{
System.out.println(“You are part of the Greatest Generation”);
}
else if (year >= 1929 && year <= 1945)
{
System.out.println(“You are part of the Silent Generation”);
}
else if (year >= 1946 && year <= 1965)
{
System.out.println(“You are a Baby Boomer”);
}
else if (year >= 1966 && year <= 1981)
{
System.out.println(“You are a Gen-Xer”);
}
else if (year >= 1982 && year <= 2000)
{
System.out.println(“You are a Millenial”);
}
else if (year >= 2001 && year <= 2019)
{
System.out.println(“You are a Gen-Zer”);
}
else
{
System.out.println(“Invalid input”);
}
}
}
Please note that you will get a certain output (i.e. “You are a Millennial”) if both conditions are true; “You are a Millennial” will only print out if the year you typed is between 1982 and 2000.
Now let’s use the year 1946 (President Trump’s birth year):
run:
Enter your birth year:
1946
You are a Baby Boomer
BUILD SUCCESSFUL (total time: 3 seconds)
As you can see, 1946 corresponds to Baby Boomer, meaning President Trump is a Baby Boomer.
Now let’s try 1996 (my birth year):
run:
Enter your birth year:
1996
You are a Millenial
BUILD SUCCESSFUL (total time: 3 seconds)
According to the program, I am a millennial.
For those who want a video demo of the program, check this out-Generation program.
Now, a concept you should know that ties in with the material in this post is precedence. Precedence is similar to order of operations in the sense that both concepts involve doing things in a certain order. However, while order of operations just deals with arithmetic and exponents, precedence deals with arithmetic, comparison, and logical operators. With precedence, there is a certain order which the compiler evaluates statements with multiple arithmetic/comparison/logical operators. Here’s a handy guide:
First-the operators +,-,++,–, and !
The ++ and — operators represent incrementing and decrementing, respectively. These operators basically increase or decrease (or increment and decrement) a number by 1; you’ll see them more when I cover loops.
Second-the operators *, / and %
Third-the operators + and –
The plus and minus signs that take highest precedence actually refer to positive and negative numbers, while the one that are 3rd in precedence order actually refer to addition and subtraction
Fourth-the operators <, >, <= and >=
Fifth-the operators == and !=
Sixth-the operator &
Seventh-the operator |
Eighth- the operator &&
Ninth-the operator ||
The difference between the single & and || and the double && and || is that the former two are known as bitwise operators, which analyze data of types int, long, short, char, and byte bit by bit.
Check out this forum to learn more about bitwise operators-Bitwise Operators.
Keep in mind that parentheses ALWAYS take highest precedence (yes even higher than the operators listed as highest precedence). Any statements inside the parentheses are evaluated in order of operator precedence; if you’re dealing with parentheses-within-parentheses, the expression in the innermost set of parentheses is evaluated first, after which the compiler will work its way outward.
Here’s a series of statements; can you guess the result (true or false) based on precedence:
temperature = 44;
temperature – 2 < 32 || (temperature + 5 != 55) && temperature / 2 < 30
If you said true, you are right. Let me break it down:
The statement temperature + 5 != 55 is evaluated first, as it is in parentheses. It is true.
The next statement to be evaluated is temperature / 2 < 30, as it right by the && sign, which takes higher precedence than ||. That statement is also true, so that results, along with the true statement in parentheses, makes for a true statement pair.
The last statement to be evaluated is temperature - 2 < 32, since it’s right by the || sign. Even though this statement is false, the true statement pair to its right makes the whole group of statements collectively true (remember with OR, only one true makes for a collective true).