Please enable JavaScript.
Coggle requires JavaScript to display documents.
PYHTON PART 1 - Coggle Diagram
PYHTON PART 1
-
Module 2
S1: Hello, World!
- The
print() function is a built-in function. it prints/outputs a specified message to the screen/console window.
- Built-in functions are always available and don't have to be imported.
- Python 3.8 comes with 69 built-in functions, here
- To call/invoke a function you need to use the
function name followed by ()
-
- Computer programs are collections of instructions. An instruction is a command to preform a specific task when executed
- e.g., to print a certain message to the screen
- In Python strings, the backslash (
\) is a special character which announces that the next character has a different meaning
- e.g.,
\n (newline character) starts a new output line.
- Positional Arguments are the ones whose meaning is dictated by their position.
- e.g., the
2nd argument is outputted after the 1st, then the 3rd after the 2nd, so on n' so forth.
- Keyword Arguments are the ones whose meaning is not dictated by their location, but by a special word (keyword) used to identify them
- The
end and sep parameters can be used for formatting the output of the print() function.
- the
sep parameter specifies the separator between the outputted arguments
print("H", "E", "L", "L", "O", sep="-")
- whereas the
end parameter specifies what to print at the end of the print statement
S2: Python Literals
-
Literals are notations for representing some fixed values in code.
- Python has various types of literals for example, a literal can be a number (numeric literals e.g.,
123) or a string (string literals, e.g., "I am a literal.")
- the
binary system is a system of numbers that employs 2 as the base.
- Therefore, a binary number is made up of
0s and 1s only e.g., 1010 is 10 in decimal
- Octal and Hexadecimal numeration systems, similarly, employ
8 and 16 as their bases respectively.
- The hexadecimal system uses the decimal numbers and six extra letters
-
Integers (or simply ints) are one of the numerical types supported by Python.
- They are numbers written without a fractional components.
- e.g.,
256, or -1 (negative intergers)
-
Floating-point numbers (or floats) are another one of the numerical types supported by Python
- They are numbers that contain (or are able to contain) a fractional components
- e.g.,
2.73
-
- Boolean values are the two constant objects
True and False used to represent truth values (in numeric contexts 1 is True, while 0 is False
-
Variables
- A variable is a named location reserved to store values in the memory.
A variable is created or initialized automatically when you assign a value to it for the first time
- Each variable must have a unique name - an identifier
- A legal identifier name must be a non-empty sequence of characters, must begin with the underscore(
_), or a letter, and in cannot be a Python keyword.
- The first character may be followed by an underscores, letters, and digits.
- Identifiers in Python are case-sensitive
- Python is a dynamically-typed language, which means you don't need to declare variables in it
- To assign values to variables, you can use a simple assignment operator in the form of the equal (
=) sign. e.g., var = 1
- You can also use compound assignment operators (shortcut operators) to modify values assigned to variables, e.g.,
var += 1, or var /= 5 * 2
-
-
-
-