Python Programming Tutorial For The Absolute Beginner + Code
- Description
- Curriculum
- FAQ
- Reviews
The creation of this course “Python Programming Tutorial For The Absolute Beginner + Code” has been for me an exciting personal journey in discovering how Python can be used today for procedural and object oriented programming, to develop applications and to provide online functionality.
Example code listed in this course “Python Programming Tutorial For The Absolute Beginner + Code” describes how to produce Python programs. I sincerely hope you enjoy discovering the exciting possibilities of Python, and have as much fun with it as I did in recording this course.
To get the most out of this course and have an amazing Python Programming journey, I invite you to take the lectures one by one and carefully watch me writing code examples, then please learn the specific concept exposed in the lecture by coding your self using the attached PDF file which contains specifically the word “instruction”; for example if you take the lecture “Writing lists” then use the attached PDF called “Writing lists instruction” to code yourself and learn how to write and manipulate lists in Python.
Learning Python programming from scratch isn’t easy, but not at all hard if you start your learning journey with the best python programming course. It’ll really help you learn python from scratch in easy step by step manner.
“Python Programming Tutorial For The Absolute Beginner” is a real opportunity for you to learn complex Python concepts by coding. The covers the followings:
- Employing variables
- Obtaining user input
- Correcting errors
- Doing arithmetic
- Assigning values
- Comparing values
- Assessing logic
- Examining conditions
- Setting precedence
- Casting data types
- Manipulating bits
- Writing lists
- Manipulating lists
- Associating list elements
- Branching with if
- Looping while true
- Looping over items
- Breaking out of loops
- Understanding functions scope
- Supplying arguments
- Returning values
- Using callbacks
- Adding placeholders
- Producing generators
- Handling exceptions
- Debugging assertions
- Importing modules
- Storing functions
- Owning function names
- Interrogating the system
- Performing mathematics
- Calculating decimals
- Telling the time
- Running a timer
- Matching patterns
- Managing strings
- Manipulating strings
- Formatting strings
- Modifying strings
- Converting strings
- Accessing files
- Reading and writing files
- Updating file strings
- Pickling data
- Encapsulating data
- Creating instance objects
- Addressing class attributes
- Examining built-in attributes
- Collecting garbage
- Inheriting features
- Overriding base methods
- Harnessing polymorphism
- Sending responses
- Handling values
- Submitting forms
- Providing text areas
- Checking boxes
- Choosing radio buttons
- Selecting options
- Uploading files
- Launching a window
- Responding to buttons
- Displaying messages
- Gathering entries
- Listing options
- Polling radio buttons
- Adding images
- Developing applications
- Generating random numbers
- Designing the interface
- Assigning static properties
- Initializing dynamic properties
- Adding runtime functionality
- Testing the program
- Installing a freezing tool
- Freezing the program
-
1Introducing PythonVideo lesson
Python is a high-level (human-readable) programming language that is processed by the Python “interpreter” to produce results.
Python includes a comprehensive standard library of tested code modules that can be easily incorporated into your own programs.
The Python language was developed by Guido van Rossum in the late eighties and early nineties at the National Research Institute for Mathematics and Computer Science in the Netherlands.
Python is derived from many other languages, including C, C++, the Unix shell and other programming languages.
Today, Python is maintained by a core development team at the Institute, although Guido van Rossum still holds a vital role in directing its progress.
The basic philosophy of the Python language is readability, which makes it particularly well-suited for beginners in computer programming, and it can be summarized by these principles
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Readability counts.
-
2The Challenge!Text lesson
-
3Installing Python on WindowsVideo lesson
Before you can begin programming in the Python language you need to installthe Python interpreter on your computer, and the standard library of tested code modules that comes along with it. This is available online as a free download from the Python website at https://python.org/downloads.
For Windows users there are installers available in both 32-bit and 64-bit versions
-
4Meeting the interpreterVideo lesson
The Python interpreter processes text-based program code, and also has an interactive mode where you can test snippets of code and is useful for debugging code. Python’s interactive mode can be entered in a number of ways:
From a regular Command Prompt – simply enter the command python to produce the Python primary prompt
From the Start Menu – choose “IDLE” (Python GUI) to launch a Python
Irrespective of the method used to enter interactive mode, the Python interpreter will respond in the same way to commands entered at its >>> primary prompt.
In its simplest form, the interpreter can be used as a calculator.
Enter Python interactive mode, using any method outlined opposite, then type a simple addition and hit Return to see the interpreter print out the sum total.
The Python interpreter also understands expressions, so parentheses can be used to give higher precedence – the part of the expression enclosed within parentheses will be calculated first.
-
5About ReviewsText lesson
-
6Writing your first programVideo lesson
Python’s interactive mode is useful as a simple calculator, but you can create programs for more extensive functionality.
A Python program is simply a plain text file script created with an editor, such as Windows’ Notepad, that has been saved with a “.py” file extension.
Python programs can be executed by stating the script file name after the python command at a terminal prompt. The traditional first program to create when learning any programming language simply prints out a specified greeting message.
In Python, the print() function is used to specify the message within its parentheses. This must be a string of characters enclosed between quote marks. These may be “ ” double quote marks or ‘ ’ single quote marks – but not a mixture of both.
-
7Hello WorldQuiz
-
8Employing variablesVideo lesson
In programming, a “variable” is a container in which a data value can be stored within the computer’s memory. The stored value can then be referenced using the variable’s name.
The programmer can choose any name for a variable, except the Python keywords listed on the inside front cover of this book, and it is good practice to choose meaningful names that reflect the variable’s content.
Data to be stored in a variable is assigned in a Python program declaration statement with the = assignment operator.
-
9VariablesQuiz
-
10Obtaining user inputVideo lesson
Just as a data value can be assigned to a variable in a Python script, a user-specified value can be assigned to a variable with the Python input() function.
This accepts a string within its parentheses that will prompt the user for input by displaying that string then wait to read a line of input.
User input is read as a text string, even when it’s numeric, and can be assigned to a variable using the = assignment operator as usual.
The value assigned to any variable can be displayed by specifying the variable name to the print() function –to reference that variable’s stored value.
Multiple values to be displayed can be specified to the print() function as a comma-separated list within its parentheses.
-
11Correcting errorsVideo lesson
In Python programming there are three types of error that can occur. It is useful to recognize the different error types so they can be corrected more easily:
Syntax Error – occurs when the interpreter encounters code that does not conform to the Python language rules.
For example, a missing quote mark around a string. The interpreter halts and reports the error without executing the program.
Runtime Error – occurs during execution of the program, at the time when the program runs.
For example, when a variable name is later mis-typed so the variable cannot be recognized. The interpreter runs the program but halts at the error and reports the nature of the error as an “Exception”.
Semantic Error – occurs when the program performs unexpectedly.
For example, when order precedence has not been specified in an expression. The interpreter runs the program and does not report an error.
Correcting syntax and runtime errors is fairly straightforward, as the interpreter reports where the error occurred or the nature of the error type, but semantic errors require code examination.
-
12SummaryVideo lesson
Python is a high-level programming language that is processed by the Python interpreter to produce results.
Python uses indentation to group statements into code blocks, where other languages use keywords or punctuation.
Python 2.7 is the final version of the 2.x branch of development, but the 3.x branch has the latest improvements.
Windows users can install Python with an installer, and Linux users can install Python with their package manager.
The Python interpreter has an interactive mode where you can test snippets of code and is useful for debugging code.
A Python program is simply a text file created with a plain text editor and saved with a “.py” file extension.
The Python print() function outputs the string specified within its parentheses.
String values must be enclosed between quote marks.
Where multiple versions of Python are installed on the same system it is important to explicitly call the desired interpreter.
A Python variable is a named container whose stored value can be referenced via that variable’s name
A Python variable can contain any data type but must be given an initial value when it is declared.
The Python input() function outputs the string specified within its parentheses,then waits to read a line of input.
Syntax errors due to incorrect code are recognized by the interpreter before execution of the program.
Runtime errors due to exceptions are recognized by the interpreter during execution of the program.
Semantic errors due to unexpected performance are not recognized by the interpreter.
-
13Doing arithmeticVideo lesson
The arithmetical operators commonly used in Python programming are listed in the table shown on the presentation of this lecture, together with the operation they perform:
The operators for addition, subtraction, multiplication, and division act as you would expect. Care must be taken, however, to group expressions where more than one operator is used to clarify the expression – operations within innermost parentheses are performed first.
-
14Assigning valuesVideo lesson
The operators that are used in Python programming to assign values are listed in the presentation of this lecture. All except the simple = assignment operator are a shorthand form of a longer expression, so each equivalent is given for clarity:
The += operator is useful to add a value onto an existing value that is stored in the a variable.
In the table example, the += operator first adds the value contained in variable a to the value contained in variable b. It then assigns the result to become the new value stored in variable a.
All the other operators work in the same way by making the arithmetical operation between the two values first, then assigning the result of that operation to the first variable – to become its new stored value.
With the %= operator, the first operand a is divided by the second operand b,then the remainder of that operation is assigned to the a variable.
-
15Comparing valuesVideo lesson
The operators that are commonly used in Python programming to compare two operand values are listed in the table below:
The == equality operator compares two operands and will return True if both are equal in value, otherwise it will return a False value. If both are the same number they are equal, or if both are characters their ASCII code values are compared numerically to achieve the comparison result.
Conversely, the != inequality operator returns True if two operands are not equal,using the same rules as the == equality operator, otherwise it returns False.
Equality and inequality operators are useful in testing the state of two variables to perform conditional branching in a program according to the result.
The > “greater than” operator compares two operands and will return True if the first is greater in value than the second, or it will return False if it is equal or less in value.
The < “less than” operator makes the same comparison but returns True if the first operand is less in value than the second, otherwise it returns False.
A > “greater than” or < “less than” operator is often used to test the value of an iteration counter in a loop. Adding the = operator after a > “greater than” or < “less than” operator makes it also return True if the two operands are exactly equal in value.
-
16Assessing logicVideo lesson
The logical operators most commonly used in Python programming are listed in the table on the presentation.
The logical operators are used with operands that have Boolean values of True or False, or are values that convert to True or False.
The (logical AND) and operator will evaluate two operands and return True only if both operands themselves are True. Otherwise the and operator will return False.
This is used in conditional branching where the direction of a program is determined by testing two conditions if both conditions are satisfied, the program will go in a certain direction, otherwise it will take a different direction. Unlike the and operator that needs both operands to be True, the (logical OR) or operator will evaluate its two operands and return True if either one of the operands itself returns True. If neither operand returns True, then the or operator will return False.
This is useful in Python programming to perform a certain action if either one of two test conditions has been met.
The (logical NOT) not operator is an operator that is used before a single operand. It returns the inverse value of the given operand, so if the variable a had a value of True then not a would have a value of False.
The not operator is useful in Python programs to toggle the value of a variable in successive loop iterations with a statement like a = not a.
This ensures that on each iteration of the loop, the Boolean value is reversed, like flicking a light switch on and off.
-
17Examining conditionsVideo lesson
Many programming languages, such as C++ or Java, have a ?: “ternary” operator that evaluates an expression for a True or False condition then returns one of two specified values depending on the result of the evaluation. A ?: ternary operator has this syntax:
( test-expression ) ? if-true-return-this : if-false-return-this
Unlike other programming languages, Python does not have a ?: ternary operator but has instead a “conditional expression” that works in a similar way using if and else keywords with this syntax:
if-true-return-this if ( test-expression ) else if-false-return-this
Although the conditional expression syntax can initially appear confusing, it is well worth becoming familiar with this expression as it can execute powerful program branching with minimal code.
For example, to branch when a variable is not a value of one:
if-true-do-this if ( var != 1 ) else if-false-do-this
The conditional expression can be used in Python programming to assign the maximum or minimum value of two variables to a third variable.
For example, to assign a minimum like this
c = a if ( a < b ) else b
The expression in parentheses returns True when the value of variable a is less than that of variable b – so in this case the lesser value of variable a gets assigned to variable c.
-
18Setting precedenceVideo lesson
Operator precedence determines the order in which the Python interpreter evaluates expressions. For example, in the expression 3 * 8 + 4 the default order of precedence determines that multiplication is completed first, so the result is 28 (24 + 4).
The table below lists operator precedence in descending order those on the middle row have highest precedence, those on lower rows have successively lower precedence. The precedence of operators on the same row is chained Left-To-Right:
-
19Casting data typesVideo lesson
Although Python variables can store data of any data type, it is important to recognize the different types of data they contain to avoid errors when manipulating that data in a program. There are several Python data types but byfar the most common ones are str (string), int (integer), and float (floating-point).
Data type recognition is especially important when assigning numeric data to variables from user input as it is stored by default as a str (string) data type.
String values cannot be used for arithmetical expressions as attempting to add string values together simply concatenates (joins) the values together rather than adding them numerically. For example ‘8’ + ‘4’ = ‘84’. Fortunately, the data type of stored values can be easily converted (“cast”) into a different data type using built-in Python functions. The value to be converted is specified within the parentheses that follow the function name. Casting str(string) values to become int (integer) values allows them to be used for arithmetical expressions, for example, 8 + 4 = 12.
Python’s built-in data type conversion functions return a new object representing the converted value, and those conversion functions most frequently used are listed in the presentation.
The Python built-in type() function can be used to determine to which data type class the value contained in a variable belongs, simply by specifying that variable’s name within its parenthesis.
-
20Manipulating bitsVideo lesson
In computer terms, each byte comprises eight bits that can each contain a 1 or a 0 to store a binary number, representing decimal values from 0 to 255.
Each bit contributes a decimal component only when that bit contains a 1. Components are designated right-to-left from the “Least Significant Bit” (LSB) to the “Most Significant Bit” (MSB). The binary number in the bit pattern below is 00110010 and represents the decimal number 50 (2+16+32):
It is possible to manipulate individual parts of a byte using the Python “bitwise” operators listed and described in the presentation.
Unless programming for a device with limited resources there is seldom a need to utilize bitwise operators, but they can be useful. For instance, the XOR (eXclusive OR) operator lets you exchange values between two variables without the need for a third variable.
-
21SummaryVideo lesson
Arithmetical operators can form expressions with two operands for addition+, subtraction -, multiplication *, division /, floor division //, modulo %, or exponent **.
The assignment = operator can be combined with an arithmetical operator to perform an arithmetical calculation then assign its result.
Comparison operators can form expressions comparing two operands for equality ==, inequality !=, greater >, lesser <, greater or equal >=, and lesser or equal <= values.
Logical and and or operators form expressions evaluating two operands to return a Boolean value of True or False.
The logical not operator returns the inverse Boolean value of a single operand.
A conditional if-else expression evaluates a given expression for a Boolean True or False value, then returns one of two operands depending on its result.
Expressions containing multiple operators will execute their operations in accordance with the default precedence rules unless explicitly determined by the addition of parentheses ( ).
The data type of a variable value can be converted to a different data type by the built-in Python functions int(), float(), and str() to return a new converted object.
Python’s built-in type() function determines to which data type class a specified variable belongs.
Bitwise operators OR |, AND &, NOT ~, and XOR ^ each return a value after comparison of the values within two bits, whereas the Shift left << and Shift right >> operators move the bit values a specified number of bits in their direction.
-
22Writing listsVideo lesson
In Python programming, a variable must be assigned an initial value (initialized) in the statement that declares it in a program, otherwise the interpreter will report a “not defined” error.
Multiple variables can be initialized with a common value in a single statement using a sequence of = assignments. For example, to simultaneously assign a common value to three variables:a = b = c = 10
Alternatively, multiple variables can be initialized with differing values in a single statement using comma separators.
For example, to simultaneously assign different values to three variables:a , b , c = 1 , 2 , 3
Unlike regular variables, which can only store a single item of data, a Python “list” is a variable that can store multiple items of data.
The data is stored sequentially in list “elements” that are index numbered starting at zero.
So the first value is stored in element zero, the second value is stored in element one, and so on. A list is created much like any other variable, but is initialized by assigning values as a comma-separated list between square brackets. For example, creating a list named “nums”, like this:nums = [ 0 , 1 , 2 , 3 , 4 , 5 ]
An individual list element can be referenced using the list name followed by square brackets containing that element’s index number. This means that nums[1] references the second element in the example above – not the first element, as element numbering starts at zero
Lists can have more than one index – to represent multiple dimensions, rather than the single dimension of a regular list. Multi-dimensional lists of three indices and more are uncommon, but two-dimensional lists are useful to store grid-based information such as X,Y coordinates.
A list of string values can even be considered to be a multi-dimensional list, as each string is itself a list of characters.
So each character can be referenced by its index number within its particular string.
-
23Manipulating listsVideo lesson
List variables, which can contain multiple items of data, are widely used in Python programming and have a number of “methods” that can be “dot-suffixed” to the list name for manipulation
Python also has a useful len(L) function that returns the length of the list L as the total number of elements it contains. Like the index() and count() methods, the returned value is numeric so cannot be directly concatenated to a text string foroutput. String representation of numeric values can, however, be produced by Python’s str(n) function for concatenation to other strings, which returns a string version of the numeric n value. Similarly, a string representation of an entire list can be returned by the str(L) function for concatenation to other strings. In both cases, remember that the original version remains unchanged as the returned versions are merely copies of the original version. Individual list elements can be deleted by specifying their index number to the Python del(i) function.
This can remove a single element at a specified i index position, or a “slice” of elements can be removed using slice notation i1:i2 to specify the index number of the first and last element. In this case, i1 is the index number of the first element to be removed and all elements up to, but not including, the element at the i2 index number will be removed.
-
24Restricting ListsVideo lesson
Tuple
The values in a regular list can be changed as the program proceeds (they are “mutable”), but a list can be created with fixed “immutable” values that cannot be changed by the program. A restrictive immutable Python list is known as a “tuple” and is created by assigning values as a comma-separated list between parentheses in a process known as “tuple packing”: colors-tuple = ( ‘Red’ , ‘Green’ , ‘Red’ , ‘Blue’, ‘Red’ )
An individual tuple element can be referenced using the tuple name followed by square brackets containing that element’s index number.
Usefully, all values stored inside a tuple can be assigned to individual variables in a process known as “sequence unpacking”: a , b , c , d , e = colors-tuple
Set
The values in a regular list can be repeated in its elements, as in the tuple above, but a list of unique values can be created where duplication is not allowed.
A restrictive Python list of unique values is known as a “set” and is created by assigning values as a comma-separated list between curly brackets (braces): phonetic-set = { ‘Alpha’ , ‘Bravo’ , ‘Charlie’ }
Individual set elements cannot be referenced using the set name followed by square brackets containing an index number, but instead sets have methods that can be dot-suffixed to the set name for manipulation and comparison
-
25Associating list elementsVideo lesson
In Python programming a “dictionary” is a data container that can store multiple items of data as a list of key:value pairs. Unlike regular list container values, which are referenced by their index number, values stored in dictionaries are referenced by their associated key. The key must be unique within that dictionary, and is typically a string name although numbers may be used. Creating a dictionary is simply a matter of assigning the key:value pairs as a comma-separated list between curly brackets (braces) to a name of your choice.
Strings must be enclosed within quotes, as usual, and a : colon character must come between the key and its associated value.
A key:value pair can be deleted from a dictionary by specifying the dictionary name and the pair’s key to the del keyword.
Conversely, a key:value pair can be added to a dictionary by assigning a value to the dictionary’s name and a new key.
Python dictionaries have a keys() method that can be dot-suffixed to the dictionary name to return a list, in random order, of all the keys in that dictionary.
If you prefer the keys to be sorted into alphanumeric order, simply enclose the statement within the parentheses of the Python sorted() function.
A dictionary can be searched to see if it contains a particular key with the Python in operator, using the syntax key in dictionary. The search will return a Boolean True value when the key is found in the specified dictionary, otherwise it will return False.
Dictionaries are the final type of data container available in Python programming. In summary, the various types are:
Variable – stores a single value.
List – stores multiple values in an ordered index.
Tuple – stores multiple fixed values in a sequence.
Set – stores multiple unique values in an unordered collection.
Dictionary – stores multiple unordered key:value pairs.
-
26If StatementVideo lesson
The Python if keyword performs the basic conditional test that evaluates a given expression for a Boolean value of True or False. This allows a program to proceed in different directions according to the result of the test, and is known as “conditional branching”.
The tested expression must be followed by a : colon, then statements to be executed when the test succeeds should follow below on separate lines, and each line must be indented from the if test line. The size of the indentation is not important, but it must be the same for each line. So the syntax looks like this:
if test-expression :
statements-to-execute-when-test-expression-is-True
statements-to-execute-when-test-expression-is-True
Optionally, an if test can offer alternative statements to execute when the test fails by appending an else keyword after the statements to be executed when the test succeeds.
The else keyword must be followed by a : colon and aligned with the if keyword, but its statements must be indented in a likewise manner, so its syntax looks like this:
if test-expression :
statements-to-execute-when-test-expression-is-Truestatements-to-execute-when-test-expression-is-True
else:
statements-to-execute-when-test-expression-is-Falsestatements-to-execute-when-test-expression-is-False
An if test block can be followed by an alternative test using the elif keyword (“else if ”) that offers statements to be executed when the alternative test succeeds. This too must be aligned with the if keyword, followed by a : colon,and its statements indented.
A final else keyword can then be added to offer alternative statements to execute when the test fails.
The syntax for the complete if-elif-else structure looks like this:
if test-expression-1 :
statements-to-execute-when-test-expression-1-is-True
statements-to-execute-when-test-expression-1-is-True
elif test-expression-2 :
statements-to-execute-when-test-expression-2-is-True
statements-to-execute-when-test-expression-2-is-True
else :
statements-to-execute-when-test-expressions-are-False
statements-to-execute-when-test-expressions-are-False
-
27While LoopVideo lesson
A loop is a piece of code in a program that automatically repeats. One complete execution of all statements within a loop is called an “iteration” or a “pass”.
The length of the loop is controlled by a conditional test made within the loop. While the tested expression is found to be True, the loop will continue until the tested expression is found to be False, at which point the loop ends.
In Python programming, the while keyword creates a loop. It is followed by the test expression then a : colon character. Statements to be executed when the test succeeds should follow below on separate lines, and each line must be indented the same space from the while test line. This statement block must include a statement that will at some point change the result of the test expression evaluation – otherwise an infinite loop is created.
Loops can be nested, one within another, to allow complete execution of alliterations of an inner nested loop on each iteration of the outer loop.
A “counter” variable can be initialized with a starting value immediately before each loop definition, included in the test expression, and incremented on each iteration until the test fails at which point the loop ends.
-
28Looping over itemsVideo lesson
In Python programming, the for keyword loops over all items in any list specified to the in keyword. This statement must end with a : colon character, and statements to be executed on each iteration of the loop must be indented below, like this:
for each-item in list-name :
statements-to-execute-on-each-iterationstatements-to-execute-on-each-iteration
As a string is simply a list of characters, the for in statement can loop over each character. Similarly, a for in statement can loop over each element in a list, each item in a tuple, each member of a set, or each key in a dictionary. A for in loop iterates over the items of any list or string in the order that they appear in the sequence, but you cannot directly specify the number of iterations to make, a halting condition, or the size of iteration step. You can, however, use the Python range() function to iterate over a sequence of numbers by specifying a numeric end value within its parameters. This will generate a sequence that starts at zero and continues up to, but not including, the specified end value. For example, range(5) generates 0,1,2,3,4.
Optionally, you can specify both a start and end value within the parentheses of the range() function, separated by a comma. For example, range(1,5) generates1,2,3,4.
Also, you can specify a start value, end value, and a step value to the range() function as a comma-separated list within its parentheses. For example,range(1,14,4) generates 1,5,9,13.
You can specify the list’s name within the parentheses of Python’s enumerate() function to display each element’s index number and its associated value.
When looping through multiple lists simultaneously, the element values of the same index number in each list can be displayed together by specifying the list names as a comma-separated list within the parentheses of Python’s zip()function.
When looping through a dictionary you can display each key and its associated value using the dictionary items() method and specifying two comma-separated variable names to the for keyword one for the key name and the other for its value.
-
29Breaking out of loopsVideo lesson
The Python break keyword can be used to prematurely terminate a loop when a specified condition is met. The break statement is situated inside the loop statement block and is preceded by a test expression. When the test returns True, the loop ends immediately and the program proceeds on to the next task. For example, in a nested inner loop it proceeds to the next iteration of the outer loop.
-
30SummaryVideo lesson
In Python, multiple assignments can be used to initialize several variables in a single statement.
A Python list is a variable that can store multiple items of data in sequentially-numbered elements that start at zero.
Data stored in a list element can be referenced using the list name followed by an index number in [ ] square brackets.
The len() function returns the length of a specified list.
A Python tuple is an immutable list whose values can be assigned to individual variables by “sequence unpacking”.
Data stored in a tuple element can be referenced using the tuple name followed by an index number in [ ] square brackets.
A Python set is an unordered collection of unique elements whose values can be compared and manipulated by its methods.
Data stored in a set cannot be referenced by index number.
A Python dictionary is a list of key:value pairs of data in which each key must be unique.
Data stored in a dictionary element can be referenced using the dictionary name followed by its key in [ ] square brackets.
The Python if keyword performs a conditional test on an expression for a Boolean value of True or False.
Conditional branching provides alternatives to an if test with the else and elif keywords.
A while loop repeats until a test expression returns False.
A for in loop iterates over each item in a specified list or string.
The range() function generates a numerical sequence that can be used to specify the length of a for in loop.
The break and continue keywords interrupt loop iterations.
-
31Mid-Term ExamQuiz
Check Your Progress!
-
32Understanding scopeVideo lesson
-
33Supplying argumentsVideo lesson
-
34Returning valuesVideo lesson
-
35Using callbacksVideo lesson
-
36Adding placeholdersVideo lesson
-
37Producing generatorsVideo lesson
-
38Handling exceptionsVideo lesson
-
39Debugging assertionsVideo lesson
-
40SummaryVideo lesson
-
41Storing functionsVideo lesson
-
42Owning function namesVideo lesson
-
43Interrogating the systemVideo lesson
-
44Performing mathematicsVideo lesson
-
45Calculating decimalsVideo lesson
-
46Telling the timeVideo lesson
-
47Running a timerVideo lesson
-
48Matching patternsVideo lesson
-
49SummaryVideo lesson
-
50Manipulating stringsVideo lesson
-
51Formatting stringsVideo lesson
-
52Modifying stringsVideo lesson
-
53Converting stringsVideo lesson
-
54Accessing filesVideo lesson
-
55Reading and writing filesVideo lesson
-
56Updating file stringsVideo lesson
-
57Pickling dataVideo lesson
-
58SummaryVideo lesson
-
59Encapsulating dataVideo lesson
-
60Creating instance objectsVideo lesson
-
61Addressing class attributesVideo lesson
-
62Examining built-in attributesVideo lesson
-
63Collecting garbageVideo lesson
-
64Inheriting featuresVideo lesson
-
65Overriding base methodsVideo lesson
-
66Harnessing polymorphismVideo lesson
-
67SummaryVideo lesson

External Links May Contain Affiliate Links read more