Block and Indentation

CodesΒ 
canΒ 
beΒ 
writtenΒ 
insideΒ 
blocks.Β 
SoΒ 
pythonΒ 
runsΒ 
onlyΒ 
aΒ 
particularΒ 
blockΒ 
ofΒ 
code
.
Indentation
Β 
refersΒ 
toΒ 
aΒ 
fixedΒ 
amountΒ 
ofΒ 
spaceΒ 
addedΒ 
atΒ 
theΒ 
beginningΒ 
ofΒ 
theΒ 
codeΒ 
thatΒ 
indicatesΒ 
aΒ 
particularΒ 
blockΒ 
ofΒ 
code.

if else block

TheΒ 
if-elseΒ 
statementΒ 
inΒ 
PythonΒ 
executesΒ 
eitherΒ 
theΒ 
TrueΒ 
orΒ 
theΒ 
FalseΒ 
partΒ 
ofΒ 
aΒ 
givenΒ 
condition.
IfΒ 
theΒ 
conditionΒ 
isΒ 
True
,Β 
theΒ 
ifΒ 
blockΒ 
executes
,Β 
andΒ 
ifΒ 
theΒ 
conditionΒ 
isΒ 
False
,Β 
theΒ 
elseΒ 
blockΒ 
executes
.
ItΒ 
isΒ 
notΒ 
necessaryΒ 
toΒ 
haveΒ 
anΒ 
elseΒ 
condition.
if condition1:
   Statement1
else:
   Statement2
number = 99
if number>0:
   print("Positive Number")
else:
   print("Negative Number")

Flowchart

ItΒ 
isΒ 
aΒ 
diagram
Β 
showingΒ 
theΒ 
flowΒ 
ofΒ 
theΒ 
program.
ItΒ 
isΒ 
aΒ 
blueprint
Β 
ofΒ 
theΒ 
programΒ 
written.
CertainΒ 
shapesΒ 
areΒ 
usedΒ 
toΒ 
drawΒ 
flowcharts,Β 
andΒ 
theseΒ 
shapesΒ 
haveΒ 
theΒ 
meaningΒ 
asΒ 
follows.
Oval
Β 
-Β 
Start/Stop
Rectangle
Β 
-Β 
ToΒ 
performΒ 
assignmentΒ 
statements
Parallelogram
Β 
-Β 
ToΒ 
takeΒ 
inputΒ 
andΒ 
useΒ 
printΒ 
commands
Diamond
Β 
-Β 
ToΒ 
evaluateΒ 
aΒ 
condition
Arrows
Β 
-Β 
ToΒ 
showΒ 
theΒ 
flowΒ 
ofΒ 
theΒ 
program
CheatSheet