Use of the conditional “if” Use of “else” with a conditional
Use of conditionals in python 3.
Use of conditionals in python 3.
Hello! Here is my #Mastery16 that is about using else in conditionals. An else statement is used on conditional to set the false part. If a value that is introduced does not fulfill the true condition, there is when the else takes part in the process. This is used to have a response to a false condition.
For example:
If you want to create a simple program for grading, that describes when a student is approved or has failed the semester, this program would have to make the sum of the three partials and calculate the average. Let´s say the approbatory grade is 70. To start, you can begin it in many ways. I would choose to do it with an if condition.
The goal here is for the program to print the phrase approved or failed depending on the sum of the partial grades. This program, of course, to proof the use of the else statement.
To begin, we would have to type what we regularly do in all of the coding processes.
using namespace std;
Then, we would have to begin with the input of each one of the partials. For the program to get the average of the three and then with an if condition, tell if the student is approved or has failed.
The code would be:
Remember that to use an else statement you have to make use of the conditional with the true condition. Al else has to follow a conditional to work. When you write an else, the response has to be following the else in between braces, this helps the condition to realize what to execute when the false condition is applied. For example:
If(average>=7){
cout
}
else {
cout
}
Remember to always make use of the correct punctuation, spaces and symbols for the code. The semicolon is very important to be included at the end of each line (That is my most common mistake).
Here is the running program. As you can see, I used the else statement to print the string when the student failed.
Tip: if your program does not work when you are trying to compile do not freak out, the compiler will try to tell you what he doesn’t understand. Here is an example of an error, the numbers show the line and the number of character in which the error is placed.
The compiler says there is a semicolon missing in line 5 space 31…
Remember to check #Mastery15 to learn how to use if conditionals.
96
Normal
0
21
false
false
false
ES-TRAD
X-NONE
X-NONE
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
WATCH MY VIDEO https://youtu.be/951plPJV2VE
“If” is really simple. You write a parameter with variables such that if thats true, the program does something. The “else” makes it so that of the parameters of the conditional aren’t met, the program does something else. And an “elif” is like an “else” but with a conditional. Here’s an example.
Here is my SECOND video about the masteries.
Hope it helps.
It’s about:
- Use of the conditional “if”
- Use of “else” with a conditional
Esta es otra forma de utilizar condicional. Condicional alternativa. En esta se presentan dos posibilidades y la condición determina cual se ejecuta, así como también qué aparecer o hacer con los valores restantes que no aparecen en la condición. Agregar… Continue Reading →
Hey today we are going to learn how to use conditions in Pythons 3 : Use of the conditional “if” Use of “else” with a conditional Use of “elif” with a conditional #Mastery15/16/17 : Have a good day !
Here I will show you that I know how to use IF and ELSE stamentes.This is the basic form, I put it simple to understand the syntax quickly. Here are some works that I made using IF and ELSEs.If you want to know more check my WSQs.