Python Programming: A Short and to the Point Guide to Learn Python for Beginners by Roberts Noah

Python Programming: A Short and to the Point Guide to Learn Python for Beginners by Roberts Noah

Author:Roberts, Noah [Roberts, Noah]
Language: eng
Format: epub
Published: 2020-11-24T16:00:00+00:00


The identifier should be descriptive – you should pick out name that is going to describe what it does.

Python is a case sensitive language. Which means, Variable and variable are different. Always give the identifiers a name which makes sense. While c = 10 is a valid name, writing count = 10 is going to make more sense, and is it also going to be a lot easier to figure out what it means when you look at your code after a long time. Multiple words can be separated using an underscore, like this_is_a_long_variable.

Flow of Control

The Control Flow of a program is the order in which the code executes. It is monitored and controlled by conditional statements/decision making statements, loops and function calls. In a program control flow mainly depends upon the conditional statements, control statements and loop statements.

Since ​ Python is an interpreter, the code is executed line by line. It is called sequential execution. The conditional statements are used to execute code only when a certain condition is satisfied. Python have decision making statements like if, if-else and elif.

The if statement is used to execute statement(s) only if certain condition is satisfied. If the If statement is not executed the the If-else statement, followed by execution of the elif statement.

Loop statements are used to execute a statement or group of statements repeatedly either number of times or till a particular condition is satisfied. Python have two loop statements for and while.

The for-loop statement is used to iterate in a sequence. In each iteration we can iterate over the sequence one by one, and then executes the statements in the body. The loop finishes when the last element in the sequence is reached or any other condition is met. The while loop statement is used to repeat a statement or group of statements till a particular condition satisfy. Statements of this loop will execute till expression is true.

Control Statements are used to decide to give control of the execution to some parts of the code. Break statement is used to terminate the loop execution immediately. Continue statement is used to skip the loop single statement or group of statements execution for certain iteration(s). Loop does not terminate; it continues with the next iteration.

Semi-colons and Indentation

When you check out other computer languages, you will see that a lot of curly brackets have been used to arrange the different blocks of code or to begin and end the statements. This way, it is easy to remember to indent the code blocks in these languages to make the code easier to read, although the computer can read the code without indentations pretty fine.

A coding like this can be very difficult to read. You will see that the computer needs a lot of unnecessary information to read the code but that makes it difficult for the human eye to read it. But Python has a different way to do this, just to make it easier for the human eye to read what you have.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.