Python For Loops
Python For Loops A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). This is less like the for keyword in otherRead More…
Python For Loops A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). This is less like the for keyword in otherRead More…
A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression. Syntax lambda arguments : expression The expression is executed and the resultRead More…
Python Loops Python has two primitive loop commands: while loops for loops The while Loop With the while loop we can execute a set of statements as long as a condition is true. Example Print iRead More…
Python Conditions and If statements Python supports the usual logical conditions from mathematics: Equals: a == b Not Equals: a != b Less than: a < b Less than or equal to: a <= b GreaterRead More…
Dictionary A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values. Example Create and print a dictionary:Read More…
Set A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets. Example Create a Set: thisset = {“apple”, “banana”, “cherry”} print(thisset) Output Note: SetsRead More…
Tuple A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets. Example Create a Tuple: thistuple = (“apple”, “banana”, “cherry”) print(thistuple) Output Access TupleRead More…
Python Collections (Arrays) There are four collection data types in the Python programming language: List is a collection which is ordered and changeable. Allows duplicate members. Tuple is a collection which is ordered andRead More…
Python Operators Operators are used to perform operations on variables and values. Python divides the operators in the following groups: Arithmetic operators Assignment operators Comparison operators Logical operators Identity operators Membership operatorsRead More…
String Literals String literals in python are surrounded by either single quotation marks, or double quotation marks. ‘hello’ is the same as “hello”. Strings can be output to screen using the print function. ForRead More…