Difference between revisions of "Python Keywords, Concepts, Functions"
(→Commonly Used Functions) |
(→Sample Quiz) |
||
Line 49: | Line 49: | ||
=Sample Quiz= | =Sample Quiz= | ||
+ | ''An example quiz over this material. After watching the video and trying out yourself to make sure you understand.'' | ||
+ | |||
+ | Fill in the blank, what is the python operator for each of the following. | ||
+ | |||
+ | Fill in the blank, what is the python data type for each of the following. | ||
+ | |||
+ | Evaluate the given python expressions. |
Revision as of 16:28, 16 January 2020
See also Python Programming - Getting Started
Following are terse descriptions for Python3 keywords, programming concepts, and commonly used functions. For more information, see w3schools for a bit more explanation and python.org for the language reference.
Keywords
The following are heavily used in all levels of Python programming. This is a minimum set of keywords to know how to use.
break
- exit the current loopcontinue
- in a loop, go to next iteration of the loopis
- determine whether two objects are the same object (not just value)import, from
- to load a moduledef
- declare a functionwhile
- loop with only conditionif, elif, else
- conditional statements (three keywords)for
- loop with that iterates through a listreturn
- keyword to send a value back from a functionand
- boolean operator, True only if both sides are Trueor
- boolean operator, True if either side is Truenot
- boolean operator, negatesTrue, False
- boolean values (two keywords)del
- remove from a list by positiontry, except
- handle an exception, basic use (2 keywords)raise, assert
- raise/indicate an exception (2 keywords)in
- test if something is inside of a list/string/tuple/dictionaryNone
- special value for a variable that has no valuepass
- empty statement that does not do anything
More Keywords
These keywords are often not introduced or heavily used until the second Python course.
as, finally, with, else
- exception handling, more keywords (4 keywords)class
- defining new class data type (for object-oriented programming)lambda
- create unnamed / anonymous functionglobal, nonlocal
- access variables outside of current scope (2 keywords)async, await
- for writing asynchronous code with asynchio package (2 keywords)yield
- for creating generator functions
Concepts
These are terms that we use to describe programs. These are terms that have a precise meaning when talking about programs.
- string - text data type
- boolean - data type for True and False
- floating point - data type that stores numbers with fractional parts (e.g., 3.14 or 2.2)
- integer - data type that stores only integers
None
- a special value in Python that means "nothing" but is different than 0, False, and ""
Commonly Used Functions
print
- function to write to the screenint, float, str
- functions to convert to integer, floating point number, or stringrange
- function to generate a sequence of numberslen
- function to get the length of a string, list, or tuple
Sample Quiz
An example quiz over this material. After watching the video and trying out yourself to make sure you understand.
Fill in the blank, what is the python operator for each of the following.
Fill in the blank, what is the python data type for each of the following.
Evaluate the given python expressions.