Anonymous
Not logged in
Talk
Contributions
Create account
Log in
WikiKnowledgeBase
Search
Editing
Technology/Software Development/General knowledge/Programming Fundamentals/Control Structures
(section)
From WikiKnowledgeBase
Namespaces
Page
Discussion
More
More
Page actions
Read
Edit
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Conditional Control Structures == '''Definition''' Conditional control structures allow you to make decisions within a program by evaluating a condition and executing different blocks of code based on whether the condition is true or false. '''If-Else Statements''' The if-else statement is one of the most common conditional control structures. It evaluates a condition and executes specific code blocks based on the result. '''Code Example''' Here's an example in Python that demonstrates the usage of if-else statements: <pre> # Conditional control structure age = 18 # If-else statement if age >= 18: print("You are an adult.") else: print("You are a minor.") </pre> In this example, we use an if-else statement to check if the `age` variable is greater than or equal to 18. If the condition is true, the program will output `"You are an adult."` Otherwise, it will output `"You are a minor."`.
Summary:
Please note that all contributions to WikiKnowledgeBase may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
My wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation
Navigation
Main page
Random page
Categories
Help about MediaWiki
Wiki tools
Wiki tools
Special pages
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs