<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Conditional_statements_with_if</id>
	<title>Conditional statements with if - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Conditional_statements_with_if"/>
	<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Conditional_statements_with_if&amp;action=history"/>
	<updated>2026-05-14T01:15:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://training-course-material.com/index.php?title=Conditional_statements_with_if&amp;diff=9206&amp;oldid=prev</id>
		<title>Kristian Rother at 20:09, 5 February 2013</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Conditional_statements_with_if&amp;diff=9206&amp;oldid=prev"/>
		<updated>2013-02-05T20:09:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Cat|Python Commands }}&lt;br /&gt;
{{Python Links}}&lt;br /&gt;
== Conditional statements with if ==&lt;br /&gt;
If statements are used to implement decisions and branching in the program. They must contain an &amp;#039;if&amp;#039; block, and optionally one or many &amp;#039;elif&amp;#039; and an &amp;#039;else&amp;#039; block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
if fruit == &amp;#039;apple&amp;#039;:&lt;br /&gt;
price = 0.55&lt;br /&gt;
elif fruit == &amp;#039;banana&amp;#039;:&lt;br /&gt;
price = 0.75&lt;br /&gt;
elif fruit == &amp;#039;orange&amp;#039;:&lt;br /&gt;
price = 0.80&lt;br /&gt;
else:&lt;br /&gt;
print &amp;#039;we dont have %s&amp;#039;%(fruit)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Boolean value of variables ==&lt;br /&gt;
Each variable can be interpreted as boolean logic. All values are treated as True, except for:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
False&lt;br /&gt;
0&lt;br /&gt;
[]&lt;br /&gt;
&amp;#039;&amp;#039;&lt;br /&gt;
{}&lt;br /&gt;
None&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code blocks ==&lt;br /&gt;
* After an if statement, all indented commands are treated as a code block, and are executed if the condition applies.&lt;br /&gt;
* The next unindented command Is executed in any case.&lt;br /&gt;
&lt;br /&gt;
== Comparison operators ==&lt;br /&gt;
An expression may contain any combination of:&lt;br /&gt;
&lt;br /&gt;
* a == b, a != b (equality)&lt;br /&gt;
* a &amp;lt; b, a &amp;gt; b, a &amp;lt;= b, a &amp;gt;= b (relations)&lt;br /&gt;
* a or b, a and b, not a (boolean logic)&lt;br /&gt;
* (a or b) and (c or d) (priority)&lt;br /&gt;
* a in b (inclusion, when b is a list)&lt;/div&gt;</summary>
		<author><name>Kristian Rother</name></author>
	</entry>
</feed>