0% found this document useful (0 votes)
27 views

Python Notes 3

The document provides information about various Python concepts including: - Built-in functions like print() do not need to be imported and there are 69 built-in functions in Python 3.8. print() outputs messages and can take positional or keyword arguments like sep to separate outputs. - Literals represent fixed values in code like numbers (123), strings ("Hello"), and Boolean values (True, False). Python supports integer, floating-point, string, and Boolean literals. - Escape characters like \n can be used in strings to encode special characters. Alternately, strings can be enclosed in different quotes to encode interior quotes. - Additional topics covered include binary, octal, hexadecimal number systems
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Python Notes 3

The document provides information about various Python concepts including: - Built-in functions like print() do not need to be imported and there are 69 built-in functions in Python 3.8. print() outputs messages and can take positional or keyword arguments like sep to separate outputs. - Literals represent fixed values in code like numbers (123), strings ("Hello"), and Boolean values (True, False). Python supports integer, floating-point, string, and Boolean literals. - Escape characters like \n can be used in strings to encode special characters. Alternately, strings can be enclosed in different quotes to encode interior quotes. - Additional topics covered include binary, octal, hexadecimal number systems
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Notes 3

Summary 1

The print() function is a built-in function. It prints/outputs a specified message


to the screen/consol window.
Built-in functions, contrary to user-defined functions, are always available and
don't have to be imported.
Python 3.8 comes with 69 built-in functions. You can find their full list provided
in alphabetical order in the Python Standard Library.
To call a function (this process is known as function invocation or function call),
you need to use the function name followed by parentheses.
You can pass arguments into a function by placing them inside the parentheses.
You must separate arguments with a comma.
E.g., print("Hello,", "world!").
An "empty" print() function outputs an empty line to the screen.
Python strings are delimited with quotes.
E.g., "I am a string" (double quotes), or 'I am a string, too' (single quotes).
Computer programs are collections of instructions.
An instruction is a command to perform 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 (the newline character) starts a new output line.
Positional arguments are the ones whose meaning is dictated by their position
E.g., the second argument is outputted after the first, the third is outputted
after the second, etc.
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
E.g., print("H", "I", sep="-"), whereas the end parameter specifies what to print
at the end of the print statement.

Summary 2

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).
9E.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 component, e.g., 256, or -1 (negative
integers).
Floating-point numbers (or simply floats) are another one of the numerical types
supported by Python.
They are numbers that contain (or are able to contain) a fractional component,
e.g., 1.27.
To encode an apostrophe or a quote inside a string, you can either use the escape
character.
E.g., 'I\'m happy.', or open and close the string using an opposite set of symbols
to the ones you wish to encode.
E.g., "I'm happy." to encode an apostrophe, and 'He said "Python", not "typhoon"'
to encode a (double) quote.
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.

Extra

There is one more, special literal that is used in Python: the None literal.
This literal is a NoneType object, and it is used to represent the absence of a
value.
We'll tell you more about it soon.

You might also like