What Is It In Code? Flashcards
Addition
+
E.g 2+2
And
And
Division
/
E.g 2/6
Less than
<
Less than or equal to
<=
Greater than
>
Greater than or equal to
> =
Not equal to
!=
Equal to
==
Multiplication
*
E.g 4*4
Modulus
%
Not
Not
Or
Or
Parens
( )
String
Str
Subtraction
E.g 6-4
Truncating division
/ /
Unary Operations
-X, +X
A unary operator is an operator which works on a single operand. Python support unary minus operator(-). When an operand is preceded by a minus sign, then the unary operator negates its value. For example, if a number is positive, it becomes negative when the number is preceded by the unary operator.
A real value (decimal) or a
Floating-point number
Float
A number with no decimal (integer)
Int
A dictionary (A set of key, value pairs)
Dict
How do you initiate using the REPL “Read-Eval-Print-Loop”
To use the REPL, type python in your console. You will get is a prompt similar to the below output, which then waits for you to input commands:
Output
Python 3.9.5 (default, May 27 2021, 19:45:35)
[GCC 9.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
»>
The REPL has a built-in help function you can use to look up keywords and functions.
E.g If object was a specific function or keyword you wanted help on what would you type into the console?
The generalized syntax for this function is:
help([object])
Where [object] is a specific function or keyword you want help on.
Template:
help([ ])
How do you enter the interactive help console without inputting the help option (Python)?
help()
If you don’t pass an argument to the help function, Python will start an interactive help.
You enter the interactive help console by typing help(). This command will list some basic instructions on how to use the help system.
From here, you can just type in the element you’re interested in. By, for example, typing string will display information about the topic string, which looks something like this:
Output
Copy Help on module string:
NAME
string - A collection of string constants.
MODULE REFERENCE
https://docs.python.org/3.5/library/string.html
The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.
REPL commands:
When there is more than one page of output, you can press _____ to display line-by-line, or _____ to go page-by-page.
Enter
Space
REPL commands:
At the end of the help screen, you can type _ to exit the page. You will be returned to the interactive help prompt.
q