I think this topic is not difficult to understand and to pick up. The important to know of programming is how to construct a statement. Knowing the operators and operands to do mathematical operations. The expression is easy as we do a sum like 1 + 1.
If you are new landed here in my blog I suggest you visit my old post.
Programming is not to difficult if you understand the foundation. I the beginning of my learning how to make a program. I was struggling to learn and I do know how to start. What I have to focus to start to write a line of code.
The most important when you learned one thing. Like how to store a value to a variable. You should practice this every time. I think learning base to the theory you will not be capable to write your own program. Therefore, it is important to practice, practice, and practice. Start with a small program. You may search using Google. How to get input from the keyboard in Python.
I will do an easy example here.
The first line of the code I want to display “Welcome!” strings. As you can see with the blue characters. With the input() function I can get the user name input from the keyboard. Then print some hello message to the user. I can print the string inside the quotes and the variable. Remember to the comma after the quotes of the string to write a variable inside the parenthesis.
What are the statements?
The statement in programming language is a unit of code that the Python interpreter can execute. The example above I wrote a print function and variable assignment. The lines of code I wrote are statements.
A script usually contains a sequence of statements. When you write the statements you should write it one per line. Therefore, the interpreter can execute easily one by one.
Let see another example of a statement.
Operators and operands
I know for sure in the school we studied what are operators. If you do not know what is operators. Please check some math book. Operators are symbols that represent computation or operation like addition and multiplication. The operands are the values that we want to retrieve the result computation.
Let’s do some use of operators.
Easy right! Oops! I have an error in my interpreter. The interpreter tells us that we have a syntax error and part where is it. I have written an old post about errors in programming. I suggest you read and familiarized. Identifying errors or bug is part of programming.
Python: A review of my programming knowledge about Python programming language from zero point one – Part II
What is expression?
Above we learn how to use operators in the Python interpreter or the IDLE program. Likewise, an expression is a combination of values, variables, and operators.
We assign a variable with a value like this x = 1 the value is the number 1. To complete the expression we need to do a computation like adding 5 to the variable x like this x + 5. The expressions x + 5 is equal to 6.
Go to the IDLE and practice.