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

Data Analysis Using Python Notes

The document provides an overview of data analysis using Python, covering essential data structures such as tuples, lists, dictionaries, and sets. It also discusses functions, including defining, arguments, and handling exceptions, as well as file operations like reading, writing, and deleting files. Key examples illustrate each concept to aid understanding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Data Analysis Using Python Notes

The document provides an overview of data analysis using Python, covering essential data structures such as tuples, lists, dictionaries, and sets. It also discusses functions, including defining, arguments, and handling exceptions, as well as file operations like reading, writing, and deleting files. Key examples illustrate each concept to aid understanding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Data Analysis Using Python

1. Python Data Structures

- Tuple - Immutable collection. Example: t = (1, 2, 3)

- List - Mutable collection. Example: l = [1, 2, 3]

- Dictionary - Key-value pairs. Example: d = {'a': 1, 'b': 2}

- Set - Unordered collection of unique items. Example: s = {1, 2, 3}

- List Comprehension - Compact list creation. Example: [x*x for x in range(5)]

- Dict and Set Comprehension - Example: {x: x*x for x in range(3)}, {x for x in range(3)}

- Nested List Comprehension - Example: [[i*j for j in range(3)] for i in range(3)]

2. Functions

- Defining Functions - Example: def func(): pass

- Arguments - Example: def add(a, b): return a + b

- Positional and Keyword Arguments - Example: func(1, b=2)

- Arbitrary Arguments (*args, **kwargs) - Example: def f(*a, **k): pass

- Namespace - Space where names are mapped to objects.

- Scope (Local, Global) - Defines where variables can be accessed.

- Returning Multiple Values - Example: return a, b

- Functions as Objects - Functions can be passed and returned.

- Anonymous (Lambda) Functions - Example: lambda x: x+1

- Lambda with Filter and Map - Example: map(lambda x: x*2, [1,2,3])

3. Exception Handling

- Try-Except Block - Handles errors. Example: try: x/0 except: print('error')

- Catching Specific Exceptions - Example: except ZeroDivisionError:

- Else and Finally Blocks - Else runs if no error; finally runs always.

4. Files and Operating System

- File Handling - Open, read, write files.

- Reading Files - Example: open('file.txt').read()

- Writing Files - Example: open('file.txt', 'w').write('data')

- Creating Files - Use write mode 'w' or 'x'

- Deleting Files - Example: os.remove('file.txt')

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy