1.5 KiB
This exercise include some programming concept we had encountered from chapter one to eight: line one is a global variable the hash sign before the value in our function body represent comment..."which mean the program should ignore and execute the follow code.
in python each variable belong to a particular data type. "Note" it key to understand type data because some operator don't work with all data type, Note line one is a integer and also a global variable that can be called from any part of the program line four in our function body is a string data type and consider as a local variable because it defined in the function.
line two: is a function and in python to declare a funcntion we use the reserve keyword "def" The name of the function is called (user_request) the value in the open and closed parenthesis is called parameter.
So in this exercise I created a function that will validate the user input. To do so we need to understand operators in python and their function. some operator use in this program are assignment operator = condition operator if, elif arithemtic operator * comparison operator ==
This program is only build to accept numerical value if I enter letter or special character the program will crash....
Which is not a good sound for our program. In the next step we need to add validation to our program to prevent our program from crashing. But for now use only number... In the next present we will talk about nested condition and in build function that can be use to prevent the program from crashing.
Questions