PYTHON DICTIONARY
CommentsData typesVariablesIf ElseIf Elif ElseFunctionsFor loopWhile loopData structuresString slicingUser defined functionLocal/Global variableValidation and TryMethodsFile I/OPseudocodeModules |
What is an If-Elif-Else statement?
Python challenge - If-Elif-Else statementEnter the following code in a Python code editor. Before running the code, what do you think it will do?. Press "F5" then "Enter" to run
Explanation:
The first line asks a user to enter an integer to answer the question. This number is then held within the variable called "litter". This value is then compared to the numbers pre-defined numbers in the "if" and "Elif" statements. If the number meets a condition, then that branch of the code is executed. Relational operatorsIn the example code above, two different relational operators are used, == and <=. Below is a list of relational operators that can be used in your code
|