Professional Documents
Culture Documents
Lecture 4
Lecture 4
LECTURE 4
Input/Output Prompt
Control Statements
Loop Statements
University of Dar es Salaam
THE INPUT PROMPT
• The input function is used for requesting for users for prompt
inputs from keyboard
• Syntax
x=input(‘enter value of x ’)
• Displays the text in prompt and waits for the user to input a
value and press the Return key
University of Dar es Salaam
THE INPUT PROMPT
Example
University of Dar es Salaam
DISPLAY FUNCTIONS
Examples..
University of Dar es Salaam
IF, ELSE, ELSEIF
Examples..
University of Dar es Salaam
IF, ELSE, ELSEIF
Examples..
University of Dar es Salaam
SWITCH, CASE, OTHERWISE
Syntax…
• Execute one of several groups switch expression
of statements case expression
statements
• Switch expression must be a case expression
scalar or string constant statements
otherwise
statements
end
University of Dar es Salaam
SWITCH, CASE, OTHERWISE
• Example