Abstract
Conditional statements are used in code to compare variables or the result from several variables used in a sum or calculation. Conditional statements are used to do different things in your code depending on the values of variables. For example, if your script asks the player in a game if they want to walk into the left room or the right, you would read some input from the keyboard and then see what the player has typed. If they type “left,” then you will use a conditional statement to check if the input string variable equals “left.” If it does, then your code will jump to the code that defines what happens in the room to the left. If the input equals “right,” then the conditional statement will run the code that deals with what happens in the right-hand room. Using conditional statements essentially controls the flow of your code, what happens next when certain conditions are met.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2021 The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature
About this chapter
Cite this chapter
Waters, I. (2021). Conditional Statements. In: PowerShell for Beginners. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-7064-6_4
Download citation
DOI: https://doi.org/10.1007/978-1-4842-7064-6_4
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-7063-9
Online ISBN: 978-1-4842-7064-6
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)