DAY-1 Edited
DAY-1 Edited
Modules:
Modules are used to borrow someone else’s codes which means that we can use someone
else’s codes in our own program with the help of modules
Modules are of two types
1) Built in modules
2) External modules
PIP
Pip is package installer for python. It installs whatever modules you ask from the
internet and saves it in your python interpreter
Python comments:
A comment is a part of the coding file that the programmer does not want to execute,
rather the programmer uses it to either explain a block of code or to avoid the execution
of a specific part of code while testing.
Multiline comments
Add a # at the start of each comment
ctrl+/
Escape sequence characters:
To insert a character that cannot be directly used in a string, we use an escape sequence
character
An escape sequence character is a backslash(only backslashes) (“\”)
Example of escape sequence characters are using double quotes inside double quotes
print(“i said, \”hello\” “)
\n - newline(inserts a linebreak)
\t - tab(it gives us whitespace)
\\ - inserts backslash
\’ - single quote
\” - double quote
More on print statement:
The syntax of print statement
print(object(s), *sep=seperator, *end=end,*file=file,*flush=flush)
Object- any object and as many as you like will be converted into strings and objects
before being printed
sep=seperator: specify how to separate the objects(if there are multiple objects). Default
is ‘ ‘.
end=end: specify what to print at the end
Default is “/n”(line feed)
file=file: an object with a write method. Default is “sys.stdout”
Parameters 2 to 4 optional
Variable:
Variable is like a container that holds data.
Very similar to how our containers in the kitchen hold sugar, salt, chocos, etc.
Creating a variable is like creating a placeholder in memory and assigning some value
to it
Sequenced data:
1) Lists - list
2) Tuples - tuple
Mapped datas:
Dictionaries - dict
print(type(variable))