Python Looping
In the previous post, we covered conditional statements in Python. In this post, we will be covering various looping constructs in Python. Like conditional statements, statements within loops are also distinguished by Python based on indentation. for loop A for loop is used to iterate over a fixed number of items (i.e., you (or at least the program) know(s) the number of items before entering into the loop). The for loop in Python can be used to iterate over any of the sequence data types which have an iterable method including strings (though they don鈥檛 have an iterable method)....
Conditional statements in Python
In one of the previous posts, we had explored the logical operators in Python. Logical operators alone cannot help much as they return only True or False. However, practically, logical operators are used in combination with conditional statements or looping statements. In this post, we would be exploring conditional statements in Python. A note on indentation Going forward from here, Python interprets the statements within a conditional statement, looping statement or a function based on indentation....
Key Math functions in Python
In an earlier post, we have learnt some of the basic mathematical operators in Python. In this post we will cover some of the key mathematical functions in Python which provide access to more mathematical operations in Python. Built-in functions The following mathematical functions are built-in and can be accessed directly: Function name Description abs(x) Returns the absolute value of a number (i.e., x). x may be an integer or a floating point number....
Basic command line input and output in Python
In the previous posts, we have covered basic concepts in Python. Now, it鈥檚 time to see some basic input and output through the command line in Python. Output in Python You鈥檝e probably already learnt to print your output on the terminal by using the print() function. This section covers some further aspects of the print function and some basic formatting while printing output on the terminal. Printing a blank line You can just use print() without any arguments when you want to print a blank line on the terminal for better visibility....
Key Concepts in Python
In the previous post, we saw what is Python, how to install and wrote a basic Hello World program. This post aims to explain some key concepts in Python including variables, operators and data types. Keywords Like any other programming language, Python also has certain keywords. Keywords are reserved words in a programming language which have a special meaning and cannot be used for user defined purposes such as naming variables, functions etc....