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

Essentials_of_Python_Unit1_Notes (2)

The document provides an overview of Python, highlighting its applications in web development, AI/ML, and data analysis, along with its easy syntax and vast libraries. It covers basic elements such as data structures, data types, operators, program flow, and functions, including how to define and use them. Additionally, it explains the use of modules and the importance of indentation in controlling program blocks.

Uploaded by

Narayan Prakash
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)
2 views

Essentials_of_Python_Unit1_Notes (2)

The document provides an overview of Python, highlighting its applications in web development, AI/ML, and data analysis, along with its easy syntax and vast libraries. It covers basic elements such as data structures, data types, operators, program flow, and functions, including how to define and use them. Additionally, it explains the use of modules and the importance of indentation in controlling program blocks.

Uploaded by

Narayan Prakash
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/ 3

Essentials of Python - Unit 1 Revision Sheet

Introduction

- What can Python do?

Web development, AI/ML, automation, data analysis, gaming, etc.

- Why Python?

Easy syntax, readable, portable, vast libraries, interpreted language.

- Python Syntax vs Other Languages

Uses indentation instead of braces {} or semicolons.

- Python Installation

From python.org, install and verify with python --version.

- Basic Elements

- print() -> Display output

- Comments: # single line, ''' multi-line '''

- Data Structures: List, Tuple, Set, Dictionary

- Data Types: int, float, str, bool, complex

- String Operations: Concatenation (+), Slicing ([:]), Methods (.upper(), .lower(), etc.)

- Input & Output

- input() -> takes input as string

- print() -> displays output

- Output Formatting

name = "Priyanshu"

print(f"Hello {name}")

print("Hello {}".format(name))

- Operators

Arithmetic (+, -, *, /, //, %, **)

Relational (>, <, ==, !=, >=, <=)

Logical (and, or, not)

Assignment (=, +=, -=, etc.)

Bitwise, Membership (in, not in), Identity (is, is not)

Python Program Flow

- Indentation: Controls program block (4 spaces standard)


- Decision Making

if condition:

# code

elif condition:

# code

else:

# code

- Loops

while loop

for loop with range()

Break: Exit loop

Continue: Skip iteration

- range() Syntax

range(start, stop, step)

- Assert

assert 5 > 2 # True -> no error

- Loop Example

for i in range(5):

print(i)

Functions & Modules

- Defining a Function

def greet():

print("Hello")

- Parameters: Default, Keyword, Variable-length (*args, **kwargs)

- Scope of Variables: Local & Global

- Function Documentation

def func():

'''This is a docstring'''

pass

- Lambda Functions

square = lambda x: x*x

- map() Function
result = list(map(lambda x: x+2, [1, 2, 3]))

- Modules

Importing modules:

import math

print(math.sqrt(16))

Create your own modules as .py files.

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