Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions 015-If Statements.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
#What are if statements?
If statements are used in python to tell python that if an argument is true,it should execute a set of instructions
Else it should execute another set of instructions.
If statements must be indented at the end of bracket ():
An example is illustrated below

#Using if statements
E.g to confirm a name that is (ibrahim) lets use an if statement
We first ask the user to input name
We then check if the name entered is ibrahim
The program should print(wrong name) if the name entered is not(ibrahim)
Soln
Line 1- Name=input('enter name:')
Line 2- if (Name=='ibrahim'):
Line 3- print('The name is',Name)
Line 4- else:
Line 5- print('wrong name')