News Ticker

Menu
Previous
Next

Latest Post

Computer IT

Multimedia

Programming

Recent Posts

While Loop In Python

October 23, 2015 / No Comments


Every programming languages provide different control structures. This can be useful for more complicated execution paths. The while loop in Python is used to iterate over a block of code as long as the test expression (condition) is true. 

A while loop repeats a statement or group of statements while a given condition is TRUE. It tests the condition before executing the loop body. In Python, the body of the while loop is determined through indentation. Body starts with indentation and the first unindented line marks the end. Python interprets any non-zero value as True. None and 0 are interpreted as False.




Understanding For Loop In Python

/ No Comments


A loop statement is important to execute a statement or group of statements more than one time. You can use the for loop in Python to iterate over an iterable objects. In programming iterating over a sequence process is called as traversal. The loop executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.

A for loop can also have an optional else block. The else part is executed if the items in the sequence used in for loop exhausts. break statement can be used to stop a for loop. In such case, the else part is ignored.







If-Else Statement In Python

/ No Comments


The if-else statement is used in Python for decision making process. Anyway , the decision making is required when we would like to execute a result only if a excact condition is completed.

Else statement can also be combined with if statement. An else statement contains the block of code that executes if the conditional expression in the if statement resolves to 0 or a FALSE value.

The else statement is an optional statement and there could be at most only one else statement following if .


Understanding Tuples In Python

/ No Comments


Tuple is sequence just the same way like lists. Otherwise the whole set of elements is enclosed in parentheses instead of square brackets, unlike list. The tuples cannot be changed unlike lists and tuples use parentheses, mean while lists use square brackets.

Tuples can be used for representing what other languages often call records, some related information that belongs together, like your employees record. There is no description of what each of these fields means, but we can guess.

Creating a tuple is as simple as putting different comma-separated values. Optionally you can put these comma-separated values between parentheses also.


Understanding Dictionaries In Python

October 22, 2015 / No Comments


A dictionary is similar to a list, but you access values by looking up a key instead of an index. A key can be any string or number. Dictionaries are enclosed in curly braces.

Keys are unique within a dictionary while values may not be. The values of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers, or tuples.