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

Python Basics Notes

Uploaded by

prathamesh27k
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)
3 views

Python Basics Notes

Uploaded by

prathamesh27k
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

Basics of Python Programming:

- Introduction to Python: High-level, interpreted, easy-to-read language.

- Setting up the environment: Install Python, use IDE like VS Code, PyCharm.

- Variables: Store data; dynamically typed.

- Data Types: int, float, str, bool, list, tuple, dict, set.

- Operators: Symbols like +, -, *, ==, etc.

- Comments: Use # to explain code.

- Basic syntax: Uses indentation for blocks.

Python Input/Output:

- input(): Takes user input as string.

- print(): Displays output.

- Formatting output: Use f-strings or .format().

Python Data Types:

- Numbers: int, float.

- Strings: Text data.

- Booleans: True or False.

- Lists: Ordered, mutable.

- Tuples: Ordered, immutable.

- Sets: Unordered, unique.

- Dictionaries: Key-value pairs.

Python Operators:

- Arithmetic: +, -, *, /, //, %, **

- Comparison: ==, !=, >, <, >=, <=

- Logical: and, or, not


- Assignment: =, +=, -=, etc.

- Bitwise: &, |, ^, ~, <<, >>

- Membership: in, not in

- Identity: is, is not

Python Conditional Statements:

- if, elif, else: Decision making.

- Nested conditions: if within if.

Python Loops:

- for: Iterates over sequences.

- while: Repeats while condition is true.

- break: Exits loop.

- continue: Skips to next iteration.

- pass: Does nothing (placeholder).

Lists and List Comprehensions:

- Creating: [1, 2, 3]

- Accessing: list[0]

- Operations: append, insert, remove, pop, slicing.

- Comprehensions: [x for x in range(5) if x % 2 == 0]

Strings and String Manipulation:

- Operations: +, slicing, split.

- Methods: lower, upper, replace, find, strip.

Dictionaries and Sets:


- Creating: {'a': 1}, {1, 2, 3}

- Accessing: dict['a']

- Operations: get, update, keys, values; add, remove for sets.

Python Functions:

- Defining: def func():

- Calling: func()

- Arguments: positional, keyword, default.

- Return: return value.

- Scope: local vs global.

Python File Handling:

- Opening: open('file.txt', 'r')

- Reading/Writing: read, readline, write

- Modes: r, w, a, b

- Closing: close() or with open(...) as file

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