Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
9 views

Vertopal.com_Day 1 - Environment Creation and Package Installation in Anaconda Prompt, Introduction to Python

Uploaded by

CATalyst
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Vertopal.com_Day 1 - Environment Creation and Package Installation in Anaconda Prompt, Introduction to Python

Uploaded by

CATalyst
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Anaconda

• Anaconda is a distribution of the Python and R programming languages for scientific


computing (data science, machine learning applications, large-scale data processing,
predictive analytics, etc.), that aims to simplify package management and
deployment.
• The distribution includes data-science packages suitable for Windows, Linux, and
macOS. It is developed and maintained by Anaconda, Inc., which was founded by
Peter Wang and Travis Oliphant in 2012.
• Package versions in Anaconda are managed by the package management system
conda. This package manager was spun out as a separate open-source package as it
ended up being useful on its own and for things other than Python.
• There is also a small, bootstrap version of Anaconda called Miniconda, which
includes only conda, Python, the packages they depend on, and a small number of
other packages.

Anaconda Navigator
• Anaconda Navigator is an application provided with Anaconda Distribution that
enables users to work with conda packages and environments using a graphical
user interface (GUI) instead of a command line interface (CLI), like Anaconda
Prompt on Windows or a terminal in macOS or Linux.
https://docs.anaconda.com/navigator/

Jupyter Notebook
• Web-based application for authoring documents that combine live-code with
narrative text, equations and visualizations.
• Jupyter Notebooks are structured data that represent your code, metadata, content,
and outputs. When saved to disk, the notebook uses the extension .ipynb, and uses a
JSON structure.
• Jupyter Notebook and its flexible interface extends the notebook beyond code to
visualization, multimedia, collaboration, and more.
• To running your code, it stores code and output, together with markdown notes, in
an editable document called a notebook. When you save it, this is sent from your
browser to the Jupyter server, which saves it on disk as a JSON file with a .ipynb
extension.
• The Jupyter server is a communication hub. The browser, notebook file on disk, and
kernel cannot talk to each other directly. They communicate through the Jupyter
server.
• The Jupyter server, not the kernel, is responsible for saving and loading notebooks,
so you can edit notebooks even if you don’t have the kernel for that language—you
just won’t be able to run code.
• The kernel doesn’t know anything about the notebook document: it just gets sent
cells of code to execute when the user runs them.
• A kernel is a “computational engine” that executes the code contained in a notebook
document.
• A cell is a container for text to be displayed in the notebook or code to be executed
by the notebook’s kernel.

Magic commands
• Magic commands are special commands that can help you with running and
analyzing data in your notebook.
• They add a special functionality that is not straight forward to achieve with python
code or jupyter notebook interface.
• Magic commands are easy to spot within the code.
• They are either proceeded by % if they are on one line of code or by %% if they are
written on several lines.
• Line magics
• Cell magics
%lsmagic

%pwd

%ls
%%time
# a=2
print("Hello World")

#List all variables


%who

var_1 = 1
var_2 = 'hello'
var_3 = 100

%who

# Get detailed information about the variable


%pinfo var_2

%%writefile training.py

# add this line of code in my py file


print("Hello Python!!")
print("Wlecome in Python training")

%load training.py

%run training.py

!python test.py

Python
• Python is a general purpose high level programming language.
• Python was developed by Guido Van Rossam in 1989 while working at National
Research Institute at Netherlands.
• But officially Python was made available to public in 1991. The official Date of Birth
for Python is : Feb 20th 1991.
• Python is recommended as first programming language for beginners.
• The name Python was selected from the TV Show "The Complete Monty Python's
Circus", which was broadcasted in BBC from 1969 to 1974

Features of Python:
• Simple and easy to learn
• Freeware and Open Source
• High Level Programming language
• Platform Independent
• Portability
• Dynamically Typed
• Both Procedure Oriented and Object Oriented ...
Python Versions
• Python 1.0V introduced in Jan 1994
• Python 2.0V introduced in October 2000
• Python 3.0V introduced in December 2008

Applications
Where we can use Python: We can use everywhere. The most common important
application areas are
1. For developing Desktop Applications
2. For developing web Applications
3. For developing database Applications
4. For Network Programming
5. For developing games
6. For Data Analysis Applications
7. For Machine Learning
8. For developing Artificial Intelligence Applications
9. For IOT ..

Limitations of Python:
1. Performance wise not up to the mark b'z it is interpreted language.
2. Not using for mobile Applications
a = "10.20"
type(a)

a = eval(input("enter number: "))


type(a)

Identifiers
A name in Python program is called identifier. It can be class name or function name or
module name or variable name.
a = 10
• Alphabet Symbols (Either Upper case OR Lower case)
• If Identifier is start with Underscore (_) then it indicates it is private.
• Identifier should not start with Digits.
• Identifiers are case sensitive.
• We cannot use reserved words as identifiers Eg: def=10
• There is no length limit for Python identifiers. But not recommended to use too
lengthy identifiers.
• Dollor ($) Symbol is not allowed in Python.
a = 10
Example :
Which of the following are valid Python identifiers?
• 123total
• total123
• java2share
• ca$h
• abc_abc
• def
• if
a = 10

Literals
• Literals in Python is defined as the raw data assigned to variables or constants while
programming.

Types of Literals in Python


• Python literals are of several types, and their usage is also pretty varied. So let’s
check them out one by one.

