NobleBlocks

Research indexBook chapter

Conditional Statements

Waters

Apress eBooks1 Jan 2021

DOI10.1007/978-1-4842-7064-6_4

Paywalled

The full text is at the publisher

You can read the abstract here, or open it at the publisher.

Read at the publisher

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.

Discussion

Topics

More

Suggest a correction or report