-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol structures.html
More file actions
117 lines (96 loc) · 4.25 KB
/
Copy pathcontrol structures.html
File metadata and controls
117 lines (96 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="en">
<head>
<title>Control Structures</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<style>
.fakeimg {
height: 400px;
width: 250px;
background: #aaa;
}
</style>
</head>
<body>
<div class="jumbotron text-center" style="margin-bottom:0">
<h1>PyWORLD</h1>
</div>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">PyWORLD</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li ><a href="index.html">Home</a></li>
<li ><a href="basics in python.html">Basics in python</a></li>
<li><a href="loops.html">Loops</a></li>
<li class="active"><a href="control structures.html">Control structures</a></li>
<li><a href="datatypes.html">Datatypes</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-sm-4">
<h3>Some topics in Control Structures</h3>
<ul class="nav nav-pills nav-stacked">
<li class="active"><a href="control structures.html">if-elif-else statements</a></li>
<li ><a href="nested if.html">Nested if statements</a></li>
<li ><a href="continue-break.html">Continue-Break statements</a></li>
</ul>
<hr class="hidden-sm hidden-md hidden-lg">
</div>
<div class="col-sm-8">
<h2>If and else statements</h2>
<div class="fakeimg">
<img src="img\if-else.jpg" width="100%" height="100%" ><br>
</div>
<b>if-else statements:</b>
<p> The if statement alone tells us that if a condition is true it will execute a block of statements and if the condition is false it won’t. But what if we want to do something else if the condition is false. Here comes the else statement. We can use the else statement with if statement to execute a block of code when the condition is false.</p>
<b>Syntax:</b>
<pre>if (condition):
# Executes this block if
# condition is true
else:
# Executes this block if
# condition is False</pre>
<br>
<iframe src="https://trinket.io/embed/python3/64aee30379" width="100%" height="356" frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>
<b>if-elif-else:</b>
<p>Here, a user can decide among multiple options. The if statements are executed from the top down. As soon as one of the conditions controlling the if is true, the statement associated with that if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then the final else statement will be executed.</p>
<b>Syntax:</b>
<pre>if (condition):
statement
elif (condition):
statement
.
.
else:
statement
</pre><br>
<iframe src="https://trinket.io/embed/python3/73223ed592" width="100%" height="356" frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe><br><br>
<b>Recommended video</b><br><br>
<iframe width="560" height="315" src="https://www.youtube.com/embed/42MBMSOZgD4" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
<div class="jumbotron text-center" style="margin-bottom:0">
<h3>PyWORLD</h3>
<font align="left">Banashankari 3rd stage,</font><br>
<font align="left">Banashankari,</font><br>
<font align="left">Bangalore 560 085.</font><br>
<font align="left">Contact us at +91 7981451469.</font>
</div>
</body>
</html>