• There are five types of literal in Python, which are as follows-

1. String Literals
2. Numeric Literals
3. Boolean Literals
4. Literal Collections
5. Special Literals
a = 18
a = [1,2,3,]

a = 'Hello'
a = "Hello"
a = """Hello"""

input_string = "Hello world"


type(input_string)

#string literals
#single line literal
single_quotes_string='Academy'
print(single_quotes_string)

double_quotes_string="Hello World"
print(double_quotes_string)

multi_text = "Welcome \
to \
Python \
Training "

multi_text = '''Welocome
to
python
Training'''

import sys

sys.maxsize

#string literals
#multi line literal
# We can enable multi-line strings in Python by adding a backslash at
the end of every line.

str1="Welcome \
to \
Python \
Training"

print(str1)

Welcome to Python Training

#string literals
#multi line literal
# Triple quotes at the beginning and end of the string literally will
allow us to create a multi-line string in Python easily!
str1="""Welcome
to
Python
Training"""

print(str1)

Welcome
to
Python
Training

!pip install package_name

Reserved Words
In Python some words are reserved to represent some meaning or functionality. Such type
of words are called Reserved words.
from math import sqrt

sqrt(49)
import math

math.sqrt(49)

import math as m
m.sqrt(25)

5.0

import keyword
print(keyword.kwlist)

['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await',


'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except',
'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is',
'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try',
'while', 'with', 'yield']

from keyword import kwlist


print(kwlist)

Data Types
Data Type represent the type of data present inside a variable.In Python we are not
required to specify the type explicitly. Based on value provided,the type will be assigned
automatically.Hence Python is Dynamically Typed Language.
Python contains the following inbuilt data types:
1. int
2. float 3.complex 4.bool 5.str 6.bytes 7.bytearray 8.range 9.list 10.tuple 11.set
12.frozenset 13.dict 14.None
a = 10
type(a)

int

a = 10

id(a)

140714446424016

b = 10.0

id(b)

2689978207248

Python contains several inbuilt functions


type()
• to check the type of variable
id()
• to get address of object

a = 10
id(a)

140720160573392

b = 10.0
id(b)

1868659693584

dir(__builtins__)

['ArithmeticError',
'AssertionError',
'AttributeError',
'BaseException',
'BlockingIOError',
'BrokenPipeError',
'BufferError',
'BytesWarning',
'ChildProcessError',
'ConnectionAbortedError',
'ConnectionError',
'ConnectionRefusedError',
'ConnectionResetError',
'DeprecationWarning',
'EOFError',
'Ellipsis',
'EnvironmentError',
'Exception',
'False',
'FileExistsError',
'FileNotFoundError',
'FloatingPointError',
'FutureWarning',
'GeneratorExit',
'IOError',
'ImportError',
'ImportWarning',
'IndentationError',
'IndexError',
'InterruptedError',
'IsADirectoryError',
'KeyError',
'KeyboardInterrupt',
'LookupError',
'MemoryError',
'ModuleNotFoundError',
'NameError',
'None',
'NotADirectoryError',
'NotImplemented',
'NotImplementedError',
'OSError',
'OverflowError',
'PendingDeprecationWarning',
'PermissionError',
'ProcessLookupError',
'RecursionError',
'ReferenceError',
'ResourceWarning',
'RuntimeError',
'RuntimeWarning',
'StopAsyncIteration',
'StopIteration',
'SyntaxError',
'SyntaxWarning',
'SystemError',
'SystemExit',
'TabError',
'TimeoutError',
'True',
'TypeError',
'UnboundLocalError',
'UnicodeDecodeError',
'UnicodeEncodeError',
'UnicodeError',
'UnicodeTranslateError',
'UnicodeWarning',
'UserWarning',
'ValueError',
'Warning',
'WindowsError',
'ZeroDivisionError',
'__IPYTHON__',
'__build_class__',
'__debug__',
'__doc__',
'__import__',
'__loader__',
'__name__',
'__package__',
'__spec__',
'abs',
'all',
'any',
'ascii',
'bin',
'bool',
'breakpoint',
'bytearray',
'bytes',
'callable',
'chr',
'classmethod',
'compile',
'complex',
'copyright',
'credits',
'delattr',
'dict',
'dir',
'display',
'divmod',
'enumerate',
'eval',
'exec',
'filter',
'float',
'format',
'frozenset',
'get_ipython',
'getattr',
'globals',
'hasattr',
'hash',
'help',
'hex',
'id',
'input',
'int',
'isinstance',
'issubclass',
'iter',
'len',
'license',
'list',
'locals',
'map',
'max',
'memoryview',
'min',
'next',
'object',
'oct',
'open',
'ord',
'pow',
'print',
'property',
'range',
'repr',
'reversed',
'round',
'set',
'setattr',
'slice',
'sorted',
'staticmethod',
'str',
'sum',
'super',
'tuple',
'type',
'vars',
'zip']

id()

help(id)

Help on built-in function id in module builtins:

id(obj, /)
Return the identity of an object.

This is guaranteed to be unique among simultaneously existing


objects.
(CPython uses the object's memory address.)
help(print)

Help on built-in function print in module builtins:

print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

Prints the values to a stream, or to sys.stdout by default.


Optional keyword arguments:
file: a file-like object (stream); defaults to the current
sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.

print

!pip install -r requirements.txt !pip freeze > requirements.txt

You might also like